From 074e21e93abf0eec59973cc35c9d2755d4a921f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sat, 26 Nov 2016 16:58:49 +0100 Subject: Fix an issue in Ranch manual Solution is a hack for now, unfortunately. --- src/asciideck_parser.erl | 9 +++++++-- test/parser_SUITE.erl | 10 ++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/asciideck_parser.erl b/src/asciideck_parser.erl index 7d81112..9755d29 100644 --- a/src/asciideck_parser.erl +++ b/src/asciideck_parser.erl @@ -195,8 +195,13 @@ p1_ll_glob([{LN, <<"+">>}|Tail], Acc) -> p1_ll_glob(Tail, [{LN, <<>>}|Acc]); p1_ll_glob([{LN, <<" ", Line/bits>>}|Tail], Acc) -> p1_ll_glob([{LN, trim_ws(Line)}|Tail], Acc); -p1_ll_glob([Line|Tail], Acc) -> - p1_ll_glob(Tail, [Line|Acc]). +p1_ll_glob(Lines=[Line={LN, Text}|Tail], Acc) -> + case binary:split(<< Text/binary, $\s >>, <<":: ">>) of + [_, _] -> + {Lines, lists:reverse([{LN, <<>>}|Acc])}; + _ -> + p1_ll_glob(Tail, [Line|Acc]) + end. p1_text(Lines=[{LN, Line}|Tail], AST, St) -> case binary:split(<< Line/binary, $\s >>, <<":: ">>) of diff --git a/test/parser_SUITE.erl b/test/parser_SUITE.erl index eca21a3..0f7b393 100644 --- a/test/parser_SUITE.erl +++ b/test/parser_SUITE.erl @@ -303,6 +303,16 @@ labeled_list(_) -> [{ll, _, [ {li, #{label := <<"The label">>}, [{p, _, <<"The value!">>, _}], _} ], _}] = parse("The label:: The value!"), + %% @todo Currently this returns two ll. This is a bug but it gives + %% me the result I want, or close enough, for now. + [{ll, _, [ + {li, #{label := <<"The label">>}, [{p, _, <<"The value!">>, _}], _} + ], _}, + {ll, _, [ + {li, #{label := <<"More labels">>}, [{p, _, <<"More values!">>, _}], _} + ], _}] = parse( + "The label:: The value!\n" + "More labels:: More values!\n"), [{ll, _, [ {li, #{label := <<"The label">>}, [{p, _, <<"The value!">>, _}], _} ], _}] = parse( -- cgit v1.2.3