aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2016-08-26 21:02:40 +0200
committerRobert Alessi <alessi@robertalessi.net>2016-08-26 21:02:40 +0200
commit55a7be70c3bb459c3efb9e2cbace117b9b1bb482 (patch)
tree26645a70e864e044e68a279f741134d081f55f3f
parent603a4562819fca15dd66831a10b1fd7344d2cd83 (diff)
downloadekdosis-55a7be70c3bb459c3efb9e2cbace117b9b1bb482.tar.gz
tidy up a bit the code
-rw-r--r--ekdosis.dtx64
1 files changed, 33 insertions, 31 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 5248f96..2a9a864 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -47,6 +47,10 @@ function closestream()
47 return true 47 return true
48end 48end
49 49
50function remove()
51 os.remove(tex.jobname..".ekd")
52end
53
50function appin(str, nl) 54function appin(str, nl)
51 local f = io.open(tex.jobname.."_tmp.ekd", "a+") 55 local f = io.open(tex.jobname.."_tmp.ekd", "a+")
52 if nl == "yes" then 56 if nl == "yes" then
@@ -66,7 +70,7 @@ function appout()
66 local output = {} 70 local output = {}
67 for i in string.gmatch(t, "<"..tex.count[0]..">.-</"..tex.count[0]..">") 71 for i in string.gmatch(t, "<"..tex.count[0]..">.-</"..tex.count[0]..">")
68 do 72 do
69 table.insert(output, i) 73 table.insert(output, i)
70 end 74 end
71 f:close() 75 f:close()
72 str = table.concat(output, "\n") 76 str = table.concat(output, "\n")
@@ -76,10 +80,6 @@ function appout()
76 else end 80 else end
77end 81end
78 82
79function remove()
80 os.remove(tex.jobname..".ekd")
81end
82
83function testapparatus() 83function testapparatus()
84 local file = io.open(tex.jobname..".ekd", "r") 84 local file = io.open(tex.jobname..".ekd", "r")
85 if file ~= nil then 85 if file ~= nil then
@@ -88,36 +88,38 @@ function testapparatus()
88 return "\\booltrue{isapp}" else return "\\boolfalse{isapp}" end 88 return "\\booltrue{isapp}" else return "\\boolfalse{isapp}" end
89 else return "\\boolfalse{isapp}" end 89 else return "\\boolfalse{isapp}" end
90 file:close() 90 file:close()
91end 91end
92
93function getlab()
94 return "\\getrefnumber{ekdl:\\theedk@lab}"
95end
96 92
97--[[ 93md5items = {}
98local linecount = 0 94local salt = 0
99 95
100count_lines = function(head) 96function isintable(table, value)
101 while head do 97 for _, v in pairs(table) do
102 if head.id == 0 then 98 if v == value then return true end
103 linecount = linecount + 1
104 end
105 head = head.next
106 end 99 end
107 return true 100 return false
108end 101end
109 102
110count_lines = function(head) 103function mdv(str)
111 for line in node.traverse_id(0, head) do 104 i = md5.sumhexa(str)
112 linecount = linecount + 1 105 if not isintable(md5items, i) then
106 table.insert(md5items, i)
107 else
108 i = i..salt
109 table.insert(md5items, i)
110 salt = salt +1
113 end 111 end
114 return head 112 return "\\linelabel{"..i.."}\\append{\\getrefnumber{"..i.."} "..str.."}"
115end 113end
116 114
117function getline() 115-- of no use
118 return linecount 116function writemdv(str)
117 str = md5.sumhexa(str)
118 local f = io.open(tex.jobname.."_tmp.ekd", "a+")
119 f:write("<md5>", str, "</md5>", "\n")
120 f:close()
121 return true
119end 122end
120--]]
121 123
122%</lua> 124%</lua>
123%<*internal> 125%<*internal>
@@ -306,7 +308,9 @@ Running "make install" installs the files in the local TeX tree.
306\RequirePackage{luacode} 308\RequirePackage{luacode}
307\RequirePackage{xparse} 309\RequirePackage{xparse}
308\RequirePackage{etoolbox} 310\RequirePackage{etoolbox}
309\RequirePackage[addpageno]{lineno} 311\RequirePackage{lineno}
312\PassOptionsToPackage{addpageno}{lineno}
313\RequirePackage{vplref}
310\RequirePackage{float} 314\RequirePackage{float}
311\newfloat{apparat}{b}{lap} 315\newfloat{apparat}{b}{lap}
312\RequirePackage{afterpage} 316\RequirePackage{afterpage}
@@ -329,10 +333,8 @@ Running "make install" installs the files in the local TeX tree.
329 \luadirect{appin(\luastringN{#1}, "no")}% 333 \luadirect{appin(\luastringN{#1}, "no")}%
330 \luadirect{appin(\luastring{</\getpagerefnumber{ekd:\theekd@lab}>}, "yes")}% 334 \luadirect{appin(\luastring{</\getpagerefnumber{ekd:\theekd@lab}>}, "yes")}%
331 \stepcounter{ekd@lab}}{}} 335 \stepcounter{ekd@lab}}{}}
332\NewDocumentCommand{\mdv}{m}{% 336\NewDocumentCommand{\obappend}{+m}%
333 \luadirect{tex.sprint(md5.sumhexa(\luastringN{#1}))}} 337 {\luadirect{tex.sprint(mdv(\luastringN{#1}))}}
334\NewDocumentCommand{\obappend}{+m}{%
335 \linelabel{\mdv{#1}}\append{\getrefnumber{\mdv{#1}}~#1}}
336\NewDocumentCommand{\myappend}{+m}{% 338\NewDocumentCommand{\myappend}{+m}{%
337 \ifbool{ekdstate}{% 339 \ifbool{ekdstate}{%
338 \label{\getlab}% 340 \label{\getlab}%