-
Notifications
You must be signed in to change notification settings - Fork 0
/
t-pretty-clrscode.mkiv
78 lines (67 loc) · 2.1 KB
/
t-pretty-clrscode.mkiv
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
%C Copyright 2022 Yi Qingliang <[email protected]>
%C Time-stamp: <2022-10-22 11:25:20>
%C This program is free software: you can redistribute it and/or modify
%C it under the terms of the GNU General Public License as published by
%C the Free Software Foundation, either version 3 of the License, or
%C (at your option) any later version.
%C
%C This program is distributed in the hope that it will be useful,
%C but WITHOUT ANY WARRANTY; without even the implied warranty of
%C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%C GNU General Public License for more details.
%C
%C You should have received a copy of the GNU General Public License
%C along with this program. If not, see <http://www.gnu.org/licenses/>.
%C
%C
%C This work is fully inspired by Peter Münster's pret-c module.
%C
%D \module[
%D file=t-pretty-clrscode,
%D version=0.9,
%D title=CLRS code Pretty Printer for the \CONTEXT\ Macro package,
%D author=Yi Qingliang
%D date=\currentdate,
%D copyright=2022 YiQingliang]
\registerctxluafile{t-pretty-clrscode.lua}{0.9}
\unprotect
\setupcolor[ema]
% TODO: the final space is a workaround for using in code section
\define[1]\clrskeyword{{\bf #1} }
\define\For{\clrskeyword{for}}
\define\While{\clrskeyword{while}}
\define\To{\clrskeyword{to}}
\define\Downto{\clrskeyword{downto}}
\define\Return{\clrskeyword{return}}
\define\If{\clrskeyword{if}}
\define\Else{\clrskeyword{else}}
\define\NIL{\clrskeyword{NIL}}
\definestartstop
[CSnippet]
[DefaultSnippet]
\definestartstop
[CSnippetKeyword]
[\c!style=\bf,
%\c!color=dodgerblue,
]
\definestartstop
[CSnippetStrip]
[]
\definetextbackground[clrscodeBG][
location=paragraph,
alternative=0,
background=color,
backgroundcolor=lightyellow,
frame=off
]
% 'framedtext' 不能跨页, 改用 'textbackground'。
\definetyping
[CLRSCODE]
[\c!option=clrscode,
\c!before={\starttextbackground[clrscodeBG]},
\c!after={\stoptextbackground},
\c!escape=no,
\c!tab=4,
\c!numbering=line]
\definetype[CLRSCODE][\c!option=clrscode]
\protect \endinput