blob: a14723178005a85e23adff83169f17ddaea043ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
(define-module (web view markdown)
#:use-module (json)
#:use-module (ice-9 match)
#:use-module (ice-9 format)
#:use-module (ice-9 iconv)
#:use-module (ice-9 receive)
#:use-module (ice-9 string-fun)
#:use-module (ice-9 textual-ports)
#:use-module (sxml simple)
#:use-module (web client)
#:use-module (web uri)
#:use-module (web request)
#:use-module (web sxml)
#:use-module (commonmark)
#:export (markdown-file->sxml
markdown-github->sxml)
)
(define (markdown-file->sxml fn)
"Parse a local file"
(commonmark->sxml
(call-with-input-file fn
get-string-all)))
;; --- fetch github style URLs
;;
;; https://github.com/genenetwork/gn-docs/master/general/brand/aging/home.md
;; https://github.com/genenetwork/gn-docs/edit/master/general/brand/aging/home.md
(define (fetch-raw-file url)
(bytevector->string (receive (response-status response-body)
(http-request "https://github.com/genenetwork/gn-docs/master/general/brand/aging/home.md")
response-body) "UTF-8"))
(define (markdown-github->sxml fn)
"Parse a github file"
(commonmark->sxml
(call-with-input-file (pk fn)
get-string-all)))
|