Update readme

This commit is contained in:
Dan Neumann 2022-05-16 20:51:51 -05:00
parent f953cc6ee4
commit 09bf0f643e

View File

@ -1,9 +1,34 @@
# elm-html-parser
<u>**Note**</u>: *Not currently published to Elm packages.*
A lenient html5 parser implemented with [Elm](https://elm-lang.org).
A lenient alternative to [hecrj/elm-html-parser](https://package.elm-lang.org/packages/hecrj/html-parser/latest/).
## Usage
- `run` to parse an html string into a list of html nodes.
- `runDocument` to parse `<!doctype html>[...]` into a root node.
```elm
import Html.Parser
Html.Parser.run "<p class=greeting>hello <strong>world</strong></p>"
-- Ok
-- [ Element "p" [ ("class", "greeting") ]
-- [ Text "hello "
-- , Element "strong" [] [ Text "world" ]
-- ]
-- ]
```
Rendering:
- `nodeToHtml` or `nodesToHtml` to render parsed nodes into virtual dom nodes that Elm can render.
- `nodeToString` and `nodesToString` to render parsed nodes into a string.
- `nodeToPrettyString` and `nodesToPrettyString` to render parsed nodes into indented strings.
## Goals
- **Leniency**