summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2011-01-10 19:40:13 +0200
committerMarius <mariausol@gmail.com>2011-01-10 19:40:13 +0200
commit490acdefca0571050ba1f633a819167c38fdde6c (patch)
treed8a5498c800316f6d8ed7bbcae7e85c9b98cb025
parentf71041e9e80a2233e1a87c6b95660ed9e369e0c2 (diff)
downloadcontext-490acdefca0571050ba1f633a819167c38fdde6c.tar.gz
beta 2011.01.10 17:55
-rw-r--r--tex/context/base/buff-ver.lua49
-rw-r--r--tex/context/base/cont-new.tex2
-rw-r--r--tex/context/base/context.tex2
-rw-r--r--tex/context/base/font-ini.mkiv23
-rw-r--r--tex/context/base/font-uni.mkiv2
-rw-r--r--tex/context/base/math-ini.lua4
-rw-r--r--tex/context/base/math-ini.mkiv8
-rw-r--r--tex/context/base/page-lay.mkiv16
-rw-r--r--tex/context/base/supp-mat.mkiv2
-rw-r--r--tex/context/base/v-lua.lua20
-rw-r--r--tex/context/base/v-lua.mkiv8
-rw-r--r--tex/context/base/v-mp.lua8
-rw-r--r--tex/context/base/v-mp.mkiv8
-rw-r--r--tex/generic/context/luatex-fonts-merged.lua2
14 files changed, 113 insertions, 41 deletions
diff --git a/tex/context/base/buff-ver.lua b/tex/context/base/buff-ver.lua
index d62d31df7..386feb206 100644
--- a/tex/context/base/buff-ver.lua
+++ b/tex/context/base/buff-ver.lua
@@ -13,7 +13,7 @@ local type, next, rawset, rawget, setmetatable, getmetatable = type, next, rawse
local format, lower, match, find, sub = string.format, string.lower, string.match, string.find, string.sub
local splitlines = string.splitlines
local concat = table.concat
-local C, P, V, Carg = lpeg.C, lpeg.P, lpeg.V, lpeg.Carg
+local C, P, R, V, Carg = lpeg.C, lpeg.P, lpeg.R, lpeg.V, lpeg.Carg
local patterns, lpegmatch, is_lpeg = lpeg.patterns, lpeg.match, lpeg.is_lpeg
local tabtospace = utilities.strings.tabtospace
@@ -286,14 +286,21 @@ local function texmethod(s)
context.egroup()
end
+local function texcommand(s)
+ context[s]()
+end
+
local function defaultmethod(s,settings)
lpegmatch(getvisualizer("default"),s,1,settings)
end
+local space_pattern = patterns.space^0
+local name_pattern = R("az","AZ")^1
+
function visualizers.registerescapepattern(name,before,after,normalmethod,escapemethod)
local escapepattern = escapepatterns[name]
if not escapepattern then
- before, after = P(before) * patterns.space^0, patterns.space^0 * P(after)
+ before, after = P(before) * space_pattern, space_pattern * P(after)
escapepattern = (
(before / "")
* ((1 - after)^0 / (escapemethod or texmethod))
@@ -305,6 +312,22 @@ function visualizers.registerescapepattern(name,before,after,normalmethod,escape
return escapepattern
end
+function visualizers.registerescapecommand(name,token,normalmethod,escapecommand)
+ local escapepattern = escapepatterns[name]
+ if not escapepattern then
+ token = P(token)
+ local notoken = (1 - token)^1
+ local cstoken = name_pattern * space_pattern
+ escapepattern = (
+ (token / "")
+ * (cstoken / (escapecommand or texcommand))
+ + (notoken / (normalmethod or defaultmethod))
+ )^0
+ escapepatterns[name] = escapepattern
+ end
+ return escapepattern
+end
+
local escapedvisualizers = { }
local function visualize(content,settings) -- maybe also method in settings
@@ -322,20 +345,20 @@ local function visualize(content,settings) -- maybe also method in settings
if e == v_yes then
start, stop = "/BTEX", "/ETEX"
else
- start,stop = match(e,"^(.-),(.-)$") -- todo: lpeg
+ start, stop = match(e,"^(.-),(.-)$") -- todo: lpeg
end
+ local oldvisualizer = specifications[method] or specifications.default
+ local oldparser = oldvisualizer.direct
+ local newparser
if start and stop then
- local oldvisualizer = specifications[method] or specifications.default
- local oldparser = oldvisualizer.direct
- local newparser = visualizers.registerescapepattern(newname,start,stop,oldparser)
- m = visualizers.register(newname, {
- parser = newparser,
- handler = oldvisualizer.handler,
- })
- else
- -- visualizers.register(newname,n)
- specifications[newname] = m -- old spec so that we have one lookup only
+ newparser = visualizers.registerescapepattern(newname,start,stop,oldparser)
+ else -- for old times sake: /em
+ newparser = visualizers.registerescapecommand(newname,e,oldparser)
end
+ m = visualizers.register(newname, {
+ parser = newparser,
+ handler = oldvisualizer.handler,
+ })
end
else
m = specifications[method] or specifications.default
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index 5f9fe0b41..92efab5c0 100644
--- a/tex/context/base/cont-new.tex
+++ b/tex/context/base/cont-new.tex
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2011.01.10 13:28}
+\newcontextversion{2011.01.10 17:55}
%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/context.tex b/tex/context/base/context.tex
index b430396da..97c588835 100644
--- a/tex/context/base/context.tex
+++ b/tex/context/base/context.tex
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2011.01.10 13:28}
+\edef\contextversion{2011.01.10 17:55}
%D For those who want to use this:
diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv
index 667bce92b..93e020d93 100644
--- a/tex/context/base/font-ini.mkiv
+++ b/tex/context/base/font-ini.mkiv
@@ -1711,7 +1711,7 @@
\let\relativefontsize\defaultrelativefontsize}
\def\dododefinebodyfont#1#2#3% style defs body
- {\checkbodyfontenvironment[#3]% just to be sure.
+ {\checkbodyfontenvironment[#3]% just to be sure; can probably be omited now
\processcommalist[#2]{\dodododefinebodyfont{#1}{#3}}}
\def\dodododefinebodyfont#1#2#3% style body def
@@ -2145,10 +2145,26 @@
%D handle changes in size as well as returning to the global
%D bodyfont size.
+% \def\dosetfont#1#2% #1 = set/switch state
+% {\doifelse{#2}\v!global
+% {\restoreglobalbodyfont}
+% {\processcommacommand[#2]{\dodosetfont{#1}}% ##1 get also passed
+% \ifproductionrun
+% \thirdstagepreloadfonts
+% \doswitchpoints[\normalizedbodyfontsize]%
+% \doswitchstyle[\fontstyle]%
+% \ifx\defaultfontclass\empty
+% \let\defaultfontclass\fontclass
+% \fi
+% \fi}%
+% \currentxfontsize\zerocount}
+
+
\def\dosetfont#1#2% #1 = set/switch state
{\doifelse{#2}\v!global
{\restoreglobalbodyfont}
- {\processcommacommand[#2]{\dodosetfont{#1}}% ##1 get also passed
+ {\processcommacommand[#2]{\dodocheckfontsize}%
+ \processcommacommand[#2]{\dodosetfont{#1}}%
\ifproductionrun
\thirdstagepreloadfonts
\doswitchpoints[\normalizedbodyfontsize]%
@@ -2159,6 +2175,9 @@
\fi}%
\currentxfontsize\zerocount}
+\def\dodocheckfontsize#1%
+ {\doifnumberelse{#1}{\checkbodyfontenvironment[#1]}\donothing}
+
\def\dodosetfont#1#2% #1 = set/switch state | check fo rempty, else space
{\doifsomething{#2}{\dododosetfont{#1}{#2}{\showmessage\m!fonts4{#2}}}}
diff --git a/tex/context/base/font-uni.mkiv b/tex/context/base/font-uni.mkiv
index ea60aa017..dddc8420b 100644
--- a/tex/context/base/font-uni.mkiv
+++ b/tex/context/base/font-uni.mkiv
@@ -20,7 +20,7 @@
\unprotect
%def\uchar#1#2{\ctxlua{commands.uchar(,)}}
-\def\uchar#1#2{\ctxcontext{utf.char(\number\numexpr#1*256+#2\relax)}}
+\def\uchar#1#2{\cldcontext{utf.char(\number\numexpr#1*256+#2\relax)}}
\let\uc\uchar
diff --git a/tex/context/base/math-ini.lua b/tex/context/base/math-ini.lua
index 27f66d127..acaf03b5f 100644
--- a/tex/context/base/math-ini.lua
+++ b/tex/context/base/math-ini.lua
@@ -316,12 +316,12 @@ end
function mathematics.utfmathcommand(chr, default)
local cd = characters.data[utfbyte(chr)]
local cmd = cd and cd.mathname
- texsprint(cmd or default or "")
+ return cmd or default or ""
end
function mathematics.utfmathfiller(chr, default)
local cd = characters.data[utfbyte(chr)]
local cmd = cd and (cd.mathfiller or cd.mathname)
- texsprint(cmd or default or "")
+ return cmd or default or ""
end
-- xml
diff --git a/tex/context/base/math-ini.mkiv b/tex/context/base/math-ini.mkiv
index 8a5b80a74..3cf050e75 100644
--- a/tex/context/base/math-ini.mkiv
+++ b/tex/context/base/math-ini.mkiv
@@ -152,10 +152,10 @@
%D Helpers:
-\def\utfmathclass #1{\ctxlua{tex.sprint(mathematics.utfmathclass ("#1"))}}
-\def\utfmathstretch#1{\ctxlua{tex.sprint(mathematics.utfmathstretch("#1"))}}
-\def\utfmathcommand#1{\ctxlua{tex.sprint(mathematics.utfmathcommand("#1"))}}
-\def\utfmathfiller #1{\ctxlua{tex.sprint(mathematics.utfmathfiller ("#1"))}}
+\def\utfmathclass #1{\cldcontext{mathematics.utfmathclass (\!!bs#1\!!es)}}
+\def\utfmathstretch#1{\cldcontext{mathematics.utfmathstretch(\!!bs#1\!!es)}}
+\def\utfmathcommand#1{\cldcontext{mathematics.utfmathcommand(\!!bs#1\!!es)}}
+\def\utfmathfiller #1{\cldcontext{mathematics.utfmathfiller (\!!bs#1\!!es)}}
% \def\utfmathclassdefault #1#2{\ctxlua{
% tex.sprint(mathematics.utfmathclass("#1","#2"))
diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv
index 7222d072f..4944712bb 100644
--- a/tex/context/base/page-lay.mkiv
+++ b/tex/context/base/page-lay.mkiv
@@ -1394,10 +1394,10 @@
%D paper size with the typeset paper size. This setting should
%D come after the first layout specification (already done).
-\setuppapersize
- [A4][A4]
-
-%D A few goodies:
+\definepapersize
+ [samesized]
+ [ \c!width=\paperwidth,
+ \c!height=\paperheight]
\definepapersize
[oversized]
@@ -1414,6 +1414,14 @@
[ \c!width=\dimexpr \paperheight+1.5cm\relax,
\c!height=\dimexpr2\paperwidth +1.5cm\relax]
+% \setuppapersize
+% [A4][A4]
+
+\setuppapersize
+ [A4][samesized]
+
+%D A few goodies:
+
%D For orthogonality:
\definepapersize
diff --git a/tex/context/base/supp-mat.mkiv b/tex/context/base/supp-mat.mkiv
index 4356b6e4e..1adc3e0a0 100644
--- a/tex/context/base/supp-mat.mkiv
+++ b/tex/context/base/supp-mat.mkiv
@@ -52,7 +52,7 @@
\let\normalstopimath \Ustopmath
\let\normalstartdmath \Ustartdisplaymath
\let\normalstopdmath \Ustopmath
-\let\normalmathaligntab\aligntab
+\def\normalmathaligntab{&} % \let\normalmathaligntab\aligntab
\let\normalsuper \Usuperscript % obsolete
\let\normalsuber \Usubscript % obsolete
diff --git a/tex/context/base/v-lua.lua b/tex/context/base/v-lua.lua
index af1db27a3..97d1b27df 100644
--- a/tex/context/base/v-lua.lua
+++ b/tex/context/base/v-lua.lua
@@ -77,6 +77,8 @@ local startLuaSnippet = context.startLuaSnippet
local stopLuaSnippet = context.stopLuaSnippet
local LuaSnippetBoundary = verbatim.LuaSnippetBoundary
+local LuaSnippetQuote = verbatim.LuaSnippetQuote
+local LuaSnippetString = verbatim.LuaSnippetString
local LuaSnippetSpecial = verbatim.LuaSnippetSpecial
local LuaSnippetComment = verbatim.LuaSnippetComment
local LuaSnippetNameCore = verbatim.LuaSnippetNameCore
@@ -122,8 +124,10 @@ local handler = visualizers.newhandler {
startdisplay = function() startLuaSnippet() end,
stopdisplay = function() stopLuaSnippet() end ,
boundary = function(s) LuaSnippetBoundary(s) end,
- special = function(s) LuaSnippetSpecial (s) end,
- comment = function(s) LuaSnippetComment (s) end,
+ special = function(s) LuaSnippetSpecial(s) end,
+ comment = function(s) LuaSnippetComment(s) end,
+ quote = function(s) LuaSnippetQuote(s) end,
+ string = function(s) LuaSnippetString(s) end,
period = function(s) verbatim(s) end,
name_a = visualizename_a,
name_b = visualizename_b,
@@ -187,13 +191,13 @@ local grammar = visualizers.newgrammar("default", { "visualizer",
--~ makepattern(handler,"default",somecontent),
sstring =
- makepattern(handler,"string",patterns.dquote)
- * (V("whitespace") + makepattern(handler,"default",1-patterns.dquote))^0
- * makepattern(handler,"string",patterns.dquote),
+ makepattern(handler,"quote",patterns.dquote)
+ * (V("whitespace") + makepattern(handler,"string",1-patterns.dquote))^0 -- patterns.nodquote
+ * makepattern(handler,"quote",patterns.dquote),
dstring =
- makepattern(handler,"string",patterns.squote)
- * (V("whitespace") + makepattern(handler,"default",1-patterns.squote))^0
- * makepattern(handler,"string",patterns.squote),
+ makepattern(handler,"quote",patterns.squote)
+ * (V("whitespace") + makepattern(handler,"string",1-patterns.squote))^0 -- patterns.nosquote
+ * makepattern(handler,"quote",patterns.squote),
longstring =
longstring / long,
comment =
diff --git a/tex/context/base/v-lua.mkiv b/tex/context/base/v-lua.mkiv
index 6bfe4a963..4ed04f169 100644
--- a/tex/context/base/v-lua.mkiv
+++ b/tex/context/base/v-lua.mkiv
@@ -45,6 +45,14 @@
\c!style=boldface]
\definestartstop
+ [LuaSnippetString]
+ [LuaSnippet]
+
+\definestartstop
+ [LuaSnippetQuote]
+ [LuaSnippetBoundary]
+
+\definestartstop
[LuaSnippetSpecial]
[\c!color=darkred,
\c!style=boldface]
diff --git a/tex/context/base/v-mp.lua b/tex/context/base/v-mp.lua
index 5e7f68712..7c356a5c8 100644
--- a/tex/context/base/v-mp.lua
+++ b/tex/context/base/v-mp.lua
@@ -137,6 +137,8 @@ local handler = visualizers.newhandler {
boundary = function(s) MetapostSnippetBoundary(s) end,
special = function(s) MetapostSnippetSpecial(s) end,
comment = function(s) MetapostSnippetComment(s) end,
+ string = function(s) MetapostSnippetString(s) end,
+ quote = function(s) MetapostSnippetQuote(s) end,
name = visualizename,
}
@@ -150,9 +152,9 @@ local grammar = visualizers.newgrammar("default", { "visualizer",
comment = makepattern(handler,"comment",comment)
* (V("space") + V("content"))^0,
- dstring = makepattern(handler,"special",patterns.dquote)
- * makepattern(handler,"default",patterns.nodquote)
- * makepattern(handler,"special",patterns.dquote),
+ dstring = makepattern(handler,"quote",patterns.dquote)
+ * makepattern(handler,"string",patterns.nodquote)
+ * makepattern(handler,"quote",patterns.dquote),
name = makepattern(handler,"name",name),
constructor = makepattern(handler,"constructor",constructor),
boundary = makepattern(handler,"boundary",boundary),
diff --git a/tex/context/base/v-mp.mkiv b/tex/context/base/v-mp.mkiv
index 57a7aeba7..30eb23f8b 100644
--- a/tex/context/base/v-mp.mkiv
+++ b/tex/context/base/v-mp.mkiv
@@ -52,11 +52,19 @@
\c!style=boldface]
\definestartstop
+ [MetapostSnippetQuote]
+ [MetapostSnippetBoundary]
+
+\definestartstop
[MetapostSnippetSpecial]
[\c!color=darkyellow,
\c!style=boldface]
\definestartstop
+ [MetapostSnippetString]
+ [MetapostSnippet]
+
+\definestartstop
[MetapostSnippetComment]
[\c!color=darkyellow,
\c!style=boldface]
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index 00b530209..837952682 100644
--- a/tex/generic/context/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 01/10/11 13:28:15
+-- merge date : 01/10/11 17:55:44
do -- begin closure to overcome local limits and interference