diff options
author | Robert Alessi <alessi@robertalessi.net> | 2016-08-15 16:50:58 +0200 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2016-08-15 16:50:58 +0200 |
commit | a24d31f5dab8e66dcaf7b84a73658f4b88c9faf5 (patch) | |
tree | 1e3bbedd363d014e05d6d24285f2ad4d767ad9f7 /ekdosis.dtx | |
download | ekdosis-a24d31f5dab8e66dcaf7b84a73658f4b88c9faf5.tar.gz |
initial project version
Diffstat (limited to 'ekdosis.dtx')
-rw-r--r-- | ekdosis.dtx | 344 |
1 files changed, 344 insertions, 0 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx new file mode 100644 index 0000000..5430f87 --- /dev/null +++ b/ekdosis.dtx | |||
@@ -0,0 +1,344 @@ | |||
1 | % \iffalse meta-comment | ||
2 | % vim: textwidth=75 | ||
3 | %<*internal> | ||
4 | \iffalse | ||
5 | %</internal> | ||
6 | %<*readme> | ||
7 | | | ||
8 | -------:| ----------------------------------------------------------------- | ||
9 | ekdosis:| Typesetting of TEI xml compliant critical editions | ||
10 | Author:| Robert Alessi | ||
11 | E-mail:| alessi@robertalessi.net | ||
12 | License:| Released under the GNU General Public License v3 or later | ||
13 | See:| http://www.gnu.org/licenses/ | ||
14 | |||
15 | |||
16 | Short description: | ||
17 | Some text about the package: probably the same as the abstract. | ||
18 | %</readme> | ||
19 | %<*lua> | ||
20 | --[[ | ||
21 | This file is part of the `ekdosis' package | ||
22 | |||
23 | ekdosis -- Typesetting of TEI xml compliant critical editions | ||
24 | Copyright (C) 2016 Robert Alessi | ||
25 | |||
26 | Please send error reports and suggestions for improvements to Robert | ||
27 | Alessi <alessi@robertalessi.net> | ||
28 | |||
29 | This program is free software: you can redistribute it and/or modify | ||
30 | it under the terms of the GNU General Public License as published by | ||
31 | the Free Software Foundation, either version 3 of the License, or | ||
32 | (at your option) any later version. | ||
33 | |||
34 | This program is distributed in the hope that it will be useful, but | ||
35 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
36 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
37 | General Public License for more details. | ||
38 | |||
39 | You should have received a copy of the GNU General Public License | ||
40 | along with this program. If not, see | ||
41 | <http://www.gnu.org/licenses/>. | ||
42 | --]] | ||
43 | |||
44 | function closestream() | ||
45 | os.remove(tex.jobname..".ekd") | ||
46 | os.rename(tex.jobname.."_tmp.ekd", tex.jobname..".ekd") | ||
47 | return true | ||
48 | end | ||
49 | |||
50 | function appin(str, nl) | ||
51 | local f = io.open(tex.jobname.."_tmp.ekd", "a+") | ||
52 | if nl == "yes" then | ||
53 | f:write(str, "\n") | ||
54 | else | ||
55 | f:write(str) | ||
56 | end | ||
57 | f:close() | ||
58 | return true | ||
59 | end | ||
60 | |||
61 | function appout() | ||
62 | local file = io.open(tex.jobname..".ekd", "r") | ||
63 | if file ~= nil then io.close(file) | ||
64 | f = assert(io.open(tex.jobname..".ekd", "r")) | ||
65 | t = f:read("*a") | ||
66 | local output = {} | ||
67 | for i in string.gmatch(t, "<"..tex.count[0]..">.-</"..tex.count[0]..">") | ||
68 | do | ||
69 | table.insert(output, i) | ||
70 | end | ||
71 | f:close() | ||
72 | str = table.concat(output, "\n") | ||
73 | str = string.gsub(str, "</"..tex.count[0]..">", " ") | ||
74 | str = string.gsub(str, "<"..tex.count[0]..">", "") | ||
75 | return str | ||
76 | else end | ||
77 | end | ||
78 | |||
79 | function remove() | ||
80 | os.remove(tex.jobname..".ekd") | ||
81 | end | ||
82 | |||
83 | function testapparatus() | ||
84 | local file = io.open(tex.jobname..".ekd", "r") | ||
85 | if file ~= nil then | ||
86 | local t = file:read("*a") | ||
87 | if string.find(t, "<"..tex.count[0]..">") then | ||
88 | return "\\booltrue{isapp}" else return "\\boolfalse{isapp}" end | ||
89 | else return "\\boolfalse{isapp}" end | ||
90 | file:close() | ||
91 | end | ||
92 | |||
93 | %</lua> | ||
94 | %<*internal> | ||
95 | \fi | ||
96 | \def\nameofplainTeX{plain} | ||
97 | \ifx\fmtname\nameofplainTeX\else | ||
98 | \expandafter\begingroup | ||
99 | \fi | ||
100 | %</internal> | ||
101 | %<*install> | ||
102 | \input docstrip.tex | ||
103 | \keepsilent | ||
104 | \askforoverwritefalse | ||
105 | \preamble | ||
106 | -------:| ----------------------------------------------------------------- | ||
107 | ekdosis:| Typesetting of TEI xml compliant critical editions | ||
108 | Author:| Robert Alessi | ||
109 | E-mail:| alessi@robertalessi.net | ||
110 | License:| Released under the GNU General Public License v3 or later | ||
111 | See:| http://www.gnu.org/licenses/ | ||
112 | |||
113 | This file is part of the `ekdosis' package | ||
114 | |||
115 | ekdosis -- Typesetting of TEI xml compliant critical editions | ||
116 | Copyright (C) 2016 Robert Alessi | ||
117 | |||
118 | Please send error reports and suggestions for improvements to Robert | ||
119 | Alessi <alessi@robertalessi.net> | ||
120 | |||
121 | This program is free software: you can redistribute it and/or modify | ||
122 | it under the terms of the GNU General Public License as published by | ||
123 | the Free Software Foundation, either version 3 of the License, or | ||
124 | (at your option) any later version. | ||
125 | |||
126 | This program is distributed in the hope that it will be useful, but | ||
127 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
128 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
129 | General Public License for more details. | ||
130 | |||
131 | You should have received a copy of the GNU General Public License | ||
132 | along with this program. If not, see | ||
133 | <http://www.gnu.org/licenses/>. | ||
134 | |||
135 | This work consists of the file ekdosis.dtx and a Makefile. | ||
136 | Running "make" generates the derived files README, ekdosis.pdf and ekdosis.sty. | ||
137 | Running "make inst" installs the files in the user's TeX tree. | ||
138 | Running "make install" installs the files in the local TeX tree. | ||
139 | \endpreamble | ||
140 | |||
141 | \usedir{tex/lualatex/ekdosis} | ||
142 | \generate{ | ||
143 | \file{\jobname.sty}{\from{\jobname.dtx}{package}} | ||
144 | } | ||
145 | %</install> | ||
146 | %<install>\endbatchfile | ||
147 | %<*internal> | ||
148 | \usedir{source/lualatex/ekdosis} | ||
149 | \generate{ | ||
150 | \file{\jobname.ins}{\from{\jobname.dtx}{install}} | ||
151 | } | ||
152 | \nopreamble\nopostamble | ||
153 | \usedir{doc/lualatex/ekdosis} | ||
154 | \generate{ | ||
155 | \file{README.txt}{\from{\jobname.dtx}{readme}} | ||
156 | } | ||
157 | \usedir{tex/lualatex/ekdosis} | ||
158 | \generate{ | ||
159 | \file{ekdosis.lua}{\from{\jobname.dtx}{lua}} | ||
160 | } | ||
161 | \ifx\fmtname\nameofplainTeX | ||
162 | \expandafter\endbatchfile | ||
163 | \else | ||
164 | \expandafter\endgroup | ||
165 | \fi | ||
166 | %</internal> | ||
167 | % \fi | ||
168 | % | ||
169 | % \iffalse | ||
170 | %<*driver> | ||
171 | \ProvidesFile{ekdosis.dtx} | ||
172 | %</driver> | ||
173 | %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] | ||
174 | %<package>\ProvidesPackage{ekdosis} | ||
175 | %<*package> | ||
176 | [2016/08/03 v1.0 Typesetting of TEI xml compliant critical editions] | ||
177 | %</package> | ||
178 | %<*driver> | ||
179 | \documentclass{ltxdoc} | ||
180 | \usepackage[a4paper,margin=25mm,left=50mm,nohead]{geometry} | ||
181 | \usepackage[numbered]{hypdoc} | ||
182 | \usepackage{\jobname} | ||
183 | \usepackage{fontspec,luatextra} | ||
184 | \newcommand{\package}[1]{\textsf{#1}\index{#1=#1 (package)}} | ||
185 | \EnableCrossrefs | ||
186 | \CodelineIndex | ||
187 | \RecordChanges | ||
188 | \begin{document} | ||
189 | \DocInput{\jobname.dtx} | ||
190 | \end{document} | ||
191 | %</driver> | ||
192 | % \fi | ||
193 | % | ||
194 | % \CheckSum{0} | ||
195 | % | ||
196 | % \CharacterTable | ||
197 | % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z | ||
198 | % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z | ||
199 | % Digits \0\1\2\3\4\5\6\7\8\9 | ||
200 | % Exclamation \! Double quote \" Hash (number) \# | ||
201 | % Dollar \$ Percent \% Ampersand \& | ||
202 | % Acute accent \' Left paren \( Right paren \) | ||
203 | % Asterisk \* Plus \+ Comma \, | ||
204 | % Minus \- Point \. Solidus \/ | ||
205 | % Colon \: Semicolon \; Less than \< | ||
206 | % Equals \= Greater than \> Question mark \? | ||
207 | % Commercial at \@ Left bracket \[ Backslash \\ | ||
208 | % Right bracket \] Circumflex \^ Underscore \_ | ||
209 | % Grave accent \` Left brace \{ Vertical bar \| | ||
210 | % Right brace \} Tilde \~} | ||
211 | % | ||
212 | % \GetFileInfo{\jobname.dtx} | ||
213 | % \DoNotIndex{\newcommand,\newenvironment} | ||
214 | % | ||
215 | %\title{\textsf{ekdosis} --- Typesetting of TEI xml compliant critical editions\thanks{This file | ||
216 | % describes version \fileversion, last revised \filedate.} | ||
217 | %} | ||
218 | %\author{Robert Alessi} | ||
219 | %\date{\fileversion\ released \filedate} | ||
220 | % | ||
221 | %\maketitle | ||
222 | % | ||
223 | %\changes{v1.00}{2016/08/03}{First public release} | ||
224 | % | ||
225 | % \begin{abstract} | ||
226 | % ==== Put abstract text here. ==== | ||
227 | % \end{abstract} | ||
228 | % | ||
229 | % \section{Usage} | ||
230 | % | ||
231 | % ==== Put descriptive text here. ==== | ||
232 | % | ||
233 | % \DescribeMacro{\dummyMacro} | ||
234 | % This macro does nothing.\index{doing nothing|usage} It is merely an | ||
235 | % example. If this were a real macro, you would put a paragraph here | ||
236 | % describing what the macro is supposed to do, what its mandatory and | ||
237 | % optional arguments are, and so forth. | ||
238 | % | ||
239 | % \DescribeEnv{dummyEnv} | ||
240 | % This environment does nothing. It is merely an example. | ||
241 | % If this were a real environment, you would put a paragraph here | ||
242 | % describing what the environment is supposed to do, what its | ||
243 | % mandatory and optional arguments are, and so forth. | ||
244 | % | ||
245 | % \StopEventually{} | ||
246 | % \PrintChanges | ||
247 | % \PrintIndex | ||
248 | % | ||
249 | % | ||
250 | % \section{Implementation} | ||
251 | % | ||
252 | % \iffalse | ||
253 | %<*package> | ||
254 | % \fi | ||
255 | % | ||
256 | % \package{ekdosis} relies on Lua functions and tables. Read the | ||
257 | % |.lua| files that accompany \package{ekdosis} for more | ||
258 | % information. | ||
259 | % \begin{macrocode} | ||
260 | \RequirePackage{ifluatex} | ||
261 | % \end{macrocode} | ||
262 | % \package{ekdosis} requires \LuaLaTeX\ of course. Issue a warning | ||
263 | % if the document is processed with another engine. | ||
264 | % \begin{macrocode} | ||
265 | \ifluatex\else | ||
266 | \PackageError{ekdosis}{lualatex needed}{% | ||
267 | Package `ekdosis' needs LuaTeX.\MessageBreak | ||
268 | So you should use `lualatex' to process your document.\MessageBreak | ||
269 | See documentation of `ekdosis' for further information.}% | ||
270 | \expandafter\expandafter\expandafter\csname endinput\endcsname | ||
271 | \fi | ||
272 | % \end{macrocode} | ||
273 | % Packages that are required by \package{ekdosis}: | ||
274 | % \begin{macrocode} | ||
275 | \RequirePackage{luacode} | ||
276 | \RequirePackage{xparse} | ||
277 | \RequirePackage{etoolbox} | ||
278 | \RequirePackage{float} | ||
279 | \newfloat{apparat}{b}{lap} | ||
280 | \RequirePackage{afterpage} | ||
281 | \RequirePackage{refcount} | ||
282 | % \end{macrocode} | ||
283 | % Here begins the real work: load |ekdosis.lua|: | ||
284 | % \begin{macrocode} | ||
285 | \luadirect{dofile(kpse.find_file("ekdosis.lua"))} | ||
286 | % \end{macrocode} | ||
287 | % \begin{macrocode} | ||
288 | \AtEndDocument{\luadirect{closestream()}} | ||
289 | \newbool{isapp} | ||
290 | \newbool{ekdstate} | ||
291 | \newbool{ekdstarted} | ||
292 | \newcounter{ekd@lab} | ||
293 | \NewDocumentCommand{\append}{+m}{% | ||
294 | \ifbool{ekdstate}{% | ||
295 | \label{ekd:\theekd@lab}% | ||
296 | \luadirect{appin(\luastring{<\getpagerefnumber{ekd:\theekd@lab}>}, "no")}% | ||
297 | \luadirect{appin(\luastringN{#1}, "no")}% | ||
298 | \luadirect{appin(\luastring{</\getpagerefnumber{ekd:\theekd@lab}>}, "yes")}% | ||
299 | \stepcounter{ekd@lab}}{}} | ||
300 | \NewDocumentCommand{\myappend}{+m}{% | ||
301 | \ifbool{ekdstate}{% | ||
302 | \label{\getlab}% | ||
303 | \luadirect{appin(\luastring{<\getpagerefnumber{\getlab}>}, "no")}% | ||
304 | \luadirect{appin(\luastringN{#1}, "no")}% | ||
305 | \luadirect{appin(\luastring{</\getpagerefnumber{\getlab}>}, "yes")}% | ||
306 | \mklab}{}} | ||
307 | \NewDocumentCommand{\apparatus}{}{\luadirect{tex.sprint(appout())}} | ||
308 | \NewDocumentCommand{\testapparatus}{}{\luadirect{tex.sprint(testapparatus())}} | ||
309 | \def\blfootnote{\gdef\@thefnmark{\relax}\@footnotetext} | ||
310 | \def\addapp{% | ||
311 | \testapparatus% | ||
312 | \ifbool{isapp}{% | ||
313 | \begin{apparat}[b!] | ||
314 | \rule{5cm}{0.5pt}\\ | ||
315 | \footnotesize\textbf{Apparat:} \apparatus | ||
316 | \end{apparat}}{}% | ||
317 | % \blfootnote{\apparatus}}{} | ||
318 | \afterpage{\addapp}} | ||
319 | \NewDocumentCommand{\EkdosisStart}{}{% | ||
320 | \testapparatus% | ||
321 | \ifbool{isapp}{% | ||
322 | \begin{apparat}[b!] | ||
323 | \rule{5cm}{0.5pt}\\ | ||
324 | \footnotesize\textbf{Apparat:} \apparatus | ||
325 | \end{apparat}}{}% | ||
326 | % \blfootnote{\apparatus}}{}% | ||
327 | \afterpage{\addapp}} | ||
328 | \NewDocumentCommand{\EkdosisOn}{}{\setbool{ekdstate}{true}} | ||
329 | \NewDocumentCommand{\EkdosisOff}{}{\setbool{ekdstate}{false}} | ||
330 | \newenvironment{ekdosis}{% | ||
331 | \ifbool{ekdstarted}{}{\EkdosisStart\global\setbool{ekdstarted}{true}} | ||
332 | \EkdosisOn}{\EkdosisOff} | ||
333 | % \end{macrocode} | ||
334 | % That is it. Say goodbye before leaving. | ||
335 | % \begin{macrocode} | ||
336 | \endinput | ||
337 | % \end{macrocode} | ||
338 | % | ||
339 | % \iffalse | ||
340 | %</package> | ||
341 | % \fi | ||
342 | % | ||
343 | % \Finale | ||
344 | \endinput | ||