Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cemerick proposal + readme #130

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,26 @@ There's a quickstart section in [Clojure Cookbook](https://github.com/clojure-co

## Where do I get support?

On the [Enlive Google Group](http://groups.google.com/group/enlive-clj)
On the [Enlive Google Group](http://groups.google.com/group/enlive-clj).
Please consider a discussion on the group before opening an issue on github.

## Artifact

All artifacts are published to [clojars](https://clojars.org/enlive). Latest version is `1.1.6`:
All artifacts are published to [clojars](https://clojars.org/enlive). Latest version is `1.1.7`:

```
[enlive "1.1.6"]
[enlive "1.1.7"]
```

## What's new in Enlive?

(most recent first)

1.1.7:
- ADD: compiled against clojure 1.7
- ADD: updated dep: jsoup 1.8.2
- FIX: several minor issues and documentation.

1.1.6:
- ADD: exception message when html-resource not found.
- FIX: auto-reload on windows (also works with chestnut).
Expand All @@ -44,6 +50,10 @@ namespace is reloaded (as per `(require ... :reload)`).

### Pluggable parsers! (1.1.1)

WYGIWTPF (What you get is what the parser fixes).
Jsoup is more well-behaved than tagsoup and follows HTML5 parsing algorithm.
See [this workaround](https://github.com/cgrand/enlive/wiki/JSoup-with-html-snippet) to use JSoup with html-snippet.

The `*parser*` dynamic var controls the parser to be used by `html-resource` at
runtime. (or you can pass `{:parser XXX}` as an additional arg).

Expand Down Expand Up @@ -267,7 +277,7 @@ any `p` with a `lang` attribute.
Similarly, sets group predicates in an union. Hence *inside steps, sets mean
"or"*. So `[#{:div.class1 :div.class2}]` match every `div` which has either
`class1` or `class2`. This can alternatively be written
as `[[:div #{:.class1 .class2}]]`. Indeed you can have nested "ors" and "ands"
as `[[:div #{:.class1 :.class2}]]`. Indeed you can have nested "ors" and "ands"
which means nested sets and vectors.

At the top level you can have a big "or" between selectors by wrapping several
Expand All @@ -276,7 +286,7 @@ selectors in a set. `#{[:td :em] [:th :em]}` is going to match any `em` insides

### Selector Syntax

See [syntax.html](http://enlive.cgrand.net/syntax.html)
See [syntax.html](https://github.com/cgrand/enlive/wiki/Enlive-selectors-syntax)

Some examples:

Expand Down
6 changes: 3 additions & 3 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(defproject enlive "1.1.6"
(defproject enlive "1.1.7-SNAPSHOT"
:min-lein-version "2.0.0"
:description "a HTML selector-based (à la CSS) templating and transformation system for Clojure"
:url "http://github.com/cgrand/enlive/"
:profiles {:dev {:resource-paths ["test/resources"]}}
:dependencies [[org.clojure/clojure "1.2.0"]
:dependencies [[org.clojure/clojure "1.7.0"]
[org.ccil.cowan.tagsoup/tagsoup "1.2.1"]
[org.jsoup/jsoup "1.7.2"]])
[org.jsoup/jsoup "1.8.2"]])
2 changes: 1 addition & 1 deletion src/net/cgrand/enlive_html.clj
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@
(defn- nodify [node-spec]
(cond
(string? node-spec) node-spec
(vector? node-spec)
(and (vector? node-spec) (not (map? (first node-spec))))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than (not (map? (first node-spec))), (keyword? (first node-spec)) seems to better handle cases such as ["abc" {:tag :b :content ["def"]} "ghi"]. Doesn't it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Been thinking and trying, but I can't figure out what you mean 8-°
That would give us:

(html (at (html [:a])
             [:a] (content "foo")))
=> ({:tag ::a, :attrs {}, :content ()})

which can't be what you want?

Plus:
Ran 30 tests containing 104 assertions. 6 failures, 0 errors. {:test 30, :pass 98, :fail 6, :error 0, :type :summary}

(let [[tag & [m & ms :as more]] node-spec
[tag-name & segments] (.split (name tag) "(?=[#.])")
id (some (fn [^String seg]
Expand Down