aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-06-12 22:32:13 +0200
committerLoïc Hoguin <[email protected]>2018-06-12 22:32:13 +0200
commit272386133de3684512ef3c371d2dc7f8b47d7c4a (patch)
tree102bd6a98e2eb85ce42c8a8f20dc36997a883f44
parent9458416ef386d4a3c6ea42b27e7945db05bce08f (diff)
downloadasciideck-272386133de3684512ef3c371d2dc7f8b47d7c4a.tar.gz
asciideck-272386133de3684512ef3c371d2dc7f8b47d7c4a.tar.bz2
asciideck-272386133de3684512ef3c371d2dc7f8b47d7c4a.zip
Add forced line breaks
-rw-r--r--src/asciideck_inline_pass.erl11
-rw-r--r--src/asciideck_to_html.erl2
2 files changed, 12 insertions, 1 deletions
diff --git a/src/asciideck_inline_pass.erl b/src/asciideck_inline_pass.erl
index 469c9f3..4bc4017 100644
--- a/src/asciideck_inline_pass.erl
+++ b/src/asciideck_inline_pass.erl
@@ -68,7 +68,9 @@ inline(Data, BinAcc, Acc) ->
fun emphasized_underline/2,
fun strong/2,
%% Passthrough macros.
- fun inline_literal_passthrough/2
+ fun inline_literal_passthrough/2,
+ %% Line breaks.
+ fun line_break/2
]).
%% The inline pass replaces \r\n and \n with a simple space
@@ -323,3 +325,10 @@ inline_literal_passthrough_test() ->
] = inline(<<"Word phrases `enclosed in backtick characters` (grave accents)...">>),
ok.
-endif.
+
+-define(IS_WS(C), (C =:= $\s) or (C =:= $\t)).
+
+%% Asciidoc User Guide 10.3
+line_break(<<C, "+", Rest0/bits>>, _) when ?IS_WS(C) ->
+ %% @todo Rest0 until \r or \n is whitespace.
+ {ok, {line_break, #{}, <<>>, inline}, Rest0}.
diff --git a/src/asciideck_to_html.erl b/src/asciideck_to_html.erl
index 035ff96..b33150f 100644
--- a/src/asciideck_to_html.erl
+++ b/src/asciideck_to_html.erl
@@ -223,6 +223,8 @@ inline({strong, _, Text, _}) ->
["<strong>", inline(Text), "</strong>"];
inline({inline_literal_passthrough, _, Text, _}) ->
["<code>", inline(Text), "</code>"];
+inline({line_break, _, _, _}) ->
+ "<br/>";
inline(Text) when is_list(Text) ->
[inline(T) || T <- Text].