forked from Orc/discount
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkd-functions.3
186 lines (186 loc) · 4.1 KB
/
mkd-functions.3
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
.\"
.Dd January 18, 2008
.Dt MKD_FUNCTIONS 3
.Os Mastodon
.Sh NAME
.Nm mkd_functions
.Nd access and process Markdown documents.
.Sh LIBRARY
Markdown
.Pq libmarkdown , -lmarkdown
.Sh SYNOPSIS
.Fd #include <mkdio.h>
.Ft int
.Fn mkd_compile "MMIOT *document" "int flags"
.Ft int
.Fn mkd_css "MMIOT *document" "char **doc"
.Ft int
.Fn mkd_generatecss "MMIOT *document" "FILE *output"
.Ft int
.Fn mkd_document "MMIOT *document" "char **doc"
.Ft int
.Fn mkd_generatehtml "MMIOT *document" "FILE *output"
.Ft int
.Fn mkd_xhtmlpage "MMIOT *document" "int flags" "FILE *output"
.Ft int
.Fn mkd_toc "MMIOT *document" "char **doc"
.Ft void
.Fn mkd_generatetoc "MMIOT *document" "FILE *output"
.Ft void
.Fn mkd_cleanup "MMIOT*"
.Ft char*
.Fn mkd_doc_title "MMIOT*"
.Ft char*
.Fn mkd_doc_author "MMIOT*"
.Ft char*
.Fn mkd_doc_date "MMIOT*"
.Sh DESCRIPTION
.Pp
The
.Nm markdown
format supported in this implementation includes
Pandoc-style header and inline
.Ar \<style\>
blocks, and the standard
.Xr markdown 3
functions do not provide access to
the data provided by either of those extensions.
These functions give you access to that data, plus
they provide a finer-grained way of converting
.Em Markdown
documents into HTML.
.Pp
Given a
.Ar MMIOT*
generated by
.Fn mkd_in
or
.Fn mkd_string ,
.Fn mkd_compile
compiles the document into
.Em \<style\> ,
.Em Pandoc ,
and
.Em html
sections.
.Pp
Once compiled, the document can be examined and written
by the
.Fn mkd_css ,
.Fn mkd_document ,
.Fn mkd_generatecss ,
.Fn mkd_generatehtml ,
.Fn mkd_generatetoc ,
.Fn mkd_toc ,
.Fn mkd_xhtmlpage ,
.Fn mkd_doc_title ,
.Fn mkd_doc_author ,
and
.Fn mkd_doc_date
functions.
.Pp
.Fn mkd_css
allocates a string and populates it with any \<style\> sections
provided in the document,
.Fn mkd_generatecss
writes any \<style\> sections to the output,
.Fn mkd_document
points
.Ar text
to the text of the document and returns the
size of the document,
.Fn mkd_generatehtml
writes the rest of the document to the output,
and
.Fn mkd_doc_title ,
.Fn mkd_doc_author ,
.Fn mkd_doc_date
are used to read the contents of a Pandoc header,
if any.
.Pp
.Fn mkd_xhtmlpage
writes a xhtml page containing the document. The regular set of
flags can be passed.
.Pp
.Fn mkd_toc
writes a document outline, in the form of a collection of nested
lists with links to each header in the document, into a string
allocated with
.Fn malloc ,
and returns the size.
.Pp
.Fn mkd_generatetoc
is like
.Fn mkd_toc ,
except that it writes the document outline to the given
.Pa FILE*
argument.
.Pp
.Fn mkd_cleanup
deletes a
.Ar MMIOT*
after processing is done.
.Pp
.Fn mkd_compile
accepts the same flags that
.Fn markdown
and
.Fn mkd_string
do;
.Bl -tag -width MKD_NOSTRIKETHROUGH -compact
.It Ar MKD_NOIMAGE
Do not process `![]' and
remove
.Em \<img\>
tags from the output.
.It Ar MKD_NOLINKS
Do not process `[]' and remove
.Em \<a\>
tags from the output.
.It Ar MKD_NOPANTS
Do not do Smartypants-style mangling of quotes, dashes, or ellipses.
.It Ar MKD_TAGTEXT
Process the input as if you were inside a html tag. This means that
no html tags will be generated, and
.Fn mkd_compile
will attempt to escape anything that might terribly confuse a
web browser.
.It Ar MKD_NO_EXT
Do not process any markdown pseudo-protocols when
handing
.Ar [][]
links.
.It Ar MKD_NOHEADER
Do not attempt to parse any Pandoc-style headers.
.It Ar MKD_TOC
Label all headers for use with the
.Fn mkd_generatetoc
function.
.It Ar MKD_1_COMPAT
MarkdownTest_1.0 compatibility flag; trim trailing spaces from the
first line of code blocks and disable implicit reference links.
.It Ar MKD_NOSTRIKETHROUGH
Disable strikethrough support.
.El
.Sh RETURN VALUES
The function
.Fn mkd_compile
returns 1 in the case of success, or 0 if the document is already compiled.
The function
.Fn mkd_generatecss
returns the number of bytes written in the case of success, or EOF if an error
occurred.
The function
.Fn mkd_generatehtml
returns 0 on success, \-1 on failure.
.Sh SEE ALSO
.Xr markdown 1 ,
.Xr markdown 3 ,
.Xr mkd-line 3 ,
.Xr markdown 7 ,
.Xr mkd-extensions 7 ,
.Xr mmap 2 .
.Pp
http://daringfireball.net/projects/markdown/syntax
.Sh BUGS
Error handling is minimal at best.