From 4c32ae07a868015986b6a9e1912302cc10c1726d Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Fri, 12 Jun 2020 17:32:36 +0200 Subject: set line number font to \normalfont. new option 'flush' added to alignment. new command \EkdosisDefaultApparatus. started preparing files for documentation --- Makefile | 18 +++++- ekdosis.dtx | 209 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------- ekdosis.ins | 10 +++ 3 files changed, 209 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 34e846c..443969a 100644 --- a/Makefile +++ b/Makefile @@ -6,37 +6,49 @@ VERS = $(shell ltxfileinfo -v $(NAME).dtx|sed -e 's/^v//') LOCAL = $(shell kpsewhich --var-value TEXMFLOCAL) UTREE = $(shell kpsewhich --var-value TEXMFHOME) HOMEDIR := $$HOME -all: $(NAME).pdf + +all: sty $(NAME).pdf test -e README.txt && mv README.txt README || exit 0 + +sty: clean + $(CMP) $(NAME).ins + $(NAME).pdf: $(NAME).dtx + $(CMP) --shell-escape -recorder -interaction=batchmode $(NAME)-ex.tex >/dev/null $(CMP) --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 $(CMP) --shell-escape --recorder --interaction=nonstopmode $(NAME).dtx > /dev/null $(CMP) --shell-escape --recorder --interaction=nonstopmode $(NAME).dtx > /dev/null + clean: rm -rf _minted-* rm -f $(NAME).{aux,fls,glo,gls,hd,idx,ilg,ind,log,out,toc,pyg} rm -f *~ rm -rf auto/ # rm -f $(NAME)_*.{bib,lua} + auctex: if [ ! -d "$(HOMEDIR)/.emacs.d/auctex/auto" ]; then \ mkdir -p $(HOMEDIR)/.emacs.d/auctex/auto; \ fi cp $(NAME)*.el $(HOMEDIR)/.emacs.d/auctex/auto + distclean: clean uninst - rm -f $(NAME).{pdf,sty,lua} README* + rm -f $(NAME).{pdf,sty,lua,ekd} $(NAME)-ex*.* README* rm -f *.zip *.tar.gz + uninst: rm -rf $(UTREE)/{tex,source,doc}/lualatex/$(NAME) rm -rf $(HOMEDIR)/.emacs.d/auctex/auto/$(NAME).{el,elc} + inst: uninst auctex 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) + local: uninst auctex $(CMP) $(NAME).ins mkdir -p $(UTREE)/{tex,source,doc}/lualatex/$(NAME) @@ -47,10 +59,12 @@ local: uninst auctex # 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,el}} rm $(NAME) + package: distclean all mkdir $(NAME)/ cp README *.dtx *.pdf $(NAME)/ diff --git a/ekdosis.dtx b/ekdosis.dtx index 6f77144..e0ad014 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx @@ -104,6 +104,16 @@ Running "make install" installs the files in the local TeX tree. } } \egroup +\usedir{doc/lualatex/ekdosis} +\generate{ + \file{ekdosis-ex.tex}{ + \from{\jobname.dtx}{examples} + } +} +\usedir{doc/lualatex/ekdosis} +\generate{ + \file{README.txt}{\from{\jobname.dtx}{readme}} +} % %\endbatchfile %<*internal> @@ -146,6 +156,8 @@ Running "make install" installs the files in the local TeX tree. \babelfont{tt}{NewComputerModern Mono} \usepackage{metalogox} \usepackage{hologo} +\usepackage{xcolor} +\definecolor{ekdcolor}{RGB}{243,241,235} \usepackage{latexcolors} \usepackage{hyperxmp} \usepackage{uri} @@ -168,15 +180,36 @@ Running "make install" installs the files in the local TeX tree. \usepackage{arabluatex} \usepackage{relsize} \usepackage{units} -\usepackage[newfloat=true]{minted} -\newminted[ekdlua]{lua}{linenos, fontsize=\relsize{-0.5}, - xleftmargin=12pt, breaklines, - numberblanklines=false, numbersep=3pt, firstnumber=last} +\PassOptionsToPackage{newfloat}{minted} +\usepackage{tikz} +\usepackage[breakable, skins, xparse, minted]{tcolorbox} +\usepackage{minted} +\setminted{bgcolor=ekdcolor,linenos, fontsize=\small} +\newminted[ekdlua]{lua}{ + bgcolor={}, + linenos, + fontsize=\relsize{-0.5}, + xleftmargin=12pt, + breaklines, + numberblanklines=false, + numbersep=3pt, + firstnumber=last} \renewcommand{\theFancyVerbLine}{\rmfamily\smaller\arabic{FancyVerbLine}} \usepackage[contents]{colordoc} \newcommand{\package}[1]{\textsf{#1}\index{#1=#1 (package)}} -\usepackage{tikz} -\usepackage[breakable, skins, xparse, minted]{tcolorbox} +% +\backgroundcolor{c}{ekdcolor} +\usepackage{caption} +\captionsetup[listing]{position=above,skip=-1ex} +\usepackage{needspace} +\NewDocumentCommand{\captof}{O{listing} m O{}}{% + \bgroup + \needspace{2\baselineskip}% + \vskip 1ex plus 2pt minus 2pt% + \captionof{#1}{#2}% + #3% + \egroup} +% \usepackage{etoc} \etocsettocdepth{paragraph} \newcommand{\ekdtableofcontents}{% @@ -289,8 +322,20 @@ Running "make install" installs the files in the local TeX tree. % -- (0,2); % \end{tikzpicture} % \end{keyfigure} +% +% %*** +% \captof{Peter and John example} +% \inputminted[firstline=17,lastline=24]{latex}{ekdosis-ex.tex} +% \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen] +% \begin{specimen} +% I saw my friend \app{ +% \lem{Peter} +% \rdg{John}} +% at the station yesterday. +% \end{specimen} +% \end{alignment} +% \inputminted[firstline=35,lastline=39]{xml}{ekdosis-ex-tei.xml} % -% \StopEventually{} % \section{Implementation} % % \iffalse @@ -385,6 +430,10 @@ Running "make install" installs the files in the local TeX tree. \luadirect{ekdosis.closestream()} } % \end{macrocode} +% General settings +% \begin{macrocode} +\renewcommand\linenumberfont{\normalfont\footnotesize} +% \end{macrocode} % Hooks % \begin{macrocode} \ekvdefinekeys{ekd@hooks}{ @@ -645,10 +694,18 @@ Running "make install" installs the files in the local TeX tree. {\luadirect{tex.sprint(ekdosis.mdvappend(\luastringO{#2}))}} {\luadirect{tex.sprint(ekdosis.mdvappend(\luastringO{#2}, \luastringO{#1}))}}} -\define@cmdkey[ekd]{appnote}[ekdan@]{type}{} + % \define@cmdkey[ekd]{appnote}[ekdan@]{type}[default]{} +\ekvdefinekeys{appnote}{ + store type = \ekdan@type, + initial type = default + } +\NewDocumentCommand{\EkdosisDefaultApparatus}{m}{% + \ekvset{appnote}{type=#1}} \NewDocumentCommand{\app}{O{} > { \TrimSpaces } +m}{% - \presetkeys[ekd]{appnote}{type=default}{}% - \setkeys[ekd]{appnote}{#1}% + % \presetkeys[ekd]{appnote}{type=default}{}% + % \setkeys[ekd]{appnote}{#1}% + \begingroup + \ekvset{appnote}{#1}% \ekd@isinapptrue% \stepcounter{ekd@lab}% \zlabel{ekd:\theekd@lab}% @@ -656,7 +713,8 @@ Running "make install" installs the files in the local TeX tree. \luastring{\zref@extract{ekd:\theekd@lab}{abspage}})}% \ifekd@state\add@apparatus\fi% \luadirect{tex.sprint(ekdosis.removesp(\luastringN{#2}))}% - \ekd@isinappfalse} + \ekd@isinappfalse% + \endgroup} \def\current@ref@arg#1#2{{%\textdir TLT% \unexpanded\expandafter{\ekd@refnumstyle}% \ifnum% @@ -932,13 +990,23 @@ Running "make install" installs the files in the local TeX tree. \fi% \egroup% } -\define@cmdkeys[ekd]{note}[ekdn@]{lem, labelb, labele} -\define@cmdkey[ekd]{note}[ekdn@]{sep}{} -\presetkeys[ekd]{note}{sep=\ekdsep}{} + % \define@cmdkeys[ekd]{note}[ekdn@]{lem, labelb, labele} + % \define@cmdkey[ekd]{note}[ekdn@]{sep}{} + % \presetkeys[ekd]{note}{sep=\ekdsep}{} +\ekvdefinekeys{note}{ + store type = \ekdan@type, + store lem = \ekdn@lem, + code labelb = \def\ekdn@labelb{#1}, + code labele = \def\ekdn@labele{#1}, + store sep = \ekdn@sep, + initial type = default, + initial sep = \ekdsep + } \NewDocumentCommand{\note@noapp}{O{} +m}{% - \presetkeys[ekd]{appnote}{type=default}{}% + % \presetkeys[ekd]{appnote}{type=default}{}% \bgroup% - \setkeys[ekd]{appnote,note}{#1}% + \ekvset{note}{#1} + % \setkeys[ekd]{appnote,note}{#1}% \stepcounter{ekd@lab}% \zlabel{ekd:\theekd@lab}% \luadirect{ekdosis.storeabspg( @@ -1097,6 +1165,7 @@ Running "make install" installs the files in the local TeX tree. bool pagelineation = \ifekd@pagelineation, choice segmentation = {auto = \def\segmentation@val{auto}, noauto = \def\segmentation@val{noauto}}, + bool flush = \ifekd@flushapp, initial tcols = 2, initial lcols = 1, initial texts = edition;translation, @@ -1138,6 +1207,9 @@ Running "make install" installs the files in the local TeX tree. \luastring{\texts@value}, "texts" )} + \ifekd@flushapp + \luadirect{ekdosis.newalignment("set")} + \fi \luadirect{ekdosis.mkenvdata( \luastring{\apparatus@value}, "apparatus" )} @@ -1151,6 +1223,9 @@ Running "make install" installs the files in the local TeX tree. } {\end{paracol} \iftei@export\luadirect{ekdosis.export_coldata_totei()}\fi + \ifekd@flushapp + \luadirect{ekdosis.newalignment("reset")} + \fi \luadirect{ekdosis.flushenvdata()} \luadirect{ekdosis.flushcolnums()} } @@ -2327,7 +2402,7 @@ local curcol = "x" local check_resetlineno = {} -function ekdosis.update_abspg(n) +function ekdosis.update_abspg(n) -- not used cur_abs_pg = n return true end @@ -2356,6 +2431,27 @@ end -- Build environments to be aligned -- +local cur_alignment = "-" +local cur_alignment_patt = "%-" +local cur_alignment_cnt = 1 + +local newalignment = false +function ekdosis.newalignment(str) + if str == "set" + then + newalignment = true + cur_alignment = "-"..cur_alignment_cnt.."-" + cur_alignment_patt = "%-"..cur_alignment_cnt.."%-" + cur_alignment_cnt = cur_alignment_cnt + 1 + elseif str == "reset" + then + newalignment = false + cur_alignment = "-" + cur_alignment_patt = "-" + end + return true +end + local aligned_texts = {} local texts_w_apparatus = {} local coldata_totei = {} @@ -2620,7 +2716,8 @@ function ekdosis.appin(str, teitype) local f = io.open(tex.jobname.."_tmp.ekd", "a+") if next(apparatuses) == nil then - f:write("<", cur_abs_pg, "-", curcol, "-0>", str, "\n") + f:write("<", cur_abs_pg, cur_alignment, curcol, "-0>", str, "\n") else for i = 1,#apparatuses do @@ -2629,7 +2726,8 @@ function ekdosis.appin(str, teitype) break end end - f:write("<", cur_abs_pg, "-", curcol, "-", appno, ">", str, "\n") + f:write("<", cur_abs_pg, cur_alignment, curcol, "-", + appno, ">", str, "\n") end f:close() return true @@ -2646,7 +2744,12 @@ function ekdosis.appout() table.insert(output, "\\noindent\\csname ekd@default@rule\\endcsname\\NLS{}") -- table.insert(output, "\\noindent ") for i in string.gmatch(t, - "<"..cur_abs_pg.."%-"..curcol.."%-0>.-") + "<"..cur_abs_pg + ..cur_alignment_patt + ..curcol.."%-0>.-") do table.insert(output, i) end @@ -2655,7 +2758,12 @@ function ekdosis.appout() local n = 1 while apparatuses[n] do - if string.match(t, "<"..cur_abs_pg.."%-"..curcol.."%-"..n..">.-") + if string.match(t, "<"..cur_abs_pg.. + cur_alignment_patt + ..curcol.."%-"..n..">.-") then -- table.insert(output, "BEGIN") table.insert(output, "\\bgroup{}") @@ -2704,7 +2812,12 @@ function ekdosis.appout() table.insert(output, "\\relax") end for i in string.gmatch(t, - "<"..cur_abs_pg.."%-"..curcol.."%-"..n..">.-") + "<"..cur_abs_pg + ..cur_alignment_patt + ..curcol.."%-"..n..">.-") do table.insert(output, i) end @@ -2721,8 +2834,8 @@ function ekdosis.appout() end f:close() str = table.concat(output) - str = string.gsub(str, "", "") - str = string.gsub(str, "<"..cur_abs_pg.."%-"..curcol.."%-[0-9]>", " ") + str = string.gsub(str, "", "") + str = string.gsub(str, "<"..cur_abs_pg..cur_alignment_patt..curcol.."%-[0-9]>", " ") return str else end @@ -2744,7 +2857,16 @@ local curcol_curabspg = {} function ekdosis.testapparatus() if isfound(curcol_curabspg, curcol.."-"..cur_abs_pg) then - return "\\boolfalse{do@app}" + if newalignment + then + if next(apparatuses) ~= nil then + reset_bagunits() + end + newalignment = false + return "\\booltrue{do@app}" + else + return "\\boolfalse{do@app}" + end else table.insert(curcol_curabspg, curcol.."-"..cur_abs_pg) if next(apparatuses) ~= nil then @@ -2843,4 +2965,39 @@ end % \iffalse % % \fi -\endinput +% +% \iffalse +%<*examples> +% \fi +% \begin{minted}[firstnumber=last]{latex} +\documentclass[12pt]{article} +\usepackage{fontspec} +\usepackage[english]{babel} +\babelfont{rm}{Old Standard} +\babelfont{sf}{NewComputerModern Sans} +\babelfont{tt}{NewComputerModern Mono} + +\usepackage[teiexport=tidy]{ekdosis} +\SetEkdosisAlignment{ + tcols=1, + lcols=1, + texts=specimen[xml:lang="fr"], + apparatus=specimen} + +\begin{document} + +\begin{alignment}[flush] + \begin{specimen} + I saw my friend \app{ + \lem{Peter} + \rdg{John}} + at the station yesterday. + \end{specimen} +\end{alignment} + +\end{document} +% \end{minted} +% \iffalse +% +% \fi +\endinput \ No newline at end of file diff --git a/ekdosis.ins b/ekdosis.ins index 77c955b..b724b43 100644 --- a/ekdosis.ins +++ b/ekdosis.ins @@ -52,4 +52,14 @@ Running "make install" installs the files in the local TeX tree. } } \egroup +\usedir{doc/lualatex/ekdosis} +\generate{ + \file{ekdosis-ex.tex}{ + \from{\jobname.dtx}{examples} + } +} +\usedir{doc/lualatex/ekdosis} +\generate{ + \file{README.txt}{\from{\jobname.dtx}{readme}} +} \endbatchfile -- cgit v1.2.3