aboutsummaryrefslogtreecommitdiffstats
path: root/src/asciideck_to_html.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_to_html.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_to_html.erl')
-rw-r--r--src/asciideck_to_html.erl16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/asciideck_to_html.erl b/src/asciideck_to_html.erl
index c6fbbff..b904f3a 100644
--- a/src/asciideck_to_html.erl
+++ b/src/asciideck_to_html.erl
@@ -12,8 +12,6 @@
%% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
%% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-%% @todo https://www.gnu.org/software/src-highlite/source-highlight.html
-
-module(asciideck_to_html).
-export([translate/2]).
@@ -96,7 +94,13 @@ paragraph({paragraph, _, Text, _}) ->
%% Listing blocks.
-listing_block({listing_block, Attrs, Listing, _}) ->
+listing_block({listing_block, Attrs, Listing0, _}) ->
+ Listing = case Attrs of
+ #{1 := <<"source">>, 2 := _} ->
+ try asciideck_source_highlight:filter(Listing0, Attrs) catch C:E -> io:format("~p ~p ~p~n", [C, E, erlang:get_stacktrace()]), exit(bad) end;
+ _ ->
+ ["<pre>", html_encode(Listing0), "</pre>"]
+ end,
[
"<div class=\"listingblock\">",
case Attrs of
@@ -105,9 +109,9 @@ listing_block({listing_block, Attrs, Listing, _}) ->
_ ->
[]
end,
- "<div class=\"content\"><pre>",
- html_encode(Listing),
- "</pre></div></div>\n"
+ "<div class=\"content\">",
+ Listing,
+ "</div></div>\n"
].
%% Lists.