Skip to content

Commit 78267ab

Browse files
authored
Merge pull request commonmark#277 from elibarzilay/master
Update the Racket wrapper
2 parents f079389 + b1c63da commit 78267ab

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

wrappers/wrapper.rkt

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,34 @@
1313
(define-ffi-definer defcmark (ffi-lib "libcmark"))
1414

1515
(define _cmark_node_type
16-
(_enum '(none
16+
(_enum '(;; Error status
17+
none
1718
;; Block
1819
document block-quote list item code-block
19-
html paragraph header hrule
20+
html-block custom-block
21+
paragraph heading thematic-break
22+
;; ?? first-block = document
23+
;; ?? last-block = thematic-break
2024
;; Inline
21-
text softbreak linebreak code inline-html
22-
emph strong link image)))
25+
text softbreak linebreak code html-inline custom-inline
26+
emph strong link image
27+
;; ?? first-inline = text
28+
;; ?? last-inline = image
29+
)))
2330
(define _cmark_list_type
2431
(_enum '(no_list bullet_list ordered_list)))
2532
(define _cmark_delim_type
2633
(_enum '(no_delim period_delim paren_delim)))
2734
(define _cmark_opts
28-
(_bitmask '(sourcepos = 1 hardbreaks = 2 normalize = 4 smart = 8)))
35+
(_bitmask
36+
'(sourcepos = 2 ; include sourcepos attribute on block elements
37+
hardbreaks = 4 ; render `softbreak` elements as hard line breaks
38+
safe = 8 ; suppress raw HTML and unsafe links
39+
nobreaks = 16 ; render `softbreak` elements as spaces
40+
normalize = 256 ; legacy (no effect)
41+
validate-utf8 = 512 ; validate UTF-8 in the input
42+
smart = 1024 ; straight quotes to curly, ---/-- to em/en dashes
43+
)))
2944

3045
(define-cpointer-type _node)
3146

@@ -56,8 +71,8 @@
5671
(defcmark cmark_node_get_type_string (_fun _node -> _bytes))
5772
(defcmark cmark_node_get_literal (_fun _node -> _string))
5873
(defcmark cmark_node_set_literal (_fun _node _string -> _bool))
59-
(defcmark cmark_node_get_header_level (_fun _node -> _int))
60-
(defcmark cmark_node_set_header_level (_fun _node _int -> _bool))
74+
(defcmark cmark_node_get_heading_level (_fun _node -> _int))
75+
(defcmark cmark_node_set_heading_level (_fun _node _int -> _bool))
6176
(defcmark cmark_node_get_list_type (_fun _node -> _cmark_list_type))
6277
(defcmark cmark_node_set_list_type (_fun _node _cmark_list_type -> _bool))
6378
(defcmark cmark_node_get_list_delim (_fun _node -> _cmark_delim_type))
@@ -84,6 +99,9 @@
8499
(defcmark cmark_node_append_child (_fun _node _node -> _bool))
85100
(defcmark cmark_consolidate_text_nodes (_fun _node -> _void))
86101

102+
(defcmark cmark_version (_fun -> _int))
103+
(defcmark cmark_version_string (_fun -> _string))
104+
87105
)
88106

89107
;; Rackety interface
@@ -108,7 +126,7 @@
108126
(define-syntax-rule (define-getters+setters name [type field ...] ...)
109127
(define name (list (list 'type (make-getter+setter field) ...) ...)))
110128
(define-getters+setters getters+setters
111-
[header header_level] [code-block fence_info]
129+
[heading heading_level] [code-block fence_info]
112130
[link url title] [image url title]
113131
[list list_type list_delim list_start list_tight])
114132

@@ -126,12 +144,12 @@
126144
[else '()]))
127145
(define (assert-no what-not b)
128146
(when b (error 'cmark->sexpr "unexpected ~a in ~s" what-not type)))
129-
(cond [(memq type '(document paragraph header block-quote list item
147+
(cond [(memq type '(document paragraph heading block-quote list item
130148
emph strong link image))
131149
(assert-no 'text text)
132150
(list type info children)]
133-
[(memq type '(text code code-block html inline-html
134-
softbreak linebreak hrule))
151+
[(memq type '(text code code-block html-block html-inline
152+
softbreak linebreak thematic-break))
135153
(assert-no 'children (pair? children))
136154
(list type info text)]
137155
[else (error 'cmark->sexpr "unknown type: ~s" type)]))

0 commit comments

Comments
 (0)