Commit 23312d6d650eeb225248688cfcb1939670f8cd3b

Martin Mitas 2016-12-05T11:13:43

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

diff --git a/md4c/md4c.c b/md4c/md4c.c
index 6044772..5b49123 100644
--- 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
index 255e459..d333c7a 100755
--- 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
new file mode 100644
index 0000000..b720b45
--- /dev/null
+++ 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>
+````````````````````````````````