summaryrefslogtreecommitdiff
path: root/tex/context/base/back-exp.lua
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2012-10-19 01:20:13 +0300
committerMarius <mariausol@gmail.com>2012-10-19 01:20:13 +0300
commit69d2352af4b60929b37fc49f3bdb263977016244 (patch)
treedb5eb11398e345dfa23b4c4500fb93575d2afb7c /tex/context/base/back-exp.lua
parentc18f7cbe51449a611ea1819fedd9a4ff18529b7d (diff)
downloadcontext-69d2352af4b60929b37fc49f3bdb263977016244.tar.gz
stable 2012.05.30 11:26
Diffstat (limited to 'tex/context/base/back-exp.lua')
-rw-r--r--tex/context/base/back-exp.lua24
1 files changed, 6 insertions, 18 deletions
diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua
index 46ce4f96c..3ce40a6c5 100644
--- a/tex/context/base/back-exp.lua
+++ b/tex/context/base/back-exp.lua
@@ -20,9 +20,8 @@ if not modules then modules = { } end modules ['back-exp'] = {
local next, type = next, type
local format, match, concat, rep, sub, gsub, gmatch, find = string.format, string.match, table.concat, string.rep, string.sub, string.gsub, string.gmatch, string.find
-local validstring = string.valid
local lpegmatch = lpeg.match
-local utfchar, utfbyte = utf.char, utf.byte
+local utfchar, utfbyte, utfsub, utfgsub = utf.char, utf.byte, utf.sub, utf.gsub
local insert, remove = table.insert, table.remove
local topoints = number.topoints
local utfvalues = string.utfvalues
@@ -155,8 +154,6 @@ local somespace = { [0x20] = true, [" "] = true } -- for testing
local entities = { ["&"] = "&amp;", [">"] = "&gt;", ["<"] = "&lt;" }
local attribentities = { ["&"] = "&amp;", [">"] = "&gt;", ["<"] = "&lt;", ['"'] = "quot;" }
-local entityremapper = utf.remapper(entities)
-
local alignmapping = {
flushright = "right",
middle = "center",
@@ -303,7 +300,7 @@ local usedstyles = { }
local documenttemplate = [[
document {
- font-size : %s !important ;
+ font-size : %s !important ;
max-width : %s !important ;
text-align : %s !important ;
hyphens : %s !important ;
@@ -385,7 +382,7 @@ local function allusedimages(xmlfile)
for element, details in sortedhash(usedimages) do
for detail, data in sortedhash(details) do
local name = data.name
- if file.suffix(name) == "pdf" then
+ if file.extname(name) == "pdf" then
-- temp hack .. we will have a remapper
name = file.replacesuffix(name,"svg")
end
@@ -400,7 +397,7 @@ local function uniqueusedimages()
for element, details in next, usedimages do
for detail, data in next, details do
local name = data.name
- if file.suffix(name) == "pdf" then
+ if file.extname(name) == "pdf" then
unique[file.replacesuffix(name,"svg")] = name
else
unique[name] = name
@@ -1354,7 +1351,7 @@ local function begintag(result,element,nature,depth,di,skip)
end
result[#result+1] = format("%s<metadata>\n",spaces[depth])
for k, v in table.sortedpairs(metadata) do
- v = entityremapper(v)
+ v = utfgsub(v,".",entities)
result[#result+1] = format("%s<metavariable name=%q>%s</metavariable>\n",spaces[depth+1],k,v)
end
result[#result+1] = format("%s</metadata>\n",spaces[depth])
@@ -1412,7 +1409,7 @@ local function flushtree(result,data,nature,depth)
-- whatever
elseif di.content then
-- already has breaks
- local content = entityremapper(di.content)
+ local content = utfgsub(di.content,".",entities)
if i == nofdata and sub(content,-1) == "\n" then -- move check
-- can be an end of line in par but can also be the last line
if trace_spacing then
@@ -2365,21 +2362,12 @@ local function stopexport(v)
report_export("saving xhtml variant in '%s",xhtmlfile)
local xmltree = cleanxhtmltree(xml.convert(results))
xml.save(xmltree,xhtmlfile)
- -- looking at identity is somewhat redundant as we also inherit from interaction
- -- at the tex end
- local identity = interactions.general.getidentity()
local specification = {
name = file.removesuffix(v),
identifier = os.uuid(),
images = uniqueusedimages(),
root = xhtmlfile,
files = files,
- language = languagenames[tex.count.mainlanguagenumber],
- title = validstring(finetuning.title) or validstring(identity.title),
- subtitle = validstring(finetuning.subtitle) or validstring(identity.subtitle),
- author = validstring(finetuning.author) or validstring(identity.author),
- firstpage = validstring(finetuning.firstpage),
- lastpage = validstring(finetuning.lastpage),
}
report_export("saving specification in '%s' (mtxrun --script epub --make %s)",specificationfilename,specificationfilename)
io.savedata(specificationfilename,table.serialize(specification,true))