aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile53
-rw-r--r--ekdosis.dtx344
3 files changed, 399 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..80e3807
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
1# emacs backups
2*~
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..f90325c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,53 @@
1NAME = ekdosis
2SHELL = bash
3PWD = $(shell pwd)
4VERS = $(shell ltxfileinfo -v $(NAME).dtx|sed -e 's/^v//')
5LOCAL = $(shell kpsewhich --var-value TEXMFLOCAL)
6UTREE = $(shell kpsewhich --var-value TEXMFHOME)
7all: $(NAME).pdf
8 test -e README.txt && mv README.txt README || exit 0
9$(NAME).pdf: $(NAME).dtx
10 lualatex -shell-escape -recorder -interaction=batchmode $(NAME).dtx >/dev/null
11 if [ -f $(NAME).glo ]; then makeindex -q -s gglo.ist -o $(NAME).gls $(NAME).glo; fi
12 if [ -f $(NAME).idx ]; then makeindex -q -s gind.ist -o $(NAME).ind $(NAME).idx; fi
13 lualatex --recorder --interaction=nonstopmode $(NAME).dtx > /dev/null
14 lualatex --recorder --interaction=nonstopmode $(NAME).dtx > /dev/null
15clean:
16 rm -f $(NAME).{aux,fls,glo,gls,hd,idx,ilg,ind,ins,log,out}
17 rm -f *~
18 rm -rf auto/
19# rm -f $(NAME)_*.{bib,lua}
20distclean: clean uninst
21 rm -f $(NAME).{pdf,sty,lua} README
22 rm -f *.zip *.tar.gz
23uninst:
24 rm -rf $(UTREE)/{tex,source,doc}/lualatex/$(NAME)
25inst: uninst all
26 mkdir -p $(UTREE)/{tex,source,doc}/lualatex/$(NAME)
27 cp $(NAME).dtx $(UTREE)/source/lualatex/$(NAME)
28 cp $(NAME).sty $(UTREE)/tex/lualatex/$(NAME)
29 cp $(NAME).lua $(UTREE)/tex/lualatex/$(NAME)
30 cp $(NAME).pdf $(UTREE)/doc/lualatex/$(NAME)
31#install: all
32# sudo mkdir -p $(LOCAL)/{tex,source,doc}/lualatex/$(NAME)
33# sudo cp $(NAME).dtx $(LOCAL)/source/lualatex/$(NAME)
34# sudo cp $(NAME).sty $(LOCAL)/tex/lualatex/$(NAME)
35# sudo cp $(NAME).pdf $(LOCAL)/doc/lualatex/$(NAME)
36zip: all
37 ln -sf . $(NAME)
38 zip -Drq $(PWD)/$(NAME)-$(VERS).zip $(NAME)/{README,$(NAME).{pdf,sty,lua}}
39 rm $(NAME)
40package: distclean all
41 mkdir $(NAME)/
42 cp README *.dtx *.pdf $(NAME)/
43 mkdir -p tex/lualatex/$(NAME)/
44 cp *.lua *.sty tex/lualatex/$(NAME)/
45 mkdir -p doc/lualatex/$(NAME)/
46 cp *.pdf doc/lualatex/$(NAME)/
47 mkdir -p source/lualatex/$(NAME)/
48 cp Makefile *.dtx source/lualatex/$(NAME)/
49 zip -r $(NAME).tds.zip tex doc source
50 rm -rf tex/ source/ doc/
51 tar czf $(NAME)-$(VERS).tar.gz $(NAME).tds.zip $(NAME)/
52 rm -rf $(NAME)/
53
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-------:| -----------------------------------------------------------------
9ekdosis:| Typesetting of TEI xml compliant critical editions
10 Author:| Robert Alessi
11 E-mail:| alessi@robertalessi.net
12License:| Released under the GNU General Public License v3 or later
13 See:| http://www.gnu.org/licenses/
14
15
16Short description:
17Some text about the package: probably the same as the abstract.
18%</readme>
19%<*lua>
20--[[
21This file is part of the `ekdosis' package
22
23ekdosis -- Typesetting of TEI xml compliant critical editions
24Copyright (C) 2016 Robert Alessi
25
26Please send error reports and suggestions for improvements to Robert
27Alessi <alessi@robertalessi.net>
28
29This program is free software: you can redistribute it and/or modify
30it under the terms of the GNU General Public License as published by
31the Free Software Foundation, either version 3 of the License, or
32(at your option) any later version.
33
34This program is distributed in the hope that it will be useful, but
35WITHOUT ANY WARRANTY; without even the implied warranty of
36MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
37General Public License for more details.
38
39You should have received a copy of the GNU General Public License
40along with this program. If not, see
41<http://www.gnu.org/licenses/>.
42--]]
43
44function closestream()
45 os.remove(tex.jobname..".ekd")
46 os.rename(tex.jobname.."_tmp.ekd", tex.jobname..".ekd")
47 return true
48end
49
50function 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
59end
60
61function 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
77end
78
79function remove()
80 os.remove(tex.jobname..".ekd")
81end
82
83function 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()
91end
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-------:| -----------------------------------------------------------------
107ekdosis:| Typesetting of TEI xml compliant critical editions
108 Author:| Robert Alessi
109 E-mail:| alessi@robertalessi.net
110License:| Released under the GNU General Public License v3 or later
111 See:| http://www.gnu.org/licenses/
112
113This file is part of the `ekdosis' package
114
115ekdosis -- Typesetting of TEI xml compliant critical editions
116Copyright (C) 2016 Robert Alessi
117
118Please send error reports and suggestions for improvements to Robert
119Alessi <alessi@robertalessi.net>
120
121This program is free software: you can redistribute it and/or modify
122it under the terms of the GNU General Public License as published by
123the Free Software Foundation, either version 3 of the License, or
124(at your option) any later version.
125
126This program is distributed in the hope that it will be useful, but
127WITHOUT ANY WARRANTY; without even the implied warranty of
128MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
129General Public License for more details.
130
131You should have received a copy of the GNU General Public License
132along with this program. If not, see
133<http://www.gnu.org/licenses/>.
134
135This work consists of the file ekdosis.dtx and a Makefile.
136Running "make" generates the derived files README, ekdosis.pdf and ekdosis.sty.
137Running "make inst" installs the files in the user's TeX tree.
138Running "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