summaryrefslogtreecommitdiff
path: root/wrappers/wrapper.rkt
diff options
context:
space:
mode:
authorEli Barzilay <eli@barzilay.org>2018-11-14 08:49:03 -0500
committerEli Barzilay <eli@barzilay.org>2018-11-14 08:49:20 -0500
commitb1c63da0caf616f9908c4fc0c4ae3028436ac137 (patch)
tree98a66af793a0e55e96b97da4e2dd2560a7d7f6cd /wrappers/wrapper.rkt
parentb1556b3407a4349b9a1f4f58d8677eda0ead09c1 (diff)
Update the Racket wrapper
Diffstat (limited to 'wrappers/wrapper.rkt')
-rw-r--r--wrappers/wrapper.rkt40
1 files changed, 29 insertions, 11 deletions
diff --git a/wrappers/wrapper.rkt b/wrappers/wrapper.rkt
index d9b34e8..1ecce17 100644
--- a/wrappers/wrapper.rkt
+++ b/wrappers/wrapper.rkt
@@ -13,19 +13,34 @@
(define-ffi-definer defcmark (ffi-lib "libcmark"))
(define _cmark_node_type
- (_enum '(none
+ (_enum '(;; Error status
+ none
;; Block
document block-quote list item code-block
- html paragraph header hrule
+ html-block custom-block
+ paragraph heading thematic-break
+ ;; ?? first-block = document
+ ;; ?? last-block = thematic-break
;; Inline
- text softbreak linebreak code inline-html
- emph strong link image)))
+ text softbreak linebreak code html-inline custom-inline
+ emph strong link image
+ ;; ?? first-inline = text
+ ;; ?? last-inline = image
+ )))
(define _cmark_list_type
(_enum '(no_list bullet_list ordered_list)))
(define _cmark_delim_type
(_enum '(no_delim period_delim paren_delim)))
(define _cmark_opts
- (_bitmask '(sourcepos = 1 hardbreaks = 2 normalize = 4 smart = 8)))
+ (_bitmask
+ '(sourcepos = 2 ; include sourcepos attribute on block elements
+ hardbreaks = 4 ; render `softbreak` elements as hard line breaks
+ safe = 8 ; suppress raw HTML and unsafe links
+ nobreaks = 16 ; render `softbreak` elements as spaces
+ normalize = 256 ; legacy (no effect)
+ validate-utf8 = 512 ; validate UTF-8 in the input
+ smart = 1024 ; straight quotes to curly, ---/-- to em/en dashes
+ )))
(define-cpointer-type _node)
@@ -56,8 +71,8 @@
(defcmark cmark_node_get_type_string (_fun _node -> _bytes))
(defcmark cmark_node_get_literal (_fun _node -> _string))
(defcmark cmark_node_set_literal (_fun _node _string -> _bool))
- (defcmark cmark_node_get_header_level (_fun _node -> _int))
- (defcmark cmark_node_set_header_level (_fun _node _int -> _bool))
+ (defcmark cmark_node_get_heading_level (_fun _node -> _int))
+ (defcmark cmark_node_set_heading_level (_fun _node _int -> _bool))
(defcmark cmark_node_get_list_type (_fun _node -> _cmark_list_type))
(defcmark cmark_node_set_list_type (_fun _node _cmark_list_type -> _bool))
(defcmark cmark_node_get_list_delim (_fun _node -> _cmark_delim_type))
@@ -84,6 +99,9 @@
(defcmark cmark_node_append_child (_fun _node _node -> _bool))
(defcmark cmark_consolidate_text_nodes (_fun _node -> _void))
+ (defcmark cmark_version (_fun -> _int))
+ (defcmark cmark_version_string (_fun -> _string))
+
)
;; Rackety interface
@@ -108,7 +126,7 @@
(define-syntax-rule (define-getters+setters name [type field ...] ...)
(define name (list (list 'type (make-getter+setter field) ...) ...)))
(define-getters+setters getters+setters
- [header header_level] [code-block fence_info]
+ [heading heading_level] [code-block fence_info]
[link url title] [image url title]
[list list_type list_delim list_start list_tight])
@@ -126,12 +144,12 @@
[else '()]))
(define (assert-no what-not b)
(when b (error 'cmark->sexpr "unexpected ~a in ~s" what-not type)))
- (cond [(memq type '(document paragraph header block-quote list item
+ (cond [(memq type '(document paragraph heading block-quote list item
emph strong link image))
(assert-no 'text text)
(list type info children)]
- [(memq type '(text code code-block html inline-html
- softbreak linebreak hrule))
+ [(memq type '(text code code-block html-block html-inline
+ softbreak linebreak thematic-break))
(assert-no 'children (pair? children))
(list type info text)]
[else (error 'cmark->sexpr "unknown type: ~s" type)]))