summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2013-05-27 01:55:10 +0000
committerNorbert Preining <preining@logic.at>2013-05-27 01:55:10 +0000
commit2ddd33f9dce3a1254f97dc5e560f9576ba63f3ef (patch)
tree16db9c0b6f9d9113fda2edd944a5ec5169bb298f /Master/texmf-dist/tex/luatex
parent0da954038fc199402b8d190a323de81a997709c4 (diff)
luaxml update 5/27
git-svn-id: svn://tug.org/texlive/trunk@30712 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex')
-rw-r--r--Master/texmf-dist/tex/luatex/luaxml/luaxml-mod-handler.lua25
-rw-r--r--Master/texmf-dist/tex/luatex/luaxml/luaxml-mod-xml.lua20
-rw-r--r--Master/texmf-dist/tex/luatex/luaxml/luaxml-selectors.lua62
-rw-r--r--Master/texmf-dist/tex/luatex/luaxml/luaxml-stack.lua10
4 files changed, 84 insertions, 33 deletions
diff --git a/Master/texmf-dist/tex/luatex/luaxml/luaxml-mod-handler.lua b/Master/texmf-dist/tex/luatex/luaxml/luaxml-mod-handler.lua
index bc4d8ea9120..19e4ac11358 100644
--- a/Master/texmf-dist/tex/luatex/luaxml/luaxml-mod-handler.lua
+++ b/Master/texmf-dist/tex/luatex/luaxml/luaxml-mod-handler.lua
@@ -1,4 +1,4 @@
-module(...,package.seeall)
+--..module(...,package.seeall)
--
-- Overview:
-- =========
@@ -111,9 +111,10 @@ module(...,package.seeall)
--@param t Table to be parsed
--@returns Returns a string representation of table
+local M = {}
local stack = require("luaxml-stack")
-function showTable(t)
+local function showTable(t)
local sep = ''
local res = ''
if type(t) ~= 'table' then
@@ -129,9 +130,12 @@ function showTable(t)
res = '{'..res..'}'
return res
end
-
+
+
+M.showTable = showTable
+
---Handler to generate a simple event trace
-printHandler = function()
+local printHandler = function()
local obj = {}
obj.starttag = function(self,t,a,s,e)
io.write("Start : "..t.."\n")
@@ -179,9 +183,9 @@ printHandler = function()
end
return obj
end
-
+M.printHandler = printHandler
---Handler to generate a lua table from a XML content string
-function simpleTreeHandler()
+local function simpleTreeHandler()
local obj = {}
obj.root = {}
@@ -242,10 +246,10 @@ function simpleTreeHandler()
return obj
end
-
+M.simpleTreeHandler = simpleTreeHandler
--- domHandler
-function domHandler()
+local function domHandler()
local obj = {}
obj.options = {commentNode=1,piNode=1,dtdNode=1,declNode=1}
obj.root = { _children = {n=0}, _type = "ROOT" }
@@ -309,9 +313,10 @@ function domHandler()
obj.cdata = obj.text
return obj
end
+M.domHandler = domHandler
--
-simpleTeXhandler=function()
+local simpleTeXhandler=function()
local obj={}
local _stack=stack.Stack:Create()
obj.starttag = function(self,t,a,s,e)
@@ -336,3 +341,5 @@ simpleTeXhandler=function()
end
return obj
end
+M.simpleTeXhandler = simpleTeXhandler
+return M
diff --git a/Master/texmf-dist/tex/luatex/luaxml/luaxml-mod-xml.lua b/Master/texmf-dist/tex/luatex/luaxml/luaxml-mod-xml.lua
index f3ebb0445e8..4da0edc43bb 100644
--- a/Master/texmf-dist/tex/luatex/luaxml/luaxml-mod-xml.lua
+++ b/Master/texmf-dist/tex/luatex/luaxml/luaxml-mod-xml.lua
@@ -1,4 +1,4 @@
-module(...,package.seeall)
+-- module(...,package.seeall)
---
-- Overview:
-- =========
@@ -162,7 +162,8 @@ local format= string.format
---Parses a XML string
--@param handler Handler object to be used to convert the XML string
--to another formats. @see handler.lua
-xmlParser = function(handler)
+local M={}
+local xmlParser = function(handler)
local obj = {}
-- Public attributes
@@ -192,7 +193,7 @@ xmlParser = function(handler)
if not match then
if string.find(str,self._WS,pos) then
-- No more text - check document complete
- if table.getn(self._stack) ~= 0 then
+ if #self._stack ~= 0 then
self:_err(self._errstr.incompleteXmlErr,pos)
else
break
@@ -477,15 +478,17 @@ xmlParser = function(handler)
return obj
end
+M.xmlParser = xmlParser
-function xmlEscape(s)
+local function xmlEscape(s)
local t = {['"']="&quot;",["'"]="&apos;",["&"]="&amp;",["<"]="&lt;",[">"]="&gt;"}
return string.gsub(s,"([\"'<>&])",t)
end
+M.xmlEscape = xmlEscape
-function serialize(tb)
+local function serialize(tb)
local function getAttributes(k,v)
local i = ""
if(type(v["_attr"])=="table") then
@@ -496,8 +499,9 @@ local function getAttributes(k,v)
--table.remove(v,"_attr")
end
return i
-end
- local function printable(tb, level,currTag)
+ end
+
+ local function printable(tb, level,currTag)
local r ={}
local currTag = currTag or ""
level = level or 0
@@ -545,3 +549,5 @@ end
end
return table.concat({'<?xml version="1.0" encoding="UTF-8"?>',printable(tb)},"\n")
end
+M.serialize = serialize
+return M
diff --git a/Master/texmf-dist/tex/luatex/luaxml/luaxml-selectors.lua b/Master/texmf-dist/tex/luatex/luaxml/luaxml-selectors.lua
index 921f971eb2e..1e65d3b8058 100644
--- a/Master/texmf-dist/tex/luatex/luaxml/luaxml-selectors.lua
+++ b/Master/texmf-dist/tex/luatex/luaxml/luaxml-selectors.lua
@@ -1,29 +1,63 @@
-module(...,package.seeall)
+--module(...,package.seeall)
-
-function makeTag(s)
- return "<"..s.."[^>]*>"
+local M = {}
+local inside = 0
+local function makeTag(s)
+ local function makeTag(fuf)
+ return fuf .. "[^>]*"
+ end
+ local print = texio.write_nl
+ if inside > 0 then print ("inside "..inside) else print("outside") end
+ --[[if inside then
+ return s .. "[^>]*"
+ else
+ inside = true--]]
+ inside = inside + 1
+ local f = "<"..s.."[^>]*>"
+ inside = inside - 1
+ return f
+ --end
end
-function matchTag(tg)
+
+M.makeTag = makeTag
+local function matchTag(tg)
return makeTag(tg)
end
-
-function matchDescendand(a,b)
+M.matchTag=matchTag
+local function matchDescendand(a,b)
return makeTag(a)..makeTag(b)
end
+M.matchDescendand = matchDescendand
-function matchChild(a,b)
+local function matchChild(a,b)
return makeTag(a)..".*"..makeTag(b)
end
+M.matchChild = matchChild
+
+local function matchSibling(a,b)
+ return a .. "[^>]*".."@%("..b.."[^>]*%)"
+end
+M.matchSibling = matchSibling
-function matchSibling(a,b)
- return makeTag(a .. "[^>]*".."@%("..b.."[^>]*%)")
+local function matchClass(tg,class)
+ return tg.."[^>]*class=[|]*[^>]*|"..class.."[^>]*|"
end
-function matchClass(tg,class)
- return makeTag(tg.."[^>]*class=[|]*[^>]*|"..class.."[^>]*|")
+M.matchClass = matchClass
+local function matchId(tg,id)
+ return tg.."[^>]*id="..id
end
-matcher = {}
+M.matchId = matchId
+local matcher = {}
+M.matcher= matcher
+local function makeElement(s)
+ local function makeTag(fuf)
+ return fuf .. "[^>]*"
+ end
+ return "<"..s .. "[^>]*>"
+end
+
+M.makeElement = makeElement
function matcher.new()
local self = {}
local selectors={}
@@ -39,4 +73,4 @@ function matcher.new()
end
return self
end
-
+return M
diff --git a/Master/texmf-dist/tex/luatex/luaxml/luaxml-stack.lua b/Master/texmf-dist/tex/luatex/luaxml/luaxml-stack.lua
index 54386ff84d3..6c2d83610fd 100644
--- a/Master/texmf-dist/tex/luatex/luaxml/luaxml-stack.lua
+++ b/Master/texmf-dist/tex/luatex/luaxml/luaxml-stack.lua
@@ -1,7 +1,9 @@
-- Code from http://lua-users.org/wiki/SimpleStack
-module(...,package.seeall)
-Stack = {}
-
+--module(...,package.seeall)
+local M={}
+local Stack = {}
+M.Stack = Stack
+local unpack = table.unpack
-- Create a Table with stack functions
function Stack:Create()
@@ -61,3 +63,5 @@ function Stack:Create()
end
return t
end
+
+return M