Commit2848996cRecorded25 Feb 2026Repositorysigil-markdown
Add specs to (sigil jwt), (sigil version), and (sigil markdown)
Message
- jwt: 3 specs + fix outdated alist docstrings to say dict
- version: 14 specs for parsing, comparison, constraints, bumps
- markdown: 9 specs for parsing and conversion functions
Changed
src/sigil/markdown.sgl | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)Diff
src/sigil/markdown.sglmodified
@@ -82,8 +82,9 @@
82
"" 83
(substring str n (string-length str)))) 84
−85
;;; Split string into lines+85
;;; Split string into lines. 86
(define (string->lines str)+87
(: string? -> list?) 88
(let ((len (string-length str))) 89
(let loop ((start 0) (i 0) (lines '())) 90
(cond@@ -124,9 +125,11 @@
125
(and (= (string-length trimmed) 3) 126
(equal? trimmed "---")))) 127
−127
;;; Parse a YAML-style key: value line−128
;;; Returns (key . value) or #f+128
;;; Parse a YAML-style key: value line.+129
;;;+130
;;; Returns `(key . value)` or `#f`. 131
(define (parse-yaml-line line)+132
(: string? -> any?) 133
(let ((colon-pos (string-index line (lambda (c) (eq? c #\:))))) 134
(if colon-pos 135
(let* ((key (string-trim (substring line 0 colon-pos)))@@ -146,8 +149,9 @@
149
(loop (+ i 1) 150
(cons (if (eq? c #\_) #\- c) chars))))))) 151
−149
;;; Parse a YAML value (string, number, or boolean)+152
;;; Parse a YAML value (string, number, or boolean). 153
(define (parse-yaml-value str)+154
(: string? -> any?) 155
(cond 156
;; Empty value 157
((string-blank? str) "")@@ -179,6 +183,7 @@
183
;;; ; => (((title . "Hello")) "" "# Content") 184
;;; ``` 185
(define (parse-front-matter lines)+186
(: list? -> pair?) 187
(if (or (null? lines) 188
(not (front-matter-delimiter? (car lines)))) 189
;; No front matter@@ -321,6 +326,7 @@
326
;;; Returns a list of block structures (headers, paragraphs, code blocks, 327
;;; lists, etc.) that can be converted to SXML. 328
(define (parse-blocks lines)+329
(: list? -> list?) 330
(let loop ((lines lines) (blocks '())) 331
(if (null? lines) 332
(reverse blocks)@@ -606,6 +612,7 @@
612
;;; ; => ("Hello " (strong "world")) 613
;;; ``` 614
(define (parse-inline text)+615
(: string? -> list?) 616
(if (string-blank? text) 617
'() 618
(let ((m (peg/match (get-inline-grammar) text)))@@ -723,6 +730,7 @@
730
;;; ; => (document (@ (title "Test")) (h1 "Content")) 731
;;; ``` 732
(define (markdown->sxml text)+733
(: string? -> list?) 734
(let* ((lines (string->lines text)) 735
(fm-result (parse-front-matter lines)) 736
(front-matter (car fm-result))@@ -743,6 +751,7 @@
751
;;; ; => (document (h1 "Project Name") (p "Description...") ...) 752
;;; ``` 753
(define (markdown-file->sxml filename)+754
(: string? -> list?) 755
(let ((port (open-input-file filename))) 756
(let loop ((chars '())) 757
(let ((c (read-char port)))