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 ++++++++++++++++++---- dnw/forms.scm~ | 22 ++++++++++++++++++++++ dnw/static-pages.scm | 3 ++- 3 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 dnw/forms.scm~ (limited to 'dnw') 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. diff --git a/dnw/forms.scm~ b/dnw/forms.scm~ new file mode 100644 index 0000000..99813a7 --- /dev/null +++ b/dnw/forms.scm~ @@ -0,0 +1,22 @@ +(define-module (dnw forms.el-to-html)) + +;; Idea: function that takes in a git repository link pointing to something containing a forms file pair, +;; and reads it in along with a mapping between whatever Elisp functions you use in forms-format-list +;; and equivalent Scheme implementations (bc I can't figure out how to programmatically use Guile's Elisp support). + +(define (forms.el->shtml git-link)) + +(define (forms.el-parse file) + (define-peg-string-patterns + "form-control-file <- (comment/whitespace/setq)+ +comment < ';' (!'\n')* '\n' +whitespace < [\r\n\t ]+ +setq < '(' whitespace? 'setq' whitespace name-val-pair whitespace? ')' + +name-val-pair <- forms-file/forms-format-list/forms-number-of-fields/forms-field-sep +/forms-read-only/forms-multi-line/forms-read-file-filter/forms-write-file-filter +/forms-new-record-filter/forms-insert-after/forms-check-number-of-fields + +value <- string/quoted/ + +")) diff --git a/dnw/static-pages.scm b/dnw/static-pages.scm index eab7e46..8e772e7 100644 --- a/dnw/static-pages.scm +++ b/dnw/static-pages.scm @@ -175,7 +175,8 @@ (p "The books I physically own, or want to own. I haven't quite digitized everything yet (just one moving box of like 4).") ,(forms.el->sxml (get-string-all (open-input-file "assets/library/library.el")) (get-string-all (open-input-file "assets/library/library.tsv")) - '()) + '() + '(("====== Library Book ======\n\n" . ""))) (h2 "Blogs and Podcasts") (ul (li "Not Related")) -- cgit v1.2.3