Comments (5)
How is this "not working?" I can only kind of try to check the two lines of code, and one problem is that s/children is not a function. The other problem is that s/child is a function, but it doesn't take a list as argument, it takes varargs. You'd want to do something like (apply s/child _yf2) in the select call. But maybe its neither of those issues.
from hickory.
David
First of all: Great piece of work! It really fits a need with a easy to use
API.
Issue: I believe you are correct. I was assuming (barring the typo on
s/children vs. s/child) that it took a list so I believe the apply will
work. I will let you know.
Regards,
Frank
Axiom:1, Inc.
Phone: (800) 558-5119
Fax: (800) 531-2819
Web: http://www.axiom1inc.com http://www.axiom1inc.com/
From: David Santiago [email protected]
Reply-To: davidsantiago/hickory
<reply+i-30463540-46d81b3b783fdaf5e3bd6d476d71aebca55a4d29-5435165@reply.git
hub.com>
Date: Sunday, March 30, 2014 at 2:02 PM
To: davidsantiago/hickory [email protected]
Cc: Frank Castellucci [email protected]
Subject: Re: [hickory] Question: Regarding Evaluation (#14)
How is this "not working?" I can only kind of try to check the two lines of
code, and one problem is that s/children is not a function. The other
problem is that s/child is a function, but it doesn't take a list as
argument, it takes varargs. You'd want to do something like (apply s/child
_yf2) in the select call. But maybe its neither of those issues.
‹
Reply to this email directly or view it on GitHub
#14 (comment) .
from hickory.
Yes, not making much headway.
What I am trying to do is parse a user query grammar and produce hickory selectors as a result to then pass to a generalized thread (-> (select (s/child _my_generated_selectors) in-data) first ...).
I am lost on how to generate the selectors. For example, I am doing something like this in the parser transform:
(cond
(= x :tag) (fn [...] `(s/tag :tagname))
(= x :att) (fn [...] `(s/attr :attname)))
And the types come back as clojure.lang.Cons
Does that shine a better light?
from hickory.
Thank you!
I'm afraid I'm still not able to understand very well what you are doing. It's probably too complicated to explain in an issue. But, it does look from this snippet like you should be expecting a Cons somewhere around there: you're returning a function that returns a Cons due to the quoting. The s/tag and s/attr (and all the selectors) return functions, and you can plug those directly into s/select, stick them in lists, pass them to other selector functions. So I don't know why they are getting wrapped in a function, but that is probably an aspect of your design unrelated to the use of Hickory.
Since I'm not able to figure out what is going on, I would suggest that you first try to get the Hickory code working by crafting by hand (in the repl, say) a query that you'd like to be able to run. That is, manually type in the code you'd like your query grammar to compile to. Once you have that working, work on making your parser generate that (or equivalent) code from the actual user input.
from hickory.
Got it working, as soon as I removed the syntax quoting and un-quoting as per your comment it works like a baby!
''''
(-> (s/select (apply s/child (->> (hfm "(#tag head) (#tag title)")
(hfm-transform))) _r0))
=> [{:type :element, :attrs nil, :tag :title, :content ["Yahoo"]}]
''''
For some reason I had it in my head that they had to be quoted.
from hickory.
Related Issues (20)
- DOM 4 deprecating node type for attributes HOT 2
- Case sensitive tags/attributes HOT 2
- React-compatible :style attribute HOT 1
- CSS Support HOT 7
- Counterparts of child and descendant for first element in the chain HOT 5
- Deleting elements with selectors? HOT 5
- Close pull requests that won't be merged HOT 5
- Parsing throws on long markdown files HOT 1
- very odd interactive issue HOT 1
- event handlers HOT 2
- Unexpected conversion result HOT 3
- StackOverflowError when parsing many unclosed tags in series HOT 8
- Hickory does not correctly parse <noscript> tags in <head> HOT 1
- License Issue with codox - GPLv3 vs EPL HOT 3
- (as-hiccup (parse-fragment ...)) doesn't work in clojurescript with shadow-cljs HOT 2
- Node.js support revisited HOT 2
- :viewBox property in svg not correctly parsed to hiccup. HOT 2
- svg tag viewBox becomes viewbox HOT 1
- Invalid output by as-hiccup HOT 2
- Link to API documentation are broken - 404 not found
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hickory.