From 824f7b0903de8ad7f6ee3d7656005e4c59155e06 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 8 Apr 2013 00:43:40 +0000 Subject: context import for TL13, from www.pragma-ade.com/context/beta/cont-tmf.zip git-svn-id: svn://tug.org/texlive/trunk@29731 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/context/base/lxml-aux.lua | 45 ++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'Master/texmf-dist/tex/context/base/lxml-aux.lua') diff --git a/Master/texmf-dist/tex/context/base/lxml-aux.lua b/Master/texmf-dist/tex/context/base/lxml-aux.lua index be12659ba10..0fffe261a00 100644 --- a/Master/texmf-dist/tex/context/base/lxml-aux.lua +++ b/Master/texmf-dist/tex/context/base/lxml-aux.lua @@ -26,7 +26,7 @@ local gmatch, gsub, format, find, strip = string.gmatch, string.gsub, string.for local utfbyte = utf.byte local function report(what,pattern,c,e) - report_xml("%s element '%s' (root: '%s', position: %s, index: %s, pattern: %s)",what,xmlname(e),xmlname(e.__p__),c,e.ni,pattern) + report_xml("%s element %a, root %a, position %a, index %a, pattern %a",what,xmlname(e),xmlname(e.__p__),c,e.ni,pattern) end local function withelements(e,handle,depth) @@ -766,3 +766,46 @@ function xml.separate(x,pattern) end return x end + +-- + +local helpers = xml.helpers or { } +xml.helpers = helpers + +local function normal(e,action) + local edt = e.dt + if edt then + for i=1,#edt do + local str = edt[i] + if type(str) == "string" and str ~= "" then + edt[i] = action(str) + end + end + end +end + +local function recurse(e,action) + local edt = e.dt + if edt then + for i=1,#edt do + local str = edt[i] + if type(str) ~= "string" then + recurse(str,action,recursive) + elseif str ~= "" then + edt[i] = action(str) + end + end + end +end + +function helpers.recursetext(collected,action,recursive) + if recursive then + for i=1,#collected do + recurse(collected[i],action) + end + else + for i=1,#collected do + normal(collected[i],action) + end + end +end -- cgit v1.2.3