md_is_html_tag: Fix parsing unquoted attribute value (issue #2).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
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>
+````````````````````````````````