aboutsummaryrefslogtreecommitdiffstats
path: root/src/asciideck_transform_pass.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-06-11 22:21:36 +0200
committerLoïc Hoguin <[email protected]>2018-06-11 22:21:36 +0200
commitdbb935a5972350f734d4abcf31c03f9e54bbd1d4 (patch)
treebbd4f56f9a5647c807187eb55f033255a29488df /src/asciideck_transform_pass.erl
parent976dfc5d92e3e23f356cb19f17ff51b22c75e634 (diff)
downloadasciideck-dbb935a5972350f734d4abcf31c03f9e54bbd1d4.tar.gz
asciideck-dbb935a5972350f734d4abcf31c03f9e54bbd1d4.tar.bz2
asciideck-dbb935a5972350f734d4abcf31c03f9e54bbd1d4.zip
Add source-highlight support to HTML output
Diffstat (limited to 'src/asciideck_transform_pass.erl')
-rw-r--r--src/asciideck_transform_pass.erl33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/asciideck_transform_pass.erl b/src/asciideck_transform_pass.erl
new file mode 100644
index 0000000..a1cf37c
--- /dev/null
+++ b/src/asciideck_transform_pass.erl
@@ -0,0 +1,33 @@
+%% Copyright (c) 2018, Loïc Hoguin <[email protected]>
+%%
+%% Permission to use, copy, modify, and/or distribute this software for any
+%% purpose with or without fee is hereby granted, provided that the above
+%% copyright notice and this permission notice appear in all copies.
+%%
+%% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+%% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+%% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+%% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+%% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+%% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+%% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+%% The purpose of this pass is to transform elements based
+%% on the style given in their attributes.
+-module(asciideck_transform_pass).
+
+-export([run/1]).
+
+run([]) ->
+ [];
+%% The following syntax gets converted in the corresponding
+%% listing_block element:
+%%
+%% [source,erlang]
+%% f() -> ok.
+%%
+%% @todo We should not totally overwrite subs.
+run([{paragraph, Attrs=#{1 := <<"source">>}, Text, Ann}|Tail]) ->
+ [{listing_block, Attrs#{<<"subs">> => <<"verbatim">>}, Text, Ann}|run(Tail)];
+run([Block|Tail]) ->
+ [Block|run(Tail)].