skribe-utils.scm 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ;;; stlog website ---
  2. ;;; Copyright © 2016 David Thompson <davet@gnu.org>
  3. ;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
  4. ;;; Copyright © 2016 Dylan Jeffers <sapientech@openmailbox.org>
  5. ;;;
  6. ;;; This program is free software: you can redistribute it and/or modify
  7. ;;; it under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation, either version 3 of the License, or
  9. ;;; (at your option) any later version.
  10. ;;;
  11. ;;; This program is distributed in the hope that it will be useful,
  12. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. ;;; Originally by David Thompson, who agreed tho license this under
  19. ;;; GPLv3 or later. Thanks Dave!
  20. (define-module (skribe-utils)
  21. #:use-module (ice-9 match)
  22. #:use-module (syntax-highlight)
  23. #:use-module (syntax-highlight scheme)
  24. #:use-module (syntax-highlight xml)
  25. ;; #:use-module (syntax-highlight c)
  26. #:export (image/caption
  27. scheme-code
  28. xml-code
  29. ;; c-source
  30. code-block
  31. code-block-scheme
  32. code-block-xml))
  33. (define (image/caption uri caption)
  34. `((img (@ (class "centered rounded")
  35. (src ,uri)
  36. (alt ,caption)))
  37. (div (@ (class "caption")) ,caption)))
  38. (define (scheme-source source)
  39. (highlights->sxml
  40. (highlight lex-scheme
  41. (match source
  42. ((source ...)
  43. (string-concatenate source))
  44. (_ source)))))
  45. (define (xml-source source)
  46. (highlights->sxml
  47. (highlight lex-xml
  48. (match source
  49. ((source ...)
  50. (string-concatenate source))
  51. (_ source)))))
  52. ;; (define (c-source source)
  53. ;; (highlights->sxml
  54. ;; (highlight lex-c
  55. ;; (match source
  56. ;; ((source ...)
  57. ;; (string-concatenate source))
  58. ;; (_ source)))))
  59. (define (code-block . source)
  60. `(div (@ (class "code"))
  61. ,@source))
  62. (define (code-block-scheme . source)
  63. (apply code-block (scheme-source source)))
  64. (define (code-block-xml . source)
  65. (apply code-block (xml-source source)))