-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsourcecode.sty
73 lines (65 loc) · 1.84 KB
/
sourcecode.sty
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
\NeedsTeXFormat{LaTeX2e}[1995/06/01]
\ProvidesPackage{sourcecode}
[2021/04/08 v0.2.1 Sourcecode Lua script]
% setup listings
\lstdefinestyle{sourcecodelua}{
language={[5.3]Lua},
basicstyle=\small\ttfamily,
keywordstyle=\color{blue},
stringstyle=\color{violet},
commentstyle=\color{gray}
}
\lstdefinestyle{sourcecodeterm}{
frame=tb,
basicstyle=\small\ttfamily
}
\definecolor{colKeys}{rgb}{0,0,1}
\definecolor{colIdentifier}{rgb}{0,0,0}
\definecolor{colString}{rgb}{0.6,0.1,0.1}
\definecolor{mydarkblue}{rgb}{0.07,0.08,0.4}
\lstdefinestyle{sourcecodelatex}{
language={[latex]tex},
basicstyle=\small\ttfamily,
identifierstyle=\color{colIdentifier},
keywordstyle=\color{colKeys}\bfseries,
stringstyle=\color{violet},
commentstyle=\itshape\color{black!70},
morekeywords=[2]{directlua,newcommand,approx,texttt,textbf},
morestring=[b]",
emph=[2]{document,tabular,article,tikzpiture},
emphstyle=[2]{\color{mydarkblue}\bfseries},
texcl=false
}
\directlua{
sourcecodelib = require [[sourcecode]]
sourcecodelib._tkprint = tex.print
}
% option run = true via attributes #[run]
% option tex via attributes #[tex]
% option lua via attributes #[lua]
% option index file attributes #[indexfile=<path>]
\newenvironment{lines}{\directlua{
luatexbase.add_to_callback(
'process_input_buffer',
sourcecodelib.process_input_buffer,
'sourcecodelib:lines',
1
)
}}{\directlua{
luatexbase.remove_from_callback(
'process_input_buffer',
'sourcecodelib:lines'
)
sourcecodelib
:trim_tail()
:typeset()
}}
\newcommand\sourcecode[1]{\directlua{
sourcecodelib
:option{#1}
:index_file()
:load_file()
:trim_tail()
:typeset()
}}
\endinput