From 9b789d24a52c6ebf4e86f6b7213eb669bfe03a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Israel=20Pe=C3=B1a?= Date: Fri, 30 Jan 2015 19:02:37 -0800 Subject: [PATCH] allow the HOEDOWN_EXT_UNDERLINE to work When the `HOEDOWN_EXT_UNDERLINE` extension was enabled, underlined spans would actually be passed verbatim to the output buffer. This was because the active_char was _only_ set when the emphasis, double_emphasis, or triple_emphasis handlers were registered. As a result, no active char was found in the input buffer, so everything was passed through verbatim. This patch fixes this by also registering the `active_char` if the underline handler is registered. I also added a simple regression test. I personally don't use this extension, but I encountered this bug over the course of writing bindings for Rust. --- src/document.c | 2 +- test/Tests/Underline.html | 1 + test/Tests/Underline.text | 1 + test/config.json | 5 +++++ 4 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 test/Tests/Underline.html create mode 100644 test/Tests/Underline.text diff --git a/src/document.c b/src/document.c index 47f6cf2..ec781e5 100644 --- a/src/document.c +++ b/src/document.c @@ -2751,7 +2751,7 @@ hoedown_document_new( memset(doc->active_char, 0x0, 256); - if (doc->md.emphasis || doc->md.double_emphasis || doc->md.triple_emphasis) { + if (doc->md.emphasis || doc->md.double_emphasis || doc->md.triple_emphasis || doc->md.underline) { doc->active_char['*'] = MD_CHAR_EMPHASIS; doc->active_char['_'] = MD_CHAR_EMPHASIS; if (extensions & HOEDOWN_EXT_STRIKETHROUGH) diff --git a/test/Tests/Underline.html b/test/Tests/Underline.html new file mode 100644 index 0000000..c2a8bba --- /dev/null +++ b/test/Tests/Underline.html @@ -0,0 +1 @@ +

This underline will work.

diff --git a/test/Tests/Underline.text b/test/Tests/Underline.text new file mode 100644 index 0000000..8068546 --- /dev/null +++ b/test/Tests/Underline.text @@ -0,0 +1 @@ +This _underline_ will work. diff --git a/test/config.json b/test/config.json index b6ecb55..d3e170e 100644 --- a/test/config.json +++ b/test/config.json @@ -101,6 +101,11 @@ "input": "Tests/Math.text", "output": "Tests/Math.html", "flags": ["--math"] + }, + { + "input": "Tests/Underline.text", + "output": "Tests/Underline.html", + "flags": ["--underline"] } ] }