aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2020-03-19 19:18:14 +0100
committerRobert Alessi <alessi@robertalessi.net>2020-03-19 19:18:14 +0100
commit5b78bc5e83cb76a2e5b9e8bb989b92ded63027d4 (patch)
tree18577197414ea07b0296a7886311ced8c4c9dac6
parentddaa143a6cfa1ace2d12be9ceaaf524658edabb8 (diff)
downloadekdosis-5b78bc5e83cb76a2e5b9e8bb989b92ded63027d4.tar.gz
new functions: any column can have any number of distinct apparatuses
-rw-r--r--ekdosis.dtx115
1 files changed, 78 insertions, 37 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 8555005..dcc4d24 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -507,6 +507,7 @@ Running "make install" installs the files in the local TeX tree.
507 \def\setLR{\boolfalse{al@rlmode}\pardir TLT \textdir TLT} 507 \def\setLR{\boolfalse{al@rlmode}\pardir TLT \textdir TLT}
508} 508}
509\newcounter{ekd@lab} 509\newcounter{ekd@lab}
510\globalcounter{ekd@lab}
510 % \def\unconditional@appin#1{% 511 % \def\unconditional@appin#1{%
511 % \luadirect{ekdosis.appin(\luastringN{#1})}% 512 % \luadirect{ekdosis.appin(\luastringN{#1})}%
512 % } 513 % }
@@ -1079,6 +1080,9 @@ Running "make install" installs the files in the local TeX tree.
1079 initial texts = edition;translation, 1080 initial texts = edition;translation,
1080 initial apparatus = edition, 1081 initial apparatus = edition,
1081} 1082}
1083\NewDocumentCommand{\ekd@storecol}{m}{%
1084 \luadirect{ekdosis.storecurcol(\luastring{\thecolumn})}%
1085}
1082\NewDocumentEnvironment{alignment}{O{}} 1086\NewDocumentEnvironment{alignment}{O{}}
1083{% 1087{%
1084 \ekvset{align}{#1}% 1088 \ekvset{align}{#1}%
@@ -1087,7 +1091,8 @@ Running "make install" installs the files in the local TeX tree.
1087 "texts" 1091 "texts"
1088 )} 1092 )}
1089 \luadirect{ekdosis.mkenvdata( 1093 \luadirect{ekdosis.mkenvdata(
1090 \luastring{\apparatus@value}, "apparatus")} 1094 \luastring{\apparatus@value}, "apparatus"
1095 )}
1091 \luadirect{tex.sprint(ekdosis.mkenv())} 1096 \luadirect{tex.sprint(ekdosis.mkenv())}
1092 \ifekd@paired 1097 \ifekd@paired
1093 \begin{paracol}[\lcols@num]{\tcols@num} 1098 \begin{paracol}[\lcols@num]{\tcols@num}
@@ -1095,8 +1100,10 @@ Running "make install" installs the files in the local TeX tree.
1095 \begin{paracol}[\lcols@num]*{\tcols@num} 1100 \begin{paracol}[\lcols@num]*{\tcols@num}
1096 \fi 1101 \fi
1097 } 1102 }
1098 {\luadirect{ekdosis.flushenvdata()} 1103 {\end{paracol}
1099 \end{paracol}} 1104 \luadirect{ekdosis.flushenvdata()}
1105 \luadirect{ekdosis.flushcolnums()}
1106 }
1100% \end{macrocode} 1107% \end{macrocode}
1101% Very basic implementation of poetry lines:--- 1108% Very basic implementation of poetry lines:---
1102% \begin{macrocode} 1109% \begin{macrocode}
@@ -1946,17 +1953,18 @@ function ekdosis.mkenvdata(str, opt)
1946 end 1953 end
1947end 1954end
1948 1955
1949-- idea: store this # in a lua variable as in ekdosis.storeabspg() 1956local prevcol = nil
1950-- above, then use it in the apparatus-page attributes 1957local curcol = "x"
1951function ekdosis.getcurcol(str) 1958
1952 for i = 1,#aligned_texts 1959function ekdosis.storecurcol(n)
1953 do 1960 curcol = n
1954 if aligned_texts[i].text == str then 1961 return true
1955 colfound = aligned_texts[i].column 1962end
1956 break 1963
1957 end 1964function ekdosis.flushcolnums()
1958 end 1965 prevcol = nil
1959 return colfound 1966 curcol = "x"
1967 return true
1960end 1968end
1961 1969
1962function ekdosis.flushenvdata() 1970function ekdosis.flushenvdata()
@@ -1975,12 +1983,14 @@ function ekdosis.mkenv()
1975 .. aligned_texts[i].text 1983 .. aligned_texts[i].text
1976 .. "}{}{\\begin{nthcolumn}{" 1984 .. "}{}{\\begin{nthcolumn}{"
1977 .. aligned_texts[i].column 1985 .. aligned_texts[i].column
1978 .."}\\begin{ekdosis}}{\\end{ekdosis}\\end{nthcolumn}}") 1986 .."}\\begin{ekdosis}"
1987 .."\\csname ekd@storecol\\endcsname{\\thecolumn}}{\\end{ekdosis}\\end{nthcolumn}}")
1979 table.insert(environments, "\\NewDocumentEnvironment{" 1988 table.insert(environments, "\\NewDocumentEnvironment{"
1980 .. aligned_texts[i].text 1989 .. aligned_texts[i].text
1981 .. "*}{O{}}{\\begin{nthcolumn*}{" 1990 .. "*}{O{}}{\\begin{nthcolumn*}{"
1982 .. aligned_texts[i].column 1991 .. aligned_texts[i].column
1983 .."}\\begin{ekdosis}}{\\end{ekdosis}\\end{nthcolumn*}}") 1992 .."}\\begin{ekdosis}"
1993 .."\\csname ekd@storecol\\endcsname{\\thecolumn}}{\\end{ekdosis}\\end{nthcolumn*}}")
1984 else 1994 else
1985 table.insert(environments, "\\NewDocumentEnvironment{" 1995 table.insert(environments, "\\NewDocumentEnvironment{"
1986 .. aligned_texts[i].text 1996 .. aligned_texts[i].text
@@ -2058,7 +2068,7 @@ function ekdosis.appin(str, teitype)
2058 local f = io.open(tex.jobname.."_tmp.ekd", "a+") 2068 local f = io.open(tex.jobname.."_tmp.ekd", "a+")
2059 if next(apparatuses) == nil 2069 if next(apparatuses) == nil
2060 then 2070 then
2061 f:write("<", cur_abs_pg, "-0>", str, "</", cur_abs_pg, "-0>\n") 2071 f:write("<", cur_abs_pg, "-", curcol, "-0>", str, "</", cur_abs_pg, "-", curcol, "-0>\n")
2062 else 2072 else
2063 for i = 1,#apparatuses 2073 for i = 1,#apparatuses
2064 do 2074 do
@@ -2067,7 +2077,7 @@ function ekdosis.appin(str, teitype)
2067 break 2077 break
2068 end 2078 end
2069 end 2079 end
2070 f:write("<", cur_abs_pg, "-", appno, ">", str, "</", cur_abs_pg, "-", appno, ">\n") 2080 f:write("<", cur_abs_pg, "-", curcol, "-", appno, ">", str, "</", cur_abs_pg, "-", curcol, "-", appno, ">\n")
2071 end 2081 end
2072 f:close() 2082 f:close()
2073 return true 2083 return true
@@ -2084,7 +2094,7 @@ function ekdosis.appout()
2084 table.insert(output, "\\noindent\\csname ekd@default@rule\\endcsname\\NLS{}") 2094 table.insert(output, "\\noindent\\csname ekd@default@rule\\endcsname\\NLS{}")
2085-- table.insert(output, "\\noindent ") 2095-- table.insert(output, "\\noindent ")
2086 for i in string.gmatch(t, 2096 for i in string.gmatch(t,
2087 "<"..cur_abs_pg.."%-0>.-</"..cur_abs_pg.."%-0>") 2097 "<"..cur_abs_pg.."%-"..curcol.."%-0>.-</"..cur_abs_pg.."%-"..curcol.."%-0>")
2088 do 2098 do
2089 table.insert(output, i) 2099 table.insert(output, i)
2090 end 2100 end
@@ -2093,7 +2103,7 @@ function ekdosis.appout()
2093 local n = 1 2103 local n = 1
2094 while apparatuses[n] 2104 while apparatuses[n]
2095 do 2105 do
2096 if string.match(t, "<"..cur_abs_pg.."%-"..n..">.-</"..cur_abs_pg.."%-"..n..">") 2106 if string.match(t, "<"..cur_abs_pg.."%-"..curcol.."%-"..n..">.-</"..cur_abs_pg.."%-"..curcol.."%-"..n..">")
2097 then 2107 then
2098 -- table.insert(output, "BEGIN") 2108 -- table.insert(output, "BEGIN")
2099 table.insert(output, "\\bgroup{}") 2109 table.insert(output, "\\bgroup{}")
@@ -2142,7 +2152,7 @@ function ekdosis.appout()
2142 table.insert(output, "\\relax") 2152 table.insert(output, "\\relax")
2143 end 2153 end
2144 for i in string.gmatch(t, 2154 for i in string.gmatch(t,
2145 "<"..cur_abs_pg.."%-"..n..">.-</"..cur_abs_pg.."%-"..n..">") 2155 "<"..cur_abs_pg.."%-"..curcol.."%-"..n..">.-</"..cur_abs_pg.."%-"..curcol.."%-"..n..">")
2146 do 2156 do
2147 table.insert(output, i) 2157 table.insert(output, i)
2148 end 2158 end
@@ -2159,10 +2169,11 @@ function ekdosis.appout()
2159 end 2169 end
2160 f:close() 2170 f:close()
2161 str = table.concat(output) 2171 str = table.concat(output)
2162 str = string.gsub(str, "</"..cur_abs_pg.."%-[0-9]>", "") 2172 str = string.gsub(str, "</"..cur_abs_pg.."%-"..curcol.."%-[0-9]>", "")
2163 str = string.gsub(str, "<"..cur_abs_pg.."%-[0-9]>", " ") 2173 str = string.gsub(str, "<"..cur_abs_pg.."%-"..curcol.."%-[0-9]>", " ")
2164 return str 2174 return str
2165 else end 2175 else
2176 end
2166end 2177end
2167 2178
2168function ekdosis.appin_out(str, nl) 2179function ekdosis.appin_out(str, nl)
@@ -2177,21 +2188,51 @@ function ekdosis.appin_out(str, nl)
2177end 2188end
2178 2189
2179function ekdosis.testapparatus() 2190function ekdosis.testapparatus()
2180 if tonumber(pg_ii) < tonumber(pg_i) 2191 if curcol ~= "x"
2181 or tonumber(pg_ii) < tonumber(cur_abs_pg) then 2192 then
2182 pg_i = cur_abs_pg 2193 if prevcol == nil or curcol ~= prevcol
2183 if next(apparatuses) ~= nil then 2194 then
2184 reset_bagunits() 2195 prevcol = curcol
2196 if next(apparatuses) ~= nil then
2197 reset_bagunits()
2198 end
2199 return "\\booltrue{do@app}"
2200 else
2201 -- return "\\boolfalse{do@app}"
2202 if tonumber(pg_ii) < tonumber(pg_i)
2203 or tonumber(pg_ii) < tonumber(cur_abs_pg) then
2204 pg_i = cur_abs_pg
2205 if next(apparatuses) ~= nil then
2206 reset_bagunits()
2207 end
2208 return "\\booltrue{do@app}"
2209 elseif tonumber(pg_ii) == tonumber(pg_i) then
2210 return "\\boolfalse{do@app}"
2211 elseif tonumber(pg_ii) > tonumber(pg_i) then
2212 pg_i = cur_abs_pg
2213 if next(apparatuses) ~= nil then
2214 reset_bagunits()
2215 end
2216 return "\\booltrue{do@app}"
2217 end
2185 end 2218 end
2186 return "\\booltrue{do@app}" 2219 else
2187 elseif tonumber(pg_ii) == tonumber(pg_i) then 2220 if tonumber(pg_ii) < tonumber(pg_i)
2188 return "\\boolfalse{do@app}" 2221 or tonumber(pg_ii) < tonumber(cur_abs_pg) then
2189 elseif tonumber(pg_ii) > tonumber(pg_i) then 2222 pg_i = cur_abs_pg
2190 pg_i = cur_abs_pg 2223 if next(apparatuses) ~= nil then
2191 if next(apparatuses) ~= nil then 2224 reset_bagunits()
2192 reset_bagunits() 2225 end
2226 return "\\booltrue{do@app}"
2227 elseif tonumber(pg_ii) == tonumber(pg_i) then
2228 return "\\boolfalse{do@app}"
2229 elseif tonumber(pg_ii) > tonumber(pg_i) then
2230 pg_i = cur_abs_pg
2231 if next(apparatuses) ~= nil then
2232 reset_bagunits()
2233 end
2234 return "\\booltrue{do@app}"
2193 end 2235 end
2194 return "\\booltrue{do@app}"
2195 end 2236 end
2196end 2237end
2197 2238