;;; GNU Guix web site ;;; Copyright © 2015, 2016, 2017 Ludovic Courtès ;;; Copyright © 2015 Mathieu Lirzin ;;; Initially written by sirgazil who waives all copyright interest on ;;; this file. ;;; ;;; This file is part of the GNU Guix web site. ;;; ;;; The GNU Guix web site is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU Affero General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; The GNU Guix web site is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU Affero General Public License for more details. ;;; ;;; You should have received a copy of the GNU Affero General Public License ;;; along with the GNU Guix web site. If not, see . (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)))