md4c

C Markdown parser. Fast. SAX-like interface. Compliant to CommonMark specification.
git clone https://noulin.net/git/md4c.git
Log | Files | Refs | README | LICENSE

commit 23312d6d650eeb225248688cfcb1939670f8cd3b
parent c5fa9a70947e7742876622bb6d7ce0b1252b8d06
Author: Martin Mitas <mity@morous.org>
Date:   Mon,  5 Dec 2016 11:13:43 +0100

md_is_html_tag: Fix parsing unquoted attribute value (issue #2).

Diffstat:
Mmd4c/md4c.c | 4++--
Mscripts/run-tests.sh | 6+++++-
Atest/coverage.txt | 41+++++++++++++++++++++++++++++++++++++++++
3 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/md4c/md4c.c b/md4c/md4c.c @@ -893,7 +893,7 @@ md_is_html_tag(MD_CTX* ctx, const MD_LINE* lines, int n_lines, OFF beg, OFF max_ while(1) { while(off < line_end && !ISNEWLINE(off)) { if(attr_state > 40) { - if(attr_state == 41 && ISANYOF(off, _T("\"'=<>`"))) { + if(attr_state == 41 && (ISBLANK(off) || ISANYOF(off, _T("\"'=<>`")))) { attr_state = 0; off--; /* Put the char back for re-inspection in the new state. */ } else if(attr_state == 42 && CH(off) == _T('\'')) { @@ -952,7 +952,7 @@ md_is_html_tag(MD_CTX* ctx, const MD_LINE* lines, int n_lines, OFF beg, OFF max_ off = lines[i].beg; line_end = lines[i].end; - if(attr_state == 0) + if(attr_state == 0 || attr_state == 41) attr_state = 1; if(off >= max_end) diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh @@ -24,9 +24,13 @@ elif which python 2>/dev/null; then fi fi -# Test CommonMark specification compliance (with default options): +# Test CommonMark specification compliance +# (using the vanilla specification file): $PYTHON "$TEST_DIR/spec_tests.py" -s "$TEST_DIR/spec.txt" -p "$PROGRAM" +# More tests for better coverage ten what the spec provides: +$PYTHON "$TEST_DIR/spec_tests.py" -s "$TEST_DIR/coverage.txt" -p "$PROGRAM" + # Test various extensions and deviations from the specifications: $PYTHON "$TEST_DIR/spec_tests.py" -s "$TEST_DIR/permissive-email-autolinks.txt" -p "$PROGRAM --fpermissive-email-autolinks" $PYTHON "$TEST_DIR/spec_tests.py" -s "$TEST_DIR/permissive-url-autolinks.txt" -p "$PROGRAM --fpermissive-url-autolinks" diff --git a/test/coverage.txt b/test/coverage.txt @@ -0,0 +1,41 @@ + +# Coverage + +This file is just a collection of unit tests not covered elsewhere. + +Most notably regression tests, tests improving code coverage and other useful +things may drop here. + +(However any tests requiring any additional command line option, like enabling +an extension, must be included in their respective files.) + + +## GitHub Issues + +### [Issue 2](https://github.com/mity/md4c/issues/2) + +Raw HTML block: + +```````````````````````````````` example +<gi att1=tok1 att2=tok2> +. +<gi att1=tok1 att2=tok2> +```````````````````````````````` + +Inline: + +```````````````````````````````` example +foo <gi att1=tok1 att2=tok2> bar +. +<p>foo <gi att1=tok1 att2=tok2> bar</p> +```````````````````````````````` + +Inline with a line break: + +```````````````````````````````` example +foo <gi att1=tok1 +att2=tok2> bar +. +<p>foo <gi att1=tok1 +att2=tok2> bar</p> +````````````````````````````````