m-markdown.mkiv /size: 1912 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=x-markdown,
3
%D version=2011.07.19,
4
%D title=\CONTEXT\ Modules,
5
%D subtitle=Processing MarkDown,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
\writestatus
{
loading
}{
ConTeXt
Modules
/
MarkDown
Renderer
}
15 16
%D This module deals with markdown which is a document encoding that
17
%D some \CONTEXT\ like much. It reminds me of the kind of minimal coding
18
%D we used before we ran into \TEX\ and were using a somewhat simple
19
%D rendering (pagination, etc) of documents. As I'm no user myself, it
20
%D is up to others to provide documentation and examples.
21 22
\registerctxluafile
{
m
-
markdown
}{}
23 24
\unprotect
25 26
% basic interface
27 28
\definebuffer
[
markdown
]
29 30
\unexpanded
\def
\stopmarkdown
31
{
\ctxlua{
moduledata
.
markdown
.
typesetbuffer
(
"
\thedefinedbuffer{markdown}
"
)
}
}
32 33
\unexpanded
\def
\processmarkdownfile
#
1
% maybe [] or both
34
{
\ctxlua{
moduledata
.
markdown
.
typesetfile
(
"
#1
"
)
}
}
35 36
\unexpanded
\def
\markdown
#
1
% maybe [] or both
37
{
\ctxlua{
moduledata
.
markdown
.
typesetstring
(
\!!bs
#1
\!!es
)
}
}
38 39
% commands
40 41
\defineitemgroup
42
[
markdownitemize
]
43 44
\definetyping
45
[
markdowntyping
]
46 47
\definetype
48
[
markdowntype
]
49 50
\definetype
51
[
markdowninlinehtml
]
52 53
\definetyping
54
[
markdowndisplayhtml
]
55 56
\definedelimitedtext
57
[
markdownblockquote
]
58
[
quotation
]
59 60
\definehighlight
61
[
markdownemphasis
]
62
[
style
=
\em
]
63 64
\definehighlight
65
[
markdownstrong
]
66
[
style
=
\bf
]
67 68
\definestructurelevels
69
[
markdown
]
70
[
\v!chapter
,
71
\v!section
,
72
\v!subsection
,
73
\v!subsubsection
,
74
\v!subsubsubsection
,
75
\v!subsubsubsubsection
]
76 77
\unexpanded
\def
\markdownrule
78
{
\hairline
\par
}
79 80
\protect
81 82
\continueifinputfile
{
m
-
markdown
.
mkiv
}
83 84
\starttext
85
\startmarkdown
86
% some examples needed
87
\stopmarkdown
88
\stoptext
89