move commonmark->sxml to commonmark sxml module
This commit is contained in:
parent
19c402f943
commit
5a00afc817
|
@ -7,7 +7,7 @@ a fully specified variant of Markdown.
|
|||
Example
|
||||
-------
|
||||
```scheme
|
||||
(use-modules (commonmark)
|
||||
(use-modules (commonmark sxml)
|
||||
(sxml simple))
|
||||
|
||||
(define doc
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
;; Copyright (C) 2015-2016 Erik Edrosa <erik.edrosa@gmail.com>
|
||||
;; Copyright (C) 2015-2016, 2020 Erik Edrosa <erik.edrosa@gmail.com>
|
||||
;;
|
||||
;; This file is part of guile-commonmark
|
||||
;;
|
||||
|
@ -16,17 +16,7 @@
|
|||
;; along with guile-commonmark. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(define-module (commonmark)
|
||||
#:use-module (commonmark blocks)
|
||||
#:use-module (commonmark inlines)
|
||||
#:use-module (commonmark node)
|
||||
#:use-module (commonmark sxml)
|
||||
#:export (commonmark->sxml))
|
||||
#:re-export (commonmark->sxml))
|
||||
|
||||
|
||||
(define* (commonmark->sxml #:optional (string-or-port (current-input-port)))
|
||||
"Parses a commonmark document from optional argument STRING-OR-PORT or
|
||||
the current input port into SXML."
|
||||
(let ((port (if (string? string-or-port)
|
||||
(open-input-string string-or-port)
|
||||
string-or-port)))
|
||||
(document->sxml (parse-inlines (parse-blocks port)))))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
;; Copyright (C) 2016-2018 Erik Edrosa <erik.edrosa@gmail.com>
|
||||
;; Copyright (C) 2016-2018, 2020 Erik Edrosa <erik.edrosa@gmail.com>
|
||||
;;
|
||||
;; This file is part of guile-commonmark
|
||||
;;
|
||||
|
@ -296,7 +296,7 @@
|
|||
(label-match (link-label (parser-advance-next-nonspace parser)))
|
||||
(after-label (link-label-rest parser label-match))
|
||||
(before-dest (skip-optional-whitespace-newline after-label))
|
||||
(dest-match (link-destination (parser-advance-next-nonspace before-dest)))
|
||||
(dest-match (match-link-destination (parser-advance-next-nonspace before-dest)))
|
||||
(after-dest (parser-advance-next-nonspace (cdr dest-match))))
|
||||
(let* ((title-match (link-title (parser-advance-next-nonspace
|
||||
(skip-optional-whitespace-newline after-dest))))
|
||||
|
@ -325,7 +325,7 @@
|
|||
(define (link-destination-normal parser)
|
||||
(regexp-exec re-link-destination (parser-str parser) (parser-pos parser)))
|
||||
|
||||
(define (link-destination parser)
|
||||
(define (match-link-destination parser)
|
||||
(define (link-destination-rest match)
|
||||
(parser-advance parser (- (match:end match 0) (parser-pos parser))))
|
||||
(define (match:substring-suffix match)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
;; Copyright (C) 2015 Erik Edrosa <erik.edrosa@gmail.com>
|
||||
;; Copyright (C) 2015, 2020 Erik Edrosa <erik.edrosa@gmail.com>
|
||||
;;
|
||||
;; This file is part of guile-commonmark
|
||||
;;
|
||||
|
@ -18,15 +18,19 @@
|
|||
(define-module (commonmark sxml)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (sxml simple)
|
||||
#:use-module (commonmark blocks)
|
||||
#:use-module (commonmark inlines)
|
||||
#:use-module (commonmark node)
|
||||
#:export (document->sxml))
|
||||
#:export (commonmark->sxml))
|
||||
|
||||
;; Document -> xml
|
||||
;; converts the document into HTML
|
||||
;; !!!
|
||||
|
||||
(define (document->xml d)
|
||||
(sxml->xml (document->sxml d)))
|
||||
(define* (commonmark->sxml #:optional (string-or-port (current-input-port)))
|
||||
"Parses a commonmark document from optional argument STRING-OR-PORT or
|
||||
the current input port into SXML."
|
||||
(let ((port (if (string? string-or-port)
|
||||
(open-input-string string-or-port)
|
||||
string-or-port)))
|
||||
(document->sxml (parse-inlines (parse-blocks port)))))
|
||||
|
||||
|
||||
(define (document->sxml d)
|
||||
|
|
Loading…
Reference in New Issue