diff options
author | Arun Isaac | 2023-08-09 16:31:48 +0100 |
---|---|---|
committer | Arun Isaac | 2023-08-09 16:43:59 +0100 |
commit | a0225f0b5492578372896d63b6ce7bd9ab041b31 (patch) | |
tree | 47c03b5ea23077f4bfaa13b5c9f775539414d362 /doc | |
parent | 1b73af1411c08f42b682b79c0d1e717c891831bd (diff) | |
download | guix-forge-a0225f0b5492578372896d63b6ce7bd9ab041b31.tar.gz guix-forge-a0225f0b5492578372896d63b6ce7bd9ab041b31.tar.lz guix-forge-a0225f0b5492578372896d63b6ce7bd9ab041b31.zip |
doc: Override description markup writer.
* doc/skribilo.scm: Import (skribilo output).
(node->html-tag): New function.
(html-engine): Override the description markup writer.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/skribilo.scm | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/doc/skribilo.scm b/doc/skribilo.scm index e65afe7..4058e62 100644 --- a/doc/skribilo.scm +++ b/doc/skribilo.scm @@ -31,6 +31,7 @@ #:use-module (skribilo ast) #:use-module (skribilo engine) #:use-module (skribilo lib) + #:use-module (skribilo output) #:use-module (skribilo writer) #:use-module (skribilo package base) #:use-module (skribilo parameters) @@ -340,6 +341,23 @@ are a list of <record-field> objects." (texi-fragment->stexi (function-docstring function))))))) +(define (node->html-tag tag node) + "Output starting HTML @var{tag} of @var{node}." + (display + (format "<~a ~a>" + tag + (string-join (map (match-lambda + ((key . value) + (format "~a=\"~a\"" key value))) + (append (if (and (markup? node) + (markup-ident node)) + (list (cons "id" (markup-ident node))) + (list)) + (if (and (markup? node) + (markup-class node)) + (list (cons "class" (markup-class node))) + (list)))))))) + ;; HTML engine customizations (let ((html-engine (find-engine 'html))) (engine-custom-set! html-engine 'css "/style.css") @@ -351,4 +369,25 @@ are a list of <record-field> objects." (markup-option markup #:long) (markup-option markup #:short) (markup-option markup #:long)) - (current-output-port))))) + (current-output-port)))) + ;; The skribilo HTML engine description markup writer does not print + ;; the id attribute. Override it so that it does. TODO: Push this + ;; fix to skribilo upstream. + (markup-writer 'description html-engine + #:options '(#:symbol) + #:before (lambda (node engine) + (node->html-tag "dl" node)) + #:action (lambda (node engine) + (for-each (lambda (item) + (for-each (lambda (key) + (node->html-tag "dt" item) + (output key engine) + (display "</dt>")) + (match (markup-option item #:key) + ((keys ...) keys) + (key (list key)))) + (node->html-tag "dd" item) + (output (markup-body item) engine) + (display "</dd>\n")) + (markup-body node))) + #:after "</dl>")) |