Browse Source

Allow parsing pre-parsed HTML trees

pull/5/head
Greg V 1 year ago
parent
commit
337b2fe8e0
2 changed files with 7 additions and 1 deletions
  1. +4
    -0
      README.md
  2. +3
    -1
      lib/microformats2.ex

+ 4
- 0
README.md View File

@@ -47,6 +47,10 @@ It will parse the object to a structure like that:
category: ["Strategy",
"Leadership"]}}]}

You can also provide HTML trees already parsed with Floki:

Microformats2.parse(Floki.parse("""<div class="h-card">...</div>"""))

## Dependencies

We need [Floki](https://github.com/philss/floki) for HTML parsing and


+ 3
- 1
lib/microformats2.ex View File

@@ -9,9 +9,11 @@ defmodule Microformats2 do
end
end

def parse(content, url) when is_binary(content), do: parse(Floki.parse(content), url)

def parse(content, url) do
doc =
Floki.parse(content)
content
|> Floki.filter_out("template")
|> Floki.filter_out("style")
|> Floki.filter_out("script")


Loading…
Cancel
Save