summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2010-11-26 22:49:00 +0100
committerHans Hagen <pragma@wxs.nl>2010-11-26 22:49:00 +0100
commitf720cb2398bd745d310315a99fea01e31d2c260e (patch)
tree4e08c03e9a2dc41ee9e8b5ba35acd09ed175f1ea
parent7baa2a92b23fc45ad596f18d6b022617e40169ca (diff)
downloadcontext-f720cb2398bd745d310315a99fea01e31d2c260e.tar.gz
beta 2010.11.26 22:49
-rw-r--r--tex/context/base/buff-ini.lua16
-rw-r--r--tex/context/base/buff-ver.lua2
-rw-r--r--tex/context/base/buff-ver.mkiv3
-rw-r--r--tex/context/base/cont-new.tex2
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/context.tex2
-rw-r--r--tex/context/base/pret-lua.lua334
-rw-r--r--tex/context/base/pret-mp.lua240
-rw-r--r--tex/context/base/pret-tex.lua92
-rw-r--r--tex/context/base/pret-xml.lua140
-rw-r--r--tex/context/base/v-parsed-xml.lua101
-rw-r--r--tex/context/base/v-parsed-xml.mkiv68
-rw-r--r--tex/generic/context/luatex-fonts-merged.lua2
13 files changed, 192 insertions, 812 deletions
diff --git a/tex/context/base/buff-ini.lua b/tex/context/base/buff-ini.lua
index 593166038..9caa673dc 100644
--- a/tex/context/base/buff-ini.lua
+++ b/tex/context/base/buff-ini.lua
@@ -218,6 +218,22 @@ function buffers.typebuffer(settings) -- todo: settings.nature = "display"
end
end
+function buffers.processbuffer(settings) -- overlaps too much with the previous
+ local name = settings.name -- maybe use processor instead of visualizer
+ local lines = name and data[name]
+ if lines then
+ if type(lines) == "string" then
+ lines = splitlines(lines)
+ data[name] = lines
+ end
+ local content, m = filter(lines,settings)
+ if content and content ~= "" then
+--~ print("!!!!!!!!!!!!!!!!!!!")
+ flush(content,"process",settings)
+ end
+ end
+end
+
function buffers.typefile(settings) -- todo: settings.nature = "display"
local name = settings.name
local str = buffers.loaddata(name)
diff --git a/tex/context/base/buff-ver.lua b/tex/context/base/buff-ver.lua
index 9574768b5..cee02c52d 100644
--- a/tex/context/base/buff-ver.lua
+++ b/tex/context/base/buff-ver.lua
@@ -326,7 +326,7 @@ local function visualize(method,nature,content,settings) -- maybe also method an
m = specifications[method] or specifications.default
end
local n = m and m[nature]
- settings.currentnature = nature or "display" -- tricky ... why sometimes no nature
+ settings.currentnature = nature or settings.nature or "display" -- tricky ... why sometimes no nature
if n then
n(content,settings)
else
diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv
index 2c478d46d..4a226885e 100644
--- a/tex/context/base/buff-ver.mkiv
+++ b/tex/context/base/buff-ver.mkiv
@@ -760,11 +760,12 @@
\def\dodoprocessbuffer#1#2%
{\edef\currenttyping{#1}%
- \ctxlua{buffers.typebuffer {
+ \ctxlua{buffers.processbuffer {
name = "#2",
strip = "\typingparameter\c!strip",
tab = "\typingparameter\c!tab",
visualizer = "\typingparameter\c!option",
+ nature = "process",
}}}
% line numbering, keep broken lines together
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index 3e94f0982..e8b89219b 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{2010.11.26 22:03}
+\newcontextversion{2010.11.26 22:49}
%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.mkiv b/tex/context/base/context.mkiv
index 4e790adad..1f9ea2200 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -242,7 +242,7 @@
\loadmarkfile{v-xml} % optional as also runtime if not loaded
\loadmarkfile{v-parsed-xml} % optional
-\loadmarkfile{v-parsed-lua} % optional
+%loadmarkfile{v-parsed-lua} % optional
\loadmarkfile{strc-blk}
diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex
index 8a349be10..06c589c92 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{2010.11.26 22:03}
+\edef\contextversion{2010.11.26 22:49}
%D For those who want to use this:
diff --git a/tex/context/base/pret-lua.lua b/tex/context/base/pret-lua.lua
deleted file mode 100644
index 6a74670b2..000000000
--- a/tex/context/base/pret-lua.lua
+++ /dev/null
@@ -1,334 +0,0 @@
-if not modules then modules = { } end modules ['pret-lua'] = {
- version = 1.001,
- comment = "companion to buff-ver.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- this is not a real parser as we also want to typeset wrong output
--- and a real parser would choke on that
-
-local utf = unicode.utf8
-
-local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues
-local utfbyte, utffind = utf.byte, utf.find
-local byte, sub, find, match = string.byte, string.sub, string.find, string.match
-local texwrite = tex.write
-
-local buffers = buffers
-local context = context
-
-local changestate, finishstate = buffers.changestate, buffers.finishstate
-
-local visualizer = buffers.newvisualizer("lua")
-
-visualizer.identifiers = { }
-
--- borrowed from scite
---
--- depricated:
---
--- gcinfo unpack getfenv setfenv loadlib
--- table.maxn table.getn table.setn
--- math.log10 math.mod math.modf math.fmod
-
-visualizer.identifiers.core = {
- "and", "break", "do", "else", "elseif", "end", "false", "for", "function",
- "if", "in", "local", "nil", "not", "or", "repeat", "return", "then",
- "true", "until", "while"
-}
-
-visualizer.identifiers.base = {
- "assert", "collectgarbage", "dofile", "error", "loadfile",
- "loadstring", "print", "rawget", "rawset", "require", "tonumber",
- "tostring", "type",
-}
-
-visualizer.identifiers.five = {
- "_G", "getmetatable", "ipairs", "next", "pairs",
- "pcall", "rawequal", "setmetatable", "xpcall", "string", "table",
- "math", "coroutine", "io", "os", "debug", "load", "module", "select",
-}
-
-visualizer.identifiers.libs = {
- -- coroutine
- "coroutine.create", "coroutine.resume", "coroutine.status", "coroutine.wrap",
- "coroutine.yield", "coroutine.running",
- -- package
- "package.cpath", "package.loaded", "package.loadlib", "package.path", "package.config",
- -- io
- "io.close", "io.flush", "io.input", "io.lines", "io.open", "io.output",
- "io.read", "io.tmpfile", "io.type", "io.write", "io.stdin", "io.stdout",
- "io.stderr", "io.popen",
- -- math
- "math.abs", "math.acos", "math.asin", "math.atan", "math.atan2", "math.ceil",
- "math.cos", "math.deg", "math.exp", "math.floor math.", "math.ldexp",
- "math.log", "math.max", "math.min", "math.pi", "math.pow",
- "math.rad", "math.random", "math.randomseed", "math.sin", "math.sqrt",
- "math.tan", "math.cosh", "math.sinh", "math.tanh",
- "math.huge",
- -- string
- "string.byte", "string.char", "string.dump", "string.find", "string.len",
- "string.lower", "string.rep", "string.sub", "string.upper", "string.format",
- "string.gfind", "string.gsub", "string.gmatch", "string.match", "string.reverse",
- -- table
- "table.concat", "table.foreach", "table.foreachi",
- "table.sort", "table.insert", "table.remove",
- "table.pack", "table.unpack",
- -- os
- "os.clock", "os.date", "os.difftime", "os.execute", "os.exit", "os.getenv",
- "os.remove", "os.rename", "os.setlocale", "os.time", "os.tmpname",
- -- package
- "package.preload", "package.seeall",
- -- bit
- -- ... todo ...
-}
-
-local known_words = { }
-
-for k,v in next, visualizer.identifiers do
- for _,w in next, v do
- known_words[w] = k
- end
-end
-
-visualizer.styles = {
- core = "",
- base = "sl ",
- five = "sl ",
- libs = "sl ",
-}
-
-local styles = visualizer.styles
-
-local colors = {
- "prettyone",
- "prettytwo",
- "prettythree",
- "prettyfour",
-}
-
-local states = {
- ['"']=1, ["'"]=1, ["[["] = 1, ["]]"] = 1,
- ['+']=1, ['-']=1, ['*']=1, ['/']=1, ['%']=1, ['^']=1,
- ["("] = 3, [")"] = 3, ["["] = 3, ["]"] = 3,
- ['--']=4,
-}
-
-local function flush_lua_word(state, word)
- if word then
- local id = known_words[word]
- if id then
- state = changestate(2,state)
- local style = styles[id]
- if style and style ~= "" then
- context[style]()
- end
- texwrite(word)
- state = finishstate(state)
- else
- state = finishstate(state) -- ?
- texwrite(word)
- end
- else
- state = finishstate(state)
- end
- return state
-end
-
-local incomment, inlongstring = false, false
-
-function visualizer.reset()
- incomment, inlongstring = false, false -- needs to be hooked into flusher
-end
-
--- we will also provide a proper parser based pretty printer although normaly
--- a pretty printer should handle faulty code too (educational purposes)
-
-local space = context.obs
-
-local function written(state,c,i)
- if c == " " then
- state = finishstate(state)
- space()
- elseif c == "\t" then
- state = finishstate(state)
- space()
- if buffers.visualizers.enabletab then
- for i=1,i%buffers.visualizers.tablength do
- space()
- end
- end
- else
- texwrite(c)
- end
- return state, 0
-end
-
-function visualizer.flush_line(str, nested)
- local state, instr, inesc, word = 0, false, false, nil
- buffers.currentcolors = colors
- local code, comment = match(str,"^(.-)%-%-%[%[(.*)$")
- if comment then
- -- process the code and then flush the comment
- elseif incomment then
- comment, code = match(str,"^(.-)%]%](.*)$")
- if comment then
- -- flush the comment and then process the code
- for c in utfcharacters(comment) do
- if c == " " then
- space()
- else
- texwrite(c)
- end
- end
- state = changestate(states['--'], state)
- texwrite("]]")
- state = finishstate(state)
- incomment = false
- else
- for c in utfcharacters(str) do
- if c == " " then
- space()
- else
- texwrite(c)
- end
- end
- end
- comment = nil
- else
- code = str
- end
- if code and code ~= "" then
- local pre, post = match(code,"^(.-)%-%-(.*)$")
- if pre then
- code = pre
- end
- local p, s, i = nil, nil, 0
- for c in utfcharacters(code) do
- i = i + 1
- if instr then
- if p then
- texwrite(p)
- p = nil
- end
- if c == s then
- if inesc then
- texwrite(c)
- inesc = false
- else
- state = changestate(states[c],state)
- instr = false
- texwrite(c)
- state = finishstate(state)
- end
- s = nil
- else
- if c == "\\" then
- inesc = not inesc
- else
- inesc = false
- end
- state, i = written(state,c,i)
- end
- elseif c == "[" then
- if word then
- texwrite(word)
- word = nil
- end
- if p == "[" then
- inlongstring = true
- state = changestate(states["[["],state)
- texwrite(p,c)
- state = finishstate(state)
- p = nil
- else
- if p then
- state, i = written(state,p,i)
- end
- p = c
- end
- elseif c == "]" then
- if word then
- texwrite(word)
- word = nil
- end
- if p == "]" then
- inlongstring = false
- state = changestate(states["]]"],state)
- texwrite(p,c)
- state = finishstate(state)
- p = nil
- else
- if p then
- state, i = written(state,p,i)
- end
- p = c
- end
- else
- if p then
- state = changestate(states[p],state)
- texwrite(p)
- state = finishstate(state)
- p = nil
- end
- if c == " " or c == "\t" then
- if word then
- state = flush_lua_word(state,word)
- word = nil
- end
- state, i = written(state,c,i)
- elseif inlongstring then
- state, i = written(state,c,i)
- elseif c == '"' or c == "'" then
-if word then
- state = flush_lua_word(state,word)
- word = nil
-end
- instr = true
- state = changestate(states[c],state)
- state, i = written(state,c,i)
- state = finishstate(state)
- s = c
- elseif find(c,"^[%a]$") then
- state = finishstate(state)
- if word then word = word .. c else word = c end
- elseif word and (#word > 1) and find(c,"^[%d%.%_]$") then
- if word then word = word .. c else word = c end
- else
- state = flush_lua_word(state,word)
- word = nil
- state = changestate(states[c],state)
- texwrite(c)
- instr = (c == '"')
- end
- end
- end
- if p then
- texwrite(p)
- -- state, i = written(state,p,i)
- p = nil
- end
- state = flush_lua_word(state,word)
- if post then
- state = changestate(states['--'], state)
- texwrite("--")
- state = finishstate(state)
- for c in utfcharacters(post) do
- state, i = written(state,c,i)
- end
- end
- end
- if comment then
- incomment = true
- state = changestate(states['--'], state)
- texwrite("[[")
- state = finishstate(state)
- -- texwrite(comment) -- maybe also split and
- for c in utfcharacters(comment) do
- state, i = written(state,c,i)
- end
- end
- state = finishstate(state)
-end
diff --git a/tex/context/base/pret-mp.lua b/tex/context/base/pret-mp.lua
deleted file mode 100644
index c701d63c8..000000000
--- a/tex/context/base/pret-mp.lua
+++ /dev/null
@@ -1,240 +0,0 @@
-if not modules then modules = { } end modules ['pret-mp'] = {
- version = 1.001,
- comment = "companion to buff-ver.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
-local utf = unicode.utf8
-
-local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues
-local utfbyte, utffind = utf.byte, utf.find
-local texwrite = tex.write
-
-local buffers = buffers
-
-local changestate, finishstate = buffers.changestate, buffers.finishstate
-
-local visualizer = buffers.newvisualizer("mp")
-
-visualizer.identifiers = { }
-
-visualizer.identifiers.primitives = {
- 'charcode', 'day', 'linecap', 'linejoin', 'miterlimit', 'month', 'pausing',
- 'prologues', 'showstopping', 'time', 'tracingcapsules', 'tracingchoices',
- 'tracingcommands', 'tracingequations', 'tracinglostchars',
- 'tracingmacros', 'tracingonline', 'tracingoutput', 'tracingrestores',
- 'tracingspecs', 'tracingstats', 'tracingtitles', 'truecorners',
- 'warningcheck', 'year', 'mpprocset',
- 'false', 'nullpicture', 'pencircle', 'true',
- 'and', 'angle', 'arclength', 'arctime', 'ASCII', 'bluepart', 'boolean', 'bot',
- 'char', 'color', 'cosd', 'cycle', 'decimal', 'directiontime', 'floor', 'fontsize',
- 'greenpart', 'hex', 'infont', 'intersectiontimes', 'known', 'length', 'llcorner',
- 'lrcorner', 'makepath', 'makepen', 'mexp', 'mlog', 'normaldeviate', 'not',
- 'numeric', 'oct', 'odd', 'or', 'path', 'pair', 'pen', 'penoffset', 'picture', 'point',
- 'postcontrol', 'precontrol', 'redpart', 'reverse', 'rotated', 'scaled',
- 'shifted', 'sind', 'slanted', 'sqrt', 'str', 'string', 'subpath', 'substring',
- 'transform', 'transformed', 'ulcorner', 'uniformdeviate', 'unknown',
- 'urcorner', 'xpart', 'xscaled', 'xxpart', 'xypart', 'ypart', 'yscaled', 'yxpart',
- 'yypart', 'zscaled',
- 'addto', 'clip', 'input', 'interim', 'let', 'newinternal', 'save', 'setbounds',
- 'shipout', 'show', 'showdependencies', 'showtoken', 'showvariable',
- 'special',
- 'begingroup', 'endgroup', 'of', 'curl', 'tension', 'and', 'controls',
- 'reflectedabout', 'rotatedaround', 'interpath', 'on', 'off', 'beginfig',
- 'endfig', 'def', 'vardef', 'enddef', 'epxr', 'suffix', 'text', 'primary', 'secondary',
- 'tertiary', 'primarydef', 'secondarydef', 'tertiarydef', 'top', 'bottom',
- 'ulft', 'urt', 'llft', 'lrt', 'randomseed', 'also', 'contour', 'doublepath',
- 'withcolor', 'withpen', 'dashed', 'if', 'else', 'elseif', 'fi', 'for', 'endfor', 'forever', 'exitif',
- 'forsuffixes', 'downto', 'upto', 'step', 'until',
- 'charlist', 'extensible', 'fontdimen', 'headerbyte', 'kern', 'ligtable',
- 'boundarychar', 'chardp', 'charext', 'charht', 'charic', 'charwd', 'designsize',
- 'fontmaking', 'charexists',
- 'cullit', 'currenttransform', 'gfcorners', 'grayfont', 'hround',
- 'imagerules', 'lowres_fix', 'nodisplays', 'notransforms', 'openit',
- 'displaying', 'currentwindow', 'screen_rows', 'screen_cols',
- 'pixels_per_inch', 'cull', 'display', 'openwindow', 'numspecial',
- 'totalweight', 'autorounding', 'fillin', 'proofing', 'tracingpens',
- 'xoffset', 'chardx', 'granularity', 'smoothing', 'turningcheck', 'yoffset',
- 'chardy', 'hppp', 'tracingedges', 'vppp',
- 'extra_beginfig', 'extra_endfig', 'mpxbreak',
- 'end', 'btex', 'etex', 'verbatimtex'
-}
-
-visualizer.identifiers.plain = {
- 'ahangle', 'ahlength', 'bboxmargin', 'defaultpen', 'defaultscale',
- 'labeloffset', 'background', 'currentpen', 'currentpicture', 'cuttings',
- 'defaultfont', 'extra_beginfig', 'extra_endfig',
- 'beveled', 'black', 'blue', 'bp', 'butt', 'cc', 'cm', 'dd', 'ditto', 'down', 'epsilon',
- 'evenly', 'fullcircle', 'green', 'halfcircle', 'identity', 'in', 'infinity', 'left',
- 'mitered', 'mm', 'origin', 'pensquare', 'pt', 'quartercircle', 'red', 'right',
- 'rounded', 'squared', 'unitsquare', 'up', 'white', 'withdots',
- 'abs', 'bbox', 'ceiling', 'center', 'cutafter', 'cutbefore', 'dir',
- 'directionpoint', 'div', 'dotprod', 'intersectionpoint', 'inverse', 'mod', 'lft',
- 'round', 'rt', 'unitvector', 'whatever',
- 'cutdraw', 'draw', 'drawarrow', 'drawdblarrow', 'fill', 'filldraw', 'drawdot',
- 'loggingall', 'pickup', 'tracingall', 'tracingnone', 'undraw', 'unfill',
- 'unfilldraw',
- 'buildcycle', 'dashpattern', 'decr', 'dotlabel', 'dotlabels', 'drawoptions',
- 'incr', 'label', 'labels', 'max', 'min', 'thelabel', 'z',
- 'beginchar', 'blacker', 'capsule_end', 'change_width',
- 'define_blacker_pixels', 'define_corrected_pixels',
- 'define_good_x_pixels', 'define_good_y_pixels',
- 'define_horizontal_corrected_pixels', 'define_pixels',
- 'define_whole_blacker_pixels', 'define_whole_pixels',
- 'define_whole_vertical_blacker_pixels',
- 'define_whole_vertical_pixels', 'endchar', 'extra_beginchar',
- 'extra_endchar', 'extra_setup', 'font_coding_scheme',
- 'font_extra_space'
-}
-
-visualizer.identifiers.metafun = {
- 'unitcircle', 'fulldiamond', 'unitdiamond',
- 'halfcircle', 'quartercircle',
- 'llcircle', 'lrcircle', 'urcircle', 'ulcircle',
- 'tcircle', 'bcircle', 'lcircle', 'rcircle',
- 'lltriangle', 'lrtriangle', 'urtriangle', 'ultriangle',
- 'smoothed', 'cornered', 'superellipsed', 'randomized', 'squeezed',
- 'punked', 'curved', 'unspiked', 'simplified', 'blownup', 'stretched',
- 'paralled', 'enlonged', 'shortened',
- 'enlarged', 'leftenlarged', 'topenlarged', 'rightenlarged', 'bottomenlarged',
- 'llenlarged', 'lrenlarged', 'urenlarged', 'ulenlarged',
- 'llmoved', 'lrmoved', 'urmoved', 'ulmoved',
- 'boundingbox', 'innerboundingbox', 'outerboundingbox',
- 'bottomboundary', 'leftboundary', 'topboundary', 'rightboundary',
- 'xsized', 'ysized', 'xysized',
- 'cmyk', 'transparent', 'withshade', 'spotcolor',
- 'drawfill', 'undrawfill',
- 'inverted', 'uncolored', 'softened', 'grayed',
- 'textext', 'graphictext',
- 'loadfigure', 'externalfigure'
-}
-
-visualizer.styles = {
- primitives = "",
- plain = "sl",
- metafun = "sl",
-}
-
-local styles = visualizer.styles
-
--- btex .. etex
-
-local colors = {
- "prettyone",
- "prettytwo",
- "prettythree",
- "prettyfour",
-}
-
-local states = {
- [';']=1, ['$']=1, ['@']=1, ['#']=1,
- ['\\']=2,
- ['(']=3, [')']=3, ['[']=3, [']']=3, [':']=3, ['=']=3, ['<']=3, ['>']=3, ['"']=3,
- ['-']=4, ['+']=4, ['/']=4, ['*']=4, ['|']=4, ['`']=4, ['!']=4, ['?']=4, ['^']=4, ['&']=4, ['%']=4,
- ['%']=4, ['.']=4, [',']=4
-}
-
-local known_words = { }
-
-for k,v in next, visualizer.identifiers do
- for _,w in next, v do
- known_words[w] = k
- end
-end
-
-local function flush_mp_word(state, word, intex)
- if word then
- if intex then
- if word == 'etex' then
- state = changestate(2,state)
- texwrite(word)
- state = finishstate(state)
- return state, false
- else
- texwrite(word)
- return state, true
- end
- else
- local id = known_words[word]
- if id then
- state = changestate(2,state)
- local style = styles[id]
- if style and style ~= "" then
- context[style]()
- end
- texwrite(word)
- state = finishstate(state)
- return state, (word == 'btex') or (word == 'verbatimtex')
- else
- state = finishstate(state)
- texwrite(word)
- return state, intex
- end
- end
- else
- state = finishstate(state)
- return state, intex
- end
-end
-
--- todo: split string in code and comment, and escape comment fast
--- could be generic
-
--- to be considered: visualizer => table [result, instr, incomment, word]
-
-local space = context.obs
-
-function visualizer.flush_line(str,nested)
- local state, word, instr, intex, incomment = 0, nil, false, false, false
- buffers.currentcolors = colors
- for c in utfcharacters(str) do
- if c == " " then
- state, intex = flush_mp_word(state, word, intex)
- word = nil
- space()
- elseif incomment then
- texwrite(c)
- elseif c == '%' then
- state = changestate(states[c], state)
- incomment = true
- texwrite(c)
- state = finishstate(state)
- elseif instr then
- if c == '"' then
- state = changestate(states[c],state)
- instr = false
- texwrite(c)
- state = finishstate(state)
- else
- texwrite(c)
- end
- elseif intex then
- if utffind(c,"^[%a]$") then
- if word then word = word .. c else word = c end
- else
- state, intex = flush_mp_word(state, word, intex)
- word = nil
- if intex then
- texwrite(c)
- else
- state = changestate(states[c], state)
- texwrite(c)
- end
- end
- elseif utffind(c,"^[%a]$") then
- state = finishstate(state)
- if word then word = word .. c else word = c end
- else
- state, intex = flush_mp_word(state, word, intex)
- word = nil
- state = changestate(states[c], state)
- texwrite(c)
- state = finishstate(state)
- instr = (c == '"')
- end
- end
- state, intex = flush_mp_word(state, word, intex)
- state = finishstate(state)
-end
diff --git a/tex/context/base/pret-tex.lua b/tex/context/base/pret-tex.lua
deleted file mode 100644
index 0baf576c8..000000000
--- a/tex/context/base/pret-tex.lua
+++ /dev/null
@@ -1,92 +0,0 @@
-if not modules then modules = { } end modules ['pret-tex'] = {
- version = 1.001,
- comment = "companion to buff-ver.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
-local utf = unicode.utf8
-
-local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues
-local utfbyte, utffind = utf.byte, utf.find
-local texwrite = tex.write
-
-local buffers = buffers
-local context = context
-
-local changestate, finishstate = buffers.changestate, buffers.finishstate
-
-local visualizer = buffers.newvisualizer("tex")
-
-local colors = {
- "prettytwo",
- "prettyone",
- "prettythree",
- "prettyfour"
-}
-
-local states = {
- ['$']=2, ['{']=2, ['}']=2,
- ['[']=3, [']']=3, ['(']=3, [')']=3, ['<']=3, ['>']=3, ['#']=3, ['=']=3, ['"']=3,
- ['/']=4, ['^']=4, ['_']=4, ['-']=4, ['&']=4, ['+']=4, ["'"]=4, ['`']=4, ['|']=4, ['%']=4
-}
-
--- some day I'll make an lpeg
-
-local chardata = characters.data
-local is_letter = characters.is_letter
-
-local space = context.obs
-
-function visualizer.flush_line(str,nested)
- local state, first, i = 0, false, 0
- buffers.currentcolors = colors
- for c in utfcharacters(str) do
- i = i + 1
- if c == " " then
- state = finishstate(state)
- space()
- first = false
- elseif c == "\t" then
- state = finishstate(state)
- space()
- if buffers.visualizers.enabletab then
- for i=1,i%buffers.visualizers.tablength do
- space()
- end
- i = 0
- end
- first = false
- elseif first then
- state = 1
- texwrite(c)
- if not utffind(c,"^[%a%!%?%@]$") then
- state = finishstate(state)
- end
- first = false
- elseif state == 1 then
- if utffind(c,"^[%a%!%?%@]$") then
- texwrite(c)
- first = false
- elseif c == "\\" then
- state = changestate(1, state)
- texwrite(c)
- first = true
- else
- state = changestate(states[c], state)
- texwrite(c)
- first = false
- end
- elseif c == "\\" then
- first = true
- state = changestate(1, state)
- texwrite(c)
- else
- state = changestate(states[c], state)
- texwrite(c)
- first = false
- end
- end
- state = finishstate(state)
-end
diff --git a/tex/context/base/pret-xml.lua b/tex/context/base/pret-xml.lua
deleted file mode 100644
index 0a79ed78a..000000000
--- a/tex/context/base/pret-xml.lua
+++ /dev/null
@@ -1,140 +0,0 @@
-if not modules then modules = { } end modules ['pret-xml'] = {
- version = 1.001,
- comment = "companion to buff-ver.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- line by line, no check because can be snippet (educational) and
--- a somewhat simplified view on xml; we forget about dtd's and
--- cdata (some day i'll make a visualizer for valid xml using the
--- built in parser)
-
-local utf = unicode.utf8
-local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues
-local utfbyte, utffind = utf.byte, utf.find
-local texwrite = tex.write
-
-local buffers = buffers
-local context = context
-
-local changestate, finishstate = buffers.changestate, buffers.finishstate
-
-local visualizer = buffers.newvisualizer("xml")
-
-local colors = {
- "prettytwo",
- "prettyone",
- "prettythree",
- "prettyfour"
-}
-
-local states = {
- ['"']=2, ["'"]=2,
- ["-"]=1, ["?"]=1, ["!"]=1, [":"]=1, ["_"]=1, ["/"]=1,
-}
-
-local state, intag, dotag, inentity, inquote
-
-function visualizer.reset()
- state, intag, dotag, inentity, inquote = 0, false, false, false, false
-end
-
-local space = context.obs
-
-function visualizer.flush_line(str,nested)
- buffers.currentcolors = colors
- for c in utfcharacters(str) do
- if c == "&" then
- inentity = true -- no further checking
- state = changestate(3, state)
- texwrite(c)
- elseif c == ";" then
- if inentity then
- inentity = false
- state = changestate(3, state)
- texwrite(c)
- state = finishstate(state)
- else
- texwrite(c)
- end
- elseif inentity then
- state = changestate(3, state)
- texwrite(c)
- elseif c == " " then
- state = finishstate(state)
- space()
- intag = false
- elseif c == "\t" then
- state = finishstate(state)
- space()
- if buffers.visualizers.enabletab then
- for i=1,i%buffers.visualizers.tablength do
- space()
- end
- end
- intag = false
- elseif c == "<" then
- if intag then
- state = finishstate(state)
- -- error
- else
- intag = 1
- dotag = true
- state = changestate(1, state)
- end
- texwrite(c)
- elseif c == ">" then
- if intag then
- texwrite(c)
- state = finishstate(state)
- intag, dotag = false, false
- elseif dotag then
- state = changestate(1, state)
- texwrite(c)
- state = finishstate(state)
- intag, dotag = false, false
- else
- state = finishstate(state)
- texwrite(c)
- end
- elseif intag then
- if utffind(c,"^[%S]$") then
- state = changestate(1, state)
- texwrite(c)
- intag = intag + 1
- else
- intag = false
- state = finishstate(state)
- texwrite(c)
- end
- elseif dotag then
- if c == "'" or c == '"' then
- if inquote then
- if c == inquote then
- state = changestate(states[c], state) -- 2
- texwrite(c)
- state = finishstate(state)
- inquote = false
- else
- texwrite(c)
- end
- else
- inquote = c
- state = changestate(states[c], state)
- texwrite(c)
- state = finishstate(state)
- end
- elseif inquote then
- texwrite(c)
- else
- state = changestate(states[c], state)
- texwrite(c)
- end
- else
- texwrite(c)
- end
- end
- state = finishstate(state)
-end
diff --git a/tex/context/base/v-parsed-xml.lua b/tex/context/base/v-parsed-xml.lua
new file mode 100644
index 000000000..530060b57
--- /dev/null
+++ b/tex/context/base/v-parsed-xml.lua
@@ -0,0 +1,101 @@
+if not modules then modules = { } end modules ['v-parsed-xml'] = {
+ version = 1.001,
+ comment = "companion to v-parsed-xml.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local format = string.format
+
+local context = context
+local verbatim = context.verbatim
+
+local write = visualizers.write
+local writespace = visualizers.writespace
+local writeargument = visualizers.writeargument
+
+local ParsedXmlSnippetKey = context.ParsedXmlSnippetKey
+local ParsedXmlSnippetValue = context.ParsedXmlSnippetValue
+
+local ParsedXmlSnippetElement = verbatim.ParsedXmlSnippetElement
+local ParsedXmlSnippetInstruction = verbatim.ParsedXmlSnippetInstruction
+local ParsedXmlSnippetComment = verbatim.ParsedXmlSnippetComment
+local ParsedXmlSnippetCdata = verbatim.ParsedXmlSnippetCdata
+local ParsedXmlSnippetDoctype = verbatim.ParsedXmlSnippetDoctype
+
+local startParsedXmlSnippet = context.startParsedXmlSnippet
+local stopParsedXmlSnippet = context.stopParsedXmlSnippet
+
+local parsedxmlhandler = xml.newhandlers { -- todo: treat spaces and tabs
+ name = "parsedxml",
+ handle = function(...)
+ print("error:",...) -- we need a handler as fallback, even if not used
+ end,
+ functions = {
+ ["@el@"] = function(e,handler)
+ local at = e.at
+ if at and next(at) then
+ ParsedXmlSnippetElement(format("<%s",e.tg))
+ for k, v in next, at do
+ writespace()
+ ParsedXmlSnippetKey()
+ writeargument(k)
+ verbatim("=")
+ ParsedXmlSnippetValue()
+ writeargument(format("%q",k))
+ end
+ ParsedXmlSnippetElement(">")
+ else
+ ParsedXmlSnippetElement(format("<%s>",e.tg))
+ end
+ handler.serialize(e.dt,handler)
+ ParsedXmlSnippetElement(format("</%s>",e.tg))
+ end,
+ ["@pi@"] = function(e,handler)
+ ParsedXmlSnippetInstruction("<?")
+ write(e.dt[1])
+ ParsedXmlSnippetInstruction("?>")
+ end ,
+ ["@cm@"] = function(e,handler)
+ ParsedXmlSnippetComment("<!--")
+ write(e.dt[1])
+ ParsedXmlSnippetComment("-->")
+ end,
+ ["@cd@"] = function(e,handler)
+ ParsedXmlSnippetCdata("<![CDATA[")
+ write(e.dt[1])
+ ParsedXmlSnippetCdata("]]>")
+ end,
+ ["@dt@"] = function(e,handler)
+ ParsedXmlSnippetDoctype("<!DOCTYPE")
+ write(e.dt[1])
+ ParsedXmlSnippetDoctype(">")
+ end,
+ ["@tx@"] = function(s,handler)
+ write(s)
+ end,
+ }
+}
+
+local function parsedxml(root,pattern)
+ if root then
+ if pattern then
+ root = xml.filter(root,pattern)
+ end
+ if root then
+ context.startParsedXmlSnippet()
+ xml.serialize(root,parsedxmlhandler)
+ context.stopParsedXmlSnippet()
+ end
+ end
+end
+
+local function parser(str,settings)
+ parsedxml(xml.convert(str),settings and settings.pattern)
+end
+
+visualizers.parsedxml = parsedxml -- for use at the lua end (maybe namespace needed)
+
+visualizers.register("parsed-xml", { parser = parser } )
+
diff --git a/tex/context/base/v-parsed-xml.mkiv b/tex/context/base/v-parsed-xml.mkiv
new file mode 100644
index 000000000..2e45df2c8
--- /dev/null
+++ b/tex/context/base/v-parsed-xml.mkiv
@@ -0,0 +1,68 @@
+%D \module
+%D [ file=v-parsed-xml,
+%D version=2010.10.19,
+%D title=\CONTEXT\ Visualizer Macros,
+%D subtitle=Parsed \XML,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright=PRAGMA-ADE]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\registerctxluafile{v-parsed-xml.lua}{1.001}
+
+\unprotect
+
+\definestartstop
+ [ParsedXmlSnippet]
+ [%\c!before=\blank,
+ %\c!after=\blank,
+ \c!style=\tt]
+
+\definestartstop
+ [ParsedXmlSnippetDocType]
+ [\c!style=boldface,
+ \c!color=darkgreen]
+
+\definestartstop
+ [ParsedXmlSnippetElement]
+ [\c!style=boldface,
+ \c!color=darkblue]
+
+\definestartstop
+ [ParsedXmlSnippetInstruction]
+ [\c!style=boldface,
+ \c!color=darkgreen]
+
+\definestartstop
+ [ParsedXmlSnippetCdata]
+ [\c!style=boldface,
+ \c!color=darkgreen]
+
+\definestartstop
+ [ParsedXmlSnippetComment]
+ [\c!style=boldface,
+ \c!color=darkgreen]
+
+\definestartstop
+ [ParsedXmlSnippetKey]
+ [\c!style=boldface,
+ \c!color=darkred]
+
+% \definestartstop
+% [ParsedXmlSnippetQuote]
+% [\c!style=,
+% \c!color=]
+
+\definestartstop
+ [ParsedXmlSnippetValue]
+ [\c!style=,
+ \c!color=]
+
+\definetyping
+ [PARSEDXML]
+ [option=parsed-xml]
+
+\protect \endinput
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index 7bda5cade..7685bb12c 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 : 11/26/10 22:03:31
+-- merge date : 11/26/10 22:49:55
do -- begin closure to overcome local limits and interference