summaryrefslogtreecommitdiff
path: root/tex/context/base
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2013-03-21 13:42:00 +0100
committerHans Hagen <pragma@wxs.nl>2013-03-21 13:42:00 +0100
commitc971a249f8c3c8c394dc1f173bae8fc14a81b700 (patch)
tree40f6a647f35fd19236104be12df17af4f8884db9 /tex/context/base
parenta927ed4f7c8cd8d4ef67877ed7a47744347a1ea2 (diff)
downloadcontext-c971a249f8c3c8c394dc1f173bae8fc14a81b700.tar.gz
beta 2013.03.21 13:42
Diffstat (limited to 'tex/context/base')
-rw-r--r--tex/context/base/cont-new.mkii2
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-base.lmx73
-rw-r--r--tex/context/base/context-version.pdfbin4134 -> 4137 bytes
-rw-r--r--tex/context/base/context-version.pngbin40182 -> 40520 bytes
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/luat-run.lua5
-rw-r--r--tex/context/base/status-files.pdfbin24788 -> 24796 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin211561 -> 211440 bytes
-rw-r--r--tex/context/base/trac-exp.lua138
-rw-r--r--tex/context/base/trac-lmx.lua19
-rw-r--r--tex/context/base/trac-log.lua5
-rw-r--r--tex/context/base/trac-tim.lua2
-rw-r--r--tex/context/base/trac-xml.lua37
15 files changed, 182 insertions, 105 deletions
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index 4fceea3cb..2a48ec5db 100644
--- a/tex/context/base/cont-new.mkii
+++ b/tex/context/base/cont-new.mkii
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2013.03.20 10:34}
+\newcontextversion{2013.03.21 13:42}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index 43c591c41..30ea51f5d 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2013.03.20 10:34}
+\newcontextversion{2013.03.21 13:42}
%D This file is loaded at runtime, thereby providing an excellent place for
%D hacks, patches, extensions and new features.
diff --git a/tex/context/base/context-base.lmx b/tex/context/base/context-base.lmx
index 2b093c3e1..482d43e88 100644
--- a/tex/context/base/context-base.lmx
+++ b/tex/context/base/context-base.lmx
@@ -2,6 +2,8 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!-- compare with lmx framework variant -->
+
<!--
filename : context-base.xml
comment : companion to mtx-server-ctx-startup.tex
@@ -12,74 +14,75 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
- <title><?lua pv('title') ?></title>
+ <title><?lua inject(variables.title) ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <?lua if (v('refreshtime') and (tonumber(v('refreshtime')) or 0) > 0) and v('refreshurl') then ?>
- <meta http-equiv='refresh' content="<?lua pv('refreshtime') ?>; <?lua pv('refreshurl') ?>"/>
+ <?lua if variables.refreshtime and (tonumber(variables.refreshtime) or 0) > 0 and variables.refreshurl then ?>
+ <meta http-equiv='refresh' content="<?lua inject(variables.refreshtime) ?>; <?lua inject(variables.refreshurl) ?>"/>
<?lua end ?>
<style type="text/css">
- <?lmx-include context.css ?>
- <?lua if v('cssdata') then ?>
-<?lua pv('cssdata') ?>
- <?lua end ?> </style>
- <?lua if v('styles') then for k, v in ipairs(v('styles')) do ?>
- <link rel="StyleSheet" href="<?lua p(v) ?>" type="text/css" />
+ <?lmx-include context.css strip ?>
+ </style>
+ <style type="text/css">
+ <?lua inject(variables.cssdata) ?>
+ </style>
+ <?lua if variables.styles then for k, v in ipairs(variables.styles) do ?>
+ <link rel="StyleSheet" href="<?lua inject(v) ?>" type="text/css" />
<?lua end end ?>
</head>
- <?lua if (v('refreshtime') and (tonumber(v('refreshtime')) or 0) > 0) and v('refreshurl') then ?>
+ <?lua if variables.refreshtime and (tonumber(variables.refreshtime) or 0) > 0 and variables.refreshurl then ?>
<!--[if IE]>
<script type="text/javascript">
- setTimeout("document.location='<?lua pv('refreshurl') ?>'", 1000*<?lua pv('refreshtime') ?>);
+ setTimeout("document.location='<?lua inject(variables.refreshurl) ?>'", 1000*<?lua inject(variables.refreshtime) ?>);
</script>
<![endif]-->
<?lua end ?>
- <?lua if v('action') then ?>
- <form action="<?lua pv(action) ?>" enctype="multi-part/form-data" method="post">
+ <?lua if variables.action then ?>
+ <form action="<?lua inject(variables.action) ?>" enctype="multi-part/form-data" method="post">
<?lua end ?>
<body>
- <div id="top">
+ <div id="top"><?lua if variables.title then ?>
<div id="top-one">
- <div id="top-two">
- <?lua pv('title') ?>
- </div>
+ <div id="top-two"><?lua
+ inject(variables.title)
+ ?> </div>
</div>
- </div>
- <div id="bottom">
+ <?lua end ?></div>
+ <div id="bottom"><?lua if variables.bottomtext then ?>
<div id="bottom-one">
- <div id="bottom-two">
- <?lua pv('bottomtext') ?>
- </div>
+ <div id="bottom-two"><?lua
+ inject(variables.bottomtext)
+ ?></div>
</div>
- </div>
- <div id="left">
+ <?lua end ?></div>
+ <div id="left"><?lua if variables.lefttext then ?>
<div id="left-one">
- <div id="left-two">
- <?lua pv('lefttext') ?>
- </div>
+ <div id="left-two"><?lua
+ inject(variables.lefttext)
+ ?></div>
</div>
- </div>
- <div id="right">
+ <?lua end ?></div>
+ <div id="right"><?lua if variables.righttext then ?>
<div id="right-safari">
<div id="right-one">
<div id="right-two">
<div id="right-three">
<div id="right-four">
- <div id="right-five">
- <?lua pv('righttext') ?>
- </div>
+ <div id="right-five"><?lua
+ inject(variables.righttext)
+ ?></div>
</div>
</div>
</div>
</div>
</div>
- </div>
+ <?lua end ?></div>
<div id="main">
<div id='main-settings'>
- <?lua pv('maintext') ?>
+ <?lua inject(variables.maintext) ?>
</div>
</div>
</body>
- <?lua if v('action') then ?>
+ <?lua if variables.action then ?>
</form>
<?lua end ?>
</html>
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index 45ca003ab..398afdd50 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png
index 71514b2c2..804c18555 100644
--- a/tex/context/base/context-version.png
+++ b/tex/context/base/context-version.png
Binary files differ
diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii
index 5158dbd76..7da4eb13e 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2013.03.20 10:34}
+\edef\contextversion{2013.03.21 13:42}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index a2f2280fa..33b230506 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -25,7 +25,7 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2013.03.20 10:34}
+\edef\contextversion{2013.03.21 13:42}
%D For those who want to use this:
diff --git a/tex/context/base/luat-run.lua b/tex/context/base/luat-run.lua
index 34d45d096..eaede1030 100644
--- a/tex/context/base/luat-run.lua
+++ b/tex/context/base/luat-run.lua
@@ -139,8 +139,9 @@ directives.register("system.synctex", function(v)
else
report_system("synctex functionality is disabled!")
end
+ synctex = tonumber(synctex) or (toboolean(synctex,true) and 1) or (synctex == "zipped" and 1) or (synctex == "unzipped" and -1) or false
-- currently this is bugged:
- tex.synctex = synctex and 1 or 0
+ tex.synctex = synctex
-- so for the moment we need:
context.normalsynctex()
if synctex then
@@ -151,7 +152,7 @@ directives.register("system.synctex", function(v)
end)
statistics.register("synctex tracing",function()
- if synctex or tex.synctex > 0 then
+ if synctex or tex.synctex ~= 0 then
return "synctex has been enabled (extra log file generated)"
end
end)
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index d1d5c4328..adb9c707d 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index b97167234..b82cb9420 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/trac-exp.lua b/tex/context/base/trac-exp.lua
index d1ce3c458..cd30500a2 100644
--- a/tex/context/base/trac-exp.lua
+++ b/tex/context/base/trac-exp.lua
@@ -35,9 +35,9 @@ local function categorytitle(category)
return xmltext(xmlfirst(category,"/title")) or ""
end
-local exporters = { }
+local exporters = logs.exporters
-exporters.man = function(specification,...)
+function exporters.man(specification,...)
local root = xml.convert(specification.helpinfo or "")
if not root then
return
@@ -54,9 +54,23 @@ exporters.man = function(specification,...)
--
local result = { }
--
- result[#result+1] = formatters['.TH %s\n.SH "NAME"\n%s.SH "SYNOPSIS"\n\\fB%s\\fP [ \\fIOPTIONS\\fP ... ]\n.SH "DESCRIPTION"\n%s\n'](
- banner,name,name,detail
- )
+ -- .TH "context" "1" "some date" "version" "ConTeXt" -- we use a fake date as I don't want to polute the git repos
+ --
+ local runner = string.match(name,"^mtx%-(.*)")
+ if runner then
+ runner = formatters["mtxrun --script %s"](runner)
+ else
+ runner = name
+ end
+ --
+ result[#result+1] = formatters[ [[.TH "%s" "1" "%s" "version %s" "%s" ]] ](name,os.date("01-01-%Y"),version,detail)
+ result[#result+1] = formatters[ [[.SH "NAME" %s]] ] ()
+ result[#result+1] = ".PP"
+ result[#result+1] = formatters[ [[.SH "SYNOPSIS" ]] ](name)
+ result[#result+1] = ".PP"
+ result[#result+1] = formatters[ [[.SH \fB%s\fP [ \fIOPTIONS\fP ... ] [ \fIFILENAMES\fP ] ]] ](runner)
+ result[#result+1] = formatters[ [[.SH "DESCRIPTION"\n%s\n ]] ](detail)
+ --
for category in xmlcollected(root,"/application/flags/category") do
if nofcategories > 1 then
result[#result+1] = formatters['.SH "OPTIONS: %s"'](string.upper(category.at.name or "all"))
@@ -89,7 +103,7 @@ local craptemplate = [[
</verbose>
]]
-exporters.xml = function(specification,...)
+function exporters.xml(specification,...)
local helpinfo = specification.helpinfo
if type(helpinfo) == "string" then
if string.find(helpinfo,"^<%?xml") then
@@ -103,54 +117,80 @@ exporters.xml = function(specification,...)
return formatters[craptemplate](specification.banner or "?",helpinfo)
end
+-- the following template is optimized a bit for space
+
+-- local bodytemplate = [[
+-- <h1>Command line options</h1>
+-- <table>
+-- <tr>
+-- <th style="width: 10em">flag</th>
+-- <th style="width: 8em">value</th>
+-- <th>description</th>
+-- </tr>
+-- <?lua
+-- for category in xml.collected(variables.root,"/application/flags/category") do
+-- if variables.nofcategories > 1 then
+-- ?><tr>
+-- <th colspan="3"><?lua inject(category.at.name) ?></th>
+-- </tr><?lua
+-- end
+-- for subcategory in xml.collected(category,"/subcategory") do
+-- ?><tr><th/><td/><td/></tr><?lua
+-- for flag in xml.collected(subcategory,"/flag") do
+-- local name, value, short = variables.flagdata(flag)
+-- ?><tr>
+-- <th>--<?lua inject(name) ?></th>
+-- <td><?lua inject(value) ?></td>
+-- <td><?lua inject(short) ?></td>
+-- </tr><?lua
+-- end
+-- end
+-- end
+-- ?>
+-- </table>
+-- <br/>
+-- <?lua
+-- for category in xml.collected(variables.root,"/application/examples/category") do
+-- local title = variables.categorytitle(category)
+-- if title ~= "" then
+-- ?><h1><?lua inject(title) ?></h1><?lua
+-- end
+-- for subcategory in xml.collected(category,"/subcategory") do
+-- for example in xml.collected(subcategory,"/example") do
+-- local command, comment = variables.exampledata(example)
+-- ?><tt><?lua inject(command) ?></tt><br/><?lua
+-- end
+-- ?><br/><?lua
+-- end
+-- end
+-- for comment in xml.collected(root,"/application/comments/comment") do
+-- ?><br/><?lua inject(xml.text(comment)) ?><br/><?lua
+-- end
+-- ?>
+-- ]]
+
local bodytemplate = [[
<h1>Command line options</h1>
<table>
- <tr>
- <th style="width: 10em">flag</th>
- <th style="width: 8em">value</th>
- <th>description</th>
- </tr>
- <?lua
- for category in xml.collected(variables.root,"/application/flags/category") do
- if variables.nofcategories > 1 then
- ?><tr><th colspan="3"><?lua inject(category.at.name) ?></td></tr><?lua
- end
- for subcategory in xml.collected(category,"/subcategory") do
- ?><tr><th/><td/><td/></tr><?lua
- for flag in xml.collected(subcategory,"/flag") do
- local name, value, short = variables.flagdata(flag)
- ?>
- <tr>
- <th>--<?lua inject(name) ?></th>
- <td><?lua inject(value) ?></td>
- <td><?lua inject(short) ?></td>
- </tr>
- <?lua
- end
- end
- end
- ?>
+ <tr><th style="width: 10em">flag</th><th style="width: 8em">value</th><th>description</th></tr>
+ <?lua for category in xml.collected(variables.root,"/application/flags/category") do if variables.nofcategories > 1 then ?>
+ <tr><th colspan="3"><?lua inject(category.at.name) ?></th></tr>
+ <?lua end for subcategory in xml.collected(category,"/subcategory") do ?>
+ <tr><th/><td/><td/></tr>
+ <?lua for flag in xml.collected(subcategory,"/flag") do local name, value, short = variables.flagdata(flag) ?>
+ <tr><th>--<?lua inject(name) ?></th><td><?lua inject(value) ?></td><td><?lua inject(short) ?></td></tr>
+ <?lua end end end ?>
</table>
-<?lua
- ?><br/><?lua
- for category in xml.collected(variables.root,"/application/examples/category") do
- local title = variables.categorytitle(category)
- if title ~= "" then
- ?><h1><?lua inject(title)?></h1><?lua
- end
- for subcategory in xml.collected(category,"/subcategory") do
- for example in xml.collected(subcategory,"/example") do
- local command, comment = variables.exampledata(example)
- ?><tt><?lua inject(command) ?></tt><br/><?lua
- end
- ?><br/><?lua
- end
- end
-?>
+<br/>
+<?lua for category in xml.collected(variables.root,"/application/examples/category") do local title = variables.categorytitle(category) if title ~= "" then ?>
+<h1><?lua inject(title) ?></h1>
+<?lua end for subcategory in xml.collected(category,"/subcategory") do for example in xml.collected(subcategory,"/example") do local command, comment = variables.exampledata(example) ?>
+<tt><?lua inject(command) ?></tt>
+<br/><?lua end ?><br/><?lua end end for comment in xml.collected(root,"/application/comments/comment") do ?>
+<br/><?lua inject(xml.text(comment)) ?><br/><?lua end ?>
]]
-exporters.html = function(specification,...)
+function exporters.html(specification,...)
local root = xml.convert(specification.helpinfo or "")
if not root then
return
@@ -186,5 +226,3 @@ exporters.html = function(specification,...)
--
return html
end
-
-logs.exporters = exporters
diff --git a/tex/context/base/trac-lmx.lua b/tex/context/base/trac-lmx.lua
index b7e811860..18c7f6020 100644
--- a/tex/context/base/trac-lmx.lua
+++ b/tex/context/base/trac-lmx.lua
@@ -13,7 +13,7 @@ local format, sub, gsub = string.format, string.sub, string.gsub
local concat = table.concat
local collapsespaces = string.collapsespaces
local P, Cc, Cs, C, Carg, lpegmatch = lpeg.P, lpeg.Cc, lpeg.Cs, lpeg.C, lpeg.Carg, lpeg.match
-local joinpath, replacesuffix, pathpart = file.join, file.replacesuffix, file.pathpart
+local joinpath, replacesuffix, pathpart, filesuffix = file.join, file.replacesuffix, file.pathpart, file.suffix
local allocate = utilities.storage.allocate
local setmetatableindex = table.setmetatableindex
@@ -221,7 +221,7 @@ local function do_type_variable(str)
end
end
-local function do_include(filename)
+local function do_include(filename,option)
local data = loadedsubfile(filename)
if (not data or data == "") and givenpath then
data = loadedsubfile(joinpath(givenpath,filename))
@@ -241,6 +241,9 @@ local function do_include(filename)
-- report_lmx("included file: %s",filename)
data = do_nested_include(data)
end
+ if filesuffix(filename,"css") and option == "strip" then -- new
+ data = lmx.stripcss(data)
+ end
return data
end
@@ -425,6 +428,8 @@ end
local whitespace = lpeg.patterns.whitespace
local optionalspaces = whitespace^0
+local dquote = P('"')
+
local begincomment = P("<!--")
local endcomment = P("-->")
@@ -435,10 +440,12 @@ local beginembedcss = P("/*")
local endembedcss = P("*/")
local gobbledendxml = (optionalspaces * endembedxml) / ""
-local argumentxml = (1-gobbledendxml)^0
+----- argumentxml = (1-gobbledendxml)^0
+local argumentxml = (whitespace^1 + dquote * C((1-dquote)^1) * dquote + C((1-gobbledendxml-whitespace)^1))^0
local gobbledendcss = (optionalspaces * endembedcss) / ""
-local argumentcss = (1-gobbledendcss)^0
+----- argumentcss = (1-gobbledendcss)^0
+local argumentcss = (whitespace^1 + dquote * C((1-dquote)^1) * dquote + C((1-gobbledendcss-whitespace)^1))^0
local commentxml = (begincomment * (1-endcomment)^0 * endcomment) / ""
@@ -697,7 +704,7 @@ end
-- Test 2:
-- local str = [[
--- <?lmx-include somefile.css ?>
+-- <?lmx-include context.css strip ?>
-- <test>
-- <?lmx-define-begin whatever?>some content a<?lmx-define-end ?>
-- <?lmx-define-begin somemore?>some content b<?lmx-define-end ?>
@@ -715,7 +722,7 @@ end
-- <td><?lua pv('title-default') ?></td>
-- </test>
-- ]]
---
+
-- local defaults = { trace = true, a = 3, b = 3 }
-- local result = lmx.new(str,defaults)
-- inspect(result.data)
diff --git a/tex/context/base/trac-log.lua b/tex/context/base/trac-log.lua
index 4f1d9ac01..211734ef3 100644
--- a/tex/context/base/trac-log.lua
+++ b/tex/context/base/trac-log.lua
@@ -703,7 +703,12 @@ local reporters = {
export = reportexport,
}
+local exporters = {
+ -- empty
+}
+
logs.reporters = reporters
+logs.exporters = exporters
function logs.application(t)
t.name = t.name or "unknown"
diff --git a/tex/context/base/trac-tim.lua b/tex/context/base/trac-tim.lua
index 25ae6b1bc..527efa088 100644
--- a/tex/context/base/trac-tim.lua
+++ b/tex/context/base/trac-tim.lua
@@ -16,7 +16,7 @@ moduledata.progress = progress
local report_timing = logs.reporter("timing")
-progress.parameters = nodes.snapshots.getparameters
+progress.parameters = nodes and nodes.snapshots.getparameters
progress.defaultfilename = ((tex and tex.jobname) or "whatever") .. "-luatex-progress"
-- storage
diff --git a/tex/context/base/trac-xml.lua b/tex/context/base/trac-xml.lua
index e44f3c399..39cfcfb22 100644
--- a/tex/context/base/trac-xml.lua
+++ b/tex/context/base/trac-xml.lua
@@ -41,9 +41,9 @@ local function showhelp(specification,...)
-- local short = xmlserialize(short,xs)
local short = xmltext(xmlfirst(flag,"/short"))
if value then
- report("--%-24s %s",formatters["%s=%s"](name,value),short)
+ report("--%-20s %s",formatters["%s=%s"](name,value),short)
else
- report("--%-24s %s",name,short)
+ report("--%-20s %s",name,short)
end
end
report()
@@ -66,6 +66,12 @@ local function showhelp(specification,...)
report()
end
end
+ for comment in xmlcollected(root,"/application/comments/comment") do
+ local comment = xmltext(comment)
+ report()
+ report(comment)
+ report()
+ end
end
local reporthelp = reporters.help
@@ -80,13 +86,30 @@ function reporters.help(t,...)
end
end
+local exporters = logs.exporters
+
function reporters.export(t,method,filename)
dofile(resolvers.findfile("trac-exp.lua","tex"))
- local exporters = logs.exporters
- local result = method and exporters and exporters[method] and exporters[method](t,method) or exporthelp(t)
- if type(filename) == "string" and filename ~= "" then
- io.savedata(filename,result)
+ if not exporters or not method then
+ return exporthelp(t)
+ end
+ if method == "all" then
+ method = table.keys(exporters)
else
- reporters.lines(t,result)
+ method = { method }
+ end
+ filename = type(filename) == "string" and filename ~= "" and filename or false
+ for i=1,#method do
+ local m = method[i]
+ local result = exporters[m](t,m)
+ if result and result ~= "" then
+ if filename then
+ local fullname = file.replacesuffix(filename,m)
+ t.report("saving export in %a",fullname)
+ io.savedata(fullname,result)
+ else
+ reporters.lines(t,result)
+ end
+ end
end
end