aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2016-10-18 18:04:35 +0200
committerLoïc Hoguin <[email protected]>2016-10-18 18:04:35 +0200
commitb534d457c3813c4c2d905a04f6183e7317d66720 (patch)
tree0cae961b1b472d373f1449cac0ae1c149987db2d /test
parent2e4d6f4d5e239198e096e09e4207214951b42db1 (diff)
downloadasciideck-b534d457c3813c4c2d905a04f6183e7317d66720.tar.gz
asciideck-b534d457c3813c4c2d905a04f6183e7317d66720.tar.bz2
asciideck-b534d457c3813c4c2d905a04f6183e7317d66720.zip
Fix the AST and add tests for formatting
Also opened the way to making configurable quoted text elements, like the original Asciidoc allows. We could potentially end up allowing users to define different types of quotes producing custom AST.
Diffstat (limited to 'test')
-rw-r--r--test/parser_SUITE.erl52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/parser_SUITE.erl b/test/parser_SUITE.erl
index 8869ec1..eca21a3 100644
--- a/test/parser_SUITE.erl
+++ b/test/parser_SUITE.erl
@@ -39,6 +39,46 @@ empty_line_spaces(_) ->
[] = parse(" \n \n \n \n \n"),
ok.
+%% Text formatting.
+
+quoted_text_strong(_) ->
+ doc("Strong text formatting. (10.1)"),
+ [{p, _, [{strong, _, <<"Hello beautiful world!">>, _}], _}] =
+ parse("*Hello beautiful world!*"),
+ [{p, _, [{strong, _, <<"Hello">>, _}, <<" beautiful world!">>], _}] =
+ parse("*Hello* beautiful world!"),
+ [{p, _, [<<"Hello ">>, {strong, _, <<"beautiful">>, _}, <<" world!">>], _}] =
+ parse("Hello *beautiful* world!"),
+ [{p, _, [<<"Hello beautiful ">>, {strong, _, <<"world!">>, _}], _}] =
+ parse("Hello beautiful *world!*"),
+ [{p, _, [<<"Hello beautiful ">>, {strong, _, <<"multiline world!">>, _}, <<" lol">>], _}] =
+ parse("Hello beautiful *multiline\nworld!* lol"),
+ %% Nested formatting.
+ [{p, _, [{strong, _, [
+ <<"Hello ">>,
+ {rel_link, #{target := <<"downloads/cowboy-2.0.tgz">>}, <<"2.0">>, _},
+ <<" world!">>
+ ], _}], _}] =
+ parse("*Hello link:downloads/cowboy-2.0.tgz[2.0] world!*"),
+ ok.
+
+quoted_text_literal_mono(_) ->
+ doc("Literal monospace text formatting. (10.1)"),
+ [{p, _, [{mono, _, <<"Hello beautiful world!">>, _}], _}] =
+ parse("`Hello beautiful world!`"),
+ [{p, _, [{mono, _, <<"Hello">>, _}, <<" beautiful world!">>], _}] =
+ parse("`Hello` beautiful world!"),
+ [{p, _, [<<"Hello ">>, {mono, _, <<"beautiful">>, _}, <<" world!">>], _}] =
+ parse("Hello `beautiful` world!"),
+ [{p, _, [<<"Hello beautiful ">>, {mono, _, <<"world!">>, _}], _}] =
+ parse("Hello beautiful `world!`"),
+ [{p, _, [<<"Hello beautiful ">>, {mono, _, <<"multiline world!">>, _}, <<" lol">>], _}] =
+ parse("Hello beautiful `multiline\nworld!` lol"),
+ %% No text formatting must occur inside backticks.
+ [{p, _, [{mono, _, <<"Hello *beautiful* world!">>, _}], _}] =
+ parse("`Hello *beautiful* world!`"),
+ ok.
+
%% Title.
%% @todo Long titles. (11.1)
@@ -275,6 +315,18 @@ labeled_list(_) ->
%% Macros.
+rel_link(_) ->
+ doc("Relative links are built using the link:<target>[<caption>] macro. (21.1.3)"),
+ [{p, _, [
+ {rel_link, #{target := <<"downloads/cowboy-2.0.tgz">>}, <<"2.0">>, _}
+ ], _}] = parse("link:downloads/cowboy-2.0.tgz[2.0]"),
+ [{p, _, [
+ <<"Download ">>,
+ {rel_link, #{target := <<"downloads/cowboy-2.0.zip">>}, <<"Cowboy 2.0">>, _},
+ <<" as zip">>
+ ], _}] = parse("Download link:downloads/cowboy-2.0.zip[Cowboy 2.0] as zip"),
+ ok.
+
comment_line(_) ->
doc("Lines starting with two slashes are treated as comments. (21.2.3)"),
[{comment, _, <<"This is a comment.">>, _}] = parse("// This is a comment."),