summaryrefslogtreecommitdiffstats
path: root/apps/aux/sxml.scm
diff options
context:
space:
mode:
Diffstat (limited to 'apps/aux/sxml.scm')
-rw-r--r--apps/aux/sxml.scm23
1 files changed, 23 insertions, 0 deletions
diff --git a/apps/aux/sxml.scm b/apps/aux/sxml.scm
new file mode 100644
index 0000000..531cdee
--- /dev/null
+++ b/apps/aux/sxml.scm
@@ -0,0 +1,23 @@
+;;; Harmonic Flow web site
+
+(define-module (apps aux sxml)
+ #:use-module (ice-9 match)
+ #:use-module (srfi srfi-1)
+ #:export (sxml->string*))
+
+
+(define (sxml->string* tree)
+ "Flatten tree by dismissing tags and attributes, and return the resulting
+string."
+ (define (sxml->strings tree)
+ (match tree
+ (((? symbol?) ('@ _ ...) body ...)
+ (append-map sxml->strings `(" " ,@body " ")))
+ (((? symbol?) body ...)
+ (append-map sxml->strings `(" " ,@body " ")))
+ ((? string?)
+ (list tree))
+ ((lst ...)
+ (sxml->strings `(div ,@lst)))))
+
+ (string-concatenate (sxml->strings tree)))