aboutsummaryrefslogtreecommitdiffstats
path: root/src/asciideck_to_manpage.erl
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 /src/asciideck_to_manpage.erl
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 'src/asciideck_to_manpage.erl')
-rw-r--r--src/asciideck_to_manpage.erl8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/asciideck_to_manpage.erl b/src/asciideck_to_manpage.erl
index dbdb74d..4158b4d 100644
--- a/src/asciideck_to_manpage.erl
+++ b/src/asciideck_to_manpage.erl
@@ -69,7 +69,7 @@ man([{ll, _Attrs, Items, _Ann}|Tail], Acc0) ->
%% @todo Attributes.
%% Currently acts as if options="headers" was always set.
man([{table, _TAttrs, [{row, RowAttrs, Headers0, RowAnn}|Rows0], _TAnn}|Tail], Acc0) ->
- Headers = [{cell, CAttrs, [{p, Attrs, [{em, P}], Ann}], CAnn}
+ Headers = [{cell, CAttrs, [{p, Attrs, [{strong, #{}, P, CAnn}], Ann}], CAnn}
|| {cell, CAttrs, [{p, Attrs, P, Ann}], CAnn} <- Headers0],
Rows = [{row, RowAttrs, Headers, RowAnn}|Rows0],
Acc = [[
@@ -133,16 +133,16 @@ man_table_contents_cols([{cell, _CAttrs, [{p, _PAttrs, Text, _PAnn}], _CAnn}|Tai
man_format(Text) when is_binary(Text) ->
Text;
-man_format({link, Link, Text}) ->
+man_format({rel_link, #{target := Link}, Text, _}) ->
case re:run(Text, "^([-_:.a-zA-Z]*)(\\([0-9]\\))$", [{capture, all, binary}]) of
nomatch -> [Text, " (", Link, ")"];
{match, [_, ManPage, ManSection]} -> ["\\fB", ManPage, "\\fR", ManSection]
end;
-man_format({em, Text}) ->
+man_format({strong, _, Text, _}) ->
["\\fB", man_format(Text), "\\fR"];
%% We are already using a monospace font.
%% @todo Maybe there's a readable formatting we could use to differentiate from normal text?
-man_format({mono, Text}) ->
+man_format({mono, _, Text, _}) ->
man_format(Text);
man_format(Text) when is_list(Text) ->
[man_format(T) || T <- Text].