diff options
author | Robert Alessi <alessi@robertalessi.net> | 2016-08-26 21:02:40 +0200 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2016-08-26 21:02:40 +0200 |
commit | 55a7be70c3bb459c3efb9e2cbace117b9b1bb482 (patch) | |
tree | 26645a70e864e044e68a279f741134d081f55f3f | |
parent | 603a4562819fca15dd66831a10b1fd7344d2cd83 (diff) | |
download | ekdosis-55a7be70c3bb459c3efb9e2cbace117b9b1bb482.tar.gz |
tidy up a bit the code
-rw-r--r-- | ekdosis.dtx | 64 |
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 |
48 | end | 48 | end |
49 | 49 | ||
50 | function remove() | ||
51 | os.remove(tex.jobname..".ekd") | ||
52 | end | ||
53 | |||
50 | function appin(str, nl) | 54 | function 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 |
77 | end | 81 | end |
78 | 82 | ||
79 | function remove() | ||
80 | os.remove(tex.jobname..".ekd") | ||
81 | end | ||
82 | |||
83 | function testapparatus() | 83 | function 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() |
91 | end | 91 | end |
92 | |||
93 | function getlab() | ||
94 | return "\\getrefnumber{ekdl:\\theedk@lab}" | ||
95 | end | ||
96 | 92 | ||
97 | --[[ | 93 | md5items = {} |
98 | local linecount = 0 | 94 | local salt = 0 |
99 | 95 | ||
100 | count_lines = function(head) | 96 | function 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 |
108 | end | 101 | end |
109 | 102 | ||
110 | count_lines = function(head) | 103 | function 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.."}" |
115 | end | 113 | end |
116 | 114 | ||
117 | function getline() | 115 | -- of no use |
118 | return linecount | 116 | function 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 | ||
119 | end | 122 | end |
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}% |