diff --git a/src/document.c b/src/document.c index ee0102f1..c0886158 100644 --- a/src/document.c +++ b/src/document.c @@ -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; diff --git a/src/html_smartypants.c b/src/html_smartypants.c index b0904da7..e3dfa285 100644 --- a/src/html_smartypants.c +++ b/src/html_smartypants.c @@ -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, "", 3) != 0) i++; diff --git a/test/Tests/CommentsInMiddleOfLine.html b/test/Tests/CommentsInMiddleOfLine.html new file mode 100644 index 00000000..2b931667 --- /dev/null +++ b/test/Tests/CommentsInMiddleOfLine.html @@ -0,0 +1,6 @@ +

It would be super-keen to be able to use MOE directives in Markdown.

+ +

But I'd really, really + +like to be able to use them in the middle of a line.

diff --git a/test/Tests/CommentsInMiddleOfLine.text b/test/Tests/CommentsInMiddleOfLine.text new file mode 100644 index 00000000..22e08be5 --- /dev/null +++ b/test/Tests/CommentsInMiddleOfLine.text @@ -0,0 +1,8 @@ +It would be super-keen to be able to use [MOE](https://github.com/google/moe) +directives in Markdown. + + + +But I'd really, really +like to be able to use them in the middle of a line. + diff --git a/test/config.json b/test/config.json index 365c7bc9..5d873ad1 100644 --- a/test/config.json +++ b/test/config.json @@ -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",