summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Wolter <swolter@google.com>2014-12-01 12:34:46 +0100
committerSteve Wolter <swolter@google.com>2014-12-01 12:35:14 +0100
commit737304d2aa24a7a225aaf14b2e23065be8adc449 (patch)
tree11112f6c945adb0dbaff491f55de927e27b76545
parent3afc3ec505dd7dd902086f8c158290962e705663 (diff)
downloadrust-hoedown-737304d2aa24a7a225aaf14b2e23065be8adc449.tar.gz
Fix issue #125: Don't escape HTML tags in tables of contents.
Before this patch, a header like "# *A*" was displayed as "<li>&lt;em&gtA&lt;/em&gt;</li>" in the TOC. The error was caused by toc_header doing the HTML escaping. In the normal HTML renderer, the escaping is done by the normal_text hook. This patch uses the same handling to fix the issue.
-rw-r--r--src/html.c4
-rw-r--r--test/MarkdownTest_1.0.3/Tests/Formatting in Table of Contents.html15
-rw-r--r--test/MarkdownTest_1.0.3/Tests/Formatting in Table of Contents.text5
-rw-r--r--test/config.json5
4 files changed, 27 insertions, 2 deletions
diff --git a/src/html.c b/src/html.c
index ddebff7..9eea3a1 100644
--- a/src/html.c
+++ b/src/html.c
@@ -586,7 +586,7 @@ toc_header(hoedown_buffer *ob, const hoedown_buffer *content, int level, const h
}
hoedown_buffer_printf(ob, "<a href=\"#toc_%d\">", state->toc_data.header_count++);
- if (content) escape_html(ob, content->data, content->size);
+ if (content) hoedown_buffer_put(ob, content->data, content->size);
HOEDOWN_BUFPUTSL(ob, "</a>\n");
}
}
@@ -654,7 +654,7 @@ hoedown_html_toc_renderer_new(int nesting_level)
NULL,
NULL,
- NULL,
+ rndr_normal_text,
NULL,
toc_finalize
diff --git a/test/MarkdownTest_1.0.3/Tests/Formatting in Table of Contents.html b/test/MarkdownTest_1.0.3/Tests/Formatting in Table of Contents.html
new file mode 100644
index 0000000..8e7be95
--- /dev/null
+++ b/test/MarkdownTest_1.0.3/Tests/Formatting in Table of Contents.html
@@ -0,0 +1,15 @@
+<ul>
+<li>
+<a href="#toc_0">Header with special &amp; characters</a>
+<ul>
+<li>
+<a href="#toc_1">With <code>Code</code></a>
+<ul>
+<li>
+<a href="#toc_2">With <em>Emphasis</em></a>
+</li>
+</ul>
+</li>
+</ul>
+</li>
+</ul>
diff --git a/test/MarkdownTest_1.0.3/Tests/Formatting in Table of Contents.text b/test/MarkdownTest_1.0.3/Tests/Formatting in Table of Contents.text
new file mode 100644
index 0000000..b95fbaa
--- /dev/null
+++ b/test/MarkdownTest_1.0.3/Tests/Formatting in Table of Contents.text
@@ -0,0 +1,5 @@
+# Header with special & characters
+
+## With `Code`
+
+### With *Emphasis*
diff --git a/test/config.json b/test/config.json
index 63cb1d7..3580686 100644
--- a/test/config.json
+++ b/test/config.json
@@ -25,6 +25,11 @@
"output": "MarkdownTest_1.0.3/Tests/Code Spans.html"
},
{
+ "input": "MarkdownTest_1.0.3/Tests/Formatting in Table of Contents.text",
+ "output": "MarkdownTest_1.0.3/Tests/Formatting in Table of Contents.html",
+ "flags": ["--html-toc", "-t", "3"]
+ },
+ {
"input": "MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.text",
"output": "MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.html"
},