markright v0.2.0 Markright

Custom syntax Markdown-like text processor.

Summary

Functions

Main application helper: call Markright.to_ast(input, fn {ast, tail} -> IO.inspect(ast) end) to transform the markright into the AST, optionally being called back on every subsequent transform

Most shame part of this package: here we use Regex because, you know, fuck Windows

Functions

main(args)
process(options)
to_ast(input, fun \\ nil, opts \\ %{})

Main application helper: call Markright.to_ast(input, fn {ast, tail} -> IO.inspect(ast) end) to transform the markright into the AST, optionally being called back on every subsequent transform.

Examples

iex> Markright.to_ast("Plain string.")
{:article, %{}, [{:p, %{}, "Plain string."}]}

iex> input = "plain *bold* rest!"
iex> Markright.to_ast(input)
{:article, %{}, [{:p, %{}, ["plain ", {:strong, %{}, "bold"}, " rest!"]}]}

iex> input = "plain *bold1* _italic_ *bold2* rest!"
iex> Markright.to_ast(input)
{:article, %{},
  [{:p, %{}, ["plain ", {:strong, %{}, "bold1"}, " ", {:em, %{}, "italic"}, " ",
     {:strong, %{}, "bold2"}, " rest!"]}]}

iex> input = "plainplainplain *bold1bold1bold1* and *bold21bold21bold21 _italicitalicitalic_ bold22bold22bold22* rest!"
iex> Markright.to_ast(input)
{:article, %{},
  [{:p, %{}, ["plainplainplain ", {:strong, %{}, "bold1bold1bold1"}, " and ",
       {:strong, %{},
        ["bold21bold21bold21 ", {:em, %{}, "italicitalicitalic"},
         " bold22bold22bold22"]}, " rest!"]}]}

iex> input = "_Please ~use~ love **[`Markright`](Markright.html#content)** since it is *great*_!"
iex> Markright.to_ast(input)
{:article, %{},
  [{:p, %{}, [
    {:em, %{},
      ["Please ", {:strike, %{}, "use"}, " love ",
       {:b, %{}, [{:code, %{}, "Markright"}]}, " since it is ",
       {:strong, %{}, "great"}]}, "!"]}]}

iex> input = "Escaped /*asterisk"
iex> Markright.to_ast(input)
{:article, %{}, [{:p, %{}, "Escaped *asterisk"}]}

iex> input = "Escaped \\*asterisk 2"
iex> Markright.to_ast(input)
{:article, %{}, [{:p, %{}, "Escaped *asterisk 2"}]}
to_ast_safe_input(input, fun \\ nil, opts \\ %{})

Most shame part of this package: here we use Regex because, you know, fuck Windows.

@fixme