Add markdown (commonmark) support

Julien LepillerSun Mar 07 22:36:25+0100 2021

d665efa

Add markdown (commonmark) support

gitile/pages.scm

1616
;;;; 
1717
1818
(define-module (gitile pages)
19+
  #:use-module (commonmark)
1920
  #:use-module (gcrypt base16)
2021
  #:use-module (gcrypt hash)
2122
  #:use-module (gitile repo)

5960
       (a (@ (href "/" ,repository-name "/raw/" ,(or ref "-")
6061
                   "/" ,path))
6162
          (img (@ (src "/images/file-type-3.svg"))))))
62-
    (pre ,(utf8->string (get-file-content repo path #:ref ref)))))
63+
    ,(let ((content (utf8->string (get-file-content repo path #:ref ref))))
64+
       (if (string-suffix? ".md" path)
65+
         `(article (@ (class "file-content"))
66+
            ,(commonmark->sxml content))
67+
         `(pre ,content)))))
6368
6469
(define* (project-files repository-name repo #:key (ref "-") (path '()))
6570
  (let* ((ref (if (equal? ref "-") #f ref))

guix.scm

5151
  (source #f)
5252
  (build-system gnu-build-system)
5353
  (propagated-inputs
54-
   `(("guile-git" ,my-guile-git)
54+
   `(("guile-commonmark" ,guile-commonmark)
55+
     ("guile-git" ,my-guile-git)
5556
     ("guile-gcrypt" ,guile-gcrypt)
5657
     ("gnutls" ,gnutls)
5758
     ("guile-fibers" ,guile-fibers)))