Current section
Files
Jump to
Current section
Files
simple_markdown
README.md
README.md
# SimpleMarkdownExA simple and extendable Markdown to HTML converter for Elixir.When first using the library the first thing to do is usually togenerate the base rule config.```bash$ mix simple_markdown.rules.new```And then importing the config in your config.exs:```elixirimport_config "simple_markdown_rules.exs"```This config can be customized as you see fit. With new rules added,and other rules removed or modified. Depending on the changes madethis may require some additional steps for things to work the wayyou want. e.g. If you add or change the way a rule type fundamentallyworks, you'll need to add or override the required rendering stepfor that type. Details for this can be found in renderer protocols.Example-------```elixir#config/simple_markdown_rules.exs#add the following rule to our rulesetlol: %{ match: ~r/\Alol/, rules: [] }#lib/lol_renderer.ex#add a renderer for the HTML renderer for our "lol" ruledefimpl SimpleMarkdown.Renderer.HTML, for: SimpleMarkdown.Attribute.Lol do def render(_), do: "<img src=\"lolcat.jpg\">"end#usage:SimpleMarkdown.convert("#lol") #=> "<h1><img src=\"lolcat.jpg\"></h1>"```Additionally new renderers can be created. How these new renderers shouldbe implemented is left up to you depending on how you'll provide input.If you use the standard `convert/2` then the input willbe parsed, then the AST will be converted to these structs, and thenthat will be passed to your renderer. Alternatively you may call`SimpleMarkdown.Parser.parse/1` directly and then manipulate that ASThow you see fit, and pass that to your renderer.Installation------------```elixirdef applications do [applications: [:simple_markdown]]enddef deps do [{ :simple_markdown, "~> 0.5.2" }]end```