From 78c78126b8a0f3a666127cc7088844604e6f2456 Mon Sep 17 00:00:00 2001 From: Duncan Wilkie Date: Thu, 21 Sep 2023 18:30:31 -0500 Subject: Testing automatic git ops --- dnw/forms.scm | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'dnw/forms.scm') diff --git a/dnw/forms.scm b/dnw/forms.scm index c163267..ba6d5a2 100644 --- a/dnw/forms.scm +++ b/dnw/forms.scm @@ -2,6 +2,7 @@ #:use-module (ice-9 peg) #:use-module (ice-9 textual-ports) #:use-module (ice-9 match) + #:use-module (ice-9 regex) #:use-module (ice-9 string-fun) #:use-module (srfi srfi-1) #:export (forms.el->sxml)) @@ -15,7 +16,7 @@ ;; but outputs an SHTML interface instead. ;; The necessary forms.el logic is basically: ;; - read in data from forms-file as lists based on field-separator value, -;; - filter out the list elements according to forms-read-file-filter, +;; - filter out the list nnelements according to forms-read-file-filter, ;; - replace the multi-line character with newlines, ;; - iterate over the list elements, setting up a proper execution environment (defining forms-fields/forms-enumerate), ;; - map over forms-format-list, replacing numbers with the corresponding field in the list element and evaluating code blocks, @@ -133,7 +134,7 @@ SETQ < 'setq'") (other other))) -(define (forms.el->sxml control-file-contents data-file-contents extra-remapping) +(define (forms.el->sxml control-file-contents data-file-contents extra-remapping result-edits) (let* ((symbol-remapping (append extra-remapping '((nil . ''()) (consp . pair?) @@ -191,13 +192,25 @@ SETQ < 'setq'") (eval format-entry (current-module))))) forms-format-list)) "")) - split-data))) + split-data)) + (edited-text-data + (map (lambda (record) + (fold (lambda (exp-sub-pair last-text) + (regexp-substitute #f + (string-match (car exp-sub-pair) + last-text) + 'pre + (cdr exp-sub-pair) + 'post)) + record + result-edits)) + textualized-data))) `(div (@ (class "forms-carousel")) (ul ,@(map (lambda (entry) `(li (div (@ (class "form-entry")) (p ,entry)))) - textualized-data))))) + edited-text-data))))) ;; TODO: explain that no modified characters can be parsed within the non-thrown-away variable settings. ;; TODO: explain that octal string escape characters will be parsed improperly/naively. @@ -205,3 +218,4 @@ SETQ < 'setq'") ;; TODO: consider how to convert propertized string literals to HTML. ;; TODO: explain that check-number-of-fields must be set and each field the correct size. ;; TODO: add option for newline replacement character re-substitution. +;; TODO: consider refactoring to build HTML trees, properly classed for styling and pruning purposes, rather than a raw string. -- cgit v1.2.3