1
0
Fork 0

Compare commits

...

4 commits

Author SHA1 Message Date
f880847f15 Merge remote-tracking branch 'sourcehut/customizations' into customizations 2023-09-06 15:25:54 -07:00
a502f2ce9c Merge branch 'svg-support' into customizations 2021-07-02 02:32:22 -07:00
3924728bab Add trickery to support embedded SVG images
- Specify the svg and xlink namespaces to the `xml->sxml' procedure so that it
  doesn't include them in full for each tag.
- For the default `pre-post-order' handler strip the `svg:' prefix if found.
- Strip the `svg:' namespace from the SVG element and insert the `xmlns' and
  `xmlns:xlink' namespace definition attributes into the attributes.

This is all very brittle and badly done, but for the moment this fixes my
use-case of wanting to display SVG images embedded in the HTML.
2021-07-02 02:28:27 -07:00
32b9adf4bf Fix tag pages by reverting to the original layout 2021-05-31 20:44:34 -07:00
2 changed files with 21 additions and 9 deletions

View file

@ -81,15 +81,24 @@
(define (wordpress->sxml text)
(let ((sxml (cadr (with-input-from-string* (string-append "<div>" text "</div>")
xml->sxml))))
(lambda () (xml->sxml #:namespaces '((svg . "http://www.w3.org/2000/svg"))))))))
(pre-post-order
sxml
`((*default* . ,(lambda (tag . body)
(if (can-contain-p? tag)
(wpautop tag body)
(cons tag body))))
(let ((tag (if (string-prefix? "svg:" (symbol->string tag))
(string->symbol (substring (symbol->string tag) 4))
tag)))
(if (can-contain-p? tag)
(wpautop tag body)
(cons tag body)))))
(*text* . ,(lambda (tag text)
text))))))
text))
(svg:svg . ,(lambda (tag . body)
(cons 'svg
(cons `(@ (xmlns "http://www.w3.org/2000/svg")
(xmlns:xlink "http://www.w3.org/1999/xlink")
,@(cdar body))
(cdr body)))))))))
(define (marxdown->sxml text)
(smarxdown->shtml (call-with-input-string text marxdown->smarxdown)))

View file

@ -301,10 +301,13 @@
(post-from-key index key))
(hash-ref tags tag '()))))
(if (pair? posts)
(respond `(,(tag-sidebar tag index)
(h2 "posts tagged \"" ,tag "\"")
,@(map (lambda (post) (show-post post #f))
(take-max (reverse posts) 10)))
(respond `((h2 "posts tagged \"" ,tag "\" ("
,(rellink '("feed" "atom") "feed"
#:query `(("with" . ,tag)))
")")
,@(map (lambda (post) `(p ,(post-link post)))
(take-max (reverse posts) 10))
,(related-tag-cloud tag index))
#:etag (assq-ref index 'master)
#:title (string-append "posts tagged \"" tag "\""))
(respond `((h2 "Unknown tag " ,tag)