diff options
author | Hans Hagen <pragma@wxs.nl> | 2011-09-27 20:05:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2011-09-27 20:05:00 +0200 |
commit | 7d5303b65f33ee0ea99f83f9a7aaa4672a405660 (patch) | |
tree | cad2e7cd1c6a7e2345b469e4f80191589ff46c40 | |
parent | 0708cb2babdfd4c6f9cb86dd408992716a0e99cf (diff) | |
download | context-7d5303b65f33ee0ea99f83f9a7aaa4672a405660.tar.gz |
beta 2011.09.27 20:05
55 files changed, 783 insertions, 283 deletions
diff --git a/context/data/scite/lexers/scite-context-lexer-lua.lua b/context/data/scite/lexers/scite-context-lexer-lua.lua index 62577d4a9..1b55be55f 100644 --- a/context/data/scite/lexers/scite-context-lexer-lua.lua +++ b/context/data/scite/lexers/scite-context-lexer-lua.lua @@ -100,10 +100,10 @@ local shortcomment = token("comment", dashes * lexer.nonnewline^0) local longcomment = token("comment", dashes * longcomment) local shortstring = token("quote", dquote) - * token("string", (escaped + (1-dquote))^0 ) + * token("string", (escaped + (1-dquote))^0) * token("quote", dquote) + token("quote", squote) - * token("string", (escaped + (1-squote))^0 ) + * token("string", (escaped + (1-squote))^0) * token("quote", squote) local longstring = token("quote", longonestart) diff --git a/context/data/scite/lexers/scite-context-lexer-mps.lua b/context/data/scite/lexers/scite-context-lexer-mps.lua index afde63bcc..d374f7f82 100644 --- a/context/data/scite/lexers/scite-context-lexer-mps.lua +++ b/context/data/scite/lexers/scite-context-lexer-mps.lua @@ -8,13 +8,15 @@ local info = { local lexer = lexer local global, string, table, lpeg = _G, string, table, lpeg -local token, style, colors, exact_match, no_style = lexer.token, lexer.style, lexer.colors, lexer.exact_match, lexer.style_nothing +local token, exact_match = lexer.token, lexer.exact_match local P, R, S, V, C, Cmt = lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.C, lpeg.Cmt -local type, next, pcall, loadfile = type, next, pcall, loadfile +local type = type module(...) -local metafunlexer = _M +local metafunlexer = _M + +local context = lexer.context local metafunhelpers = { } local metafunconstants = { } @@ -23,14 +25,14 @@ local primitivecommands = { } do - local definitions = lexer.context.loaddefinitions("scite-context-data-metapost") + local definitions = context.loaddefinitions("scite-context-data-metapost") if definitions then plaincommands = definitions.plain or { } primitivecommands = definitions.primitives or { } end - local definitions = lexer.context.loaddefinitions("scite-context-data-metafun") + local definitions = context.loaddefinitions("scite-context-data-metafun") if definitions then metafunhelpers = definitions.helpers or { } @@ -44,16 +46,9 @@ local whitespace = metafunlexer.WHITESPACE -- triggers states local space = lexer.space -- S(" \n\r\t\f\v") local any = lexer.any -local digit = R("09") -local sign = S("+-") -local period = P(".") local dquote = P('"') local cstoken = R("az","AZ") + P("_") -local number = sign^-1 * ( -- at most one - digit^1 * period * digit^0 -- 10.0 10. - + digit^0 * period * digit^1 -- 0.10 .10 - + digit^1 -- 10 - ) +local number = context.patterns.real local cstokentex = R("az","AZ","\127\255") + S("@!?_") @@ -66,10 +61,10 @@ local constant = token('data', exact_match(metafunconstants)) local helper = token('command', exact_match(metafunhelpers)) local plain = token('plain', exact_match(plaincommands)) local quoted = token('quote', dquote) - * token('string', P(1-dquote)^1) + * token('string', P(1-dquote)^0) * token('quote', dquote) local primitive = token('primitive', exact_match(primitivecommands)) -local identifier = token('default', cstoken) +local identifier = token('default', cstoken^1) local number = token('number', number) local special = token('special', S("#()[]<>=:\"")) -- or else := <> etc split local texlike = token('string', P("\\") * cstokentex^1) @@ -86,12 +81,12 @@ _rules = { { 'number', number }, { 'quoted', quoted }, { 'special', special }, --- { 'texlike', texlike }, + -- { 'texlike', texlike }, { 'extra', extra }, { 'rest', rest }, } -_tokenstyles = lexer.context.styleset +_tokenstyles = context.styleset _foldsymbols = { _patterns = { diff --git a/context/data/scite/lexers/scite-context-lexer-pdf-object.lua b/context/data/scite/lexers/scite-context-lexer-pdf-object.lua new file mode 100644 index 000000000..1de006813 --- /dev/null +++ b/context/data/scite/lexers/scite-context-lexer-pdf-object.lua @@ -0,0 +1,115 @@ +local info = { + version = 1.002, + comment = "scintilla lpeg lexer for pdf", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files", +} + +local lexer = lexer +local token = lexer.token +local P, R, S, C, V = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.V +local global = _G + +module(...) + +local objectlexer = _M + +local context = lexer.context +local patterns = context.patterns + +local whitespace = objectlexer.WHITESPACE -- triggers states + +local space = lexer.space +local somespace = space^1 + +local newline = S("\n\r") +local real = patterns.real +local cardinal = patterns.cardinal + +local lparent = P("(") +local rparent = P(")") +local langle = P("<") +local rangle = P(">") +local escape = P("\\") +local anything = P(1) +local unicodetrigger = P("feff") + +local nametoken = 1 - space - S("<>/[]()") +local name = P("/") * nametoken^1 + +local p_string = P { ( escape * anything + lparent * V(1) * rparent + (1 - rparent) )^0 } + +local t_spacing = token(whitespace, space^1) +local t_spaces = token(whitespace, space^1)^0 + +local p_stream = P("stream") +local p_endstream = P("endstream") +----- p_obj = P("obj") +local p_endobj = P("endobj") +local p_reference = P("R") + +local p_objectnumber = patterns.cardinal +local p_comment = P('%') * (1-S("\n\r"))^0 + +local string = token("quote", lparent) + * token("string", p_string) + * token("quote", rparent) +local unicode = token("quote", langle) + * token("plain", unicodetrigger) + * token("string", (1-rangle)^1) + * token("quote", rangle) +local whatsit = token("quote", langle) + * token("string", (1-rangle)^1) + * token("quote", rangle) +local keyword = token("command", name) +local constant = token("constant", name) +local number = token('number', real) +local reference = token("number", cardinal) + * t_spacing + * token("number", cardinal) + * t_spacing + * token("keyword", p_reference) +local t_comment = token("comment", p_comment) + +-- t_openobject = token("number", p_objectnumber) +-- * t_spacing +-- * token("number", p_objectnumber) +-- * t_spacing +-- * token("keyword", p_obj) +local t_closeobject = token("keyword", p_endobj) + +local t_opendictionary = token("grouping", P("<<")) +local t_closedictionary = token("grouping", P(">>")) + +local t_openarray = token("grouping", P("[")) +local t_closearray = token("grouping", P("]")) + +local t_stream = token("keyword", p_stream) +-- * token("default", newline * (1-newline*p_endstream*newline)^1 * newline) + * token("default", (1 - p_endstream)^1) + * token("keyword", p_endstream) + +local t_dictionary = { "dictionary", + dictionary = t_opendictionary * (t_spaces * keyword * t_spaces * V("whatever"))^0 * t_spaces * t_closedictionary, + array = t_openarray * (t_spaces * V("whatever"))^0 * t_spaces * t_closearray, + whatever = V("dictionary") + V("array") + constant + reference + string + unicode + number + whatsit, + } + +local t_object = { "object", -- weird that we need to catch the end here (probably otherwise an invalid lpeg) + object = t_spaces * (V("dictionary") * t_spaces * t_stream^-1 + V("array") + t_spaces) * t_spaces * t_closeobject, + dictionary = t_opendictionary * (t_spaces * keyword * t_spaces * V("whatever"))^0 * t_spaces * t_closedictionary, + array = t_openarray * (t_spaces * V("whatever"))^0 * t_spaces * t_closearray, + whatever = V("dictionary") + V("array") + constant + reference + string + unicode + number + whatsit, + } + +_shared = { + dictionary = t_dictionary, +} + +_rules = { + { 'whitespace', t_spacing }, + { 'object', t_object }, +} + +_tokenstyles = context.styleset diff --git a/context/data/scite/lexers/scite-context-lexer-pdf-xref.lua b/context/data/scite/lexers/scite-context-lexer-pdf-xref.lua new file mode 100644 index 000000000..8988fbbb4 --- /dev/null +++ b/context/data/scite/lexers/scite-context-lexer-pdf-xref.lua @@ -0,0 +1,41 @@ +local info = { + version = 1.002, + comment = "scintilla lpeg lexer for pdf", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files", +} + +local lexer = lexer +local token = lexer.token +local P = lpeg.P +local global = _G + +module(...) + +local pdflexer = _M +local objectlexer = lexer.load("scite-context-lexer-pdf-object") + +local context = lexer.context +local patterns = context.patterns + +local whitespace = pdflexer.WHITESPACE -- triggers states + +local space = patterns.space +local spacing = patterns.spacing + +local t_spacing = token(whitespace, spacing) + +local p_trailer = P("trailer") + +local t_xref = token("default", (1-p_trailer)^1) + * token("keyword", p_trailer) + * t_spacing + * objectlexer._shared.dictionary + +_rules = { + { 'whitespace', t_spacing }, + { 'xref', t_xref }, +} + +_tokenstyles = context.styleset diff --git a/context/data/scite/lexers/scite-context-lexer-pdf.lua b/context/data/scite/lexers/scite-context-lexer-pdf.lua new file mode 100644 index 000000000..ebc3fba4f --- /dev/null +++ b/context/data/scite/lexers/scite-context-lexer-pdf.lua @@ -0,0 +1,63 @@ +local info = { + version = 1.002, + comment = "scintilla lpeg lexer for pdf", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files", +} + +local lexer = lexer +local token = lexer.token +local P, R, S = lpeg.P, lpeg.R, lpeg.S +local global = _G + +module(...) + +local pdflexer = _M +local objectlexer = lexer.load("scite-context-lexer-pdf-object") +local xreflexer = lexer.load("scite-context-lexer-pdf-xref") + +local context = lexer.context +local patterns = context.patterns + +local whitespace = pdflexer.WHITESPACE -- triggers states + +local space = patterns.space +local spacing = patterns.spacing +local nospacing = patterns.nospacing +local anything = patterns.anything +local restofline = patterns.restofline + +local t_spacing = token(whitespace, spacing) +local t_rest = token("default", nospacing) -- anything + +local p_obj = P("obj") +local p_endobj = P("endobj") +local p_xref = P("xref") +local p_startxref = P("startxref") + +local p_objectnumber = patterns.cardinal +local p_comment = P('%') * restofline + +local t_comment = token("comment", p_comment) +local t_openobject = token("number", p_objectnumber) + * t_spacing + * token("number", p_objectnumber) + * t_spacing + * token("keyword", p_obj) + * t_spacing^0 +local t_closeobject = token("keyword", p_endobj) + +local t_openxref = token("keyword", p_xref) +local t_closexref = token("keyword", p_startxref) + +lexer.embed_lexer(pdflexer, objectlexer, t_openobject, t_closeobject) +lexer.embed_lexer(pdflexer, xreflexer, t_openxref, t_closexref) + +_rules = { + { 'whitespace', t_spacing }, + { 'comment', t_comment }, + { 'rest', t_rest }, +} + +_tokenstyles = context.styleset diff --git a/context/data/scite/lexers/scite-context-lexer-tex.lua b/context/data/scite/lexers/scite-context-lexer-tex.lua index cea0aa544..8204ae3a0 100644 --- a/context/data/scite/lexers/scite-context-lexer-tex.lua +++ b/context/data/scite/lexers/scite-context-lexer-tex.lua @@ -34,9 +34,9 @@ local info = { local lexer = lexer local global, string, table, lpeg = _G, string, table, lpeg -local token, style, colors, exact_match, no_style = lexer.token, lexer.style, lexer.colors, lexer.exact_match, lexer.style_nothing +local token, exact_match = lexer.token, lexer.exact_match local P, R, S, V, C, Cmt, Cp, Cc, Ct = lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.C, lpeg.Cmt, lpeg.Cp, lpeg.Cc, lpeg.Ct -local type, next, pcall, loadfile, setmetatable = type, next, pcall, loadfile, setmetatable +local type, next = type, next local find, match, lower = string.find, string.match, string.lower module(...) @@ -45,14 +45,16 @@ local contextlexer = _M local cldlexer = lexer.load('scite-context-lexer-cld') local mpslexer = lexer.load('scite-context-lexer-mps') -local commands = { en = { } } -local primitives = { } -local helpers = { } -local constants = { } +local commands = { en = { } } +local primitives = { } +local helpers = { } +local constants = { } + +local context = lexer.context do -- todo: only once, store in global - local definitions = lexer.context.loaddefinitions("scite-context-data-interfaces") + local definitions = context.loaddefinitions("scite-context-data-interfaces") if definitions then for interface, list in next, definitions do @@ -72,14 +74,14 @@ do -- todo: only once, store in global end end - local definitions = lexer.context.loaddefinitions("scite-context-data-context") + local definitions = context.loaddefinitions("scite-context-data-context") if definitions then helpers = definitions.helpers or { } constants = definitions.constants or { } end - local definitions = lexer.context.loaddefinitions("scite-context-data-tex") + local definitions = context.loaddefinitions("scite-context-data-tex") if definitions then local function add(data) @@ -109,9 +111,10 @@ local knowncommand = Cmt(cstoken^1, function(_,i,s) return currentcommands[s] and i end) -local wordpattern = lexer.context.wordpattern -local checkedword = lexer.context.checkedword -local setwordlist = lexer.context.setwordlist +local wordtoken = context.patterns.wordtoken +local wordpattern = context.patterns.wordpattern +local checkedword = context.checkedword +local setwordlist = context.setwordlist local validwords = false -- % language=uk @@ -121,11 +124,11 @@ local knownpreamble = Cmt(#P("% "), function(input,i,_) -- todo : utfbomb validwords = false local s, e, word = find(input,'^(.+)[\n\r]',i) -- combine with match if word then - local interface = match(word,"interface=(..)") + local interface = match(word,"interface=([a-z]+)") if interface then currentcommands = commands[interface] or commands.en or { } end - local language = match(word,"language=(..)") + local language = match(word,"language=([a-z]+)") validwords = language and setwordlist(language) end end @@ -170,6 +173,8 @@ end) -- experiment: keep space with whatever ... less tables +-- 10pt + local commentline = P('%') * (1-S("\n\r"))^0 local endline = S("\n\r")^1 @@ -194,7 +199,10 @@ local p_csname = backslash * (cstoken^1 + P(1)) local p_grouping = S("{$}") local p_special = S("#()[]<>=\"") local p_extra = S("`~%^&_-+/\'|") -local p_text = cstoken^1 --maybe add punctuation and space +local p_text = wordtoken^1 --maybe add punctuation and space + +local p_number = context.patterns.real +local p_unit = P("pt") + P("bp") + P("sp") + P("mm") + P("cm") + P("cc") + P("dd") -- no looking back = #(1-S("[=")) * cstoken^3 * #(1-S("=]")) @@ -283,10 +291,11 @@ local primitive = token('primitive', p_primitive ) local ifprimitive = token('primitive', p_ifprimitive) local csname = token('user', p_csname ) local grouping = token('grouping', p_grouping ) +local number = token('number', p_number ) + * token('constant', p_unit ) local special = token('special', p_special ) local extra = token('extra', p_extra ) ------ text = token('default', p_text ) ------ word = token("okay", p_word ) +local text = token('default', p_text ) local word = p_word ----- startluacode = token("grouping", P("\\startluacode")) @@ -306,7 +315,7 @@ end local function stopdisplaylua(_,i,s) local ok = luatag == s if ok then -cldlexer._directives.cld_inline = false + cldlexer._directives.cld_inline = false luastatus = false end return ok @@ -344,7 +353,7 @@ local function stopinlinelua_e(_,i,s) -- } lualevel = lualevel - 1 local ok = lualevel <= 0 if ok then -cldlexer._directives.cld_inline = false + cldlexer._directives.cld_inline = false luastatus = false end return ok @@ -395,7 +404,7 @@ _rules = { { "whitespace", spacing }, { "preamble", preamble }, { "word", word }, - -- { "text", text }, + { "text", text }, -- non words { "comment", comment }, { "constant", constant }, { "helper", helper }, @@ -405,12 +414,13 @@ _rules = { { "csname", csname }, -- { "whatever", specialword }, -- not yet, crashes { "grouping", grouping }, + -- { "number", number }, { "special", special }, { "extra", extra }, { "rest", rest }, } -_tokenstyles = lexer.context.styleset +_tokenstyles = context.styleset local folds = { ["\\start"] = 1, ["\\stop" ] = -1, diff --git a/context/data/scite/lexers/scite-context-lexer-txt.lua b/context/data/scite/lexers/scite-context-lexer-txt.lua new file mode 100644 index 000000000..07dff2970 --- /dev/null +++ b/context/data/scite/lexers/scite-context-lexer-txt.lua @@ -0,0 +1,69 @@ +local lexer = lexer +local token = lexer.token +local P, S, Cmt = lpeg.P, lpeg.S, lpeg.Cmt +local find, match = string.find, string.match + +module(...) + +local textlexer = _M + +local context = lexer.context + +local whitespace = textlexer.WHITESPACE -- triggers states + +local space = lexer.space +local any = lexer.any + +local wordtoken = context.patterns.wordtoken +local wordpattern = context.patterns.wordpattern +local checkedword = context.checkedword +local setwordlist = context.setwordlist +local validwords = false + +-- [#!-%] language=uk + +local p_preamble = Cmt(#(S("#!-%") * P(" ")), function(input,i,_) -- todo: utf bomb + if i == 1 then -- < 10 then + validwords = false + local s, e, line = find(input,'^[#!%-%%](.+)[\n\r]',i) + if line then + local language = match(line,"language=([a-z]+)") + if language then + validwords = setwordlist(language) + end + end + end + return false +end) + +local t_preamble = + token('preamble', p_preamble) + +local t_word = + Cmt(wordpattern, function(_,i,s) + if validwords then + return checkedword(validwords,s,i) + else + return true, { "text", i } + end + end) + +local t_text = + token("default", wordtoken^1) + +local t_rest = + token("default", (1-wordtoken-space)^1) + +local t_spacing = + token(whitespace, space^1) + +_rules = { + { "whitespace", t_spacing }, + { "preamble", t_preamble }, + { "word", t_word }, -- words >= 3 + { "text", t_text }, -- non words + { "rest", t_rest }, +} + +_tokenstyles = lexer.context.styleset + diff --git a/context/data/scite/lexers/scite-context-lexer-xml.lua b/context/data/scite/lexers/scite-context-lexer-xml.lua index 0441585c1..f8892bbce 100644 --- a/context/data/scite/lexers/scite-context-lexer-xml.lua +++ b/context/data/scite/lexers/scite-context-lexer-xml.lua @@ -14,15 +14,17 @@ local info = { local lexer = lexer local global, string, table, lpeg = _G, string, table, lpeg -local token, style, colors, exact_match, no_style = lexer.token, lexer.style, lexer.colors, lexer.exact_match, lexer.style_nothing +local token, exact_match = lexer.token, lexer.exact_match local P, R, S, V, C, Cmt = lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.C, lpeg.Cmt -local type, setmetatable = type, setmetatable +local type = type local match, find = string.match, string.find module(...) local examplelexer = _M +local context = lexer.context + local whitespace = examplelexer.WHITESPACE -- triggers states local space = lexer.space -- S(" \t\n\r\v\f") @@ -49,9 +51,9 @@ local closecdata = P("]]>") local entity = ampersand * (1-semicolon)^1 * semicolon -local wordpattern = lexer.context.wordpattern -local checkedword = lexer.context.checkedword -local setwordlist = lexer.context.setwordlist +local wordpattern = context.patterns.wordpattern +local checkedword = context.patterns.checkedword +local setwordlist = context.setwordlist local validwords = false -- <?xml version="1.0" encoding="UTF-8" language="uk" ?> @@ -72,7 +74,6 @@ local p_preamble = Cmt(#P("<?xml "), function(input,i,_) -- todo: utf bomb return false end) - local p_word = Cmt(wordpattern, function(_,i,s) if validwords then @@ -190,7 +191,7 @@ _rules = { { "rest", p_rest }, } -_tokenstyles = lexer.context.styleset +_tokenstyles = context.styleset _foldsymbols = { -- somehow doesn't work yet _patterns = { diff --git a/context/data/scite/lexers/scite-context-lexer.lua b/context/data/scite/lexers/scite-context-lexer.lua index a2bb35a57..13b8d77a8 100644 --- a/context/data/scite/lexers/scite-context-lexer.lua +++ b/context/data/scite/lexers/scite-context-lexer.lua @@ -41,7 +41,11 @@ local type, next, setmetatable, rawset = type, next, setmetatable, rawset dofile(_LEXERHOME .. '/lexer.lua') -lexer.context = lexer.context or { } +lexer.context = lexer.context or { } +local context = lexer.context + +context.patterns = context.patterns or { } +local patterns = context.patterns local locations = { -- lexer.context.path, @@ -87,7 +91,7 @@ end -- end -- end -function lexer.context.loaddefinitions(name) +function context.loaddefinitions(name) for i=1,#locations do local data = collect(locations[i] .. "/" .. name) if data then @@ -98,7 +102,7 @@ end -- maybe more efficient: -function lexer.context.word_match(words,word_chars,case_insensitive) +function context.word_match(words,word_chars,case_insensitive) local chars = '%w_' -- maybe just "" when word_chars if word_chars then chars = '^([' .. chars .. gsub(word_chars,'([%^%]%-])', '%%%1') ..']+)' @@ -128,16 +132,42 @@ end -- nicer (todo: utf): -local defaults = R("az","AZ","\127\255","__") +local idtoken = R("az","AZ","\127\255","__") +local digit = R("09") +local sign = S("+-") +local period = P(".") +local space = S(" \n\r\t\f\v") + +patterns.idtoken = idtoken + +patterns.digit = digit +patterns.sign = sign +patterns.period = period + +patterns.cardinal = digit^1 +patterns.integer = sign^-1 * digit^1 -function lexer.context.exact_match(words,word_chars,case_insensitive) +patterns.real = + sign^-1 * ( -- at most one + digit^1 * period * digit^0 -- 10.0 10. + + digit^0 * period * digit^1 -- 0.10 .10 + + digit^1 -- 10 + ) + +patterns.restofline = (1-S("\n\r"))^1 +patterns.space = space +patterns.spacing = space^1 +patterns.nospacing = (1-space)^1 +patterns.anything = P(1) + +function context.exact_match(words,word_chars,case_insensitive) local characters = concat(words) local pattern -- the concat catches _ etc if word_chars == true or word_chars == false or word_chars == nil then word_chars = "" end if type(word_chars) == "string" then - pattern = S(characters) + defaults + pattern = S(characters) + idtoken if case_insensitive then pattern = pattern + S(upper(characters)) + S(lower(characters)) end @@ -166,7 +196,6 @@ function lexer.context.exact_match(words,word_chars,case_insensitive) end end - -- spell checking (we can only load lua files) -- return { @@ -185,13 +214,13 @@ local function splitwords(words) return lpegmatch(splitter,words) end -function lexer.context.setwordlist(tag,limit) -- returns hash (lowercase keys and original values) +function context.setwordlist(tag,limit) -- returns hash (lowercase keys and original values) if not tag or tag == "" then return false elseif lists[tag] ~= nil then return lists[tag] else - local list = lexer.context.loaddefinitions("spell-" .. tag) + local list = context.loaddefinitions("spell-" .. tag) if not list or type(list) ~= "table" then lists[tag] = false return nil @@ -207,9 +236,10 @@ function lexer.context.setwordlist(tag,limit) -- returns hash (lowercase keys an end end -lexer.context.wordpattern = R("az","AZ","\127\255")^3 -- todo: if limit and #s < limit then +patterns.wordtoken = R("az","AZ","\127\255") +patterns.wordpattern = patterns.wordtoken^3 -- todo: if limit and #s < limit then -function lexer.context.checkedword(validwords,s,i) -- ,limit +function context.checkedword(validwords,s,i) -- ,limit if not validwords then return true, { "text", i } else @@ -302,7 +332,7 @@ local splitlines = ( ( + ( newline ) / function() action_n() end ) )^0 -function lexer.context.fold(text, start_pos, start_line, start_level) +function context.fold(text, start_pos, start_line, start_level) if text == '' then return { } end @@ -413,7 +443,7 @@ function lexer.context.fold(text, start_pos, start_line, start_level) return folds end -function lexer.context.lex(text,init_style) +function context.lex(text,init_style) local lexer = global._LEXER local grammar = lexer._GRAMMAR if not grammar then @@ -499,11 +529,11 @@ end -- todo: keywords: one lookup and multiple matches -function lexer.context.token(name, patt) +function context.token(name, patt) return Ct(patt * Cc(name) * Cp()) end -lexer.fold = lexer.context.fold -lexer.lex = lexer.context.lex -lexer.token = lexer.context.token -lexer.exact_match = lexer.context.exact_match +lexer.fold = context.fold +lexer.lex = context.lex +lexer.token = context.token +lexer.exact_match = context.exact_match diff --git a/context/data/scite/scite-context-external.properties b/context/data/scite/scite-context-external.properties index 14bdd222f..021c72133 100644 --- a/context/data/scite/scite-context-external.properties +++ b/context/data/scite/scite-context-external.properties @@ -24,6 +24,8 @@ lexer.$(file.patterns.context)=lpeg_scite-context-lexer-tex lexer.$(file.patterns.tex)=lpeg_scite-context-lexer-tex lexer.$(file.patterns.lua)=lpeg_scite-context-lexer-lua lexer.$(file.patterns.example)=lpeg_scite-context-lexer-xml +lexer.$(file.patterns.text)=lpeg_scite-context-lexer-txt +lexer.$(file.patterns.pdf)=lpeg_scite-context-lexer-pdf comment.block.lpeg_scite-context-lexer-tex=% comment.block.at.line.start.lpeg_scite-context-lexer-tex=1 @@ -37,9 +39,6 @@ comment.block.at.line.start.lpeg_scite-context-lexer-lua=1 comment.block.lpeg_scite-context-lexer-cld=-- comment.block.at.line.start.lpeg_scite-context-lexer-cld=1 -#~ comment.block.lpeg_scite-context-lexer-xml=<!-- -#~ comment.block.at.line.start.lpeg_scite-context-lexer-xml=1 - comment.block.lpeg_props=# comment.block.at.line.start.lpeg_props=1 diff --git a/context/data/scite/scite-context.properties b/context/data/scite/scite-context.properties index 03df9fb75..5e57d8fcd 100644 --- a/context/data/scite/scite-context.properties +++ b/context/data/scite/scite-context.properties @@ -60,6 +60,18 @@ lexer.$(file.patterns.lua)=lua command.compile.$(file.patterns.lua)=mtxrun --script "$(FileNameExt)" command.go.$(file.patterns.lua)=mtxrun --script "$(FileNameExt)" +# Test: patterns + +file.patterns.text=*.txt + +filter.text=Text |$(file.patterns.text)| + +file.patterns.pdf=*.pdf + +filter.pdf=PDF |$(file.patterns.pdf)| + +# lexer.$(file.patterns.txt)=txt + # Commands: some scripts if PLAT_WIN diff --git a/metapost/context/base/mp-char.mp b/metapost/context/base/mp-char.mp index 786c1f904..fd9e33848 100644 --- a/metapost/context/base/mp-char.mp +++ b/metapost/context/base/mp-char.mp @@ -37,7 +37,6 @@ grid_width := 60pt ; grid_height := 40pt ; shape_width := 45pt ; shape_height := 30pt ; chart_offset := 2pt ; - color chart_background_color ; chart_background_color := white ; %D test mode diff --git a/scripts/context/lua/mtx-check.lua b/scripts/context/lua/mtx-check.lua index e0ab3b882..38ab2254a 100644 --- a/scripts/context/lua/mtx-check.lua +++ b/scripts/context/lua/mtx-check.lua @@ -6,6 +6,9 @@ if not modules then modules = { } end modules ['mtx-check'] = { license = "see context related readme files" } +local P, R, S, V, C, CP, CC, lpegmatch = lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.C, lpeg.Cp, lpeg.Cc, lpeg.match +local gsub, sub, format = string.gsub, string.sub, string.format + local helpinfo = [[ --convert check tex file for errors ]] @@ -31,21 +34,23 @@ validator.direct = false validator.printer = print validator.tracer = print -local message = function(position, kind) +local message = function(position, kind, extra) local ve = validator.errors - ve[#ve+1] = { kind, position, validator.n } + ve[#ve+1] = { kind, position, validator.n, extra } if validator.direct then - validator.printer(string.format("%s error at position %s (line %s)", kind, position, validator.n)) + if extra then + validator.printer(format("%s error at position %s (line %s) (%s)",kind,position,validator.n,extra)) + else + validator.printer(format("%s error at position %s (line %s)",kind,position,validator.n)) + end end end local progress = function(position, data, kind) if validator.trace then - validator.tracer(string.format("%s at position %s: %s", kind, position, data or "")) + validator.tracer(format("%s at position %s: %s", kind, position, data or "")) end end -local P, R, S, V, C, CP, CC = lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.C, lpeg.Cp, lpeg.Cc - local i_m, d_m = P("$"), P("$$") local l_s, r_s = P("["), P("]") local l_g, r_g = P("{"), P("}") @@ -61,44 +66,56 @@ local newline = crlf + cr + lf local line = newline / function() validator.n = validator.n + 1 end --- local grammar = P { "tokens", --- ["tokens"] = (V("whatever") + V("grouped") + V("setup") + V("display") + V("inline") + V("errors") + 1)^0, --- ["whatever"] = line + esc * 1 + C(P("%") * (1-line)^0), --- ["grouped"] = CP() * C(l_g * (V("whatever") + V("grouped") + V("setup") + V("display") + V("inline") + (1 - l_g - r_g))^0 * r_g) * CC("group") / progress, --- ["setup"] = CP() * C(l_s * (V("whatever") + V("grouped") + V("setup") + V("display") + V("inline") + (1 - l_s - r_s))^0 * r_s) * CC("setup") / progress, --- ["display"] = CP() * C(d_m * (V("whatever") + V("grouped") + (1 - d_m))^0 * d_m) * CC("display") / progress, --- ["inline"] = CP() * C(i_m * (V("whatever") + V("grouped") + (1 - i_m))^0 * i_m) * CC("inline") / progress, --- ["errors"] = (V("gerror") + V("serror") + V("derror") + V("ierror")) * true, --- ["gerror"] = CP() * (l_g + r_g) * CC("grouping") / message, --- ["serror"] = CP() * (l_s + r_g) * CC("setup error") / message, --- ["derror"] = CP() * d_m * CC("display math error") / message, --- ["ierror"] = CP() * i_m * CC("inline math error") / message, --- } - local startluacode = P("\\startluacode") local stopluacode = P("\\stopluacode") local somecode = startluacode * (1-stopluacode)^1 * stopluacode +local stack = { } + +local function push(p,s) +-- print("start",p,s) + table.insert(stack,{ p, s }) +end + +local function pop(p,s) +-- print("stop",p,s) + local top = table.remove(stack) + if not top then + message(p,"missing start") + elseif top[2] ~= s then + message(p,"missing stop",format("see line %s",top[1])) + else + -- okay + end +end + +local cstoken = R("az","AZ","\127\255") + +local start = CP() * P("\\start") * C(cstoken^0) / push +local stop = CP() * P("\\stop") * C(cstoken^0) / pop + local grammar = P { "tokens", - ["tokens"] = (V("ignore") + V("whatever") + V("grouped") + V("setup") + V("display") + V("inline") + V("errors") + 1)^0, - ["whatever"] = line + esc * 1 + C(P("%") * (1-line)^0), - ["grouped"] = l_g * (V("whatever") + V("grouped") + V("setup") + V("display") + V("inline") + (1 - l_g - r_g))^0 * r_g, - ["setup"] = l_s * (okay + V("whatever") + V("grouped") + V("setup") + V("display") + V("inline") + (1 - l_s - r_s))^0 * r_s, - ["display"] = d_m * (V("whatever") + V("grouped") + (1 - d_m))^0 * d_m, - ["inline"] = i_m * (V("whatever") + V("grouped") + (1 - i_m))^0 * i_m, - ["errors"] = (V("gerror")+ V("serror") + V("derror") + V("ierror")), - ["gerror"] = CP() * (l_g + r_g) * CC("grouping") / message, - ["serror"] = CP() * (l_s + r_g) * CC("setup error") / message, - ["derror"] = CP() * d_m * CC("display math error") / message, - ["ierror"] = CP() * i_m * CC("inline math error") / message, - ["ignore"] = somecode, + ["tokens"] = (V("ignore") + V("start") + V("stop") + V("whatever") + V("grouped") + V("setup") + V("display") + V("inline") + V("errors") + 1)^0, + ["start"] = start, + ["stop"] = stop, + ["whatever"] = line + esc * 1 + C(P("%") * (1-line)^0), + ["grouped"] = l_g * (V("whatever") + V("grouped") + V("setup") + V("display") + V("inline") + (1 - l_g - r_g))^0 * r_g, + ["setup"] = l_s * (okay + V("whatever") + V("grouped") + V("setup") + V("display") + V("inline") + (1 - l_s - r_s))^0 * r_s, + ["display"] = d_m * (V("whatever") + V("grouped") + (1 - d_m))^0 * d_m, + ["inline"] = i_m * (V("whatever") + V("grouped") + (1 - i_m))^0 * i_m, + ["errors"] = (V("gerror")+ V("serror") + V("derror") + V("ierror")), + ["gerror"] = CP() * (l_g + r_g) * CC("grouping") / message, + ["serror"] = CP() * (l_s + r_g) * CC("setup error") / message, + ["derror"] = CP() * d_m * CC("display math error") / message, + ["ierror"] = CP() * i_m * CC("inline math error") / message, + ["ignore"] = somecode, } function validator.check(str) validator.n = 1 validator.errors = { } - grammar:match(str) + lpegmatch(grammar,str) end --~ str = [[ @@ -109,6 +126,12 @@ end --~ ]] --~ str = string.rep(str,10) +local remapper = { + ["\n"] = " <lf> ", + ["\r"] = " <cr> ", + ["\t"] = " <tab> ", +} + function scripts.checker.check(filename) local str = io.loaddata(filename) if str then @@ -117,15 +140,15 @@ function scripts.checker.check(filename) if #errors > 0 then for k=1,#errors do local v = errors[k] - local kind, position, line = v[1], v[2], v[3] - local data = str:sub(position-30,position+30) - data = data:gsub("(.)", { - ["\n"] = " <lf> ", - ["\r"] = " <cr> ", - ["\t"] = " <tab> ", - }) - data = data:gsub("^ *","") - print(string.format("% 5i %-10s %s", line, kind, data)) + local kind, position, line, extra = v[1], v[2], v[3], v[4] + local data = sub(str,position-30,position+30) + data = gsub(data,".", remapper) + data = gsub(data,"^ *","") + if extra then + print(format("% 5i %-10s %s (%s)", line, kind, data, extra)) + else + print(format("% 5i %-10s %s", line, kind, data)) + end end else print("no error") diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua index 43dcd3455..82346f394 100644 --- a/scripts/context/lua/mtx-context.lua +++ b/scripts/context/lua/mtx-context.lua @@ -626,7 +626,7 @@ scripts.context.interfaces = { de = "cont-de", fr = "cont-fr", nl = "cont-nl", - cz = "cont-cz", + cs = "cont-cs", it = "cont-it", ro = "cont-ro", pe = "cont-pe", diff --git a/scripts/context/lua/mtx-epub.lua b/scripts/context/lua/mtx-epub.lua index a4b96d3be..0dc533c4a 100644 --- a/scripts/context/lua/mtx-epub.lua +++ b/scripts/context/lua/mtx-epub.lua @@ -62,7 +62,7 @@ local package = [[ <dc:language>en</dc:language> <dc:identifier id="%s" >urn:uuid:%s</dc:identifier> <dc:creator opf:file-as="Self, My" opf:role="aut">MySelf</dc:creator> - <dc:date>%s</dc:date> + <dc:date>%s</dc:date> </metadata> <manifest> @@ -168,13 +168,13 @@ function scripts.epub.make() local filename = environment.files[1] - if filename and filename ~= "" then + if filename and filename ~= "" and type(filename) == "string" then filename = file.basename(filename) local specfile = file.replacesuffix(filename,"specification") local specification = lfs.isfile(specfile) and dofile(specfile) or { } - -- inspect(specification) +-- inspect(specification) local name = specification.name or file.removesuffix(filename) local identifier = specification.identifier or os.uuid(true) @@ -215,7 +215,10 @@ function scripts.epub.make() local function copythem(files) for i=1,#files do - copyone(files[i]) + local filename = files[i] + if type(filename) == "string" then + copyone(filename) + end end end diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 7061c54d5..3e6d9e303 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -3719,7 +3719,7 @@ local function utf16_to_utf8_be(t) if right then local now = 256*left + right if more > 0 then - now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 + now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong more = 0 r = r + 1 result[r] = utfchar(now) @@ -3747,7 +3747,7 @@ local function utf16_to_utf8_le(t) if right then local now = 256*right + left if more > 0 then - now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 + now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong more = 0 r = r + 1 result[r] = utfchar(now) diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 7061c54d5..3e6d9e303 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -3719,7 +3719,7 @@ local function utf16_to_utf8_be(t) if right then local now = 256*left + right if more > 0 then - now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 + now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong more = 0 r = r + 1 result[r] = utfchar(now) @@ -3747,7 +3747,7 @@ local function utf16_to_utf8_le(t) if right then local now = 256*right + left if more > 0 then - now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 + now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong more = 0 r = r + 1 result[r] = utfchar(now) diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 7061c54d5..3e6d9e303 100755 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -3719,7 +3719,7 @@ local function utf16_to_utf8_be(t) if right then local now = 256*left + right if more > 0 then - now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 + now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong more = 0 r = r + 1 result[r] = utfchar(now) @@ -3747,7 +3747,7 @@ local function utf16_to_utf8_le(t) if right then local now = 256*right + left if more > 0 then - now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 + now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong more = 0 r = r + 1 result[r] = utfchar(now) diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua index 8a588ce6a..11ed26366 100644 --- a/tex/context/base/back-exp.lua +++ b/tex/context/base/back-exp.lua @@ -25,6 +25,7 @@ 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 +local fromunicode16 = fonts.mappings.fromunicode16 local trace_export = false trackers.register ("export.trace", function(v) trace_export = v end) local less_state = false directives.register("export.lessstate", function(v) less_state = v end) @@ -1825,10 +1826,12 @@ local function collectresults(head,list) -- is last used (we also have currentat local u = fc.tounicode if u and u ~= "" then -- tracing - for s in gmatch(u,"....") do -- is this ok? - nofcurrentcontent = nofcurrentcontent + 1 - currentcontent[nofcurrentcontent] = utfchar(tonumber(s,16)) - end +-- for s in gmatch(u,"....") do -- is this ok? +-- nofcurrentcontent = nofcurrentcontent + 1 +-- currentcontent[nofcurrentcontent] = utfchar(tonumber(s,16)) +-- end + nofcurrentcontent = nofcurrentcontent + 1 + currentcontent[nofcurrentcontent] = utfchar(fromunicode16(u)) else nofcurrentcontent = nofcurrentcontent + 1 currentcontent[nofcurrentcontent] = utfchar(c) @@ -2188,9 +2191,6 @@ local function stopexport(v) local result = allcontent(tree) -- also does some housekeeping and data collecting -- local files = { - xhtmlfile, - -- stylefilename, - -- imagefilename, } local results = concat { wholepreamble(), @@ -2218,6 +2218,7 @@ local function stopexport(v) else xhtmlfile = file.addsuffix(xhtmlfile,"xhtml") end + files[#files+1] = xhtmlfile report_export("saving xhtml variant in '%s",xhtmlfile) local xmltree = cleanxhtmltree(xml.convert(results)) xml.save(xmltree,xhtmlfile) diff --git a/tex/context/base/bibl-bib.lua b/tex/context/base/bibl-bib.lua index d7c195576..444f7e9bc 100644 --- a/tex/context/base/bibl-bib.lua +++ b/tex/context/base/bibl-bib.lua @@ -204,12 +204,12 @@ function bibtex.toxml(session,options) local strip = options.strip -- todo: interface local entries = session.entries r = r + 1 ; result[r] = format("<?xml version='1.0' standalone='yes'?>") - result[#result+1] = format("<bibtex>") + r = r + 1 ; result[r] = format("<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 - result[#result+1] = format("<entry tag='%s' category='%s'>",lower(name),id) + r = r + 1 ; result[r] = format("<entry tag='%s' category='%s'>",lower(name),id) for key, value in next, entry do value = gsub(value,"\\(.)",ihatethis) value = lpegmatch(escaped_pattern,value) diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 78cc2795c..20a06246e 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{2011.09.19 23:43} +\newcontextversion{2011.09.27 20:05} %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 9c2ac5258..41106bfc6 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{2011.09.19 23:43} +\newcontextversion{2011.09.27 20:05} %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-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 0a3d4b524..1347294c2 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png Binary files differindex 70f13ed78..4fe6a22e5 100644 --- a/tex/context/base/context-version.png +++ b/tex/context/base/context-version.png diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index 9355e5357..454c8fcae 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{2011.09.19 23:43} +\edef\contextversion{2011.09.27 20:05} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 5aaf50cea..0a44b2efb 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2011.09.19 23:43} +\edef\contextversion{2011.09.27 20:05} %D For those who want to use this: diff --git a/tex/context/base/font-con.lua b/tex/context/base/font-con.lua index 9028443f0..f6b415bc7 100644 --- a/tex/context/base/font-con.lua +++ b/tex/context/base/font-con.lua @@ -403,21 +403,35 @@ function constructors.scale(tfmdata,specification) local sharedkerns = { } -- for unicode, character in next, characters do - local chr, description, index + local chr, description, index, touni if changed then - -- basemode hack + -- basemode hack (we try to catch missing tounicodes, e.g. needed for ssty in math cambria) local c = changed[unicode] if c then - description = descriptions[c] or character + description = descriptions[c] or descriptions[unicode] or character character = characters[c] or character index = description.index or c + if tounicode then + touni = tounicode[index] -- nb: index! + if not touni then -- goodie + local d = descriptions[unicode] or characters[unicode] + local i = d.index or unicode + touni = tounicode[i] -- nb: index! + end + end else description = descriptions[unicode] or character index = description.index or unicode + if tounicode then + touni = tounicode[index] -- nb: index! + end end else description = descriptions[unicode] or character index = description.index or unicode + if tounicode then + touni = tounicode[index] -- nb: index! + end end local width = description.width local height = description.height @@ -460,15 +474,12 @@ function constructors.scale(tfmdata,specification) } end end + if touni then + chr.tounicode = touni + end -- if trace_scaling then -- report_defining("t=%s, u=%s, i=%s, n=%s c=%s",k,chr.tounicode or "",index or 0,description.name or '-',description.class or '-') -- end - if tounicode then - local tu = tounicode[index] -- nb: index! - if tu then - chr.tounicode = tu - end - end if hasquality then -- we could move these calculations elsewhere (saves calculations) local ve = character.expansion_factor diff --git a/tex/context/base/font-map.lua b/tex/context/base/font-map.lua index b30462f23..7f5305f9a 100644 --- a/tex/context/base/font-map.lua +++ b/tex/context/base/font-map.lua @@ -98,6 +98,15 @@ local function tounicode16sequence(unicodes) return concat(t) end +local function fromunicode16(str) + if #str == 4 then + return tonumber(str,16) + else + local l, r = match(str,"(....)(....)") + return (tonumber(l,16)- 0xD800)*0x400 + tonumber(r,16) - 0xDC00 + end +end + --~ This is quite a bit faster but at the cost of some memory but if we --~ do this we will also use it elsewhere so let's not follow this route --~ now. I might use this method in the plain variant (no caching there) @@ -122,6 +131,7 @@ mappings.loadlumtable = loadlumtable mappings.makenameparser = makenameparser mappings.tounicode16 = tounicode16 mappings.tounicode16sequence = tounicode16sequence +mappings.fromunicode16 = fromunicode16 local separator = S("_.") local other = C((1 - separator)^1) @@ -177,7 +187,9 @@ function mappings.addtounicode(data,filename) if unic == -1 or unic >= private or (unic >= 0xE000 and unic <= 0xF8FF) or unic == 0xFFFE or unic == 0xFFFF then local unicode = lumunic and lumunic[name] or unicodevector[name] if unicode then - originals[index], tounicode[index], ns = unicode, tounicode16(unicode), ns + 1 + originals[index] = unicode + tounicode[index] = tounicode16(unicode) + ns = ns + 1 end -- cidmap heuristics, beware, there is no guarantee for a match unless -- the chain resolves @@ -186,7 +198,9 @@ function mappings.addtounicode(data,filename) if foundindex then unicode = cidcodes[foundindex] -- name to number if unicode then - originals[index], tounicode[index], ns = unicode, tounicode16(unicode), ns + 1 + originals[index] = unicode + tounicode[index] = tounicode16(unicode) + ns = ns + 1 else local reference = cidnames[foundindex] -- number to name if reference then @@ -194,16 +208,23 @@ function mappings.addtounicode(data,filename) if foundindex then unicode = cidcodes[foundindex] if unicode then - originals[index], tounicode[index], ns = unicode, tounicode16(unicode), ns + 1 + originals[index] = unicode + tounicode[index] = tounicode16(unicode) + ns = ns + 1 end end if not unicode then local foundcodes, multiple = lpegmatch(uparser,reference) if foundcodes then + originals[index] = foundcodes if multiple then - originals[index], tounicode[index], nl, unicode = foundcodes, tounicode16sequence(foundcodes), nl + 1, true + tounicode[index] = tounicode16sequence(foundcodes) + nl = nl + 1 + unicode = true else - originals[index], tounicode[index], ns, unicode = foundcodes, tounicode16(foundcodes), ns + 1, foundcodes + tounicode[index] = tounicode16(foundcodes) + ns = ns + 1 + unicode = foundcodes end end end @@ -214,19 +235,8 @@ function mappings.addtounicode(data,filename) -- a.whatever or a_b_c.whatever or a_b_c (no numbers) if not unicode then local split = lpegmatch(ligsplitter,name) - local nplit = (split and #split) or 0 - if nplit == 0 then - -- skip - elseif nplit == 1 then - local base = split[1] - unicode = unicodes[base] or unicodevector[base] - if unicode then - if type(unicode) == "table" then - unicode = unicode[1] - end - originals[index], tounicode[index], ns = unicode, tounicode16(unicode), ns + 1 - end - else + local nplit = split and #split or 0 + if nplit >= 2 then local t, n = { }, 0 for l=1,nplit do local base = split[l] @@ -244,25 +254,38 @@ function mappings.addtounicode(data,filename) if n == 0 then -- done then -- nothing elseif n == 1 then - originals[index], tounicode[index], nl, unicode = t[1], tounicode16(t[1]), nl + 1, true + originals[index] = t[1] + tounicode[index] = tounicode16(t[1]) else - originals[index], tounicode[index], nl, unicode = t, tounicode16sequence(t), nl + 1, true + originals[index] = t + tounicode[index] = tounicode16sequence(t) end + nl = nl + 1 + unicode = true + else + -- skip: already checked and we don't want privates here end end - -- last resort + -- last resort (we might need to catch private here as well) if not unicode then local foundcodes, multiple = lpegmatch(uparser,name) if foundcodes then if multiple then - originals[index], tounicode[index], nl, unicode = foundcodes, tounicode16sequence(foundcodes), nl + 1, true + originals[index] = foundcodes + tounicode[index] = tounicode16sequence(foundcodes) + nl = nl + 1 + unicode = true else - originals[index], tounicode[index], ns, unicode = foundcodes, tounicode16(foundcodes), ns + 1, foundcodes + originals[index] = foundcodes + tounicode[index] = tounicode16(foundcodes) + ns = ns + 1 + unicode = foundcodes end end end -- if not unicode then - -- originals[index], tounicode[index] = 0xFFFD, "FFFD" + -- originals[index] = 0xFFFD + -- tounicode[index] = "FFFD" -- end end end diff --git a/tex/context/base/l-unicode.lua b/tex/context/base/l-unicode.lua index 6295ecb7d..246171aec 100644 --- a/tex/context/base/l-unicode.lua +++ b/tex/context/base/l-unicode.lua @@ -218,7 +218,7 @@ local function utf16_to_utf8_be(t) if right then local now = 256*left + right if more > 0 then - now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 + now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong more = 0 r = r + 1 result[r] = utfchar(now) @@ -246,7 +246,7 @@ local function utf16_to_utf8_le(t) if right then local now = 256*right + left if more > 0 then - now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 + now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong more = 0 r = r + 1 result[r] = utfchar(now) diff --git a/tex/context/base/math-tag.lua b/tex/context/base/math-tag.lua index 49138ac3b..0ac5b0897 100644 --- a/tex/context/base/math-tag.lua +++ b/tex/context/base/math-tag.lua @@ -87,6 +87,8 @@ end -- todo: check function here and keep attribute the same +-- todo: variants -> original + local actionstack = { } process = function(start) -- we cannot use the processor as we have no finalizers (yet) @@ -117,6 +119,7 @@ process = function(start) -- we cannot use the processor as we have no finalizer else tag = "mo" end +-- print(start,a,tag) set_attribute(start,a_tagged,start_tagged(tag,a)) stop_tagged() break -- okay? diff --git a/tex/context/base/math-vfu.lua b/tex/context/base/math-vfu.lua index 9aa2f400a..31c13cf8c 100644 --- a/tex/context/base/math-vfu.lua +++ b/tex/context/base/math-vfu.lua @@ -653,11 +653,12 @@ function vfmath.define(specification,set,goodies) ref = { { 'slot', s, index } } si[index] = ref end + local italic = fci.italic local t = { - width = fci.width, + width = fci.width + italic, -- watch this ! height = fci.height, depth = fci.depth, - italic = fci.italic, + italic = italic, commands = ref, } local n = fci.next diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv index f76a03727..7ff3420d9 100644 --- a/tex/context/base/page-lay.mkiv +++ b/tex/context/base/page-lay.mkiv @@ -586,13 +586,13 @@ \recalculatelayout} \def\checkcurrentoddlayout - {\ifcsname\??ly\v!odd\c!state\endcsname - \doifvalue{\??ly\v!odd\c!state}\v!start{\changetolayout\v!odd}% + {\ifcsname\namedlayouthash\v!odd\c!state\endcsname + \doif{\namedlayoutparameter\v!odd\c!state}\v!start{\changetolayout\v!odd}% \fi} \def\checkcurrentevenlayout - {\ifcsname\??ly\v!even\c!state\endcsname - \doifvalue{\??ly\v!even\c!state}\v!start{\changetolayout\v!even}% + {\ifcsname\namedlayouthash\v!even\c!state\endcsname + \doif{\namedlayoutparameter\v!even\c!state}\v!start{\changetolayout\v!even}% \fi} \ifx\lastpage\undefined @@ -613,11 +613,11 @@ \fi} \def\checkcurrentlayout % public and used in naw, so keep this name - {\ifcsname\??ly\realfolio\c!state\endcsname - \doifvalue{\??ly\realfolio\c!state}\v!start{\changetolayout\realfolio}% - \else\ifcsname\??ly\reverserealfolio\c!state\endcsname - \doifvalue{\??ly\reverserealfolio\c!state}\v!start{\changetolayout\reverserealfolio}% - \else\ifcsname\??ly\v!current\c!state\endcsname + {\ifcsname\namedlayouthash\realfolio\c!state\endcsname + \doif{\namedlayoutparameter\realfolio\c!state}\v!start{\changetolayout\realfolio}% + \else\ifcsname\namedlayouthash\reverserealfolio\c!state\endcsname + \doif{\namedlayoutparameter\reverserealfolio\c!state}\v!start{\changetolayout\reverserealfolio}% + \else\ifcsname\namedlayouthash\v!current\c!state\endcsname \changetolayout\v!current % no start test ? \else \doifoddpageelse\checkcurrentoddlayout\checkcurrentevenlayout diff --git a/tex/context/base/page-set.mkiv b/tex/context/base/page-set.mkiv index 7ef196d53..0c3dfff30 100644 --- a/tex/context/base/page-set.mkiv +++ b/tex/context/base/page-set.mkiv @@ -2480,7 +2480,7 @@ \setcolumnsetspanhsize\mofcolumns\!!countc % a/b used \hsize\columnsetspanhsize \setbox\scratchbox\vbox\bgroup - \dostartframedtext[cs:#1][\v!none]% geen nils placement + \dostartframedtext{cs:#1}[\v!none]% geen nils placement % spoils spacing : \vskip-\struttotal\par\verticalstrut\par \ifnum\columnsetlevel>\zerocount \namedframedtextparameter{cs:#1}\c!before diff --git a/tex/context/base/s-pre-61.tex b/tex/context/base/s-pre-61.tex index d4e06d0a7..21e461320 100644 --- a/tex/context/base/s-pre-61.tex +++ b/tex/context/base/s-pre-61.tex @@ -234,6 +234,7 @@ \StartSteps \startitemize +\item Fiona Apple \FlushStep \item Tori Amos \FlushStep \item Kate Bush \FlushStep \item Heather Nova \FlushStep diff --git a/tex/context/base/s-pre-70.mkiv b/tex/context/base/s-pre-70.mkiv index 9f76fc84a..2c8bb2d26 100644 --- a/tex/context/base/s-pre-70.mkiv +++ b/tex/context/base/s-pre-70.mkiv @@ -119,16 +119,16 @@ [state=start] \startinteractionmenu[bottom] - \txt + \starttxt \interactionbar [alternative=d, symbol=yes, color=white, contrastcolor=textcolor] - \\ + \stoptxt \hfilll - \but [previouspage] < < < \\ - \but [nextpage] > > > \\ + \startbut [previouspage] < < < \stopbut + \startbut [nextpage] > > > \stopbut \stopinteractionmenu %D Instead of the normal symbols we use more punky ones. @@ -150,7 +150,7 @@ %D Run this file with the command: \type {context --mode=demo s-pre-70} %D in order to get an example. -\doifnotmode{demo} {\endinput} +\continueifinputfile{s-pre-70.mkiv} \usemodule[pre-60] % use the stepper @@ -159,14 +159,18 @@ \title {Punk for dummies} \dorecurse{10} { + \title{Just a few dummy pages} - \StartSteps \startitemize[packed] - \startitemize - \startitem bla \FlushStep \stopitem - \startitem bla bla \FlushStep \stopitem - \startitem bla bla bla \FlushStep \stopitem - \startitem bla bla bla bla \FlushStep \stopitem - \stopitemize \StopSteps + + \StartSteps + \startitemize[packed] + \startitem bla \FlushStep \stopitem + \startitem bla bla \FlushStep \stopitem + \startitem bla bla bla \FlushStep \stopitem + \startitem bla bla bla bla \FlushStep \stopitem + \stopitemize + \StopSteps + } \stoptext diff --git a/tex/context/base/s-pre-71.mkiv b/tex/context/base/s-pre-71.mkiv index a52718576..38dae61df 100644 --- a/tex/context/base/s-pre-71.mkiv +++ b/tex/context/base/s-pre-71.mkiv @@ -145,7 +145,7 @@ \let\StartText\starttext \let\StopText \stoptext -\doifnotmode{demo}{\endinput} +\continueifinputfile{s-pre-71.mkiv} \starttext diff --git a/tex/context/base/scrn-but.mkvi b/tex/context/base/scrn-but.mkvi index 7370d944f..693996d8a 100644 --- a/tex/context/base/scrn-but.mkvi +++ b/tex/context/base/scrn-but.mkvi @@ -739,7 +739,7 @@ \unexpanded\def\scrn_menu_but#content\\{\scrn_menu_but_start#content\stopbut} \let\stopbut\relax \unexpanded\def\scrn_menu_got#content\\{\scrn_menu_got_start#content\stopgot} \let\stopgot\relax \unexpanded\def\scrn_menu_nop#content\\{\scrn_menu_nop_start#content\stopnop} \let\stopnop\relax -\unexpanded\def\scrn_menu_txt#content\\{\scrn_menu_nop_start#content\stoptxt} \let\stoptxt\relax +\unexpanded\def\scrn_menu_txt#content\\{\scrn_menu_txt_start#content\stoptxt} \let\stoptxt\relax \unexpanded\def\scrn_menu_rul#content\\{\scrn_menu_rul_start#content\stoprul} \let\stoprul\relax \unexpanded\def\scrn_menu_com#content\\{\scrn_menu_com_start#content\stopcom} \let\stopcom\relax diff --git a/tex/context/base/sort-ini.lua b/tex/context/base/sort-ini.lua index d9a6bb64d..8640ba825 100644 --- a/tex/context/base/sort-ini.lua +++ b/tex/context/base/sort-ini.lua @@ -96,10 +96,11 @@ local validmethods = table.tohash { } local predefinedmethods = { - [v_before] = "mm,mc,uc", - [v_after] = "pm,mc,uc", - [v_first] = "pc,mm,uc", - [v_last] = "mc,mm,uc", + [v_default] = "zc,pc,zm,pm,uc", + [v_before] = "mm,mc,uc", + [v_after] = "pm,mc,uc", + [v_first] = "pc,mm,uc", + [v_last] = "mc,mm,uc", } sorters = { @@ -113,7 +114,7 @@ sorters = { digitsoffset = digitsoffset, digitsmaximum = digitsmaximum, defaultlanguage = v_default, - defaultmethod = v_before, + defaultmethod = v_default, defaultdigits = v_numbers, } } diff --git a/tex/context/base/spac-ali.mkiv b/tex/context/base/spac-ali.mkiv index 686bcfb83..ffc1f2434 100644 --- a/tex/context/base/spac-ali.mkiv +++ b/tex/context/base/spac-ali.mkiv @@ -244,6 +244,10 @@ \let\raggedtopcommand \vfilll % used with \framed for \fi} % instance in tables +\setvalue{\@@ragged@@command\v!last}% + {\appendtoks\centeredlastline\to\everyraggedcommand + \!!donecfalse} + \setvalue{\@@ragged@@command\v!flushleft }{\getvalue{\@@ragged@@command\v!right }} \setvalue{\@@ragged@@command\v!flushright}{\getvalue{\@@ragged@@command\v!left }} \setvalue{\@@ragged@@command\v!center }{\getvalue{\@@ragged@@command\v!middle}} @@ -358,8 +362,8 @@ \let\updateraggedskips\relax -\def\setraggedskips#1#2#3#4#5#6#7% never change this name - {\def\updateraggedskips{\dosetraggedskips{#1}{#2}{#3}{#4}{#5}{#6}{#7}}% +\unexpanded\def\setraggedskips#1#2#3#4#5#6#7% never change this name + {\unexpanded\def\updateraggedskips{\dosetraggedskips{#1}{#2}{#3}{#4}{#5}{#6}{#7}}% \updateraggedskips} \def\dosetraggedskips#1#2#3#4#5#6#7% @@ -419,10 +423,12 @@ % defaults -\def\raggedfillamount {1fil} -\def\raggedhalffillamount{.5fil} -\def\raggedspaceamount {\interwordspace} % {.3333em} -\def\raggedxspaceamount {.5em} +\def\raggedfillamount {1fil} +\def\raggednegativefillamount{-1fil} +\def\raggeddoublefillamount {2fil} +\def\raggedhalffillamount {.5fil} +\def\raggedspaceamount {\interwordspace} % {.3333em} +\def\raggedxspaceamount {.5em} \unexpanded\def\notragged {\raggedstatus\zerocount @@ -445,6 +451,16 @@ \setraggedskips2\middleraggedness\middleraggedness\raggedspaceamount \raggedxspaceamount\zeropoint\zeropoint} +\unexpanded\def\centeredlastline + {\setraggedskips + \zerocount + \raggedfillamount + \raggednegativefillamount + \zeropoint + \zeropoint + \raggeddoublefillamount + \zeropoint} + %D We used to have: %D %D \starttyping @@ -561,6 +577,8 @@ \installalign {l2r} {\lefttoright} \installalign {r2l} {\righttoleft} +\installalign \v!last {\centeredlastline} + \newcount\hyphenminoffset \ifx\sethyphenationvariables\undefined \let\sethyphenationvariables\relax \fi diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex a72d471d4..c8c6b27a5 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex 27829fd27..e4e11892c 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/strc-doc.lua b/tex/context/base/strc-doc.lua index fff357574..7532ac63f 100644 --- a/tex/context/base/strc-doc.lua +++ b/tex/context/base/strc-doc.lua @@ -595,6 +595,9 @@ function sections.typesetnumber(entry,kind,...) -- kind='section','number','pref local firstprefix, lastprefix = 0, 16 if segments then local f, l = match(tostring(segments),"^(.-):(.+)$") + if l == "*" then + l = 100 -- new + end if f and l then -- 0:100, chapter:subsubsection firstprefix = tonumber(f) or sections.getlevel(f) or 0 diff --git a/tex/context/base/strc-flt.mkiv b/tex/context/base/strc-flt.mkiv index 3a6aea0ab..219ff812a 100644 --- a/tex/context/base/strc-flt.mkiv +++ b/tex/context/base/strc-flt.mkiv @@ -912,7 +912,7 @@ \flushsidefloats % hoort eigenlijk niet hier \docomplexplacefloat[#1][\v!text,#2,\v!left][#3]} -\def\docomplexreserveblock#1#2% +\def\dodocomplexreserveblock#1#2% {\begingroup \edef\currentfloat{#1}% \let\currentfloatcaption\currentfloat @@ -921,7 +921,7 @@ \endgroup} \long\def\docomplexreserveblock[#1][#2][#3][#4]#5% - {\getvalue{\e!place#1}[#3][#4]{#5}{\docomplexreserveblock{#1}{#2}{#1}}} + {\getvalue{\e!place#1}[#3][#4]{#5}{\dodocomplexreserveblock{#1}{#2}}} \def\docomplexstartreservetextblock[#1][#2][#3][#4]% {\flushsidefloats % hoort eigenlijk niet hier diff --git a/tex/context/base/strc-reg.mkiv b/tex/context/base/strc-reg.mkiv index 0467eac96..4871b40ce 100644 --- a/tex/context/base/strc-reg.mkiv +++ b/tex/context/base/strc-reg.mkiv @@ -706,9 +706,9 @@ \def\withregisterpagecommand#1#2#3#4% {\def\currentregisterpageindex{#2}% \iflocation - \goto{\registerparameter\c!pagecommand{#4}}[internal(#2)]% + \goto{\applyprocessor{#1}{\registerparameter\c!pagecommand{#4}}}[internal(#2)]% \else - \registerparameter\c!pagecommand{#4}% + \applyprocessor{#1}{\registerparameter\c!pagecommand{#4}}% \fi} \def\registeronepage#1#2#3#4% #1:processor content diff --git a/tex/context/base/strc-ren.mkiv b/tex/context/base/strc-ren.mkiv index 0d82b7f6f..11a2ee2b3 100644 --- a/tex/context/base/strc-ren.mkiv +++ b/tex/context/base/strc-ren.mkiv @@ -25,12 +25,6 @@ \newevery \everyheadstart \relax -% \unexpanded\def\placeheadmargintexts -% {\the\everyheadstart -% \doif{\headparameter\c!margintext}\v!yes\placemargincontent} - -\let\placeheadmargintexts\relax - \unexpanded\def\setupheadcomponentfont#1#2% {\dontconvertfont \ifconditional\headisdisplay @@ -77,9 +71,8 @@ {\begingroup \setupheadcomponentfont\c!textstyle\c!textcolor \headparameter\c!commandbefore - \placeheadmargintexts - \ifcsname\??nh\currenthead\c!deeptextcommand\endcsname - \expandafter\let\expandafter\deepstructuretitlecommand\csname\??nh\currenthead\c!deeptextcommand\endcsname + \ifcsname\currentheadhash\c!deeptextcommand\endcsname + \expandafter\let\expandafter\deepstructuretitlecommand\csname\currentheadhash\c!deeptextcommand\endcsname \fi \ifconditional\headisdisplay % \ifdisplaysectionhead % struts can be nilled with \setnostrut @@ -100,9 +93,8 @@ \def\doplaceheadnumbercomponent#1% {\begingroup \setupheadcomponentfont\c!numberstyle\c!numbercolor - \placeheadmargintexts - \ifcsname\??nh\currenthead\c!deepnumbercommand\endcsname - \expandafter\let\expandafter\deepstructurenumbercommand\csname\??nh\currenthead\c!deepnumbercommand\endcsname + \ifcsname\currentheadhash\c!deepnumbercommand\endcsname + \expandafter\let\expandafter\deepstructurenumbercommand\csname\currentheadhash\c!deepnumbercommand\endcsname \fi \ifconditional\headisdisplay % \ifdisplaysectionhead % can be nilled with \setnostrut @@ -149,7 +141,7 @@ % maybe auto: backreference when given, else list \fi\fi} -\unexpanded\def\placeheadtext +\unexpanded\def\placecurrentheadtext {\beginheadplacement \setheadmarking \doresettructureheadnumbercontent @@ -161,13 +153,13 @@ \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \headreferenceattributes {\dosetlocalgridsnapping{\headparameter\c!internalgrid}% \doresettructureheadnumbercontent - \dosetfontattribute{\??nh\currenthead}\c!style % but we don't want color to influence user command, todo: get the if-else out of it + \dosetheadfontattribute\c!style \setinlineheadreferenceattributes \headparameter\c!command{}{\doplaceheadtextcomponent\getheadtitle}}% \fi \endheadplacement{\getheadsyncs}} -\unexpanded\def\placeheadnumbertext +\unexpanded\def\placecurrentheadnumbertext {\beginheadplacement \setheadmarking \doiftextelse{\getheadnumber}\dosettructureheadnumbercontent\doresettructureheadnumbercontent @@ -178,13 +170,13 @@ \docheckheadreference \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \headreferenceattributes {\dosetlocalgridsnapping{\headparameter\c!internalgrid}% - \dosetfontattribute{\??nh\currenthead}\c!style + \dosetheadfontattribute\c!style \setinlineheadreferenceattributes \headparameter\c!command{\doplaceheadnumbercomponent\getheadnumber}{\doplaceheadtextcomponent\getheadtitle}}% \fi \endheadplacement{\getheadsyncs}} -\unexpanded\def\placeheadempty +\unexpanded\def\placecurrentheadempty {\hbox \headreferenceattributes {\getheadsyncs}} %D \starttyping @@ -461,7 +453,7 @@ \fi #2}} -\unexpanded\def\placeheadmargin#1#2% +\unexpanded\def\placeheadmarginalternative#1#2% {\vbox {\localheadsetup \begstrut % use one \strut here! @@ -473,8 +465,8 @@ \fi {#2}}} -\defineheadplacement[\v!inmargin][\v!vertical]#1#2{\placeheadmargin{#1}{#2}} -\defineheadplacement[\v!margin] [\v!vertical]#1#2{\placeheadmargin{#1}{#2}} +\defineheadplacement[\v!inmargin][\v!vertical]#1#2{\placeheadmarginalternative{#1}{#2}} +\defineheadplacement[\v!margin] [\v!vertical]#1#2{\placeheadmarginalternative{#1}{#2}} \defineheadplacement[\v!middle][\v!vertical]#1#2% {\vbox @@ -496,7 +488,7 @@ {\begstrut#2}% \egroup} -\unexpanded\def\placeheadlohi#1#2#3% +\unexpanded\def\placeheadlohialternative#1#2#3% {\ifconditional\headshownumber \setbox0\hbox{#2} \setbox2=#1{\localheadsetup\advance\hsize-\wd0\relax#3}% @@ -508,8 +500,8 @@ % onder/boven lijnt het nummer op de onderste/bovenste regel % uit van een meerregelige kop -\defineheadplacement[\v!bottom][\v!vertical]#1#2{\placeheadlohi\vbox{#1}{#2}} -\defineheadplacement[\v!top] [\v!vertical]#1#2{\placeheadlohi\vtop{#1}{#2}} +\defineheadplacement[\v!bottom][\v!vertical]#1#2{\placeheadlohialternative\vbox{#1}{#2}} +\defineheadplacement[\v!top] [\v!vertical]#1#2{\placeheadlohialternative\vtop{#1}{#2}} % helpers diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv index a2f011941..d2836d6eb 100644 --- a/tex/context/base/strc-sec.mkiv +++ b/tex/context/base/strc-sec.mkiv @@ -426,8 +426,8 @@ [#3]% \reportcurrentstructure} -\unexpanded\def\placeheadtext {\dosingleempty\doplaceheadtext } % use with care -\unexpanded\def\placeheadnumber{\dosingleempty\doplaceheadnumber} % use with care +\unexpanded\def\placeheadtext {\dosingleempty\place_head_text } % use with care +\unexpanded\def\placeheadnumber{\dosingleempty\place_head_number} % use with care \ifdefined\setupheadcomponentfont \else @@ -439,7 +439,7 @@ \fi -\def\doplaceheadtext[#1]% +\def\place_head_text[#1]% {\dontleavehmode \begingroup \edef\currenthead{#1}% @@ -449,7 +449,7 @@ \endgraf \endgroup} -\def\doplaceheadnumber[#1]% +\def\place_head_number[#1]% {\dontleavehmode \begingroup \edef\currenthead{#1}% @@ -504,20 +504,20 @@ \let\getheadtitle\fullheadtitle \ifconditional\headshownumber \let\getheadnumber\fullheadnumber - \placeheadnumbertext + \placecurrentheadnumbertext \else - \placeheadtext + \placecurrentheadtext \fi \doheadspacingafteryes \else\ifconditional\headhidden \doregisterhead\currenthead{#2}{#3}% after optional \page \let\getheadsyncs\theheadsynchonization - \placeheadhidden % only something when tracing + \placecurrentheadhidden % only something when tracing \else \doheadspacingbeforenop % toegevoegd ivm subpaginanr / tug sheets \doregisterhead\currenthead{#2}{#3}% after optional \page \let\getheadsyncs\theheadsynchonization - \placeheadempty % just flush 'm + \placecurrentheadempty % just flush 'm \doheadspacingafternop \fi\fi \else @@ -526,18 +526,18 @@ \doregisterhead\currenthead{#2}{#3}% after optional \page \let\getheadsyncs\theheadsynchonization \let\getheadtitle\fullheadtitle - \placeheadtext + \placecurrentheadtext \doheadspacingafteryes \else\ifconditional\headhidden \doregisterhead\currenthead{#2}{#3}% after optional \page \let\getheadsyncs\theheadsynchonization - \placeheadhidden % only something when tracing + \placecurrentheadhidden % only something when tracing \else % do nothing / should be vbox to 0pt \doheadspacingbeforenop \doregisterhead\currenthead{#2}{#3}% after optional \page \let\getheadsyncs\theheadsynchonization - \placeheadempty % just flush 'm + \placecurrentheadempty % just flush 'm \doheadspacingafternop \fi\fi \fi @@ -553,21 +553,21 @@ % typesetting -\unexpanded\def\placeheadnumbertext % dummy, will be overloaded +\unexpanded\def\placecurrentheadnumbertext {\setheadmarking \getheadnumber/\getheadtitle \getheadsyncs} -\unexpanded\def\placeheadtext % dummy, will be overloaded +\unexpanded\def\placecurrentheadtext {\setheadmarking \getheadtitle \getheadsyncs} -\unexpanded\def\placeheadempty % dummy, will be overloaded +\unexpanded\def\placecurrentheadempty {\setheadmarking \getheadsyncs} -\unexpanded\def\placeheadhidden +\unexpanded\def\placecurrentheadhidden {\setxvalue{\currenthead:sync}% {\noexpand\setgvalue{\currenthead:sync}{}% \noexpand\pagetype[\currentheadcoupling]% hm also number diff --git a/tex/context/interface/cont-cs.xml b/tex/context/interface/cont-cs.xml index 03e68bbc5..7af35cd94 100644 --- a/tex/context/interface/cont-cs.xml +++ b/tex/context/interface/cont-cs.xml @@ -13,6 +13,8 @@ <cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context test" language="cs" version="2006.08.02"> + <!-- there are some more --> + <cd:define name="align"> <cd:constant type="uvnitr"/> <cd:constant type="vnejsi"/> @@ -25,6 +27,10 @@ <cd:constant type="normalni"/> <cd:constant type="ne"/> <cd:constant type="ano"/> + <cd:constant type="siroky"/> + <cd:constant type="posledni"/> + <cd:constant type="r2l"/> + <cd:constant type="l2r"/> </cd:define> <cd:define name="symalign"> diff --git a/tex/context/interface/cont-de.xml b/tex/context/interface/cont-de.xml index 659fdf3f0..7d164e861 100644 --- a/tex/context/interface/cont-de.xml +++ b/tex/context/interface/cont-de.xml @@ -13,6 +13,8 @@ <cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context test" language="de" version="2006.08.02"> + <!-- there are some more --> + <cd:define name="align"> <cd:constant type="innen"/> <cd:constant type="aussen"/> @@ -25,6 +27,10 @@ <cd:constant type="normal"/> <cd:constant type="nein"/> <cd:constant type="ja"/> + <cd:constant type="breit"/> + <cd:constant type="letzte"/> + <cd:constant type="r2l"/> + <cd:constant type="l2r"/> </cd:define> <cd:define name="symalign"> diff --git a/tex/context/interface/cont-en.xml b/tex/context/interface/cont-en.xml index 46568857a..8cc1bac6c 100644 --- a/tex/context/interface/cont-en.xml +++ b/tex/context/interface/cont-en.xml @@ -13,6 +13,8 @@ <cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context test" language="en" version="2006.08.02"> + <!-- there are some more --> + <cd:define name="align"> <cd:constant type="inner"/> <cd:constant type="outer"/> @@ -25,6 +27,10 @@ <cd:constant type="normal"/> <cd:constant type="no"/> <cd:constant type="yes"/> + <cd:constant type="broad"/> + <cd:constant type="last"/> + <cd:constant type="r2l"/> + <cd:constant type="l2r"/> </cd:define> <cd:define name="symalign"> diff --git a/tex/context/interface/cont-fr.xml b/tex/context/interface/cont-fr.xml index 081ea1802..7b109fd68 100644 --- a/tex/context/interface/cont-fr.xml +++ b/tex/context/interface/cont-fr.xml @@ -13,6 +13,8 @@ <cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context test" language="fr" version="2006.08.02"> + <!-- there are some more --> + <cd:define name="align"> <cd:constant type="interieur"/> <cd:constant type="exterieur"/> @@ -25,6 +27,10 @@ <cd:constant type="normal"/> <cd:constant type="non"/> <cd:constant type="oui"/> + <cd:constant type="large"/> + <cd:constant type="dernier"/> + <cd:constant type="r2l"/> + <cd:constant type="l2r"/> </cd:define> <cd:define name="symalign"> diff --git a/tex/context/interface/cont-it.xml b/tex/context/interface/cont-it.xml index b739b60cb..e8574d2f6 100644 --- a/tex/context/interface/cont-it.xml +++ b/tex/context/interface/cont-it.xml @@ -13,6 +13,8 @@ <cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context test" language="it" version="2006.08.02"> + <!-- there are some more --> + <cd:define name="align"> <cd:constant type="interno"/> <cd:constant type="esterno"/> @@ -25,6 +27,10 @@ <cd:constant type="normale"/> <cd:constant type="no"/> <cd:constant type="si"/> + <cd:constant type="ampio"/> + <cd:constant type="ultimo"/> + <cd:constant type="r2l"/> + <cd:constant type="l2r"/> </cd:define> <cd:define name="symalign"> diff --git a/tex/context/interface/cont-nl.xml b/tex/context/interface/cont-nl.xml index b3036a5a9..cb585d771 100644 --- a/tex/context/interface/cont-nl.xml +++ b/tex/context/interface/cont-nl.xml @@ -13,6 +13,8 @@ <cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context test" language="nl" version="2006.08.02"> + <!-- there are some more --> + <cd:define name="align"> <cd:constant type="binnen"/> <cd:constant type="buiten"/> @@ -25,6 +27,10 @@ <cd:constant type="normaal"/> <cd:constant type="nee"/> <cd:constant type="ja"/> + <cd:constant type="ruim"/> + <cd:constant type="laatste"/> + <cd:constant type="r2l"/> + <cd:constant type="l2r"/> </cd:define> <cd:define name="symalign"> diff --git a/tex/context/interface/cont-pe.xml b/tex/context/interface/cont-pe.xml index 956087029..e271cb846 100644 --- a/tex/context/interface/cont-pe.xml +++ b/tex/context/interface/cont-pe.xml @@ -13,6 +13,8 @@ <cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context test" language="pe" version="2006.08.02"> + <!-- there are some more --> + <cd:define name="align"> <cd:constant type="داخلی"/> <cd:constant type="خارجی"/> @@ -25,6 +27,10 @@ <cd:constant type="نرمال"/> <cd:constant type="نه"/> <cd:constant type="بله"/> + <cd:constant type="گسترده"/> + <cd:constant type="آخرین"/> + <cd:constant type="r2l"/> + <cd:constant type="l2r"/> </cd:define> <cd:define name="symalign"> diff --git a/tex/context/interface/cont-ro.xml b/tex/context/interface/cont-ro.xml index d91aa40f1..dc198d252 100644 --- a/tex/context/interface/cont-ro.xml +++ b/tex/context/interface/cont-ro.xml @@ -13,6 +13,8 @@ <cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context test" language="ro" version="2006.08.02"> + <!-- there are some more --> + <cd:define name="align"> <cd:constant type="intern"/> <cd:constant type="extern"/> @@ -25,6 +27,10 @@ <cd:constant type="normal"/> <cd:constant type="nu"/> <cd:constant type="da"/> + <cd:constant type="broad"/> + <cd:constant type="ultim"/> + <cd:constant type="r2l"/> + <cd:constant type="l2r"/> </cd:define> <cd:define name="symalign"> diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 28ac0347a..b60a0b79b 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 09/19/11 23:43:44 +-- merge date : 09/27/11 20:05:02 do -- begin closure to overcome local limits and interference @@ -3520,21 +3520,35 @@ function constructors.scale(tfmdata,specification) local sharedkerns = { } -- for unicode, character in next, characters do - local chr, description, index + local chr, description, index, touni if changed then - -- basemode hack + -- basemode hack (we try to catch missing tounicodes, e.g. needed for ssty in math cambria) local c = changed[unicode] if c then - description = descriptions[c] or character + description = descriptions[c] or descriptions[unicode] or character character = characters[c] or character index = description.index or c + if tounicode then + touni = tounicode[index] -- nb: index! + if not touni then -- goodie + local d = descriptions[unicode] or characters[unicode] + local i = d.index or unicode + touni = tounicode[i] -- nb: index! + end + end else description = descriptions[unicode] or character index = description.index or unicode + if tounicode then + touni = tounicode[index] -- nb: index! + end end else description = descriptions[unicode] or character index = description.index or unicode + if tounicode then + touni = tounicode[index] -- nb: index! + end end local width = description.width local height = description.height @@ -3577,15 +3591,12 @@ function constructors.scale(tfmdata,specification) } end end + if touni then + chr.tounicode = touni + end -- if trace_scaling then -- report_defining("t=%s, u=%s, i=%s, n=%s c=%s",k,chr.tounicode or "",index or 0,description.name or '-',description.class or '-') -- end - if tounicode then - local tu = tounicode[index] -- nb: index! - if tu then - chr.tounicode = tu - end - end if hasquality then -- we could move these calculations elsewhere (saves calculations) local ve = character.expansion_factor @@ -4569,6 +4580,15 @@ local function tounicode16sequence(unicodes) return concat(t) end +local function fromunicode16(str) + if #str == 4 then + return tonumber(str,16) + else + local l, r = match(str,"(....)(....)") + return (tonumber(l,16)- 0xD800)*0x400 + tonumber(r,16) - 0xDC00 + end +end + --~ This is quite a bit faster but at the cost of some memory but if we --~ do this we will also use it elsewhere so let's not follow this route --~ now. I might use this method in the plain variant (no caching there) @@ -4593,6 +4613,7 @@ mappings.loadlumtable = loadlumtable mappings.makenameparser = makenameparser mappings.tounicode16 = tounicode16 mappings.tounicode16sequence = tounicode16sequence +mappings.fromunicode16 = fromunicode16 local separator = S("_.") local other = C((1 - separator)^1) @@ -4648,7 +4669,9 @@ function mappings.addtounicode(data,filename) if unic == -1 or unic >= private or (unic >= 0xE000 and unic <= 0xF8FF) or unic == 0xFFFE or unic == 0xFFFF then local unicode = lumunic and lumunic[name] or unicodevector[name] if unicode then - originals[index], tounicode[index], ns = unicode, tounicode16(unicode), ns + 1 + originals[index] = unicode + tounicode[index] = tounicode16(unicode) + ns = ns + 1 end -- cidmap heuristics, beware, there is no guarantee for a match unless -- the chain resolves @@ -4657,7 +4680,9 @@ function mappings.addtounicode(data,filename) if foundindex then unicode = cidcodes[foundindex] -- name to number if unicode then - originals[index], tounicode[index], ns = unicode, tounicode16(unicode), ns + 1 + originals[index] = unicode + tounicode[index] = tounicode16(unicode) + ns = ns + 1 else local reference = cidnames[foundindex] -- number to name if reference then @@ -4665,16 +4690,23 @@ function mappings.addtounicode(data,filename) if foundindex then unicode = cidcodes[foundindex] if unicode then - originals[index], tounicode[index], ns = unicode, tounicode16(unicode), ns + 1 + originals[index] = unicode + tounicode[index] = tounicode16(unicode) + ns = ns + 1 end end if not unicode then local foundcodes, multiple = lpegmatch(uparser,reference) if foundcodes then + originals[index] = foundcodes if multiple then - originals[index], tounicode[index], nl, unicode = foundcodes, tounicode16sequence(foundcodes), nl + 1, true + tounicode[index] = tounicode16sequence(foundcodes) + nl = nl + 1 + unicode = true else - originals[index], tounicode[index], ns, unicode = foundcodes, tounicode16(foundcodes), ns + 1, foundcodes + tounicode[index] = tounicode16(foundcodes) + ns = ns + 1 + unicode = foundcodes end end end @@ -4685,19 +4717,8 @@ function mappings.addtounicode(data,filename) -- a.whatever or a_b_c.whatever or a_b_c (no numbers) if not unicode then local split = lpegmatch(ligsplitter,name) - local nplit = (split and #split) or 0 - if nplit == 0 then - -- skip - elseif nplit == 1 then - local base = split[1] - unicode = unicodes[base] or unicodevector[base] - if unicode then - if type(unicode) == "table" then - unicode = unicode[1] - end - originals[index], tounicode[index], ns = unicode, tounicode16(unicode), ns + 1 - end - else + local nplit = split and #split or 0 + if nplit >= 2 then local t, n = { }, 0 for l=1,nplit do local base = split[l] @@ -4715,25 +4736,38 @@ function mappings.addtounicode(data,filename) if n == 0 then -- done then -- nothing elseif n == 1 then - originals[index], tounicode[index], nl, unicode = t[1], tounicode16(t[1]), nl + 1, true + originals[index] = t[1] + tounicode[index] = tounicode16(t[1]) else - originals[index], tounicode[index], nl, unicode = t, tounicode16sequence(t), nl + 1, true + originals[index] = t + tounicode[index] = tounicode16sequence(t) end + nl = nl + 1 + unicode = true + else + -- skip: already checked and we don't want privates here end end - -- last resort + -- last resort (we might need to catch private here as well) if not unicode then local foundcodes, multiple = lpegmatch(uparser,name) if foundcodes then if multiple then - originals[index], tounicode[index], nl, unicode = foundcodes, tounicode16sequence(foundcodes), nl + 1, true + originals[index] = foundcodes + tounicode[index] = tounicode16sequence(foundcodes) + nl = nl + 1 + unicode = true else - originals[index], tounicode[index], ns, unicode = foundcodes, tounicode16(foundcodes), ns + 1, foundcodes + originals[index] = foundcodes + tounicode[index] = tounicode16(foundcodes) + ns = ns + 1 + unicode = foundcodes end end end -- if not unicode then - -- originals[index], tounicode[index] = 0xFFFD, "FFFD" + -- originals[index] = 0xFFFD + -- tounicode[index] = "FFFD" -- end end end |