summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkiv/s-xml-analyzers.lua
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-04-25 14:10:48 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-04-25 14:10:48 +0200
commit4668b7323a6bc1b01e72418fb646b697d68bbcb7 (patch)
tree926785b550bed158e0489d209edbab366c6997c2 /tex/context/modules/mkiv/s-xml-analyzers.lua
parent55666205c2c1a7287105e23f58e2047c1e0dbc5a (diff)
downloadcontext-4668b7323a6bc1b01e72418fb646b697d68bbcb7.tar.gz
2016-04-25 13:34:00
Diffstat (limited to 'tex/context/modules/mkiv/s-xml-analyzers.lua')
-rw-r--r--tex/context/modules/mkiv/s-xml-analyzers.lua28
1 files changed, 27 insertions, 1 deletions
diff --git a/tex/context/modules/mkiv/s-xml-analyzers.lua b/tex/context/modules/mkiv/s-xml-analyzers.lua
index 9de6471d1..c356d4c37 100644
--- a/tex/context/modules/mkiv/s-xml-analyzers.lua
+++ b/tex/context/modules/mkiv/s-xml-analyzers.lua
@@ -20,6 +20,7 @@ local chardata = characters.data
local tags = { }
local char = { }
local attr = { }
+local ents = { }
local name = nil
local function analyze(filename)
@@ -40,6 +41,7 @@ local function analyze(filename)
tags = { }
char = { }
attr = { }
+ ents = { }
table.setmetatableindex(tags,function(t,k)
local v = {
@@ -62,6 +64,11 @@ local function analyze(filename)
return 0
end)
+ table.setmetatableindex(ents,function(t,k)
+ t[k] = 0
+ return 0
+ end)
+
local function collect(e,parent)
local dt = e.dt
if e.special then
@@ -112,12 +119,19 @@ local function analyze(filename)
end
for i=1,#filename do
- collect(xml.load(filename[i]))
+ local root = xml.load(filename[i])
+ collect(root)
+ --
+ local names = root.statistics.entities.names
+ for n in next, names do
+ ents[n] = ents[n] + 1
+ end
end
table.setmetatableindex(tags,nil)
table.setmetatableindex(char,nil)
table.setmetatableindex(attr,nil)
+ table.setmetatableindex(ents,nil)
end
@@ -170,3 +184,15 @@ function moduledata.xml.analyzers.characters(filename)
context.stoptabulate()
end
+function moduledata.xml.analyzers.entities(filename)
+ analyze(filename)
+ context.starttabulate { "|l|r|" }
+ for e, n in table.sortedhash(ents) do
+ NC() context(e)
+ NC() context(n)
+ NC() NR()
+ end
+ context.stoptabulate()
+end
+
+