From 272386133de3684512ef3c371d2dc7f8b47d7c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 12 Jun 2018 22:32:13 +0200 Subject: Add forced line breaks --- src/asciideck_inline_pass.erl | 11 ++++++++++- src/asciideck_to_html.erl | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) 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(<>, _) 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, _}) -> ["", inline(Text), ""]; inline({inline_literal_passthrough, _, Text, _}) -> ["", inline(Text), ""]; +inline({line_break, _, _, _}) -> + "
"; inline(Text) when is_list(Text) -> [inline(T) || T <- Text]. -- cgit v1.2.3