From ed4e86f47935994fb424c977e4123bde625ddff1 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 3 Jun 2024 16:56:30 -0500 Subject: Fix html/other sourcing; re-scramble Makefile --- src/emit.scm | 69 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 34 insertions(+), 35 deletions(-) (limited to 'src/emit.scm') diff --git a/src/emit.scm b/src/emit.scm index e57e437..4c3581f 100644 --- a/src/emit.scm +++ b/src/emit.scm @@ -1,3 +1,5 @@ +(declare (module (jimmy emit))) + (import scheme (chicken base) (chicken format) (chicken irregex) @@ -9,41 +11,36 @@ (for-each display (map format-stanza doc))) (define-public formats - ;;; (TYPE (line . LINE-FMT) (stanza . STANZA-FMT) (inline . INLINE-FMT)) - '((para (line . "~A") - (stanza . "~A~%~%")) - (verb (line . "~A~%") - (stanza . "```~%~A```~%~%")) - (link (line . "=> ~A ~A~%") ; Note: link has 2 format arguments - (stanza . "~A~%") - (inline . "~%=> ~A ~A~%")) - (list (line . "* ~A~%") - (stanza . "~A~%")) - (quot (line . "~A") - (stanza . "> ~A~%~%")) - (hdr1 (line . "# ~A~%") - (stanza . "~A~%")) - (hdr2 (line . "## ~A~%") - (stanza . "~A~%")) - (hdr3 (line . "### ~A~%") - (stanza . "~A~%")) - (meta (line . "") - (stanza . "")) - (default - (line . "~A") - (stanza . "~A~%~%")))) + (make-parameter + ;; (TYPE (line . LINE-FMT) (stanza . STANZA-FMT) (inline . INLINE-FMT)) + '((para (line . "~A") + (stanza . "~A~%~%")) + (verb (line . "~A~%") + (stanza . "```~%~A```~%~%")) + (link (line . "=> ~A ~A~%") ; Note: link has 2 format arguments + (stanza . "~A~%") + (inline . "~%=> ~A ~A~%")) + (list (line . "* ~A~%") + (stanza . "~A~%")) + (quot (line . "~A") + (stanza . "> ~A~%~%")) + (hdr1 (line . "# ~A~%") + (stanza . "~A~%")) + (hdr2 (line . "## ~A~%") + (stanza . "~A~%")) + (hdr3 (line . "### ~A~%") + (stanza . "~A~%"))))) (define-public filters - ;;; (TYPE (line . LINE-FILTER) (stanza . STANZA-FILTER)) - ;; line-filter : (lambda (list-of-strs) ...) -> list-of-strs (for format) - ;; stanza-filter : (lambda (list-of-strs) ...) -> str - `((verb (line . ,identity) - (stanza . ,(lambda (lines) (apply string-append lines)))) - (default - (line . ,identity) - (stanza . ,(lambda (lines) - (irregex-replace/all '(: bol (* space)) - (string-join lines) "")))))) + (make-parameter + ;; (TYPE (line . LINE-FILTER) (stanza . STANZA-FILTER)) + ;; line-filter : (lambda (list-of-strs) ...) -> list-of-strs (for format) + ;; stanza-filter : (lambda (list-of-strs) ...) -> str + `((verb (line . ,identity) + (stanza . ,join-lines)) + (default + (line . ,identity) + (stanza . ,flush-lines-left))))) (define (format-line line el) (cond @@ -72,8 +69,10 @@ (and (eq? scope 'inline) (alist-walk alist 'default 'line)))) -(define (get-format el scope) (get-from formats el scope)) -(define (get-filter el scope) (get-from filters el scope)) +(define (get-format el scope) + (or (get-from (formats) el scope) + "")) +(define (get-filter el scope) (get-from (filters) el scope)) (define (sprintf* fmt lis) (let loop ((num (length (irregex-extract "~[aA]" fmt))) -- cgit 1.4.1-21-gabe81