Merge pull request #146 from stevewolter/master

Fix issue #125 (formatting in TOCs) and out-of-bounds memory access in tab expansion
This commit is contained in:
Xavier Mendez 2014-12-01 17:32:53 +01:00
commit 977e26e2c9
5 changed files with 28 additions and 3 deletions

View file

@ -2707,10 +2707,10 @@ static void expand_tabs(hoedown_buffer *ob, const uint8_t *line, size_t size)
size_t org = i;
while (i < size && line[i] != '\t') {
i++;
/* ignore UTF-8 continuation bytes */
if ((line[i] & 0xc0) != 0x80)
tab++;
i++;
}
if (i > org)

View file

@ -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

View file

@ -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>

View file

@ -0,0 +1,5 @@
# Header with special & characters
## With `Code`
### With *Emphasis*

View file

@ -92,6 +92,11 @@
"input": "Tests/Escape character.text",
"output": "Tests/Escape character.html"
},
{
"input": "Tests/Formatting in Table of Contents.text",
"output": "Tests/Formatting in Table of Contents.html",
"flags": ["--html-toc", "-t", "3"]
},
{
"input": "Tests/Math.text",
"output": "Tests/Math.html",