Hi,

Attached is a patch to fix the safe argument to cmark->html. Recent versions of 
cmark are safe by default and require CMARK_OPT_UNSAFE to parse raw html.

As another note, cmark->sxml is a pretty impressive effort, but it doesn't 
handle parsing raw HTML at all. This seems fairly complicated to do, especially 
when cmark->html will already handle it and we can pass its output to an 
existing html->sxml parser (I'm partial to the html-parser egg). I think that 
may be a more robust approach so as to not have to re-implement the quirks of 
HTML parsing from the cmark node structure, which appears to be pretty flat.

If the maintainer of the cmark egg is inactive (judging by previous emails in 
the mailing list), I would be interested in maintaining this.

Diego
From 1661bac829ac9a2a144c3597af5a67a86b042c54 Mon Sep 17 00:00:00 2001
From: "Diego A. Mundo" <[email protected]>
Date: Tue, 29 Sep 2026 08:52:20 -0400
Subject: [PATCH] Fix safe argument to cmark->html

New versions of cmark are safe with CMARK_OPT_DEFAULT and require
CMARK_OPT_UNSAFE to parse raw HTML.
---
 cmark.scm | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/cmark.scm b/cmark.scm
index b01a429..38ac968 100644
--- a/cmark.scm
+++ b/cmark.scm
@@ -124,6 +124,7 @@
  (foreign-declare "#include \"cmark.h\"")
 
  (define CMARK_OPT_SAFE (foreign-value "CMARK_OPT_SAFE" int))
+ (define CMARK_OPT_UNSAFE (foreign-value "CMARK_OPT_UNSAFE" int))
  (define CMARK_OPT_DEFAULT (foreign-value "CMARK_OPT_DEFAULT" int))
 
  ;; Event Types
@@ -632,10 +633,7 @@ (define cmark-markdown-to-html
    (foreign-lambda c-string "cmark_markdown_to_html" c-string size_t int))
 
  (define (commonmark->html input #!key (safe #t))
-   (let ((opt (if safe CMARK_OPT_SAFE CMARK_OPT_DEFAULT)))
+   (let ((opt (if safe CMARK_OPT_DEFAULT CMARK_OPT_UNSAFE)))
      (cmark-markdown-to-html input (string-length input) opt)))
 
- (define (cmark->html input #!key (safe #t))
-   (let ((opt (if safe CMARK_OPT_SAFE CMARK_OPT_DEFAULT)))
-     (cmark-markdown-to-html input (string-length input) opt)))
- )
+ (define cmark->html commonmark->html))
-- 
2.47.3

Reply via email to