https://github.com/niku/earmark_raw_html
Avoid escaping html in a markdown when converting from markdown to html through Earmak's AST
https://github.com/niku/earmark_raw_html
Last synced: 10 months ago
JSON representation
Avoid escaping html in a markdown when converting from markdown to html through Earmak's AST
- Host: GitHub
- URL: https://github.com/niku/earmark_raw_html
- Owner: niku
- License: mit
- Created: 2019-12-29T08:05:21.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-29T08:05:42.000Z (over 6 years ago)
- Last Synced: 2025-01-12T16:41:36.268Z (over 1 year ago)
- Language: Elixir
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EarmarkRawHtml
If you write html in markdown and convert to html using earmark's [AST feature](https://github.com/pragdave/earmark#earmarkas_ast2), the html in markdown is escaped.
This library keeps raw html when it is converted.
Status: **EXPERIMENTAL**
## Installation
```elixir
def deps do
[
{:earmark_raw_html, github: "niku/earmark_raw_html"}
]
end
```
## Usage
Note: When you use this library, you should add an option `pure_links: false` to `Earmark.as_ast/2` to avoid [adding auto link by earmak](https://hexdocs.pm/earmark/1.4.3/Earmark.html#as_html/2).
```elixir
markdown = """
example link
[example link md style](http://example.com/)
"""
{:ok, ast, []} = Earmark.as_ast(markdown, pure_links: false)
ast |> Earmark.Transform.transform() |> IO.puts()
#
# <a href="http://example.com/">example link</a>
#
#
ast |> EarmarkRawHtml.melt_raw_html_into_ast() |> Earmark.Transform.transform() |> IO.puts()
#
#
# example link
#
#
#
```
## LICENSE
MIT. Check the [LICENSE](LICENSE) file for more information.