fix: dialog draw-border arg, markdown/slot nil guards, +integration test suite

This commit is contained in:
Hermes Agent
2026-05-12 14:30:31 +00:00
parent 6e73c3bb19
commit 00db3c61a5
7 changed files with 423 additions and 44 deletions

View File

@@ -31,6 +31,7 @@
;; ─── Block-level parser ───────────────────────────────────────────────────────
(defun split-string-into-lines (string)
(unless string (return-from split-string-into-lines (coerce nil 'vector)))
(let ((result nil) (start 0))
(flet ((add-line (end) (push (subseq string start end) result)))
(loop for i from 0 below (length string)
@@ -212,6 +213,7 @@
i))))
(defun parse-blocks (text)
(unless text (return-from parse-blocks nil))
(let ((lines (split-string-into-lines text)) (nodes nil) (i 0))
(loop while (< i (length lines))
do (let* ((line (string-trim (list #\return) (aref lines i)))
@@ -502,6 +504,7 @@
(nreverse tokens)))
(defun highlight-code (code language)
(unless code (return-from highlight-code nil))
(let ((highlighter (get-highlighter (and language (string-downcase language)))))
(unless highlighter (return-from highlight-code (list (cons code :plain))))
(let ((tokens nil))
@@ -672,6 +675,7 @@
lines))
(defun render-markdown (text)
(unless text (return-from render-markdown ""))
(let ((nodes (parse-blocks text)) (parts nil))
(dolist (line (render-md nodes)) (push line parts))
(with-output-to-string (s)