Merge pull request #181 from mikesamuel/master

HTML comments in middle of block
This commit is contained in:
Xavier Mendez 2015-11-20 22:48:38 +01:00
commit d8d37c3013
5 changed files with 35 additions and 3 deletions

View file

@ -402,9 +402,23 @@ tag_length(uint8_t *data, size_t size, hoedown_autolink_type *autolink)
/* a valid tag can't be shorter than 3 chars */
if (size < 3) return 0;
/* begins with a '<' optionally followed by '/', followed by letter or number */
if (data[0] != '<') return 0;
i = (data[1] == '/') ? 2 : 1;
/* HTML comment, laxist form */
if (size > 5 && data[1] == '!' && data[2] == '-' && data[3] == '-') {
i = 5;
while (i < size && !(data[i - 2] == '-' && data[i - 1] == '-' && data[i] == '>'))
i++;
i++;
if (i <= size)
return i;
}
/* begins with a '<' optionally followed by '/', followed by letter or number */
i = (data[1] == '/') ? 2 : 1;
if (!isalnum(data[i]))
return 0;

View file

@ -314,7 +314,7 @@ smartypants_cb__ltag(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t
size_t tag, i = 0;
/* This is a comment. Copy everything verbatim until --> or EOF is seen. */
if (i + 4 < size && memcmp(text, "<!--", 4) == 0) {
if (i + 4 < size && memcmp(text + i, "<!--", 4) == 0) {
i += 4;
while (i + 3 < size && memcmp(text + i, "-->", 3) != 0)
i++;

View file

@ -0,0 +1,6 @@
<p>It would be super-keen to be able to use <a href=
"https://github.com/google/moe">MOE</a> directives in Markdown.</p>
<!-- HTML comments work at the start of a block -->
<p>But I'd <!-- MOE:begin_strip -->really, really
<!-- MOE:end_strip -->
like to be able to use them in the middle of a line.</p>

View file

@ -0,0 +1,8 @@
It would be super-keen to be able to use [MOE](https://github.com/google/moe)
directives in Markdown.
<!-- HTML comments work at the start of a block -->
But I'd <!-- MOE:begin_strip -->really, really <!-- MOE:end_strip -->
like to be able to use them in the middle of a line.

View file

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