diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2015-04-12 01:15:04 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2015-04-12 01:15:04 +0200 |
commit | 5a96cf7b6e9ade3c3df8a119e6f0bd1a0a81a2bf (patch) | |
tree | 8df60c57ee7659e7ad87cebbcf93177530e13aa9 /tex | |
parent | cb778ed4a2252111bd0498f3d80ebe9ab03c8b41 (diff) | |
download | context-5a96cf7b6e9ade3c3df8a119e6f0bd1a0a81a2bf.tar.gz |
2015-04-12 00:56:00
Diffstat (limited to 'tex')
24 files changed, 456 insertions, 268 deletions
diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua index 974ae1e43..a4127e6be 100644 --- a/tex/context/base/back-exp.lua +++ b/tex/context/base/back-exp.lua @@ -150,8 +150,9 @@ local overloads = fonts.mappings.overloads -- todo: more locals (and optimize) -local exportversion = "0.33" +local exportversion = "0.34" local mathmlns = "http://www.w3.org/1998/Math/MathML" +local contextns = "http://www.contextgarden.net/context/export" -- whatever suits local nofcurrentcontent = 0 -- so we don't free (less garbage collection) local currentcontent = { } @@ -208,13 +209,6 @@ local alignmapping = { flushleft = "left", } -local numbertoallign = { - [0] = "justify", ["0"] = "justify", [v_normal ] = "justify", - [1] = "right", ["1"] = "right", [v_flushright] = "right", - [2] = "center", ["2"] = "center", [v_middle ] = "center", - [3] = "left", ["3"] = "left", [v_flushleft ] = "left", -} - local defaultnature = "mixed" -- "inline" setmetatableindex(used, function(t,k) @@ -306,7 +300,7 @@ local function setattribute(di,key,value,escaped) end end -local listdata = { } -- maybe do this otherwise +local listdata = { } -- this has to be done otherwise: each element can just point back to ... function wrapups.hashlistdata() local c = structures.lists.collected @@ -315,13 +309,12 @@ function wrapups.hashlistdata() local tag = ci.references.tag if tag then local m = ci.metadata - listdata[m.kind .. ":" .. m.name .. "-" .. tag] = ci +-- listdata[m.kind .. ":" .. m.name .. "-" .. tag] = ci + listdata[m.kind .. ">" .. tag] = ci end end end -local spaces = utilities.strings.newrepeater(" ",-1) - function structurestags.setattributehash(attr,key,value) -- public hash local specification = taglist[attr] if specification then @@ -333,6 +326,12 @@ end local usedstyles = { } +local namespacetemplate = [[ +/* %what% for file %filename% */ + +@namespace context url('%namespace%') ; +]] + do -- experiment: styles and images @@ -352,7 +351,7 @@ document { ]] local styletemplate = [[ -%element%[detail="%detail%"], div.%element%.detail-%detail% { +%element%[detail="%detail%"], context|div.%element%.%detail% { display : inline ; font-style : %style% ; font-variant : %variant% ; @@ -361,8 +360,19 @@ local styletemplate = [[ color : %color% ; }]] + local numbertoallign = { + [0] = "justify", ["0"] = "justify", [v_normal ] = "justify", + [1] = "right", ["1"] = "right", [v_flushright] = "right", + [2] = "center", ["2"] = "center", [v_middle ] = "center", + [3] = "left", ["3"] = "left", [v_flushleft ] = "left", + } + function wrapups.allusedstyles(basename) - local result = { formatters["/* %s for file %s */"]("styles",basename) } + local result = { replacetemplate(namespacetemplate, { + what = "styles", + filename = basename, + namespace = contextns, + }) } -- local bodyfont = finetuning.bodyfont local width = finetuning.width @@ -404,6 +414,7 @@ local styletemplate = [[ for detail, data in sortedhash(details) do local s = fontspecification(data.style) local c = colorspecification(data.color) + detail = gsub(detail,"[^A-Za-z0-9]+","-") result[#result+1] = replacetemplate(styletemplate,{ element = element, detail = detail, @@ -425,7 +436,7 @@ local usedimages = { } do local imagetemplate = [[ -%element%[id="%id%"], div.%element%[id="%id%"] { +%element%[id="%id%"], context|div.%element%[id="%id%"] { display : block ; background-image : url('%url%') ; background-size : 100%% auto ; @@ -457,7 +468,11 @@ local imagetemplate = [[ end function wrapups.allusedimages(basename) - local result = { formatters["/* %s for file %s */"]("images",basename) } + local result = { replacetemplate(namespacetemplate, { + what = "images", + filename = basename, + namespace = contextns, + }) } for element, details in sortedhash(usedimages) do for detail, data in sortedhash(details) do local name = data.name @@ -675,8 +690,10 @@ do local highlight = { } usedstyles.highlight = highlight - function structurestags.sethighlight(style,color) -- we assume global styles - highlight[locatedtag("highlight")] = { + local strippedtag = structurestags.strip -- we assume global styles + + function structurestags.sethighlight(style,color) + highlight[strippedtag(locatedtag("highlight"))] = { style = style, -- xml.css.fontspecification(style), color = color, -- xml.css.colorspec(color), } @@ -2867,14 +2884,14 @@ local cssheadlink = [[ local elementtemplate = [[ /* element="%element%" detail="%detail%" chain="%chain%" */ -%element%, div.%element% { +%element%, context|div.%element% { display: %display% ; }]] local detailtemplate = [[ /* element="%element%" detail="%detail%" chain="%chain%" */ -%element%[detail=%detail%], div.%element%.%detail% { +%element%[detail=%detail%], context|div.%element%.%detail% { display: %display% ; }]] @@ -2895,11 +2912,13 @@ local htmltemplate = [[ </head> <body> + <div xmlns="http://www.pragma-ade.com/context/export"> - <div class="warning">Rendering can be suboptimal because there is no default/fallback css loaded.</div> +<div class="warning">Rendering can be suboptimal because there is no default/fallback css loaded.</div> %body% + </div> </body> </html> ]] @@ -2911,7 +2930,11 @@ local htmltemplate = [[ } local function allusedelements(basename) - local result = { formatters["/* %s for file %s */"]("template",basename) } + local result = { replacetemplate(namespacetemplate, { + what = "template", + filename = basename, + namespace = contextns, + }) } for element, details in sortedhash(used) do if namespaces[element] then -- skip math @@ -3050,6 +3073,7 @@ local htmltemplate = [[ local addclicks = true local f_onclick = formatters[ [[location.href='%s']] ] + local f_onclick = formatters[ [[location.href='%s']] ] local p_cleanid = lpeg.replacer { [":"] = "-" } local p_cleanhref = lpeg.Cs(lpeg.P("#") * p_cleanid) @@ -3533,5 +3557,5 @@ implement { implement { name = "settaglist", actions = structurestags.setlist, - arguments = "string" + arguments = "integer" } diff --git a/tex/context/base/back-exp.mkiv b/tex/context/base/back-exp.mkiv index b29f45f82..bddb6de4d 100644 --- a/tex/context/base/back-exp.mkiv +++ b/tex/context/base/back-exp.mkiv @@ -182,7 +182,7 @@ \appendtoks \unexpanded\def\dotaglistlocation {\iftrialtypesetting\else - \clf_settaglist{\currentlistindex}% + \clf_settaglist\currentlistindex\relax \fi}% \to \everyenableelements diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index f4cba9b2a..5162e693e 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{2015.04.10 15:19} +\newcontextversion{2015.04.12 00:54} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 35bc74037..9f040f8a0 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 72f6cfa3c..d9e0dcd3d 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2015.04.10 15:19} +\edef\contextversion{2015.04.12 00:54} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/export-example.css b/tex/context/base/export-example.css index 41321ead4..af99d95db 100644 --- a/tex/context/base/export-example.css +++ b/tex/context/base/export-example.css @@ -19,46 +19,48 @@ \definefloat[myfloata] \definefloat[myfloatb][myfloatbs][figure] - div.float.myfloata { } float[detail='myfloata'] { } - div.float.myfloatb { } float[detail='myfloatb'] { } - div.float.figure { } float[detail='figure'] { } - div.float.figure.myfloatb { } float[chain~='figure'][detail='myfloata'] { } - div.myfloata { } *[detail='myfloata'] { } - div.myfloatb { } *[detail='myfloatb'] { } - div.figure { } *[chain~='figure'] { } - div.figure.myfloatb { } *[chain~='figure'][detail='myfloatb'] { } + context|div.float.myfloata { } float[detail='myfloata'] { } + context|div.float.myfloatb { } float[detail='myfloatb'] { } + context|div.float.figure { } float[detail='figure'] { } + context|div.float.figure.myfloatb { } float[chain~='figure'][detail='myfloata'] { } + context|div.myfloata { } *[detail='myfloata'] { } + context|div.myfloatb { } *[detail='myfloatb'] { } + context|div.figure { } *[chain~='figure'] { } + context|div.figure.myfloatb { } *[chain~='figure'][detail='myfloatb'] { } */ +@namespace context url('http://www.pragma-ade.com/context/export') ; + /* ignore : mixed */ /* metadata: display */ -ignore, div.ignore { +ignore, context|div.ignore { display : none ; } -ignore, div.private { +ignore, context|div.private { display : none ; } -xmetadata, div.xmetadata { +xmetadata, context|div.xmetadata { display : none ; } -xmetavariable, div.xmetavariable { +xmetavariable, context|div.xmetavariable { display : none ; } /* document : display */ -document:before, div.document:before { +document:before, context|div.document:before { content : attr(title) ; font-size : 44pt ; font-weight : bold ; margin-bottom : 1em ; } -document, div.document { +document, context|div.document { font-family : "DejaVu Serif", "Lucida Bright", serif ; font-size : 12pt ; line-height : 14.4pt; @@ -70,35 +72,35 @@ document, div.document { /* text-justify : inter-word ; */ } -document>metadata, div.document div.metadata { +document>metadata, context|div.document context|div.metadata { font-family : "DejaVu Sans Mono", "Lucida Console", monospace ; margin-bottom : 2em ; } document>metadata>metavariable[name="title"]:before, - div.document div.metadata div.metavariable.name-title:before { + context|div.document context|div.metadata context|div.metavariable.name-title:before { content : "title\00A0\00A0\00A0:\00A0" ; } document>metadata>metavariable[name="author"]:before, - div.document div.metadata div.metavariable.name-author:before { + context|div.document context|div.metadata context|div.metavariable.name-author:before { content : "author\00A0\00A0:\00A0" ; } document>metadata>metavariable[name="version"]:before, - div.document div.metadata div.metavariable.name-version:before { + context|div.document context|div.metadata context|div.metavariable.name-version:before { content : "version\00A0:\00A0" ; } document>metadata>metavariable[name="title"], document>metadata>metavariable[name="author"], document>metadata>metavariable[name="version"], - div.document div.metadata div.metavariable.name-title, div.document div.metadata div.metavariable.name-author, div.document div.metadata div.metavariable.name-version { + context|div.document context|div.metadata context|div.metavariable.name-title, context|div.document context|div.metadata context|div.metavariable.name-author, context|div.document context|div.metadata context|div.metavariable.name-version { display : block ; } /* paragraph : mixed */ /* p : mixed */ -paragraph, p, div.paragraph, div.p { +paragraph, p, context|div.paragraph, context|div.p { display : block ; margin-top : 0.5em ; margin-bottom : 0.5em ; @@ -106,7 +108,7 @@ paragraph, p, div.paragraph, div.p { /* break : display */ -break, div.break { +break, context|div.break { display : block ; margin-bottom : 0.5em ; } @@ -114,14 +116,14 @@ break, div.break { /* construct : inline */ /* highlight : inline */ -construct, div.construct { +construct, context|div.construct { } -construct[detail="important"], div.construct.important { +construct[detail="important"], context|div.construct.important { font-weight : bold ; } -highlight, div.highlight { /* todo: style and color */ +highlight, context|div.highlight { /* todo: style and color */ display : inline ; } @@ -130,18 +132,18 @@ highlight, div.highlight { /* todo: style and color */ /* sectionnumber : mixed */ /* sectioncontent : display */ -section, div.section { +section, context|div.section { display : block ; } -sectioncontent, div.sectioncontent { +sectioncontent, context|div.sectioncontent { display : block ; margin-top : 1em ; margin-bottom : 1em ; } section[detail="chapter"], section[detail="title"], - div.section.chapter, div.section.title { + context|div.section.chapter, context|div.section.title { page-break-before : always ; page-break-after : avoid ; margin-top : 3em ; @@ -149,34 +151,34 @@ section[detail="chapter"], section[detail="title"], } section[detail="section"], section[detail="subject"], - div.section.section, div.section.subject { + context|div.section.section, context|div.section.subject { page-break-after : avoid ; margin-top : 2.5em ; margin-bottom : 2.5em ; } section[detail="subsection"], section[detail="subsubject"], - div.section.subsection, div.section.subsubject { + context|div.section.subsection, context|div.section.subsubject { page-break-after : avoid ; margin-top : 2em ; margin-bottom : 2em ; } section[detail="subsubsection"], section[detail="subsubsubject"], - div.section.subsubsection, div.section.subsubsubject { + context|div.section.subsubsection, context|div.section.subsubsubject { page-break-after : avoid ; margin-top : 1em ; margin-bottom : 0em ; } section[detail="summary"], section[detail="subsummary"], - div.section.summary, div.section.subsummary { + context|div.section.summary, context|div.section.subsummary { margin-top : 1em ; margin-bottom : 1em ; } section[detail="chapter"]>sectionnumber, - div.section.chapter div.sectionnumber { + context|div.section.chapter context|div.sectionnumber { display : inline-block ; margin-right : 1em ; font-size : 3em ; @@ -184,41 +186,41 @@ section[detail="chapter"]>sectionnumber, } section[detail="chapter"]>sectiontitle, section[detail="title"]>sectiontitle, - div.section.chapter div.sectiontitle, div.section.title div.sectiontitle { + context|div.section.chapter context|div.sectiontitle, context|div.section.title context|div.sectiontitle { display : inline-block ; font-size : 3em ; font-weight : bold ; } section[detail="section"]>sectiontitle, section[detail="subject"]>sectiontitle, - div.section.section div.sectiontitle, div.section.subject div.sectiontitle { + context|div.section.section context|div.sectiontitle, context|div.section.subject context|div.sectiontitle { display : inline-block ; font-size : 2.5em ; font-weight : bold ; } section[detail="subsection"]>sectiontitle, section[detail="subsubject"]>sectiontitle, - div.section.subsection div.sectiontitle, div.section.subsubject div.sectiontitle { + context|div.section.subsection context|div.sectiontitle, context|div.section.subsubject context|div.sectiontitle { display : inline-block ; font-size : 2em ; font-weight : bold ; } section[detail="subsubsection"]>sectiontitle, section[detail="subsubsubject"]>sectiontitle, - div.section.subsubsection div.sectiontitle, div.section.subsubsubject div.sectiontitle { + context|div.section.subsubsection context|div.sectiontitle, context|div.section.subsubsubject context|div.sectiontitle { display : inline-block ; font-size : 1em ; font-weight : bold ; } -section[detail="section"]>sectionnumber, div.section.section div.sectionnumber { +section[detail="section"]>sectionnumber, context|div.section.section context|div.sectionnumber { display : inline-block ; margin-right : 1em ; font-size : 2.5em ; font-weight : bold ; } -section[detail="summary"]>sectiontitle, div.section.summary div.sectiontitle { +section[detail="summary"]>sectiontitle, context|div.section.summary context|div.sectiontitle { display : block ; margin-top : 1em ; margin-bottom : 1em ; @@ -228,14 +230,14 @@ section[detail="summary"]>sectiontitle, div.section.summary div.sectiontitle { border-width : .15em; } -section[detail="subsection"]>sectionnumber, div.section.subsection div.sectionnumber { +section[detail="subsection"]>sectionnumber, context|div.section.subsection context|div.sectionnumber { display : inline-block ; margin-right : 1em ; font-size : 1em ; font-weight : bold ; } -section[detail="subsummary"]>sectiontitle, div.section.subsummary div.sectiontitle { +section[detail="subsummary"]>sectiontitle, context|div.section.subsummary context|div.sectiontitle { display : block ; margin-top : 1em ; margin-bottom : 1em ; @@ -263,37 +265,37 @@ section[detail="subsummary"]>sectiontitle, div.section.subsummary div.sectiontit glyphs : 'Α' 'B' 'Γ' 'Δ' 'Ε' 'Ζ' 'Η' 'Θ' 'Ι' 'Κ' 'Λ' 'Μ' 'Ν' 'Ξ' 'Ο' 'Π' 'Ρ' 'Σ' 'Τ' 'Υ' 'Φ' 'Χ' 'Ψ' 'Ω' ; } -itemgroup, div.itemgroup { +itemgroup, context|div.itemgroup { display : block ; margin-bottom : 0.5em ; margin-top : 0.5em ; } -itemgroup[symbol="1"], div.itemgroup.symbol-1 { list-style-type : disc ; } -itemgroup[symbol="2"], div.itemgroup.symbol-2 { list-style-type : square ; } -itemgroup[symbol="3"], div.itemgroup.symbol-3 { list-style-type : square ; } -itemgroup[symbol="4"], div.itemgroup.symbol-4 { list-style-type : square ; } -itemgroup[symbol="5"], div.itemgroup.symbol-5 { list-style-type : circ ; } -itemgroup[symbol="a"], div.itemgroup.symbol-a { list-style-type : lower-alpha ; } -itemgroup[symbol="A"], div.itemgroup.symbol-A { list-style-type : alpha ; } -itemgroup[symbol="r"], div.itemgroup.symbol-r { list-style-type : lower-roman ; } -itemgroup[symbol="R"], div.itemgroup.symbol-R { list-style-type : upper-roman ; } -itemgroup[symbol="n"], div.itemgroup.symbol-n { list-style-type : decimal ; } -itemgroup[symbol="g"], div.itemgroup.symbol-g { list-style-type : lower-greek ; } -itemgroup[symbol="G"], div.itemgroup.symbol-G { list-style-type : upper-greek ; } - -item, div.item { +itemgroup[symbol="1"], context|div.itemgroup.symbol-1 { list-style-type : disc ; } +itemgroup[symbol="2"], context|div.itemgroup.symbol-2 { list-style-type : square ; } +itemgroup[symbol="3"], context|div.itemgroup.symbol-3 { list-style-type : square ; } +itemgroup[symbol="4"], context|div.itemgroup.symbol-4 { list-style-type : square ; } +itemgroup[symbol="5"], context|div.itemgroup.symbol-5 { list-style-type : circ ; } +itemgroup[symbol="a"], context|div.itemgroup.symbol-a { list-style-type : lower-alpha ; } +itemgroup[symbol="A"], context|div.itemgroup.symbol-A { list-style-type : alpha ; } +itemgroup[symbol="r"], context|div.itemgroup.symbol-r { list-style-type : lower-roman ; } +itemgroup[symbol="R"], context|div.itemgroup.symbol-R { list-style-type : upper-roman ; } +itemgroup[symbol="n"], context|div.itemgroup.symbol-n { list-style-type : decimal ; } +itemgroup[symbol="g"], context|div.itemgroup.symbol-g { list-style-type : lower-greek ; } +itemgroup[symbol="G"], context|div.itemgroup.symbol-G { list-style-type : upper-greek ; } + +item, context|div.item { display : list-item ; margin-left : 1em ; margin-bottom : 0.5em ; margin-top : 0.5em ; } -itemtag, div.item { +itemtag, context|div.item { display: none ; } -itemcontent, div.itemcontent { +itemcontent, context|div.itemcontent { } /* description : display */ @@ -301,13 +303,13 @@ itemcontent, div.itemcontent { /* descriptioncontent : mixed */ /* descriptionsymbol : inline */ -description, div.description { +description, context|div.description { display : block ; margin-bottom : 1em ; margin-top : 1em ; } -descriptiontag, div.descriptiontag { +descriptiontag, context|div.descriptiontag { display : inline ; float : left ; clear : left ; @@ -316,10 +318,10 @@ descriptiontag, div.descriptiontag { font-weight : bold ; } -descriptioncontent, div.descriptioncontent { +descriptioncontent, context|div.descriptioncontent { } -descriptionsymbol, div.descriptionsymbol { +descriptionsymbol, context|div.descriptionsymbol { display : inline ; } @@ -328,7 +330,7 @@ descriptionsymbol, div.descriptionsymbol { /* verbatimline : mixed */ /* verbatim : inline */ -verbatimblock, div.verbatimblock { +verbatimblock, context|div.verbatimblock { background-color : rgb(50%,50%,100%) ; display : block ; padding : 1em ; @@ -337,17 +339,17 @@ verbatimblock, div.verbatimblock { font-family : "DejaVu Sans Mono", "Lucida Console", monospace ; } -verbatimlines+verbatimlines, div.verbatimlines+div.verbatimlines { +verbatimlines+verbatimlines, context|div.verbatimlines+context|div.verbatimlines { display : block ; margin-top : 1em ; } -verbatimline, div.verbatimline { +verbatimline, context|div.verbatimline { display : block ; white-space : pre-wrap ; } -verbatim, div.verbatim { +verbatim, context|div.verbatim { display : inline ; white-space : pre-wrap ; color : rgb(60%,60%,0%) ; @@ -357,18 +359,18 @@ verbatim, div.verbatim { /* lines : display */ /* line : mixed */ -lines, div.lines { +lines, context|div.lines { display : block ; margin-bottom : 1em ; margin-top : 1em ; } -lines+lines, div.lines+div.lines { +lines+lines, context|div.lines+context|div.lines { display : block ; margin-top : 1em ; } -line, div.line { +line, context|div.line { display : block ; white-space : pre-wrap ; } @@ -376,7 +378,7 @@ line, div.line { /* synonym : inline */ /* sorting : inline */ -sorting, synonym, div.sorting, div.synonym { +sorting, synonym, context|div.sorting, context|div.synonym { display : inline ; font-variant : small-caps ; } @@ -391,15 +393,15 @@ sorting, synonym, div.sorting, div.synonym { /* registerpage : inline */ /* registerpagerange : mixed */ -register, div.register { +register, context|div.register { display: none ; } -registerlocation, div.registerlocation { +registerlocation, context|div.registerlocation { display: inline ; } -registerlocation:after, div.registerlocation:after { +registerlocation:after, context|div.registerlocation:after { content : "\25B6\00A0\00A0" ; color : rgb(40%,40%,40%) ; font-size : x-small ; @@ -412,33 +414,33 @@ registerlocation:after, div.registerlocation:after { /* tablerow : display */ /* tablecell : mixed */ -table, div.table { +table, context|div.table { display : table ; } -tablerow, div.tablerow { +tablerow, context|div.tablerow { display : table-row ; } -tablecell[align="middle"], div.tablecell.align-middle { +tablecell[align="middle"], context|div.tablecell.align-middle { display : table-cell ; text-align : center ; padding : .1em ; } -tablecell[align="flushleft"], div.tablecell.align-flushleft { +tablecell[align="flushleft"], context|div.tablecell.align-flushleft { display : table-cell ; text-align : left ; padding : .1em ; } -tablecell[align="flushright"], div.tablecell.align-flushright { +tablecell[align="flushright"], context|div.tablecell.align-flushright { display : table-cell ; text-align : right ; padding : .1em ; } -tablecell, div.tablecell { +tablecell, context|div.tablecell { display : table-cell ; text-align : left ; padding : .1em ; @@ -448,40 +450,40 @@ tablecell, div.tablecell { /* tabulaterow : display */ /* tabulatecell : mixed */ -tabulate, div.tabulate { +tabulate, context|div.tabulate { display : table ; margin-top : 1em ; margin-bottom : 1em ; margin-left : 2.5em ; } -floatcontent>tabulate, div.floatcontent div.tabulate { +floatcontent>tabulate, context|div.floatcontent context|div.tabulate { margin-left : 0em ; } -tabulaterow, div.tabulaterow { +tabulaterow, context|div.tabulaterow { display : table-row ; } -tabulatecell[align="middle"], div.tabulatecell.align-middle { +tabulatecell[align="middle"], context|div.tabulatecell.align-middle { display : table-cell ; text-align : center ; padding-right : 1em ; } -tabulatecell[align="flushleft"], div.tabulatecell.align-flushleft { +tabulatecell[align="flushleft"], context|div.tabulatecell.align-flushleft { display : table-cell ; text-align : left ; padding-right : 1em ; } -tabulatecell[align="flushright"], div.tabulatecell.align-flushright { +tabulatecell[align="flushright"], context|div.tabulatecell.align-flushright { display : table-cell ; text-align : right ; padding-right : 1em ; } -tabulatecell, div.tabulatecell { +tabulatecell, context|div.tabulatecell { display : table-cell ; text-align : left ; padding-right : 1em ; @@ -492,23 +494,23 @@ tabulatecell, div.tabulatecell { /* combinationcontent : mixed */ /* combinationcaption : mixed */ -combination, div.combination { +combination, context|div.combination { display : table ; margin-top : 0em ; margin-bottom : 0em ; } -combinationpair, div.combinationpair { +combinationpair, context|div.combinationpair { display : table-cell ; padding-right : 1em ; } -combinationcontent, div.combinationcontent { +combinationcontent, context|div.combinationcontent { display : table-row ; text-align : center ; } -combinationcaption, div.combinationcaption { +combinationcaption, context|div.combinationcaption { display : table-row ; padding-top : 1ex ; text-align : center ; @@ -522,39 +524,39 @@ combinationcaption, div.combinationcaption { /* listdata : mixed */ /* listpage : mixed */ -list, div.list { +list, context|div.list { display : block ; } -listitem[detail="chapter"], div.listitem.chapter { +listitem[detail="chapter"], context|div.listitem.chapter { display : block ; margin-top : 1em ; font-weight : bold ; } -listitem[detail="section"], div.listitem.section { +listitem[detail="section"], context|div.listitem.section { display : block ; } -listitem[detail="subsection"], div.listitem.subsection { +listitem[detail="subsection"], context|div.listitem.subsection { display : block ; display : inline-block ; } -listtag, div.listtag { +listtag, context|div.listtag { display : inline-block ; width : 5em ; } -listcontent, div.listcontent { +listcontent, context|div.listcontent { display : inline-block ; } -listdata, div.listdata { +listdata, context|div.listdata { display : inline-block ; } -listpage, div.listpage { +listpage, context|div.listpage { display : none ; } @@ -565,42 +567,42 @@ listpage, div.listpage { /* :lang(en) */ delimited[detail="quotation"]:before, delimitedblock[detail="quotation"]:before, - div.delimited.quotation:before, div.delimitedblock.quotation:before { + context|div.delimited.quotation:before, context|div.delimitedblock.quotation:before { /* content : "\201C" ; */ font-style : italic ; } delimited[detail="quotation"]:after, delimitedblock[detail="quotation"]:after, - div.delimited.quotation:after, div.delimitedblock.quotation:after { + context|div.delimited.quotation:after, context|div.delimitedblock.quotation:after { /* content : "\201D" ; */ font-style : italic ; } delimited[detail="quote"]:before, delimitedblock[detail="quote"]:before, - div.delimited.quote:before, div.delimitedblock.quote:before { + context|div.delimited.quote:before, context|div.delimitedblock.quote:before { /* content : "\2018" ; */ font-style : italic ; } delimited[detail="quote"]:after, delimitedblock[detail="quote"]:after, - div.delimited.quote:after, div.delimitedblock.quote:after { + context|div.delimited.quote:after, context|div.delimitedblock.quote:after { /* content : "\2019" ; */ font-style : italic ; } -delimited, div.delimited { +delimited, context|div.delimited { display : inline } -delimitedblock, div.delimitedblock { +delimitedblock, context|div.delimitedblock { display : block } -subsentence:before, subsentence:after, div.subsentence:before, div.subsentence:after { +subsentence:before, subsentence:after, context|div.subsentence:before, context|div.subsentence:after { content : "\2014" ; } -subsentence, div.subsentence { +subsentence, context|div.subsentence { display : inline } @@ -614,36 +616,36 @@ subsentence, div.subsentence { /* floattext : mixed */ /* floatcontent : mixed */ -float, div.float { +float, context|div.float { display : block ; margin-top : 1em ; margin-bottom : 1em ; margin-left : 2.5em ; } -floatcaption, div.floatcaption { +floatcaption, context|div.floatcaption { display : block ; margin-top : 0.5em ; color : rgb(60%,60%,0%) ; } -floatlabel, div.floatlabel { +floatlabel, context|div.floatlabel { display : inline-block ; font-weight : bold ; margin-right : 0.25em ; } -floatnumber, div.floatnumber { +floatnumber, context|div.floatnumber { display : inline ; font-weight : bold ; margin-right : 0.25em ; } -floattext, div.floattext { +floattext, context|div.floattext { display : inline ; } -floatcontent, div.floatcontent { +floatcontent, context|div.floatcontent { } /* image : mixed */ @@ -657,11 +659,11 @@ floatcontent, div.floatcontent { height : 5.994cm ; } */ -mpgraphic:before, div.mpgraphic:before { /* does not work with empty element */ +mpgraphic:before, context|div.mpgraphic:before { /* does not work with empty element */ content : "[runtime metapost graphic]" ; } -mpgraphic, div.mpgraphic { +mpgraphic, context|div.mpgraphic { display : inline ; } @@ -673,63 +675,63 @@ mpgraphic, div.mpgraphic { /* formulanumber : mixed */ /* formulacontent : display */ -formula, div.formula { +formula, context|div.formula { display : block ; margin-top : 1em ; margin-bottom : 1em ; margin-left : 2.5em ; } -subformula, div.subformula { /* todo */ +subformula, context|div.subformula { /* todo */ display : block ; margin-top : 1em ; margin-bottom : 1em ; margin-left : 2.5em ; } -formulaset, div.formulaset { /* todo */ +formulaset, context|div.formulaset { /* todo */ display : block ; margin-top : 1em ; margin-bottom : 1em ; margin-left : 2.5em ; } -formulacaption, div.formulacaption { /* todo */ +formulacaption, context|div.formulacaption { /* todo */ display : block ; margin-top : 0.5em ; color : rgb(60%,60%,0%) ; } -formulalabel, div.formulalabel { +formulalabel, context|div.formulalabel { display : inline ; font-weight : bold ; margin-right : .25em ; } -formulanumber, div.formulanumber { +formulanumber, context|div.formulanumber { display : inline ; font-weight : bold ; } -formulacontent, div.formulacontent { +formulacontent, context|div.formulacontent { display : block ; } -link, div.link { +link, context|div.link { display : inline ; } /* margintextblock : inline */ /* margintext : inline */ -margintext, div.margintext { +margintext, context|div.margintext { display : block ; font-weight : bold ; margin-top : 1em ; margin-bottom : 1em ; } -margintext:before, div.margintext:before { +margintext:before, context|div.margintext:before { content : "\25B6\00A0\00A0" ; color : rgb(40%,40%,40%) ; } @@ -757,12 +759,12 @@ margintext:before, div.margintext:before { /* mtr : display */ /* mtd : display */ -div.math-inline { +context|div.math-inline { display : inline ; vertical-align : 0 ; /* this will be set directly */ } -div.math-display { +context|div.math-display { display : block ; margin : 1ex 0ex 1em 3em ; } @@ -771,15 +773,15 @@ div.math-display { /* unit : inline */ /* number : inline */ -quantity, div.quantity { +quantity, context|div.quantity { display : inline ; } -quantity>unit, div.quantity>div.unit { +quantity>unit, context|div.quantity>context|div.unit { display : inline ; } -quantity>number, div.quantity>div.number { +quantity>number, context|div.quantity>context|div.number { display : inline ; } @@ -787,42 +789,42 @@ quantity>number, div.quantity>div.number { /* sup : inline */ /* subsup : inline */ -sup, div.sup { +sup, context|div.sup { display : inline-block ; font-size : xx-small ; vertical-align : super ; } -sub, div.sub { +sub, context|div.sub { display : inline-block ; font-size : xx-small ; vertical-align : sub ; } -subsup>sup, div.subsup>div.sup { +subsup>sup, context|div.subsup>context|div.sup { display : inline ; vertical-align : top ; } -subsup>sub, div.subsup>div.sub { +subsup>sub, context|div.subsup>context|div.sub { display : inline ; vertical-align : bottom ; } /* links */ -div[href]:hover { +context|div[href]:hover { color : rgb(50%,0%,0%) ; background-color : rgb(85%,85%,85%) ; } /* setups */ -setup, div.setup { +setup, context|div.setup { display : block ; } -comment, div.comment { +comment, context|div.comment { background-color : rgb(50%,75%,100%) ; display : block ; padding : 1em ; @@ -833,10 +835,10 @@ comment, div.comment { /* special */ -c, div.c { +c, context|div.c { display : inline ; } -warning, div.warning { +warning, context|div.warning { display : none ; } diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua index c538c5759..ab1c0d314 100644 --- a/tex/context/base/grph-inc.lua +++ b/tex/context/base/grph-inc.lua @@ -1733,6 +1733,8 @@ bmpconverter.default = converter -- srgb.icc -- srgb_v4_icc_preference.icc +-- [[convert %?colorspace: -colorspace "%colorspace%" ?%]] + local rgbprofile = "srgb_v4_icc_preference.icc" -- srgb.icc local cmykprofile = "isocoated_v2_300_eci.icc" -- isocoated_v2_eci.icc @@ -1761,40 +1763,62 @@ end programs.pngtocmykpdf = { command = "gm", - argument = [[convert -strip +profile "*" -profile "%rgbprofile%" -profile "%cmykprofile%" -colorspace cmyk -sampling-factor 1x1 "%oldname%" "%newname%"]], - -- argument = [[convert -strip +profile "*" -colorspace cmyk -sampling-factor 1x1 "%oldname%" "%newname%"]], + argument = [[convert -compress Zip -strip +profile "*" -profile "%rgbprofile%" -profile "%cmykprofile%" -sampling-factor 1x1 "%oldname%" "%newname%"]], } programs.jpgtocmykpdf = { command = "gm", - argument = [[convert -strip +profile "*" -profile "%rgbprofile%" -profile "%cmykprofile%" -colorspace cmyk -sampling-factor 1x1 -compress JPEG "%oldname%" "%newname%"]], - -- argument = [[convert -strip +profile "*" -colorspace cmyk -sampling-factor 1x1 -compress JPEG "%oldname%" "%newname%"]], + argument = [[convert -compress JPEG -strip +profile "*" -profile "%rgbprofile%" -profile "%cmykprofile%" -sampling-factor 1x1 "%oldname%" "%newname%"]], +} + +programs.pngtograypdf = { + command = "gm", + argument = [[convert -colorspace gray -compress Zip -sampling-factor 1x1 "%oldname%" "%newname%"]], +} + +programs.jpgtograypdf = { + command = "gm", + argument = [[convert -colorspace gray -compress Zip -sampling-factor 1x1 "%oldname%" "%newname%"]], } figures.converters.png = { ["cmyk.pdf"] = function(oldname,newname,resolution) local rgbprofile, cmykprofile = profiles() runprogram(programs.pngtocmykpdf.command, programs.pngtocmykpdf.argument, { --- new: runprogram(programs.pngtocmykpdf, { + -- runprogram(programs.pngtocmykpdf, { rgbprofile = rgbprofile, cmykprofile = cmykprofile, oldname = oldname, newname = newname, } ) end, + ["gray.pdf"] = function(oldname,newname,resolution) + runprogram(programs.pngtograypdf.command, programs.pngtograypdf.argument, { + -- runprogram(programs.pngtograypdf, { + oldname = oldname, + newname = newname, + } ) + end, } figures.converters.jpg = { ["cmyk.pdf"] = function(oldname,newname,resolution) local rgbprofile, cmykprofile = profiles() runprogram(programs.jpgtocmykpdf.command, programs.jpgtocmykpdf.argument, { --- new: runprogram(programs.jpgtocmykpdf, { + -- runprogram(programs.jpgtocmykpdf, { rgbprofile = rgbprofile, cmykprofile = cmykprofile, oldname = oldname, newname = newname, } ) end, + ["gray.pdf"] = function(oldname,newname,resolution) + runprogram(programs.jpgtograypdf.command, programs.jpgtograypdf.argument, { + -- runprogram(programs.jpgtograypdf, { + oldname = oldname, + newname = newname, + } ) + end, } -- -- -- bases -- -- -- diff --git a/tex/context/base/lang-hyp.lua b/tex/context/base/lang-hyp.lua index b263ea1b0..496cfd19b 100644 --- a/tex/context/base/lang-hyp.lua +++ b/tex/context/base/lang-hyp.lua @@ -362,6 +362,7 @@ local function hyphenate(dictionary,word,n) -- odd is okay local specials = dictionary.specials local patterns = dictionary.patterns -- +-- inspect(specials) local spec for i=1,l do for j=i,l do @@ -572,7 +573,7 @@ do lpegmatch(u_pattern,str,1,dictionary.patterns,dictionary.specials) -- unregister_pattern(dictionary.patterns,dictionary.specials,str) else - lpegmatch(r_pattern,str,1,dictionary.patterns,dictionary.specials,specification or false) + lpegmatch(r_pattern,str,1,dictionary.patterns,dictionary.specials,type(specification) == "table" and specification or false) -- register_pattern(dictionary.patterns,dictionary.specials,str,specification) end end diff --git a/tex/context/base/lang-url.lua b/tex/context/base/lang-url.lua index ee5171eef..39418beef 100644 --- a/tex/context/base/lang-url.lua +++ b/tex/context/base/lang-url.lua @@ -30,39 +30,39 @@ commands.hyphenatedurl = commands.hyphenatedurl or { } local hyphenatedurl = commands.hyphenatedurl local characters = utilities.storage.allocate { - ["!"] = 1, - ["\""] = 1, - ["#"] = 1, - ["$"] = 1, - ["%"] = 1, - ["&"] = 1, - ["("] = 1, - ["*"] = 1, - ["+"] = 1, - [","] = 1, - ["-"] = 1, - ["."] = 1, - ["/"] = 1, - [":"] = 1, - [";"] = 1, - ["<"] = 1, - ["="] = 1, - [">"] = 1, - ["?"] = 1, - ["@"] = 1, - ["["] = 1, - ["\\"] = 1, - ["^"] = 1, - ["_"] = 1, - ["`"] = 1, - ["{"] = 1, - ["|"] = 1, - ["~"] = 1, - - ["'"] = 2, - [")"] = 2, - ["]"] = 2, - ["}"] = 2, + ["!"] = "before", + ["\""] = "before", + ["#"] = "before", + ["$"] = "before", + ["%"] = "before", + ["&"] = "before", + ["("] = "before", + ["*"] = "before", + ["+"] = "before", + [","] = "before", + ["-"] = "before", + ["."] = "before", + ["/"] = "before", + [":"] = "before", + [";"] = "before", + ["<"] = "before", + ["="] = "before", + [">"] = "before", + ["?"] = "before", + ["@"] = "before", + ["["] = "before", + ["\\"] = "before", + ["^"] = "before", + ["_"] = "before", + ["`"] = "before", + ["{"] = "before", + ["|"] = "before", + ["~"] = "before", + + ["'"] = "after", + [")"] = "after", + ["]"] = "after", + ["}"] = "after", } local mapping = utilities.storage.allocate { diff --git a/tex/context/base/lang-url.mkiv b/tex/context/base/lang-url.mkiv index 53b775ffc..e7d62ba01 100644 --- a/tex/context/base/lang-url.mkiv +++ b/tex/context/base/lang-url.mkiv @@ -44,18 +44,21 @@ \newtoks\everyhyphenatedurl \appendtoks - \let\&\letterampersand - \let\#\letterhash - \let\~\lettertilde - \let\\\letterbackslash - \let\$\letterdollar - \let\^\letterhat - \let\_\letterunderscore - \let\{\letterleftbrace - \let\}\letterrightbrace - \let\|\letterbar - \let~=\lettertilde - \let|=\letterbar + \resetfontfeature + \resetcharacterspacing + % + \let\&\letterampersand + \let\#\letterhash + \let\~\lettertilde + \let\\\letterbackslash + \let\$\letterdollar + \let\^\letterhat + \let\_\letterunderscore + \let\{\letterleftbrace + \let\}\letterrightbrace + \let\|\letterbar + \let~=\lettertilde + \let|=\letterbar \to \everyhyphenatedurl \let\hyphenatedurlseparator \empty % \periodcentered diff --git a/tex/context/base/luat-usr.lua b/tex/context/base/luat-usr.lua index e84cacab3..071e3bf5b 100644 --- a/tex/context/base/luat-usr.lua +++ b/tex/context/base/luat-usr.lua @@ -37,7 +37,10 @@ local tex_errormessage = context.errmessage local implement = interfaces.implement local reporter = logs.reporter -local report = reporter("lua instance") +local report_instance = reporter("lua instance") +local report_script = reporter("lua script") +local report_thread = reporter("lua thread") +local newline = logs.newline lua.numbers = lua.numbers or { } lua.messages = lua.messages or { } @@ -48,17 +51,84 @@ local messages = lua.messages storage.register("lua/numbers", numbers, "lua.numbers" ) storage.register("lua/messages", messages, "lua.messages") +-- First we implement a pure lua version of directlua and a persistent +-- variant of it: + +local function runscript(code) + local done, message = loadstring(code) + if done then + done() + else + newline() + report_script("error : %s",message or "unknown") + report_script() + report_script("code : %s",code) + newline() + end +end + +local threads = setmetatableindex(function(t,k) + local v = setmetatableindex({},global) + t[k] = v + return v +end) + +local function runthread(name,code) + if not code or code == "" then + threads[name] = nil + else + local thread = threads[name] + local done, message = loadstring(code,nil,nil,thread) + if done then + done() + else + newline() + report_thread("thread: %s",name) + report_thread("error : %s",message or "unknown") + report_thread() + report_thread("code : %s",code) + newline() + end + end +end + +interfaces.implement { + name = "luascript", + actions = runscript, + arguments = "string" +} + +interfaces.implement { + name = "luathread", + actions = runthread, + arguments = { "string", "string" } +} + +-- local scanners = interfaces.scanners +-- +-- local function ctxscanner(name) +-- local scanner = scanners[name] +-- if scanner then +-- scanner() +-- else +-- report("unknown scanner: %s",name) +-- end +-- end +-- +-- interfaces.implement { +-- name = "clfscanner", +-- actions = ctxscanner, +-- arguments = "string", +-- } + local function registername(name,message) if not name or name == "" then - report("no valid name given") + report_instance("no valid name given") return end if not message or message == "" then message = name end - if not message or message == "" then - message = name - end local lnn = numbers[name] if not lnn then lnn = #messages + 1 @@ -69,9 +139,9 @@ local function registername(name,message) local report = reporter("lua instance",message) local proxy = { -- we can access all via: - global = global, + global = global, -- or maybe just a metatable -- some protected data - moduledata = setmetatableindex(moduledata), -- + moduledata = setmetatableindex(moduledata), thirddata = setmetatableindex(thirddata), -- less protected data userdata = userdata, @@ -95,7 +165,7 @@ local function registername(name,message) return function(code) local code, message = load(code,nil,nil,proxy) if not code then - report("error: %s",message or code) + report_instance("error: %s",message or code) elseif not xpcall(code,report) then tex_errormessage("hit return to continue or quit this run") end @@ -116,7 +186,7 @@ implement { scope = "private", } else - report("unvalid csname for %a",message or name or "?") + report_instance("unvalid csname for %a",message or name or "?") end end } diff --git a/tex/context/base/luat-usr.mkiv b/tex/context/base/luat-usr.mkiv index 648a806af..92d40010c 100644 --- a/tex/context/base/luat-usr.mkiv +++ b/tex/context/base/luat-usr.mkiv @@ -17,6 +17,24 @@ \registerctxluafile{luat-usr}{1.001} +%D A few goodies: +%D +%D \startbuffer +%D \luascript { context("foo 1:") context(i) } +%D \luathread {test} { i = 10 context("bar 1:") context(i) } +%D \luathread {test} { context("bar 2:") context(i) } +%D \luathread {test} {} +%D \luathread {test} { context("bar 3:") context(i) } +%D \luascript { context("foo 2:") context(i) } +%D \stopbuffer +%D +%D \typebuffer \startlines \getbuffer \stoplines + +\let\luascript \clf_luascript +\let\luathread \clf_luathread +%let\clfscanner\clf_clfscanner +%def\clfscanner#1{\csname clf_#1\endcsname} + %D \macros %D {definenamedlua} %D diff --git a/tex/context/base/mlib-int.lua b/tex/context/base/mlib-int.lua index d355f0bfe..43bf14d38 100644 --- a/tex/context/base/mlib-int.lua +++ b/tex/context/base/mlib-int.lua @@ -58,6 +58,8 @@ function mp.PageDepth () mpprint(getdimen("pagebackgrounddepth") *fact function mp.LayoutColumns () mpprint(getcount("layoutcolumns")) end function mp.LayoutColumnDistance() mpprint(getdimen("layoutcolumndistance")*factor) end function mp.LayoutColumnWidth () mpprint(getdimen("layoutcolumnwidth") *factor) end +function mp.SpineWidth () mpprint(getdimen("spinewidth") *factor) end +function mp.PaperBleed () mpprint(getdimen("paperbleed") *factor) end function mp.PageNumber () mpprint(getcount("pageno")) end function mp.RealPageNumber () mpprint(getcount("realpageno")) end diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv index a1bb35027..d1328bb6b 100644 --- a/tex/context/base/page-lay.mkiv +++ b/tex/context/base/page-lay.mkiv @@ -30,6 +30,8 @@ \newdimen\paperheight \paperheight = 297mm \newdimen\paperwidth \paperwidth = 210mm \newdimen\paperoffset \paperoffset = \zeropoint +\newdimen\paperbleed \paperbleed = \zeropoint +\newdimen\spinewidth \spinewidth = \zeropoint \newdimen\printpaperheight \printpaperheight = \paperheight \newdimen\printpaperwidth \printpaperwidth = \paperwidth diff --git a/tex/context/base/publ-imp-list.mkvi b/tex/context/base/publ-imp-list.mkvi index 77c009911..8c8d9014f 100644 --- a/tex/context/base/publ-imp-list.mkvi +++ b/tex/context/base/publ-imp-list.mkvi @@ -62,11 +62,13 @@ } \btxstopstyleandcolor \stopsetups + \startsetups \s!btx:\s!list:num \texdefinition {\s!btx:\s!list:inject} { \currentbtxfirst } \stopsetups + \startsetups \s!btx:\s!list:bib \texdefinition {\s!btx:\s!list:inject} { \currentbtxfirst diff --git a/tex/context/base/publ-ini.lua b/tex/context/base/publ-ini.lua index 7b36852a9..9ac534c63 100644 --- a/tex/context/base/publ-ini.lua +++ b/tex/context/base/publ-ini.lua @@ -523,6 +523,7 @@ local findallused do tags[#tags+1] = tag end elseif find then +-- print("case 1.1") tags = { } for i=1,#ordered do local entry = ordered[i] @@ -537,6 +538,7 @@ local findallused do reported[reference] = true end else +-- print("case 1.2") for i=1,#tags do local tag = tags[i] if valid[tag] then @@ -549,6 +551,7 @@ local findallused do end else if find then +-- print("case 2.1") tags = { } for i=1,#ordered do local entry = ordered[i] @@ -563,6 +566,7 @@ local findallused do reported[reference] = true end else +-- print("case 2.2") for i=1,#tags do local tag = tags[i] if valid[tag] then diff --git a/tex/context/base/publ-ini.mkiv b/tex/context/base/publ-ini.mkiv index 6010df995..4a754744b 100644 --- a/tex/context/base/publ-ini.mkiv +++ b/tex/context/base/publ-ini.mkiv @@ -1251,7 +1251,7 @@ \edef\currentbtxreference{#1}% \clf_btxhandlenocite dataset {\currentbtxdataset}% - reference {\currentbtxreference#1}% + reference {\currentbtxreference}% markentry true% \relax % \clf_btxflushmarked diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 1f1074357..66adaca55 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 2f1162456..32948e8b2 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/strc-tag.lua b/tex/context/base/strc-tag.lua index 0b14c1d9f..eda53c8be 100644 --- a/tex/context/base/strc-tag.lua +++ b/tex/context/base/strc-tag.lua @@ -390,6 +390,10 @@ function tags.elementtag() end end +function tags.strip(fulltag) + return lpegmatch(strip,fulltag) +end + function tags.setuserproperties(tag,list) if not list or list == "" then tag, list = chain[stacksize], tag diff --git a/tex/context/base/util-tpl.lua b/tex/context/base/util-tpl.lua index bd0e261a9..468dd429c 100644 --- a/tex/context/base/util-tpl.lua +++ b/tex/context/base/util-tpl.lua @@ -128,6 +128,11 @@ local function replacekeyquoted(s,t,how,recurse) -- ".. \" " end end +local function replaceoptional(l,m,r,t,how,recurse) + local v = t[l] + return v and v ~= "" and lpegmatch(replacer,r,1,t,how or "lua",recurse or false) or "" +end + local single = P("%") -- test %test% test : resolves test local double = P("%%") -- test 10%% test : %% becomes % local lquoted = P("%[") -- test '%[test]%' test : resolves to test with escaped "'s @@ -143,12 +148,19 @@ local norquoted = rquoted / '' local nolquotedq = lquotedq / '' local norquotedq = rquotedq / '' -local key = nosingle * ((C((1-nosingle )^1) * Carg(1) * Carg(2) * Carg(3)) / replacekey ) * nosingle -local quoted = nolquotedq * ((C((1-norquotedq)^1) * Carg(1) * Carg(2) * Carg(3)) / replacekeyquoted ) * norquotedq -local unquoted = nolquoted * ((C((1-norquoted )^1) * Carg(1) * Carg(2) * Carg(3)) / replacekeyunquoted) * norquoted +local noloptional = P("%?") / '' +local noroptional = P("?%") / '' +local nomoptional = P(":") / '' + + +local args = Carg(1) * Carg(2) * Carg(3) +local key = nosingle * ((C((1-nosingle )^1) * args) / replacekey ) * nosingle +local quoted = nolquotedq * ((C((1-norquotedq )^1) * args) / replacekeyquoted ) * norquotedq +local unquoted = nolquoted * ((C((1-norquoted )^1) * args) / replacekeyunquoted) * norquoted +local optional = noloptional * ((C((1-nomoptional)^1) * nomoptional * C((1-noroptional)^1) * args) / replaceoptional) * noroptional local any = P(1) - replacer = Cs((unquoted + quoted + escape + key + any)^0) + replacer = Cs((unquoted + quoted + escape + optional + key + any)^0) local function replace(str,mapping,how,recurse) if mapping and str then @@ -164,6 +176,7 @@ end -- print(replace("test '%[x]%' test",{ x = [[a '%y%' a]], y = "oeps" },'sql',true)) -- print(replace([[test %[x]% test]],{ x = [[a "x" a]]})) -- print(replace([[test %(x)% test]],{ x = [[a "x" a]]})) +-- print(replace([[convert %?x: -x "%x%" ?% %?y: -y "%y%" ?%]],{ x = "yes" })) templates.replace = replace diff --git a/tex/context/base/x-mathml.lua b/tex/context/base/x-mathml.lua index 5a60fab52..a0db339bc 100644 --- a/tex/context/base/x-mathml.lua +++ b/tex/context/base/x-mathml.lua @@ -6,16 +6,18 @@ if not modules then modules = { } end modules ['x-mathml'] = { license = "see context related readme files" } --- This needs an upgrade to the latest greatest mechanisms. +-- This needs an upgrade to the latest greatest mechanisms. But ... it +-- probably doesn't pay back as no mathml support ever did. local type, next = type, next local formatters, lower, find, gsub, match = string.formatters, string.lower, string.find, string.gsub, string.match local strip = string.strip -local xmlsprint, xmlcprint, xmltext, xmlcontent = xml.sprint, xml.cprint, xml.text, xml.content -local lxmlcollected = lxml.collected +local xmlsprint, xmlcprint, xmltext, xmlcontent, xmlempty = xml.sprint, xml.cprint, xml.text, xml.content, xml.empty +local lxmlcollected, lxmlfilter = lxml.collected, lxml.filter local getid = lxml.getid -local utfchar, utfcharacters, utfvalues = utf.char, utf.characters, utf.values +local utfchar, utfcharacters, utfvalues, utfsplit, utflen = utf.char, utf.characters, utf.values, utf.split, utf.len local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns +local P, Cs = lpeg.P, lpeg.Cs local mathml = { } moduledata.mathml = mathml @@ -502,20 +504,39 @@ function mathml.stripped(str) context(strip(str)) end +local p_entity = (P("&") * ((1-P(";"))^0) * P(";")) +local p_utfchar = lpegpatterns.utf8character +local p_spacing = lpegpatterns.whitespace^1 + +local p_mn = Cs((p_entity/"" + p_spacing/utfchar(0x205F) + p_utfchar/n_replacements)^0) +local p_strip = Cs((p_entity/"" + p_utfchar )^0) +local p_mi = Cs((p_entity/"" + p_utfchar/i_replacements)^0) + +-- function mathml.mn(id,pattern) +-- -- maybe at some point we need to interpret the number, but +-- -- currently we assume an upright font +-- local str = xmlcontent(getid(id)) or "" +-- local rep = gsub(str,"&.-;","") +-- local rep = gsub(rep,"(%s+)",utfchar(0x205F)) -- medspace e.g.: twenty one (nbsp is not seen) +-- local rep = gsub(rep,".",n_replacements) +-- ctx_mn(rep) +-- end + function mathml.mn(id,pattern) -- maybe at some point we need to interpret the number, but -- currently we assume an upright font - local str = xmlcontent(getid(id)) or "" - local rep = gsub(str,"&.-;","") - local rep = gsub(rep,"(%s+)",utfchar(0x205F)) -- medspace e.g.: twenty one (nbsp is not seen) - local rep = gsub(rep,".",n_replacements) - ctx_mn(rep) + ctx_mn(lpegmatch(p_mn,xmlcontent(getid(id)) or "")) end +-- function mathml.mo(id) +-- local str = xmlcontent(getid(id)) or "" +-- local rep = gsub(str,"&.-;","") -- todo +-- context(simpleoperatorremapper(rep) or rep) +-- end + function mathml.mo(id) - local str = xmlcontent(getid(id)) or "" - local rep = gsub(str,"&.-;","") -- todo - context(simpleoperatorremapper(rep) or rep) + local str = lpegmatch(p_strip,xmlcontent(getid(id)) or "") + context(simpleoperatorremapper(str) or str) end function mathml.mi(id) @@ -529,11 +550,13 @@ function mathml.mi(id) elseif n == 1 then local first = str[1] if type(first) == "string" then - local str = gsub(first,"&.-;","") -- bah - local rep = i_replacements[str] - if not rep then - rep = gsub(str,".",i_replacements) - end + -- local str = gsub(first,"&.-;","") -- bah + -- local rep = i_replacements[str] + -- if not rep then + -- rep = gsub(str,".",i_replacements) + -- end + local str = lpegmatch(p_strip,first) + local rep = i_replacements[str] or lpegmatch(p_mi,str) context(rep) -- ctx_mi(rep) else @@ -549,8 +572,12 @@ end function mathml.mfenced(id) -- multiple separators id = getid(id) - local left, right, separators = id.at.open or "(", id.at.close or ")", id.at.separators or "," - local l, r = l_replacements[left], r_replacements[right] + local at = id.at + local left = at.open or "(" + local right = at.close or ")" + local separators = at.separators or "," + local l = l_replacements[left] + local r = r_replacements[right] ctx_enabledelimiter() if l then context(l_replacements[left] or o_replacements[left] or "") @@ -559,7 +586,7 @@ function mathml.mfenced(id) -- multiple separators context(left) end ctx_disabledelimiter() - local collected = lxml.filter(id,"/*") -- check the * + local collected = lxmlfilter(id,"/*") -- check the * if collected then local n = #collected if n == 0 then @@ -567,7 +594,7 @@ function mathml.mfenced(id) -- multiple separators elseif n == 1 then xmlsprint(collected[1]) -- to be checked else - local t = utf.split(separators,true) + local t = utfsplit(separators,true) for i=1,n do xmlsprint(collected[i]) -- to be checked if i < n then @@ -667,12 +694,12 @@ function mathml.mcolumn(root) local tag = e.tg if tag == "mi" or tag == "mn" or tag == "mo" or tag == "mtext" then local str = xmltext(e) - str = gsub(str,"&.-;","") + str = lpegmatch(p_strip,str) for s in utfcharacters(str) do m[#m+1] = { tag, s } end if tag == "mn" then - local n = utf.len(str) + local n = utflen(str) if n > numbers then numbers = n end @@ -795,7 +822,7 @@ function mathml.mtable(root) local cca = columnalignments[at.columnalign or (columnaligns and columnaligns[col]) or rca or "center"] or "middle" local cfr = frametypes [at.frame or (frames and frames [col]) or rfr or "none" ] or "off" ctx_bTD { align = formatters["{%s,%s}"](cra,cca), frame = cfr, nx = columnspan, ny = rowspan } - if xml.empty(e,".") then + if xmlempty(e,".") then -- nothing, else hsize max else ctx_startimath() diff --git a/tex/context/base/x-mathml.mkiv b/tex/context/base/x-mathml.mkiv index d090d5752..65a7223ce 100644 --- a/tex/context/base/x-mathml.mkiv +++ b/tex/context/base/x-mathml.mkiv @@ -172,11 +172,6 @@ %D filter. There is an intermediate cleaner module but it has %D some namespace limitations. Here we do it the \MKIV\ way. -\def\widevec#1% - {\vbox{\mathsurround\zeropoint\ialign{##\crcr - \rightarrowfill\crcr\noalign{\nointerlineskip}% - \startimath\hfil\displaystyle{#1}\hfil\stopimath\crcr}}} - %D The rendering macros: \def\MMLrm{\mr} @@ -534,7 +529,6 @@ \starttexdefinition mmlapplycsymbol #1#2#3#4 % #1=full url, #2=name, #3=encoding, #4=text \doifelse {#3} {text} { -% {\mr #4} \text{#4} } { \doifelsesetups {mml:csymbol:#1} { @@ -590,7 +584,7 @@ \stopxmlsetups \startxmlsetups mml:ci:vector - \widevec{\xmlflush{#1}} + \overrightarrow{\xmlflush{#1}} \stopxmlsetups \startxmlsetups mml:ci:matrix @@ -1341,13 +1335,11 @@ \xmlfirst{#1}{/mml:ci} } { \MMLcreset -\ifnum\xmlcount{#1}{/mml:apply/*}>\plustwo % hack - \left( - \xmlfirst{#1}{/mml:apply} - \right) -\else - \xmlfirst{#1}{/mml:apply} -\fi + \ifnum\xmlcount{#1}{/mml:apply/*}>\plustwo % hack + \left(\xmlfirst{#1}{/mml:apply}\right) + \else + \xmlfirst{#1}{/mml:apply} + \fi } } } { diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 0c3cb5d78..fe8704b19 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 : 04/10/15 15:19:00 +-- merge date : 04/12/15 00:54:05 do -- begin closure to overcome local limits and interference |