Fix issue #125: Don't escape HTML tags in tables of contents.
Before this patch, a header like "# *A*" was displayed as "<li><em>A</em></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.
This commit is contained in:
parent
3afc3ec505
commit
737304d2aa
4 changed files with 27 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<ul>
|
||||
<li>
|
||||
<a href="#toc_0">Header with special & 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>
|
|
@ -0,0 +1,5 @@
|
|||
# Header with special & characters
|
||||
|
||||
## With `Code`
|
||||
|
||||
### With *Emphasis*
|
|
@ -24,6 +24,11 @@
|
|||
"input": "MarkdownTest_1.0.3/Tests/Code Spans.text",
|
||||
"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"
|
||||
|
|
Loading…
Reference in a new issue