From 8c43cd8f9356a764170ddb435a8b79beee9b95b0 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 25 Oct 2022 22:49:18 -0700 Subject: [PATCH 1/5] Install all headers in include/cmark-gfm These are needed to actually use the library it seems. Signed-off-by: Keith Packard --- src/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 84dd2a037..6a67078f1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -175,6 +175,10 @@ if(CMARK_SHARED OR CMARK_STATIC) DESTINATION include ) + install(FILES ${HEADERS} + DESTINATION include/cmark-gfm + ) + install(EXPORT cmark-gfm DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake) endif() From 2c223c48f646c3874464f497b0fa9784a8237bde Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 5 Jan 2025 09:31:56 -0800 Subject: [PATCH 2/5] man: Add missing command line options These options were documented in --help but missing from the man page. Signed-off-by: Keith Packard --- man/man1/cmark-gfm.1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/man/man1/cmark-gfm.1 b/man/man1/cmark-gfm.1 index 4fca62732..c25791c33 100644 --- a/man/man1/cmark-gfm.1 +++ b/man/man1/cmark-gfm.1 @@ -66,6 +66,18 @@ URLs are those that begin with `javascript:`, `vbscript:`, `file:`, or `data:` (except for `image/png`, `image/gif`, `image/jpeg`, or `image/webp` mime types). .TP 12n +.B \-\-github-pre-lang +Use GitHub-style
 for code blocks.
+.TP 12n
+.B \-\-strikethrough-double-tilde
+Only parse strikethrough (if enabled) with two tildes.
+.TP 12n
+.B \-\-table-prefer-style-attributes
+Use style attributes to align table cells instead of align attributes.
+.TP 12n
+.B \-\-full-info-string
+Include remainder of code block info string in a separate attribute.
+.TP 12n
 .B \-\-help
 Print usage information.
 .TP 12n

From 80d687b0f453e42865d7cf081cb91d13cead1d59 Mon Sep 17 00:00:00 2001
From: Keith Packard 
Date: Sun, 5 Jan 2025 09:18:22 -0800
Subject: [PATCH 3/5] Provide a way to extend test timeouts

Some hardware is really slow; let users set CMARK_TIMING_SCALE to
multiply the timeouts by an arbitrary amount

Signed-off-by: Keith Packard 
---
 api_test/main.c            | 17 +++++++++++++++--
 test/pathological_tests.py |  4 +++-
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/api_test/main.c b/api_test/main.c
index 1a41e694a..790327c62 100644
--- a/api_test/main.c
+++ b/api_test/main.c
@@ -942,6 +942,13 @@ static void test_feed_across_line_ending(test_batch_runner *runner) {
 #  include 
 static struct timeval _before, _after;
 static int _timing;
+static int _timing_scale = 1;
+#  define SETUP_TIMING()                        \
+  do {                                          \
+    char *scale = getenv("CMARK_TIMING_SCALE"); \
+    if (scale)                                  \
+      _timing_scale = atoi(scale);              \
+  } while (0)
 #  define START_TIMING() \
        gettimeofday(&_before, NULL)
 
@@ -952,10 +959,13 @@ static int _timing;
         } while (0)
 
 #  define TIMING _timing
+#  define TIMING_SCALE _timing_scale
 #else
+#  define SETUP_TIMING()
 #  define START_TIMING()
 #  define END_TIMING()
 #  define TIMING 0
+#  define TIMING_SCALE 1
 #endif
 
 static void test_pathological_regressions(test_batch_runner *runner) {
@@ -973,7 +983,8 @@ static void test_pathological_regressions(test_batch_runner *runner) {
     free(html);
     free(input);
 
-    OK(runner, TIMING < 1000, "takes less than 1000ms to run");
+    OK(runner, TIMING < 1000 * TIMING_SCALE,
+       "takes less than CMARK_TIMING_SCALE * 1000ms to run");
   }
 
   {
@@ -989,7 +1000,8 @@ static void test_pathological_regressions(test_batch_runner *runner) {
     free(html);
     free(input);
 
-    OK(runner, TIMING < 1000, "takes less than 1000ms to run");
+    OK(runner, TIMING < 1000 * TIMING_SCALE,
+       "takes less than CMARK_TIMING_SCALE * 1000ms to run");
   }
 }
 
@@ -1133,6 +1145,7 @@ int main() {
   int retval;
   test_batch_runner *runner = test_batch_runner_new();
 
+  SETUP_TIMING();
   cmark_enable_safety_checks(true);
   version(runner);
   constructor(runner);
diff --git a/test/pathological_tests.py b/test/pathological_tests.py
index d0e910c5e..f556a1dce 100644
--- a/test/pathological_tests.py
+++ b/test/pathological_tests.py
@@ -7,6 +7,7 @@
 import platform
 import itertools
 import multiprocessing
+import os
 from cmark import CMark
 
 def hash_collisions():
@@ -106,7 +107,8 @@ def badhash(ref):
 passed = 0
 errored = 0
 ignored = 0
-TIMEOUT = 5
+timing_scale = float(os.getenv("CMARK_TIMING_SCALE", "1"))
+TIMEOUT = 5 * timing_scale
 
 def run_test(inp, regex):
     parser = argparse.ArgumentParser(description='Run cmark tests.')

From 2cd7a1abd8ed23625648481059c2bd7161111ec4 Mon Sep 17 00:00:00 2001
From: Keith Packard 
Date: Sun, 5 Jan 2025 16:51:03 -0800
Subject: [PATCH 4/5] test: Fix regex syntax errors

The regular expressions in normalize.py and pathological_tests.py are
missing a lot of backslashes -- you need two in the source file to get
one in the string.

Signed-off-by: Keith Packard 
---
 test/normalize.py          |  4 ++--
 test/pathological_tests.py | 20 ++++++++++----------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/test/normalize.py b/test/normalize.py
index b7fd9b245..ec4979c0b 100644
--- a/test/normalize.py
+++ b/test/normalize.py
@@ -18,7 +18,7 @@ class HTMLParseError(Exception):
 # Normalization code, adapted from
 # https://github.com/karlcow/markdown-testsuite/
 significant_attrs = ["alt", "href", "src", "title"]
-whitespace_re = re.compile('\s+')
+whitespace_re = re.compile('\\s+')
 class MyHTMLParser(HTMLParser):
     def __init__(self):
         HTMLParser.__init__(self)
@@ -176,7 +176,7 @@ def normalize_html(html):
         '\u2200&><"'
 
     """
-    html_chunk_re = re.compile("(\|\<[^>]*\>|[^<]+)")
+    html_chunk_re = re.compile("(\\|\\<[^>]*\\>|[^<]+)")
     try:
         parser = MyHTMLParser()
         # We work around HTMLParser's limitations parsing CDATA
diff --git a/test/pathological_tests.py b/test/pathological_tests.py
index f556a1dce..80b5261dc 100644
--- a/test/pathological_tests.py
+++ b/test/pathological_tests.py
@@ -30,7 +30,7 @@ def badhash(ref):
 
     document = ''.join("[%s]: /url\n\n[%s]\n\n" % (key, bad_key) for key in collisions)
 
-    return document, re.compile("(

\[%s\]

\n){%d}" % (bad_key, COUNT-1)) + return document, re.compile("(

\\[%s\\]

\n){%d}" % (bad_key, COUNT-1)) allowed_failures = {"many references": True} @@ -48,10 +48,10 @@ def badhash(ref): re.compile("(_a ){64999}_a")), "many link closers with no openers": (("a]" * 65000), - re.compile("(a\]){65000}")), + re.compile("(a\\]){65000}")), "many link openers with no closers": (("[a" * 65000), - re.compile("(\[a){65000}")), + re.compile("(\\[a){65000}")), "mismatched openers and closers": (("*a_ " * 50000), re.compile("([*]a[_] ){49999}[*]a_")), @@ -60,19 +60,19 @@ def badhash(ref): re.compile("a[*][*]b(c[*] ){49999}c[*]")), "link openers and emph closers": (("[ a_" * 50000), - re.compile("(\[ a_){50000}")), + re.compile("(\\[ a_){50000}")), "pattern [ (]( repeated": (("[ (](" * 80000), - re.compile("(\[ \(\]\(){80000}")), + re.compile("(\\[ \\(\\]\\(){80000}")), "pattern ![[]() repeated": ("![[]()" * 160000, - re.compile("(!\[){160000}")), + re.compile("(!\\[){160000}")), "hard link/emph case": ("**x [a*b**c*](d)", re.compile("\\*\\*x ab\\*\\*c")), "nested brackets": (("[" * 50000) + "a" + ("]" * 50000), - re.compile("\[{50000}a\]{50000}")), + re.compile("\\[{50000}a\\]{50000}")), "nested block quotes": ((("> " * 50000) + "a"), re.compile("(
\n){50000}")), @@ -87,13 +87,13 @@ def badhash(ref): re.compile("^

[e`]*

\n$")), "unclosed links A": ("[a](aaa

\n\n\n\n\n\n\n\n(\n\n\n\n\n\n\n\n\n){29999}\n
bbb
aaa
bbb
-\x0b
\n$")), From f29ba485c91cfc9d059556c643e175e61d44ead3 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 5 Jan 2025 16:52:48 -0800 Subject: [PATCH 5/5] test: Fix use of allowed_failures in pathological_tests.py The test needs to check if the test description is a valid key in the allowed_failures dictionary instead of attempting to fetch from the dictionary as most of the descriptions are not present in the dictionary leading to a missing key error at runtime. Signed-off-by: Keith Packard --- test/pathological_tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/pathological_tests.py b/test/pathological_tests.py index 80b5261dc..c2fdff64d 100644 --- a/test/pathological_tests.py +++ b/test/pathological_tests.py @@ -146,12 +146,12 @@ def run_test(inp, regex): p.terminate() p.join() print('[TIMED OUT]') - if allowed_failures[description]: + if description in allowed_failures: ignored += 1 else: errored += 1 elif p.exitcode != 0: - if allowed_failures[description]: + if description in allowed_failures: ignored += 1 else: errored += 1