-
Notifications
You must be signed in to change notification settings - Fork 162
Expand file tree
/
Copy pathmarkdown.3
More file actions
156 lines (156 loc) · 3.87 KB
/
markdown.3
File metadata and controls
156 lines (156 loc) · 3.87 KB
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
.\"
.Dd December 20, 2007
.Dt MARKDOWN 3
.Os Mastodon
.Sh NAME
.Nm markdown
.Nd process Markdown documents
.Sh LIBRARY
Markdown
.Pq libmarkdown , -lmarkdown
.Sh SYNOPSIS
.Fd #include <mkdio.h>
.Ft MMIOT
.Fn *mkd_in "FILE *input" "mkd_flag_t *flags"
.Ft MMIOT
.Fn *mkd_string "char *string" "int size" "mkd_flag_t *flags"
.Ft int
.Fn markdown "MMIOT *doc" "FILE *output" "mkd_flag_t *flags"
.Sh DESCRIPTION
These functions
convert
.Em Markdown
documents and strings into HTML.
.Fn markdown
processes an entire document, while
.Fn mkd_text
processes a single string.
.Pp
To process a file, you pass a FILE* to
.Fn mkd_in ,
and if it returns a nonzero value you pass that in to
.Fn markdown ,
which then writes the converted document to the specified
.Em FILE* .
If your input has already been written into a string (generated
input or a file opened
with
.Xr mmap 2 )
you can feed that string to
.Fn mkd_string
and pass its return value to
.Fn markdown.
.Pp
.Fn Markdown
holds the flag values in an opaque flag blob that you need to
initialize and populate before using:
.Bl -tag -width MKD_NOSTRIKETHROUGH -compact
.It Ft "mkd_flag_t*" Fn mkd_flag_t
creates a mkd_flag_t structure and returns a pointer to it.
.It Fn mkd_free_flags "mkd_flag_t *"
deletes a mkd_flag_t structure when you are finished with it.
.It Ft mkd_flag_t* Fn mkd_copy_flags "mkd_flag_t*"
Makes a copy of a flag blob and returns a pointer to it.
.It Fn mkd_flag_isset "mkd_flag_t *" "int"
tells you if a specific flag is set
.It Fn mkd_set_flag_num "mkd_flag_t *" "int"
Sets a specified flag
.It Fn mkd_clr_flag_num "mkd_flag_t *" "int"
Clears a specified flag
.El
.Pp
The following flags are currently accepted:
.Bl -tag -width MKD_NOSTRIKETHROUGH -compact
.It Ar MKD_NOLINKS
don't do link processing, block <a> tags
.It Ar MKD_NOIMAGE
don't do image processing, block <img>
.It Ar MKD_NOPANTS
don't run smartypants()
.It Ar MKD_NOHTML
don't allow raw html through AT ALL
.It Ar MKD_NORMAL_LISTITEM
disable github-style checkbox lists
.It Ar MKD_TAGTEXT
process text inside an html tag
.It Ar MKD_NO_EXT
don't allow pseudo-protocols
.It Ar MKD_EXPLICITLIST
don't combine numbered/bulletted lists
.It Ar MKD_CDATA
generate code for xml ![CDATA[...]]
.It Ar MKD_NOSUPERSCRIPT
no A^B
.It Ar MKD_STRICT
conform to Markdown standard as implemented in Markdown.pl
.It Ar MKD_NOTABLES
disallow tables
.It Ar MKD_NOSTRIKETHROUGH
forbid ~~strikethrough~~
.It Ar MKD_1_COMPAT
compatibility with MarkdownTest_1.0
.It Ar MKD_TOC
do table-of-contents processing
.It Ar MKD_AUTOLINK
make http://foo.com link even without <>s
.It Ar MKD_NOHEADER
don't process header blocks
.It Ar MKD_TABSTOP
expand tabs to 4 spaces
.It Ar MKD_SAFELINK
paranoid check for link protocol
.It Ar MKD_NODIVQUOTE
forbid >%class% blocks
.It Ar MKD_NOALPHALIST
forbid alphabetic lists
.It Ar MKD_EXTRA_FOOTNOTE
enable markdown extra-style footnotes
.It Ar MKD_NOSTYLE
don't extract <style> blocks
.It Ar MKD_DLDISCOUNT
enable discount-style definition lists
.It Ar MKD_DLEXTRA
enable extra-style definition lists
.It Ar MKD_FENCEDCODE
enabled fenced code blocks
.It Ar MKD_IDANCHOR
use id= anchors for TOC links
.It Ar MKD_GITHUBTAGS
allow dash and underscore in element names
.It Ar MKD_URLENCODEDANCHOR
urlencode non-identifier chars instead of replacing with dots
.It Ar MKD_LATEX
handle embedded LaTeX escapes
.It Ar MKD_ALT_AS_TITLE
use alt text as the title if no title is listed
.It Ar MKD_EXTENDED_ATTR
allow extended attribute suffixes
.El
.Sh RETURN VALUES
.Fn markdown
returns 0 on success, 1 on failure.
The
.Fn mkd_in
and
.Fn mkd_string
functions return a MMIOT* on success, null on failure.
.Sh SEE ALSO
.Xr markdown 1 ,
.Xr mkd-callbacks 3 ,
.Xr mkd-functions 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.
.Pp
The
.Ar MMIOT
created by
.Fn mkd_string
is deleted by the
.Nm
function.