Comments (5)
I can't quite understand the problem, what are you trying to achieve?
If you want to serialize the data structure, so it will look pretty much like that:
#=(clojure.lang.PersistentHashMap/create {:tag :a, :attrs #=(clojure.lang.PersistentArrayMap/create {:title "Equals si\
gn", :href "/wiki/Equals_sign"}), :content ("=")})
You can read it back and it will evaluate to:
{:content ("="), :attrs {:title "Equals sign", :href "/wiki/Equals_sign"}, :tag :a}
Am I missing something?
from enlive.
Probably I have to cc @jackrusher
from enlive.
Sorry it has taken me so long to reply.
I tend to do loads of exploratory programming using emacs + SLIME/nrepl, quite a bit of which involves scraping/spidering. An example of this might be:
(def symbols
(html/html-resource (java.net.URL. "http://en.wikipedia.org/wiki/List_of_mathematical_symbols")))
(html/select symbols [:table.wikitable :td :a])
;; C-u C-x C-e in emacs to bring the result of evaluating this express into the buffer
;; => ({:tag :a, :attrs {:title "Equals sign", :href "/wiki/Equals_sign"}, :content ("=")} ... )
... which I would then wrap in a (def) form to use as data for whatever program I might be writing at the time.
Sadly, the form returned by (html/select) cannot be used in this way because the reader tries to execute the string at the head of the :content list. In Common Lisp or Scheme, I'd expect the :content list to be quoted to avoid this problem, whereas in Clojure I'd expect the data to be stored in a vector (using vectors literals rather than quoted lists seems like the preferred convention in Clojure).
Thanks for your consideration.
from enlive.
To me it's the difference between readable and evaluable.
The sensible solution seems to just quite the whole thing when you wrap it
into a def -- after all it's a value not a piece code (Code is data but all
data is not ocde.)
(def foo '({:tag :a, :attrs {:title "Equals sign", :href
"/wiki/Equals_sign"}, :content ("=")} ... )))
On Wed, Jan 23, 2013 at 7:15 PM, Jack Rusher [email protected]:
Sorry it has taken me so long to reply.
I tend to do loads of exploratory programming using emacs + SLIME/nrepl,
quite a bit of which involves scraping/spidering. An example of this might
be:(def symbols
(html/html-resource (java.net.URL. "
http://en.wikipedia.org/wiki/List_of_mathematical_symbols")))(html/select symbols [:table.wikitable :td :a])
;; C-u C-x C-e in emacs to bring the result of evaluating this express
into the buffer
;; => ({:tag :a, :attrs {:title "Equals sign", :href "/wiki/Equals_sign"},
:content ("=")} ... )... which I would then wrap in a (def) form to use as data for whatever
program I might be writing at the time.Sadly, the form returned by (html/select) cannot be used in this way
because the reader tries to execute the string at the head of the :content
list. In Common Lisp or Scheme, I'd expect the :content list to be quoted
to avoid this problem, whereas in Clojure I'd expect the data to be stored
in a vector (using vectors literals rather than quoted lists seems like the
preferred convention in Clojure).Thanks for your consideration.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/50#issuecomment-12613574.
On Clojure http://clj-me.cgrand.net/
Clojure Programming http://clojurebook.com
Training, Consulting & Contracting http://lambdanext.eu/
from enlive.
On 23 Jan, 2013, at 16:00, Christophe Grand [email protected] wrote:
The sensible solution seems to just quite the whole thing when you wrap it
into a def -- after all it's a value not a piece code (Code is data but all
data is not ocde.)
I can, of course, work around this, but what is the advantage of making me do so? That is, why would one not want this data to be usable in this way?
from enlive.
Related Issues (20)
- Automated CSS selector translation to vector form HOT 5
- [org.jsoup/jsoup "1.8.3"] exists HOT 1
- Make JSoup the default for enlive 1.2 HOT 1
- StackOverflowError when parsing certain html HOT 4
- Composable selector/transform in snippet HOT 1
- Simple variable substitution (with example) in meta tag throwing NullPointerException HOT 2
- Less obscure error messages
- first-child
- End tag for <col> violates the specs
- javax.net.ssl.SSLHandshakeException while trying to reach some resources HOT 1
- attribute matching inside at-form HOT 1
- "safe write" "feature" in IntelliJ prevents auto-reloading of namespace depending on changed HTML
- Removing element cleanly HOT 2
- Is this project dead? HOT 1
- Update jsoup dependency to v1.11.3+
- Setting HTTP headers HOT 1
- Broken wiki link in project description
- HTML resource not found
- Any interest in CSS-style selector syntax option? HOT 1
- [BUG] Some tags are loosing part of their content when selected.
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 enlive.