diff options
author | Hans Hagen <pragma@wxs.nl> | 2020-06-19 12:25:31 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2020-06-19 12:25:31 +0200 |
commit | 63bb70d210dc6e8a17959c4e056fe41da3f1c398 (patch) | |
tree | eec8ab8eea553b8c5beea443624d725bb8d4f07e /tex/context/base/mkiv/lxml-tex.lua | |
parent | f46fe99c7c361a66c68987b22d235fe9f793fad6 (diff) | |
download | context-63bb70d210dc6e8a17959c4e056fe41da3f1c398.tar.gz |
2020-06-19 11:07:00
Diffstat (limited to 'tex/context/base/mkiv/lxml-tex.lua')
-rw-r--r-- | tex/context/base/mkiv/lxml-tex.lua | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tex/context/base/mkiv/lxml-tex.lua b/tex/context/base/mkiv/lxml-tex.lua index 079ab29da..00bff7873 100644 --- a/tex/context/base/mkiv/lxml-tex.lua +++ b/tex/context/base/mkiv/lxml-tex.lua @@ -14,7 +14,7 @@ local concat, insert, remove, sortedkeys, reversed = table.concat, table.insert, local format, sub, gsub, find, gmatch, match = string.format, string.sub, string.gsub, string.find, string.gmatch, string.match local type, next, tonumber, tostring, select = type, next, tonumber, tostring, select local lpegmatch = lpeg.match -local P, S, C, Cc, Cs = lpeg.P, lpeg.S, lpeg.C, lpeg.Cc, lpeg.Cs +local P, S, C = lpeg.P, lpeg.S, lpeg.C local patterns = lpeg.patterns local setmetatableindex = table.setmetatableindex local formatters, strip = string.formatters, string.strip @@ -1755,6 +1755,23 @@ local function concatlist(collected,separator,lastseparator,textonly) -- test th concatrange(collected,false,false,separator,lastseparator,textonly) end +local function depth(collected) + local d = 0 + if collected then + local c = collected and collected[1] + if c.tg then + while c do + d = d + 1 + c = c.__p__ + if not c then + break + end + end + end + end + contextsprint(ctxcatcodes,d) +end + texfinalizers.first = first texfinalizers.last = last texfinalizers.all = all @@ -1778,6 +1795,7 @@ texfinalizers.concatrange = concatrange texfinalizers.chainattribute = chainattribute texfinalizers.chainpath = chainpath texfinalizers.default = all -- !! +texfinalizers.depth = depth function texfinalizers.tag(collected,n) if collected then @@ -1863,6 +1881,10 @@ lxml.verbatim = verbatim -- helpers +function lxml.depth(id) + depth { getid(id) } +end + function lxml.first(id,pattern) local collected = xmlapplylpath(getid(id),pattern) if collected then |