From a24d31f5dab8e66dcaf7b84a73658f4b88c9faf5 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Mon, 15 Aug 2016 16:50:58 +0200 Subject: initial project version --- .gitignore | 2 + Makefile | 53 ++++++++++ ekdosis.dtx | 344 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 399 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 ekdosis.dtx diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..80e3807 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# emacs backups +*~ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f90325c --- /dev/null +++ b/Makefile @@ -0,0 +1,53 @@ +NAME = ekdosis +SHELL = bash +PWD = $(shell pwd) +VERS = $(shell ltxfileinfo -v $(NAME).dtx|sed -e 's/^v//') +LOCAL = $(shell kpsewhich --var-value TEXMFLOCAL) +UTREE = $(shell kpsewhich --var-value TEXMFHOME) +all: $(NAME).pdf + test -e README.txt && mv README.txt README || exit 0 +$(NAME).pdf: $(NAME).dtx + lualatex -shell-escape -recorder -interaction=batchmode $(NAME).dtx >/dev/null + if [ -f $(NAME).glo ]; then makeindex -q -s gglo.ist -o $(NAME).gls $(NAME).glo; fi + if [ -f $(NAME).idx ]; then makeindex -q -s gind.ist -o $(NAME).ind $(NAME).idx; fi + lualatex --recorder --interaction=nonstopmode $(NAME).dtx > /dev/null + lualatex --recorder --interaction=nonstopmode $(NAME).dtx > /dev/null +clean: + rm -f $(NAME).{aux,fls,glo,gls,hd,idx,ilg,ind,ins,log,out} + rm -f *~ + rm -rf auto/ +# rm -f $(NAME)_*.{bib,lua} +distclean: clean uninst + rm -f $(NAME).{pdf,sty,lua} README + rm -f *.zip *.tar.gz +uninst: + rm -rf $(UTREE)/{tex,source,doc}/lualatex/$(NAME) +inst: uninst all + mkdir -p $(UTREE)/{tex,source,doc}/lualatex/$(NAME) + cp $(NAME).dtx $(UTREE)/source/lualatex/$(NAME) + cp $(NAME).sty $(UTREE)/tex/lualatex/$(NAME) + cp $(NAME).lua $(UTREE)/tex/lualatex/$(NAME) + cp $(NAME).pdf $(UTREE)/doc/lualatex/$(NAME) +#install: all +# sudo mkdir -p $(LOCAL)/{tex,source,doc}/lualatex/$(NAME) +# sudo cp $(NAME).dtx $(LOCAL)/source/lualatex/$(NAME) +# sudo cp $(NAME).sty $(LOCAL)/tex/lualatex/$(NAME) +# sudo cp $(NAME).pdf $(LOCAL)/doc/lualatex/$(NAME) +zip: all + ln -sf . $(NAME) + zip -Drq $(PWD)/$(NAME)-$(VERS).zip $(NAME)/{README,$(NAME).{pdf,sty,lua}} + rm $(NAME) +package: distclean all + mkdir $(NAME)/ + cp README *.dtx *.pdf $(NAME)/ + mkdir -p tex/lualatex/$(NAME)/ + cp *.lua *.sty tex/lualatex/$(NAME)/ + mkdir -p doc/lualatex/$(NAME)/ + cp *.pdf doc/lualatex/$(NAME)/ + mkdir -p source/lualatex/$(NAME)/ + cp Makefile *.dtx source/lualatex/$(NAME)/ + zip -r $(NAME).tds.zip tex doc source + rm -rf tex/ source/ doc/ + tar czf $(NAME)-$(VERS).tar.gz $(NAME).tds.zip $(NAME)/ + rm -rf $(NAME)/ + diff --git a/ekdosis.dtx b/ekdosis.dtx new file mode 100644 index 0000000..5430f87 --- /dev/null +++ b/ekdosis.dtx @@ -0,0 +1,344 @@ +% \iffalse meta-comment +% vim: textwidth=75 +%<*internal> +\iffalse +% +%<*readme> +| +-------:| ----------------------------------------------------------------- +ekdosis:| Typesetting of TEI xml compliant critical editions + Author:| Robert Alessi + E-mail:| alessi@robertalessi.net +License:| Released under the GNU General Public License v3 or later + See:| http://www.gnu.org/licenses/ + + +Short description: +Some text about the package: probably the same as the abstract. +% +%<*lua> +--[[ +This file is part of the `ekdosis' package + +ekdosis -- Typesetting of TEI xml compliant critical editions +Copyright (C) 2016 Robert Alessi + +Please send error reports and suggestions for improvements to Robert +Alessi + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +. +--]] + +function closestream() + os.remove(tex.jobname..".ekd") + os.rename(tex.jobname.."_tmp.ekd", tex.jobname..".ekd") + return true +end + +function appin(str, nl) + local f = io.open(tex.jobname.."_tmp.ekd", "a+") + if nl == "yes" then + f:write(str, "\n") + else + f:write(str) + end + f:close() + return true +end + +function appout() + local file = io.open(tex.jobname..".ekd", "r") + if file ~= nil then io.close(file) + f = assert(io.open(tex.jobname..".ekd", "r")) + t = f:read("*a") + local output = {} + for i in string.gmatch(t, "<"..tex.count[0]..">.-") + do + table.insert(output, i) + end + f:close() + str = table.concat(output, "\n") + str = string.gsub(str, "", " ") + str = string.gsub(str, "<"..tex.count[0]..">", "") + return str + else end +end + +function remove() + os.remove(tex.jobname..".ekd") +end + +function testapparatus() + local file = io.open(tex.jobname..".ekd", "r") + if file ~= nil then + local t = file:read("*a") + if string.find(t, "<"..tex.count[0]..">") then + return "\\booltrue{isapp}" else return "\\boolfalse{isapp}" end + else return "\\boolfalse{isapp}" end + file:close() +end + +% +%<*internal> +\fi +\def\nameofplainTeX{plain} +\ifx\fmtname\nameofplainTeX\else + \expandafter\begingroup +\fi +% +%<*install> +\input docstrip.tex +\keepsilent +\askforoverwritefalse +\preamble +-------:| ----------------------------------------------------------------- +ekdosis:| Typesetting of TEI xml compliant critical editions + Author:| Robert Alessi + E-mail:| alessi@robertalessi.net +License:| Released under the GNU General Public License v3 or later + See:| http://www.gnu.org/licenses/ + +This file is part of the `ekdosis' package + +ekdosis -- Typesetting of TEI xml compliant critical editions +Copyright (C) 2016 Robert Alessi + +Please send error reports and suggestions for improvements to Robert +Alessi + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +. + +This work consists of the file ekdosis.dtx and a Makefile. +Running "make" generates the derived files README, ekdosis.pdf and ekdosis.sty. +Running "make inst" installs the files in the user's TeX tree. +Running "make install" installs the files in the local TeX tree. +\endpreamble + +\usedir{tex/lualatex/ekdosis} +\generate{ + \file{\jobname.sty}{\from{\jobname.dtx}{package}} +} +% +%\endbatchfile +%<*internal> +\usedir{source/lualatex/ekdosis} +\generate{ + \file{\jobname.ins}{\from{\jobname.dtx}{install}} +} +\nopreamble\nopostamble +\usedir{doc/lualatex/ekdosis} +\generate{ + \file{README.txt}{\from{\jobname.dtx}{readme}} +} +\usedir{tex/lualatex/ekdosis} +\generate{ + \file{ekdosis.lua}{\from{\jobname.dtx}{lua}} +} +\ifx\fmtname\nameofplainTeX + \expandafter\endbatchfile +\else + \expandafter\endgroup +\fi +% +% \fi +% +% \iffalse +%<*driver> +\ProvidesFile{ekdosis.dtx} +% +%\NeedsTeXFormat{LaTeX2e}[1999/12/01] +%\ProvidesPackage{ekdosis} +%<*package> + [2016/08/03 v1.0 Typesetting of TEI xml compliant critical editions] +% +%<*driver> +\documentclass{ltxdoc} +\usepackage[a4paper,margin=25mm,left=50mm,nohead]{geometry} +\usepackage[numbered]{hypdoc} +\usepackage{\jobname} +\usepackage{fontspec,luatextra} +\newcommand{\package}[1]{\textsf{#1}\index{#1=#1 (package)}} +\EnableCrossrefs +\CodelineIndex +\RecordChanges +\begin{document} + \DocInput{\jobname.dtx} +\end{document} +% +% \fi +% +% \CheckSum{0} +% +% \CharacterTable +% {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 +% 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 +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% \GetFileInfo{\jobname.dtx} +% \DoNotIndex{\newcommand,\newenvironment} +% +%\title{\textsf{ekdosis} --- Typesetting of TEI xml compliant critical editions\thanks{This file +% describes version \fileversion, last revised \filedate.} +%} +%\author{Robert Alessi} +%\date{\fileversion\ released \filedate} +% +%\maketitle +% +%\changes{v1.00}{2016/08/03}{First public release} +% +% \begin{abstract} +% ==== Put abstract text here. ==== +% \end{abstract} +% +% \section{Usage} +% +% ==== Put descriptive text here. ==== +% +% \DescribeMacro{\dummyMacro} +% This macro does nothing.\index{doing nothing|usage} It is merely an +% example. If this were a real macro, you would put a paragraph here +% describing what the macro is supposed to do, what its mandatory and +% optional arguments are, and so forth. +% +% \DescribeEnv{dummyEnv} +% This environment does nothing. It is merely an example. +% If this were a real environment, you would put a paragraph here +% describing what the environment is supposed to do, what its +% mandatory and optional arguments are, and so forth. +% +% \StopEventually{} +% \PrintChanges +% \PrintIndex +% +% +% \section{Implementation} +% +% \iffalse +%<*package> +% \fi +% +% \package{ekdosis} relies on Lua functions and tables. Read the +% |.lua| files that accompany \package{ekdosis} for more +% information. +% \begin{macrocode} +\RequirePackage{ifluatex} +% \end{macrocode} +% \package{ekdosis} requires \LuaLaTeX\ of course. Issue a warning +% if the document is processed with another engine. +% \begin{macrocode} +\ifluatex\else + \PackageError{ekdosis}{lualatex needed}{% + Package `ekdosis' needs LuaTeX.\MessageBreak + So you should use `lualatex' to process your document.\MessageBreak + See documentation of `ekdosis' for further information.}% + \expandafter\expandafter\expandafter\csname endinput\endcsname +\fi +% \end{macrocode} +% Packages that are required by \package{ekdosis}: +% \begin{macrocode} +\RequirePackage{luacode} +\RequirePackage{xparse} +\RequirePackage{etoolbox} +\RequirePackage{float} +\newfloat{apparat}{b}{lap} +\RequirePackage{afterpage} +\RequirePackage{refcount} +% \end{macrocode} +% Here begins the real work: load |ekdosis.lua|: +% \begin{macrocode} +\luadirect{dofile(kpse.find_file("ekdosis.lua"))} +% \end{macrocode} +% \begin{macrocode} +\AtEndDocument{\luadirect{closestream()}} +\newbool{isapp} +\newbool{ekdstate} +\newbool{ekdstarted} +\newcounter{ekd@lab} +\NewDocumentCommand{\append}{+m}{% + \ifbool{ekdstate}{% + \label{ekd:\theekd@lab}% + \luadirect{appin(\luastring{<\getpagerefnumber{ekd:\theekd@lab}>}, "no")}% + \luadirect{appin(\luastringN{#1}, "no")}% + \luadirect{appin(\luastring{}, "yes")}% + \stepcounter{ekd@lab}}{}} +\NewDocumentCommand{\myappend}{+m}{% + \ifbool{ekdstate}{% + \label{\getlab}% + \luadirect{appin(\luastring{<\getpagerefnumber{\getlab}>}, "no")}% + \luadirect{appin(\luastringN{#1}, "no")}% + \luadirect{appin(\luastring{}, "yes")}% + \mklab}{}} +\NewDocumentCommand{\apparatus}{}{\luadirect{tex.sprint(appout())}} +\NewDocumentCommand{\testapparatus}{}{\luadirect{tex.sprint(testapparatus())}} +\def\blfootnote{\gdef\@thefnmark{\relax}\@footnotetext} +\def\addapp{% + \testapparatus% + \ifbool{isapp}{% + \begin{apparat}[b!] + \rule{5cm}{0.5pt}\\ + \footnotesize\textbf{Apparat:} \apparatus + \end{apparat}}{}% + % \blfootnote{\apparatus}}{} + \afterpage{\addapp}} +\NewDocumentCommand{\EkdosisStart}{}{% + \testapparatus% + \ifbool{isapp}{% + \begin{apparat}[b!] + \rule{5cm}{0.5pt}\\ + \footnotesize\textbf{Apparat:} \apparatus + \end{apparat}}{}% + % \blfootnote{\apparatus}}{}% + \afterpage{\addapp}} +\NewDocumentCommand{\EkdosisOn}{}{\setbool{ekdstate}{true}} +\NewDocumentCommand{\EkdosisOff}{}{\setbool{ekdstate}{false}} +\newenvironment{ekdosis}{% +\ifbool{ekdstarted}{}{\EkdosisStart\global\setbool{ekdstarted}{true}} +\EkdosisOn}{\EkdosisOff} +% \end{macrocode} +% That is it. Say goodbye before leaving. +% \begin{macrocode} +\endinput +% \end{macrocode} +% +% \iffalse +% +% \fi +% +% \Finale +\endinput -- cgit v1.2.3