From a0225f0b5492578372896d63b6ce7bd9ab041b31 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Wed, 9 Aug 2023 16:31:48 +0100 Subject: doc: Override description markup writer. * doc/skribilo.scm: Import (skribilo output). (node->html-tag): New function. (html-engine): Override the description markup writer. --- doc/skribilo.scm | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) 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 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 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 "")) + (match (markup-option item #:key) + ((keys ...) keys) + (key (list key)))) + (node->html-tag "dd" item) + (output (markup-body item) engine) + (display "\n")) + (markup-body node))) + #:after "")) -- cgit v1.2.3