From 55a7be70c3bb459c3efb9e2cbace117b9b1bb482 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Fri, 26 Aug 2016 21:02:40 +0200 Subject: tidy up a bit the code --- ekdosis.dtx | 64 +++++++++++++++++++++++++++++++------------------------------ 1 file 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() return true end +function remove() + os.remove(tex.jobname..".ekd") +end + function appin(str, nl) local f = io.open(tex.jobname.."_tmp.ekd", "a+") if nl == "yes" then @@ -66,7 +70,7 @@ function appout() local output = {} for i in string.gmatch(t, "<"..tex.count[0]..">.-") do - table.insert(output, i) + table.insert(output, i) end f:close() str = table.concat(output, "\n") @@ -76,10 +80,6 @@ function appout() 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 @@ -88,36 +88,38 @@ function testapparatus() return "\\booltrue{isapp}" else return "\\boolfalse{isapp}" end else return "\\boolfalse{isapp}" end file:close() -end - -function getlab() - return "\\getrefnumber{ekdl:\\theedk@lab}" -end +end ---[[ -local linecount = 0 +md5items = {} +local salt = 0 -count_lines = function(head) - while head do - if head.id == 0 then - linecount = linecount + 1 - end - head = head.next +function isintable(table, value) + for _, v in pairs(table) do + if v == value then return true end end - return true + return false end -count_lines = function(head) - for line in node.traverse_id(0, head) do - linecount = linecount + 1 +function mdv(str) + i = md5.sumhexa(str) + if not isintable(md5items, i) then + table.insert(md5items, i) + else + i = i..salt + table.insert(md5items, i) + salt = salt +1 end - return head + return "\\linelabel{"..i.."}\\append{\\getrefnumber{"..i.."} "..str.."}" end -function getline() - return linecount +-- of no use +function writemdv(str) + str = md5.sumhexa(str) + local f = io.open(tex.jobname.."_tmp.ekd", "a+") + f:write("", str, "", "\n") + f:close() + return true end ---]] % %<*internal> @@ -306,7 +308,9 @@ Running "make install" installs the files in the local TeX tree. \RequirePackage{luacode} \RequirePackage{xparse} \RequirePackage{etoolbox} -\RequirePackage[addpageno]{lineno} +\RequirePackage{lineno} +\PassOptionsToPackage{addpageno}{lineno} +\RequirePackage{vplref} \RequirePackage{float} \newfloat{apparat}{b}{lap} \RequirePackage{afterpage} @@ -329,10 +333,8 @@ Running "make install" installs the files in the local TeX tree. \luadirect{appin(\luastringN{#1}, "no")}% \luadirect{appin(\luastring{}, "yes")}% \stepcounter{ekd@lab}}{}} -\NewDocumentCommand{\mdv}{m}{% - \luadirect{tex.sprint(md5.sumhexa(\luastringN{#1}))}} -\NewDocumentCommand{\obappend}{+m}{% - \linelabel{\mdv{#1}}\append{\getrefnumber{\mdv{#1}}~#1}} +\NewDocumentCommand{\obappend}{+m}% + {\luadirect{tex.sprint(mdv(\luastringN{#1}))}} \NewDocumentCommand{\myappend}{+m}{% \ifbool{ekdstate}{% \label{\getlab}% -- cgit v1.2.3