diff options
author | Loïc Hoguin <[email protected]> | 2018-06-11 12:38:07 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2018-06-11 12:38:07 +0200 |
commit | 976dfc5d92e3e23f356cb19f17ff51b22c75e634 (patch) | |
tree | 2589053dfc25bd6f38afdd9a06bdbbf63680464c /src/asciideck.erl | |
parent | 524777054be30c848c1883ffd15b245c29f73004 (diff) | |
download | asciideck-976dfc5d92e3e23f356cb19f17ff51b22c75e634.tar.gz asciideck-976dfc5d92e3e23f356cb19f17ff51b22c75e634.tar.bz2 asciideck-976dfc5d92e3e23f356cb19f17ff51b22c75e634.zip |
Add scripts/asciidoc ad-hoc replacement and HTML output
This allows me to build ninenines.eu using Asciideck and
while the results are not perfect yet things are looking
pretty, pretty good. Adding source-highlight support,
showing images and fixing a few minor issues should bring
me to the point where I can drop Asciidoc.
Diffstat (limited to 'src/asciideck.erl')
-rw-r--r-- | src/asciideck.erl | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/asciideck.erl b/src/asciideck.erl index bd5792c..d962c1b 100644 --- a/src/asciideck.erl +++ b/src/asciideck.erl @@ -14,14 +14,25 @@ -module(asciideck). +-export([parse_stdin/0]). +-export([parse_stdin/1]). -export([parse_file/1]). -export([parse_file/2]). -export([parse/1]). -export([parse/2]). +-export([to_html/1]). +-export([to_html/2]). -export([to_manpage/1]). -export([to_manpage/2]). +parse_stdin() -> + parse_stdin(#{}). + +parse_stdin(St) -> + {ok, ReaderPid} = asciideck_stdin_reader:start_link(), + parse(ReaderPid, St). + parse_file(Filename) -> parse_file(Filename, #{}). @@ -32,7 +43,7 @@ parse_file(Filename, St) -> parse(Data) -> parse(Data, #{}). -parse(Data, _St) when is_binary(Data) -> +parse(Data, _St) -> Passes = [ asciideck_attributes_pass, asciideck_lists_pass, @@ -40,9 +51,13 @@ parse(Data, _St) when is_binary(Data) -> asciideck_inline_pass ], lists:foldl(fun(M, AST) -> M:run(AST) end, - asciideck_block_parser:parse(Data), Passes); -parse(Data, St) -> - parse(iolist_to_binary(Data), St). + asciideck_block_parser:parse(Data), Passes). + +to_html(AST) -> + asciideck_to_html:translate(AST, #{}). + +to_html(AST, Opts) -> + asciideck_to_html:translate(AST, Opts). to_manpage(AST) -> asciideck_to_manpage:translate(AST, #{}). |