summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkiv/m-markdown.mkiv
blob: 29d41341e4ee091c9ddbcb56d6e1a698a28a103d (plain)
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
%D \module
%D   [       file=x-markdown,
%D        version=2011.07.19,
%D          title=\CONTEXT\ Modules,
%D       subtitle=Processing MarkDown,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\writestatus{loading}{ConTeXt Modules / MarkDown Renderer}

%D This module deals with markdown which is a document encoding that
%D some \CONTEXT\ like much. It reminds me of the kind of minimal coding
%D we used before we ran into \TEX\ and were using a somewhat simple
%D rendering (pagination, etc) of documents. As I'm no user myself, it
%D is up to others to provide documentation and examples.

\registerctxluafile{m-markdown}{}

\unprotect

% basic interface

\definebuffer[markdown]

\unexpanded\def\stopmarkdown
  {\ctxlua{moduledata.markdown.typesetbuffer("\thedefinedbuffer{markdown}")}}

\unexpanded\def\processmarkdownfile#1% maybe [] or both
  {\ctxlua{moduledata.markdown.typesetfile("#1")}}

\unexpanded\def\markdown#1% maybe [] or both
  {\ctxlua{moduledata.markdown.typesetstring(\!!bs#1\!!es)}}

% commands

\defineitemgroup
  [markdownitemize]

\definetyping
  [markdowntyping]

\definetype
  [markdowntype]

\definetype
  [markdowninlinehtml]

\definetyping
  [markdowndisplayhtml]

\definedelimitedtext
  [markdownblockquote]
  [quotation]

\definehighlight
  [markdownemphasis]
  [style=\em]

\definehighlight
  [markdownstrong]
  [style=\bf]

\definestructurelevels
  [markdown]
  [\v!chapter,
   \v!section,
   \v!subsection,
   \v!subsubsection,
   \v!subsubsubsection,
   \v!subsubsubsubsection]

\unexpanded\def\markdownrule
  {\hairline\par}

\protect

\continueifinputfile{m-markdown.mkiv}

\starttext
    \startmarkdown
    % some examples needed
    \stopmarkdown
\stoptext