Skip to content

Commit

Permalink
Fixes: #296;
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertDober committed Oct 14, 2019
1 parent c09299c commit 6f3aaeb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,19 @@ a map or keyword list of which the following keys will be used:
- `initial_indent:` `number`
- `indent:` `number`

iex(1)> Earmark.Transform.transform({"p", [], [{"em", [], "help"}, "me"]})
iex(1)> transform({"p", [], [{"em", [], "help"}, "me"]})
"<p>\n <em>\n help\n </em>\n me\n</p>\n"

Right now only transformation to HTML is supported.

The transform is also agnostic to any annotation map that is added to the AST.

Only the `:meta` key is reserved and by passing annotation maps with a `:meta` key
into the AST the result might become altered or an exception might be raised, otherwise...

iex(2)> transform({"p", [], [{"em", [], ["help"], %{inner: true}}], %{level: 1}})
"<p>\n <em>\n help\n </em>\n</p>\n"

<!-- END inserted functiondoc Earmark.Transform.transform/2 -->

## Contributing
Expand Down
10 changes: 9 additions & 1 deletion lib/earmark/transform.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@ defmodule Earmark.Transform do
- `initial_indent:` `number`
- `indent:` `number`
iex(1)> Earmark.Transform.transform({"p", [], [{"em", [], "help"}, "me"]})
iex(1)> transform({"p", [], [{"em", [], "help"}, "me"]})
"<p>\\n <em>\\n help\\n </em>\\n me\\n</p>\\n"
Right now only transformation to HTML is supported.
The transform is also agnostic to any annotation map that is added to the AST.
Only the `:meta` key is reserved and by passing annotation maps with a `:meta` key
into the AST the result might become altered or an exception might be raised, otherwise...
iex(2)> transform({"p", [], [{"em", [], ["help"], %{inner: true}}], %{level: 1}})
"<p>\\n <em>\\n help\\n </em>\\n</p>\\n"
"""
def transform(ast, options \\ %{initial_indent: 0, indent: 2})
def transform(ast, options) when is_list(options) do
Expand Down
1 change: 0 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ defmodule Earmark.Mixfile do
"lib",
"src/*.xrl",
"src/*.yrl",
"tasks",
"mix.exs",
"README.md"
],
Expand Down
2 changes: 1 addition & 1 deletion test/transform_test.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defmodule TransformTest do
use ExUnit.Case

doctest Earmark.Transform
doctest Earmark.Transform, import: true
end

0 comments on commit 6f3aaeb

Please sign in to comment.