summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/bibl-bib.lua
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-04-08 00:43:40 +0000
committerKarl Berry <karl@freefriends.org>2013-04-08 00:43:40 +0000
commit824f7b0903de8ad7f6ee3d7656005e4c59155e06 (patch)
treeabfc8673ef9916f3ab7074e811207384c301492b /Master/texmf-dist/tex/context/base/bibl-bib.lua
parent689aefb0727676ed3cddf331337b4be226495e72 (diff)
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
Diffstat (limited to 'Master/texmf-dist/tex/context/base/bibl-bib.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/bibl-bib.lua25
1 files changed, 12 insertions, 13 deletions
diff --git a/Master/texmf-dist/tex/context/base/bibl-bib.lua b/Master/texmf-dist/tex/context/base/bibl-bib.lua
index 444f7e9bcc4..c86a0c0c263 100644
--- a/Master/texmf-dist/tex/context/base/bibl-bib.lua
+++ b/Master/texmf-dist/tex/context/base/bibl-bib.lua
@@ -12,7 +12,6 @@ bibtex files and converts them to xml so that the we access the content
in a convenient way. Actually handling the data takes place elsewhere.</p>
--ldx]]--
-local utf = unicode.utf8
local lower, format, gsub, concat = string.lower, string.format, string.gsub, table.concat
local next = next
local utfchar = utf.char
@@ -22,6 +21,7 @@ local variables = interfaces and interfaces.variables
local settings_to_hash = utilities.parsers.settings_to_hash
local finalizers = xml.finalizers.tex
local xmlfilter, xmltext, getid = xml.filter, xml.text, lxml.getid
+local formatters = string.formatters
local P, R, S, C, Cc, Cs, Ct = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.Ct
@@ -144,9 +144,9 @@ function bibtex.load(session,filename)
if filename ~= "" then
local data = io.loaddata(filename) or ""
if data == "" then
- report_xml("empty file '%s', no conversion to xml",filename)
+ report_xml("empty file %a, no conversion to xml",filename)
elseif trace_bibxml then
- report_xml("converting file '%s' to xml",filename)
+ report_xml("converting file %a to xml",filename)
end
bibtex.convert(session,data)
end
@@ -163,7 +163,7 @@ function bibtex.new()
}
end
-local escaped_pattern = lpegpatterns.xml.escaped
+local p_escaped = lpegpatterns.xml.escaped
local ihatethis = {
f = "\\f",
@@ -203,17 +203,16 @@ function bibtex.toxml(session,options)
local convert = options.convert -- todo: interface
local strip = options.strip -- todo: interface
local entries = session.entries
- r = r + 1 ; result[r] = format("<?xml version='1.0' standalone='yes'?>")
- r = r + 1 ; result[r] = format("<bibtex>")
+ r = r + 1 ; result[r] = "<?xml version='1.0' standalone='yes'?>"
+ r = r + 1 ; result[r] = "<bibtex>"
for id, categories in next, session.data do
id = lower(gsub(id,"^@",""))
for name, entry in next, categories do
if not entries or entries[name] then
- r = r + 1 ; result[r] = format("<entry tag='%s' category='%s'>",lower(name),id)
+ r = r + 1 ; result[r] = formatters["<entry tag='%s' category='%s'>"](lower(name),id)
for key, value in next, entry do
- value = gsub(value,"\\(.)",ihatethis)
- value = lpegmatch(escaped_pattern,value)
-
+ value = gsub(value,"\\(.)",ihatethis) -- this really needs checking
+ value = lpegmatch(p_escaped,value)
if value ~= "" then
if convert then
value = textoutf(value,true)
@@ -223,14 +222,14 @@ function bibtex.toxml(session,options)
-- kind of hackery ... bibtex databases are quite unportable
value = lpegmatch(filter,value) or value
end
- r = r + 1 ; result[r] = format(" <field name='%s'>%s</field>",key,value)
+ r = r + 1 ; result[r] = formatters[" <field name='%s'>%s</field>"](key,value)
end
end
- r = r + 1 ; result[r] = format("</entry>")
+ r = r + 1 ; result[r] = "</entry>"
end
end
end
- r = r + 1 ; result[r] = format("</bibtex>")
+ r = r + 1 ; result[r] = "</bibtex>"
result = concat(result,"\n")
-- alternatively we could use lxml.convert
session.xml = xml.convert(result, {