Skip to content

Commit

Permalink
Fix attribute skipping for chibi-doc text rendering.
Browse files Browse the repository at this point in the history
Closes #996.

Also guard against bad input with proper-list?.
  • Loading branch information
ashinn committed Aug 15, 2024
1 parent 020469b commit e09fdb7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions lib/chibi/sxml.scm
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
sxml)))
(let lp ((sxml sxml))
(cond
((pair? sxml)
((proper-list? sxml)
(let ((tag (car sxml)))
(cond
;; skip headers and the menu
Expand All @@ -176,16 +176,18 @@
(pair? (cdr sxml))
(pair? (cadr sxml))
(eq? '@ (car (cadr sxml)))
(equal? '(id . "menu") (assq 'id (cdr (cadr sxml)))))))
(equal? '(id . "menu") (assq 'id (cdr (cadr sxml))))))
)
;; recurse other tags, appending newlines for new sections
((symbol? tag)
(if (memq tag '(h1 h2 h3 h4 h5 h6))
(newline out))
(for-each
lp
(if (and (pair? (cdr sxml)) (eq? '@ (cadr sxml)))
(cddr sxml)
(cdr sxml)))
(let ((ls (if (and (pair? (cdr sxml))
(pair? (cadr sxml))
(eq? '@ (car (cadr sxml))))
(cddr sxml)
(cdr sxml))))
(for-each lp ls))
(if (memq tag '(p li br h1 h2 h3 h4 h5 h6))
(newline out)))
(else
Expand Down
2 changes: 1 addition & 1 deletion lib/chibi/sxml.sld
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
(define-library (chibi sxml)
(export sxml->xml sxml-display-as-html sxml-display-as-text sxml-strip
html-escape html-tag->string)
(import (scheme base) (scheme write))
(import (scheme base) (scheme list) (scheme write))
(include "sxml.scm"))

0 comments on commit e09fdb7

Please sign in to comment.