From d8ecb24627ac6402f5e57e67363d9f4ccee5241b Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Wed, 11 Jun 2014 19:01:19 +0200 Subject: 2014-06-11 15:54:00 --- tex/context/base/back-ini.mkiv | 2 - tex/context/base/back-pdf.lua | 11 +- tex/context/base/back-pdf.mkiv | 123 +-- tex/context/base/char-utf.lua | 515 +++++++----- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4323 -> 4348 bytes tex/context/base/context.mkiv | 2 +- tex/context/base/file-lib.lua | 54 +- tex/context/base/file-mod.lua | 25 +- tex/context/base/hand-ini.mkiv | 8 +- tex/context/base/lpdf-col.lua | 2 +- tex/context/base/lpdf-ini.lua | 86 +- tex/context/base/meta-ini.mkiv | 28 +- tex/context/base/page-txt.mkvi | 10 +- tex/context/base/publ-imp-apa.bib | 29 - tex/context/base/publ-imp-apa.mkvi | 175 ++-- tex/context/base/publ-imp-aps.mkvi | 890 +++++++++++++++++++++ tex/context/base/publ-imp-test.bib | 63 ++ tex/context/base/publ-ini.lua | 32 +- tex/context/base/publ-ini.mkiv | 6 + tex/context/base/spac-ver.lua | 67 +- tex/context/base/status-files.pdf | Bin 24884 -> 24885 bytes tex/context/base/status-lua.pdf | Bin 246770 -> 246860 bytes tex/context/base/syst-ini.mkiv | 18 +- tex/context/bib/sample.bib | 1 - tex/context/sample/dawkins.tex | 6 +- tex/context/sample/douglas.tex | 8 +- tex/context/sample/sample.tex | 80 +- tex/context/sample/samples.bib | 29 + tex/context/sample/samples.tex | 77 ++ tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 31 files changed, 1892 insertions(+), 459 deletions(-) delete mode 100644 tex/context/base/publ-imp-apa.bib create mode 100644 tex/context/base/publ-imp-aps.mkvi create mode 100644 tex/context/base/publ-imp-test.bib create mode 100644 tex/context/sample/samples.bib create mode 100644 tex/context/sample/samples.tex (limited to 'tex') diff --git a/tex/context/base/back-ini.mkiv b/tex/context/base/back-ini.mkiv index c3bc78ae6..8a3f77b1d 100644 --- a/tex/context/base/back-ini.mkiv +++ b/tex/context/base/back-ini.mkiv @@ -51,8 +51,6 @@ %D Not everything here makes sense and the content of this file will %D definitely change. -\newcount\backendtransformlevel - \let \dostartrotation \gobbleoneargument \let \dostoprotation \donothing \let \dostartscaling \gobbletwoarguments diff --git a/tex/context/base/back-pdf.lua b/tex/context/base/back-pdf.lua index 9eb4a9b73..2fbaaa0d2 100644 --- a/tex/context/base/back-pdf.lua +++ b/tex/context/base/back-pdf.lua @@ -38,13 +38,17 @@ end -- -- we could also do the save restore wrapping here + colorhack +local pdfsave = nodes.pool.pdfsave +local pdfrestore = nodes.pool.pdfrestore local pdfsetmatrix = nodes.pool.pdfsetmatrix + local stack = { } local function popmatrix() local top = remove(stack) if top then context(pdfsetmatrix(unpack(top))) + context(pdfrestore()) end end @@ -53,6 +57,7 @@ function commands.pdfstartrotation(a) insert(stack,false) else local s, c = sind(a), cosd(a) + context(pdfsave()) context(pdfsetmatrix(c,s,-s,c)) insert(stack,{ c, -s, s, c }) end @@ -68,6 +73,7 @@ function commands.pdfstartscaling(sx,sy) if sy == 0 then sy = 0.0001 end + context(pdfsave()) context(pdfsetmatrix(sx,0,0,sy)) insert(stack,{ 1/sx, 0, 0, 1/sy }) end @@ -81,6 +87,7 @@ function commands.pdfstartmatrix(sx,rx,ry,sy) -- tx, ty if sx == 1 and rx == 0 and ry == 0 and sy == 1 then insert(stack,false) else + context(pdfsave()) context(pdfsetmatrix(sx,rx,ry,sy)) insert(stack,{ -sx, -rx, -ry, -sy }) end @@ -88,5 +95,7 @@ end commands.pdfstoprotation = popmatrix commands.pdfstopscaling = popmatrix -commands.pdfstopmirroring = commands.pdfstartmirroring +commands.pdfstopmirroring = popmatrix commands.pdfstopmatrix = popmatrix + +-- todo : clipping diff --git a/tex/context/base/back-pdf.mkiv b/tex/context/base/back-pdf.mkiv index 3fbad1350..c91d2251d 100644 --- a/tex/context/base/back-pdf.mkiv +++ b/tex/context/base/back-pdf.mkiv @@ -41,17 +41,31 @@ %D %D Here we initialize some internal quantities. We also protect them. -\pdfoutput 1 \let\pdfoutput \undefined \newcount\pdfoutput \pdfoutput 1 -\pdfhorigin 1 true in \let\pdfhorigin\undefined \newdimen\pdfhorigin \pdfhorigin 1 true in -\pdfvorigin 1 true in \let\pdfvorigin\undefined \newdimen\pdfvorigin \pdfvorigin 1 true in +\pdfoutput \plusone \let\pdfoutput \undefined \newcount\pdfoutput \pdfoutput \plusone -% most of these will be protected as well +%D These are already set: +\pdfhorigin 1 true in \let\pdfhorigin\undefined \newdimen\pdfhorigin \pdfhorigin 1 true in +\pdfvorigin \pdfhorigin \let\pdfvorigin\undefined \newdimen\pdfvorigin \pdfvorigin \pdfhorigin + +%D These too and most of them will be protected as well: + +\pdfminorversion \plussix +\pdfgentounicode \plusone \let\pdfgentounicode \undefined \newcount\pdfgentounicode +\pdfinclusioncopyfonts \plusone \let\pdfinclusioncopyfonts \undefined \newcount\pdfinclusioncopyfonts +\pdfinclusionerrorlevel \zerocount \let\pdfinclusionerrorlevel\undefined \newcount\pdfinclusionerrorlevel +\pdfdecimaldigits \plusten \let\pdfdecimaldigits \undefined \newcount\pdfdecimaldigits \pdfimageresolution 300 \pdfpkresolution 600 -\pdfdecimaldigits 10 -\pdfinclusionerrorlevel 0 -\pdfminorversion 6 % use setupbackend for changes + +%D Let's block these (we could share a dummy: + +\let\pdfcatalog \relax \newtoks\pdfcatalog +\let\pdfinfo \relax \newtoks\pdfinfo +\let\pdfnames \relax \newtoks\pdfnames +\let\pdfpageresources\relax \newtoks\pdfpageresources +\let\pdfpageattr \relax \newtoks\pdfpageattr +\let\pdfpagesattr \relax \newtoks\pdfpagesattr %D This one can be consulted by users although the suffix is also %D a system mode. @@ -102,16 +116,8 @@ \unexpanded\def\pdfbackendsetshade #1#2{\ctxlua{lpdf.adddocumentshade ("#1",lpdf.verbose(\!!bs#2\!!es))}} \def\pdfbackendcurrentresources {\cldcontext{lpdf.collectedresources()}} - \def\pdfcolor #1{\ctxlua{lpdf.pdfcolor(\thecolorattribute{#1})}} \let\PDFcolor\pdfcolor - -%D Let's block these: - -\let\pdfcatalog \relax \newtoks\pdfcatalog -\let\pdfinfo \relax \newtoks\pdfinfo -\let\pdfnames \relax \newtoks\pdfnames -\let\pdfpageresources\relax \newtoks\pdfpageresources -\let\pdfpageattr \relax \newtoks\pdfpageattr -\let\pdfpagesattr \relax \newtoks\pdfpagesattr + \def\pdfcolor #1{\cldcontext{lpdf.pdfcolor(\thecolorattribute{#1})}} + \let\PDFcolor\pdfcolor %D An example of usage is: @@ -120,38 +126,35 @@ \pdfbackendsetinfo{ConTeXt.Time} {\number\normalyear.\twodigits\normalmonth.\twodigits\normalday\space \twodigits\currenthour:\twodigits\currentminute}% \pdfbackendsetinfo{ConTeXt.Jobname}{\jobname}% \pdfbackendsetinfo{ConTeXt.Url} {www.pragma-ade.com}% + \pdfbackendsetinfo{ConTeXt.Support}{contextgarden.net}% \to \everylastbackendshipout %D Transformations. Some day we will use primitives (once they're fixed). + % todo: inject at the lua end cq. deal with #5 and #6 too % % % rotation % % % \unexpanded\def\dostartrotation#1% grouped - {\advance\backendtransformlevel\plusone - \forcecolorhack + {\forcecolorhack \pdfsave \pdfsetmatrix{\ctxcommand{pdfrotation(#1)}}} \unexpanded\def\dostoprotation {\pdfrestore - \forcecolorhack - \advance\backendtransformlevel\minusone} + \forcecolorhack} % \unexpanded\def\dostartrotation#1% grouped % {\forcecolorhack -% \advance\backendtransformlevel\plusone % \ctxcommand{pdfstartrotation(#1)}} % \unexpanded\def\dostoprotation -% {\ctxcommand{pdfstoprotation()}% -% \advance\backendtransformlevel\minusone} +% {\ctxcommand{pdfstoprotation()}} % % % scaling % % % \unexpanded\def\dostartscaling#1#2% the test is needed because acrobat is bugged! - {\advance\backendtransformlevel\plusone - \forcecolorhack % maybe use signal instead + {\forcecolorhack % maybe use signal instead \pdfsave \pdfsetmatrix {\ifdim#1\points=\zeropoint.0001\else#1\fi\space 0 0 @@ -159,60 +162,49 @@ \unexpanded\def\dostopscaling {\pdfrestore - \forcecolorhack - \advance\backendtransformlevel\minusone} + \forcecolorhack} % \unexpanded\def\dostartscaling#1#2% the test is needed because acrobat is bugged! % {\forcecolorhack -% \advance\backendtransformlevel\plusone % \ctxcommand{pdfstartscaling(#1,#2)}} % \unexpanded\def\dostopscaling -% {\ctxcommand{pdfstopscaling()}% -% \advance\backendtransformlevel\minusone} +% {\ctxcommand{pdfstopscaling()}} % % % mirroring % % % \unexpanded\def\dostartmirroring - {\advance\backendtransformlevel\plusone - \forcecolorhack + {\forcecolorhack \pdfsave \pdfsetmatrix{-1 0 0 1}} % 0 0 \unexpanded\def\dostopmirroring {\pdfrestore - \forcecolorhack - \advance\backendtransformlevel\minusone} + \forcecolorhack} % \unexpanded\def\dostartmirroring -% {\advance\backendtransformlevel\plusone -% \ctxcommand{pdfstartmirroring()}} +% {\ctxcommand{pdfstartmirroring()}} % \unexpanded\def\dostopmirroring -% {\ctxcommand{pdfstopmirroring()}% -% \advance\backendtransformlevel\minusone} +% {\ctxcommand{pdfstopmirroring()}} % % % transform % % % \unexpanded\def\dotransformnextbox#1#2#3#4#5#6% sx rx ry sy tx ty (will change) / basepoints ! - {\advance\backendtransformlevel\plusone - % fixing ht/dp/wd should happen elsewhere - \dowithnextbox{\dodotransformnextbox{#5}{#6}{#1 #2 #3 #4}}} + {\dowithnextbox{\dodotransformnextbox{#5}{#6}{#1 #2 #3 #4}}} \unexpanded\def\dodotransformnextbox#1#2#3% - {%\forcecolorhack - \hbox + {\hbox {\kern#1\onebasepoint \raise#2\onebasepoint\hbox {\pdfsave \pdfsetmatrix{#3}% 0 0 (no #5 #6 yet) \box\nextbox \pdfrestore - \advance\backendtransformlevel\minusone}}} + }}} % \unexpanded\def\dotransformnextbox#1#2#3#4#5#6% sx rx ry sy tx ty (will change) / basepoints ! -% {\advance\backendtransformlevel\plusone -% % fixing ht/dp/wd should happen elsewhere +% {% fixing ht/dp/wd should happen elsewhere % \dowithnextbox{\dodotransformnextbox{#1}{#2}{#3}{#4}{#5}{#6}}} % \unexpanded\def\dodotransformnextbox#1#2#3#4#5#6% @@ -222,8 +214,41 @@ % \hbox % {\ctxcommand{pdfstartmatrix(#1,#2,#3,#4)}% % \box\nextbox -% \ctxcommand{pdfstopmatrix()}% -% \advance\backendtransformlevel\minusone}}} +% \ctxcommand{pdfstopmatrix()}}}} + +% somehow the shift is not happening .. bug in luatex? +% +% \unexpanded\def\dodotransformnextbox#1#2#3#4#5#6% +% {\ctxcommand{pdftransformbox(\number\nextbox,#1,#2,#3,#4,\number\dimexpr#5\onebasepoint,\number\dimexpr#6\onebasepoint)}% +% \box\nextbox} +% +% \startluacode +% function commands.pdftransformbox(box,sx,rx,ry,sy,tx,ty) +% if sx == 1 and rx == 0 and ry == 0 and sy == 1 then +% if tx == 0 and ty == 0 then +% local b = nodes.hpack(nodes.concat { +% nodes.pool.kern(tx), +% nodes.takebox(box), +% }) +% b.shift = -ty +% tex.setbox(box,b) +% else +% -- no need to transform +% end +% else +% local b = nodes.hpack(nodes.concat { +% nodes.pool.kern(tx), +% nodes.pool.pdfsave(), +% nodes.pool.pdfsetmatrix(sx,rx,ry,sy), +% nodes.takebox(box), +% nodes.pool.pdfsetmatrix(-sx,-rx,-ry,-sy), +% nodes.pool.pdfrestore(), +% }) +% b.shift = -ty +% tex.setbox(box,b) +% end +% end +% \stopluacode % % % clipping % % % diff --git a/tex/context/base/char-utf.lua b/tex/context/base/char-utf.lua index d406b8bfe..8714d6b44 100644 --- a/tex/context/base/char-utf.lua +++ b/tex/context/base/char-utf.lua @@ -29,28 +29,31 @@ local utfchar, utfbyte, utfcharacters, utfvalues = utf.char, utf.byte, utf.chara local allocate = utilities.storage.allocate local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns -local charfromnumber = characters.fromnumber +local charfromnumber = characters.fromnumber -characters = characters or { } -local characters = characters +characters = characters or { } +local characters = characters -characters.graphemes = allocate() -local graphemes = characters.graphemes +local graphemes = allocate() +characters.graphemes = graphemes -characters.combined = allocate() -local combined = characters.combined +local collapsed = allocate() +characters.collapsed = collapsed -characters.decomposed = allocate() -local decomposed = characters.decomposed +local combined = allocate() +characters.combined = combined -characters.mathpairs = allocate() -local mathpairs = characters.mathpairs +local decomposed = allocate() +characters.decomposed = decomposed -characters.filters = allocate() -local filters = characters.filters +local mathpairs = allocate() +characters.mathpairs = mathpairs -filters.utf = filters.utf or { } -local utffilters = characters.filters.utf +local filters = allocate() +characters.filters = filters + +local utffilters = { } +characters.filters.utf = utffilters -- is characters.combined cached? @@ -81,90 +84,132 @@ local decomposed = allocate { characters.decomposed = decomposed -local function initialize() -- maybe only 'mn' +-- local function initialize() -- maybe only 'mn' +-- local data = characters.data +-- for unicode, v in next, data do +-- -- using vs and first testing for length is faster (.02->.01 s) +-- local vs = v.specials +-- if vs and #vs == 3 then +-- local vc = vs[1] +-- if vc == "char" then +-- local one, two = vs[2], vs[3] +-- if data[two].category == "mn" then +-- local cgf = combined[one] +-- if not cgf then +-- cgf = { [two] = unicode } +-- combined[one] = cgf +-- else +-- cgf[two] = unicode +-- end +-- end +-- local first, second, combination = utfchar(one), utfchar(two), utfchar(unicode) +-- local cgf = graphemes[first] +-- if not cgf then +-- cgf = { [second] = combination } +-- graphemes[first] = cgf +-- else +-- cgf[second] = combination +-- end +-- if v.mathclass or v.mathspec then +-- local mps = mathpairs[two] +-- if not mps then +-- mps = { [one] = unicode } +-- mathpairs[two] = mps +-- else +-- mps[one] = unicode -- here unicode +-- end +-- local mps = mathpairs[second] +-- if not mps then +-- mps = { [first] = combination } +-- mathpairs[second] = mps +-- else +-- mps[first] = combination +-- end +-- end +-- -- elseif vc == "compat" then +-- -- else +-- -- local description = v.description +-- -- if find(description,"LIGATURE") then +-- -- if vs then +-- -- local t = { } +-- -- for i=2,#vs do +-- -- t[#t+1] = utfchar(vs[i]) +-- -- end +-- -- decomposed[utfchar(unicode)] = concat(t) +-- -- else +-- -- local vs = v.shcode +-- -- if vs then +-- -- local t = { } +-- -- for i=1,#vs do +-- -- t[i] = utfchar(vs[i]) +-- -- end +-- -- decomposed[utfchar(unicode)] = concat(t) +-- -- end +-- -- end +-- -- end +-- end +-- end +-- end +-- initialize = false +-- characters.initialize = function() end -- when used outside tex +-- end + +local function initialize() local data = characters.data - for unicode, v in next, data do - -- using vs and first testing for length is faster (.02->.01 s) + local function backtrack(v,last,target) local vs = v.specials - local vc = vs and #vs == 3 and vs[1] - if vc == "char" then + if vs and #vs == 3 and vs[1] == "char" then local one, two = vs[2], vs[3] - if data[two].category == "mn" then - local cgf = combined[one] + local first, second = utfchar(one), utfchar(two) .. last + collapsed[first..second] = target + backtrack(data[one],second,target) + end + end + for unicode, v in next, data do + local vs = v.specials + if vs and #vs == 3 then + if vs[1] == "char" then + -- + local one, two = vs[2], vs[3] + local first, second, combination = utfchar(one), utfchar(two), utfchar(unicode) + -- + collapsed[first..second] = combination + backtrack(data[one],second,combination) + -- sort of obsolete: + local cgf = graphemes[first] if not cgf then - cgf = { [two] = unicode } - combined[one] = cgf - else - cgf[two] = unicode - end - end - local first, second, combination = utfchar(one), utfchar(two), utfchar(unicode) - local cgf = graphemes[first] - if not cgf then - cgf = { [second] = combination } - graphemes[first] = cgf - else - cgf[second] = combination - end - if v.mathclass or v.mathspec then - local mps = mathpairs[two] - if not mps then - mps = { [one] = unicode } - mathpairs[two] = mps + cgf = { [second] = combination } + graphemes[first] = cgf else - mps[one] = unicode -- here unicode + cgf[second] = combination end - local mps = mathpairs[second] - if not mps then - mps = { [first] = combination } - mathpairs[second] = mps - else - mps[first] = combination + -- + if v.mathclass or v.mathspec then + local mps = mathpairs[two] + if not mps then + mps = { [one] = unicode } + mathpairs[two] = mps + else + mps[one] = unicode -- here unicode + end + local mps = mathpairs[second] + if not mps then + mps = { [first] = combination } + mathpairs[second] = mps + else + mps[first] = combination + end end + -- end - -- elseif vc == "compat" then - -- else - -- local description = v.description - -- if find(description,"LIGATURE") then - -- if vs then - -- local t = { } - -- for i=2,#vs do - -- t[#t+1] = utfchar(vs[i]) - -- end - -- decomposed[utfchar(unicode)] = concat(t) - -- else - -- local vs = v.shcode - -- if vs then - -- local t = { } - -- for i=1,#vs do - -- t[i] = utfchar(vs[i]) - -- end - -- decomposed[utfchar(unicode)] = concat(t) - -- end - -- end - -- end end end initialize = false - characters.initialize = function() end -- when used outside tex + characters.initialize = function() end end characters.initialize = initialize --- utffilters.addgrapheme(utfchar(318),'l','\string~') --- utffilters.addgrapheme('c','a','b') - -function utffilters.addgrapheme(result,first,second) -- can be U+ 0x string or utf or number - local result = charfromnumber(result) - local first = charfromnumber(first) - local second = charfromnumber(second) - if not graphemes[first] then - graphemes[first] = { [second] = result } - else - graphemes[first][second] = result - end -end - --[[ldx--

In order to deal with 8-bit output, we need to find a way to go from to 8-bit. This is handled in the engine itself.

@@ -252,109 +297,130 @@ not collecting tokens is not only faster but also saves garbage collecting. local skippable = table.tohash { "mkiv", "mkvi" } local filesuffix = file.suffix -function utffilters.collapse(str,filename) -- we can make high a seperate pass (never needed with collapse) - if skippable[filesuffix(filename)] then - return str - -- elseif find(filename,"^virtual://") then - -- return str - -- else - -- -- print("\n"..filename) - end - if str and str ~= "" then - local nstr = #str - if nstr > 1 then - if initialize then -- saves a call - initialize() - end - local tokens, t, first, done, n = { }, 0, false, false, 0 - for second in utfcharacters(str) do - if done then - if first then - if second == " " then - t = t + 1 - tokens[t] = first - first = second - else - -- local crs = high[second] - -- if crs then - -- t = t + 1 - -- tokens[t] = first - -- first = crs - -- else - local cgf = graphemes[first] - if cgf and cgf[second] then - first = cgf[second] - else - t = t + 1 - tokens[t] = first - first = second - end - -- end - end - elseif second == " " then - first = second - else - -- local crs = high[second] - -- if crs then - -- first = crs - -- else - first = second - -- end - end - elseif second == " " then - first = nil - n = n + 1 - else - -- local crs = high[second] - -- if crs then - -- for s in utfcharacters(str) do - -- if n == 1 then - -- break - -- else - -- t = t + 1 - -- tokens[t] = s - -- n = n - 1 - -- end - -- end - -- if first then - -- t = t + 1 - -- tokens[t] = first - -- end - -- first = crs - -- done = true - -- else - local cgf = graphemes[first] - if cgf and cgf[second] then - for s in utfcharacters(str) do - if n == 1 then - break - else - t = t + 1 - tokens[t] = s - n = n - 1 - end - end - first = cgf[second] - done = true - else - first = second - n = n + 1 - end - -- end - end - end - if done then - if first then - t = t + 1 - tokens[t] = first - end - return concat(tokens) -- seldom called - end - elseif nstr > 0 then - return high[str] or str +-- function utffilters.collapse(str,filename) -- we can make high a seperate pass (never needed with collapse) +-- if skippable[filesuffix(filename)] then +-- return str +-- -- elseif find(filename,"^virtual://") then +-- -- return str +-- -- else +-- -- -- print("\n"..filename) +-- end +-- if str and str ~= "" then +-- local nstr = #str +-- if nstr > 1 then +-- if initialize then -- saves a call +-- initialize() +-- end +-- local tokens, t, first, done, n = { }, 0, false, false, 0 +-- for second in utfcharacters(str) do +-- if done then +-- if first then +-- if second == " " then +-- t = t + 1 +-- tokens[t] = first +-- first = second +-- else +-- -- local crs = high[second] +-- -- if crs then +-- -- t = t + 1 +-- -- tokens[t] = first +-- -- first = crs +-- -- else +-- local cgf = graphemes[first] +-- if cgf and cgf[second] then +-- first = cgf[second] +-- else +-- t = t + 1 +-- tokens[t] = first +-- first = second +-- end +-- -- end +-- end +-- elseif second == " " then +-- first = second +-- else +-- -- local crs = high[second] +-- -- if crs then +-- -- first = crs +-- -- else +-- first = second +-- -- end +-- end +-- elseif second == " " then +-- first = nil +-- n = n + 1 +-- else +-- -- local crs = high[second] +-- -- if crs then +-- -- for s in utfcharacters(str) do +-- -- if n == 1 then +-- -- break +-- -- else +-- -- t = t + 1 +-- -- tokens[t] = s +-- -- n = n - 1 +-- -- end +-- -- end +-- -- if first then +-- -- t = t + 1 +-- -- tokens[t] = first +-- -- end +-- -- first = crs +-- -- done = true +-- -- else +-- local cgf = graphemes[first] +-- if cgf and cgf[second] then +-- for s in utfcharacters(str) do +-- if n == 1 then +-- break +-- else +-- t = t + 1 +-- tokens[t] = s +-- n = n - 1 +-- end +-- end +-- first = cgf[second] +-- done = true +-- else +-- first = second +-- n = n + 1 +-- end +-- -- end +-- end +-- end +-- if done then +-- if first then +-- t = t + 1 +-- tokens[t] = first +-- end +-- return concat(tokens) -- seldom called +-- end +-- elseif nstr > 0 then +-- return high[str] or str -- thsi will go from here +-- end +-- end +-- return str +-- end + +-- this is about twice as fast + +local p_collapse = nil -- so we can reset if needed + +function utffilters.collapse(str,filename) + if not p_collapse then + if initialize then + initialize() end + local tree = lpeg.utfchartabletopattern(table.keys(collapsed)) + p_collapse = lpeg.Cs((tree/collapsed + lpegpatterns.utf8char)^0) + end + if not str or #str == "" or #str == 1 then + return str + elseif filename and skippable[filesuffix(filename)] then -- we could hash the collapsables or do a quicker test + return str + else + return lpegmatch(p_collapse,str) or str end - return str end -- function utffilters.decompose(str) @@ -399,17 +465,86 @@ end -- return str -- end -local tree = lpeg.utfchartabletopattern(table.keys(decomposed)) -local finder = lpeg.finder(tree,false,true) -local replacer = lpeg.replacer(tree,decomposed,false,true) +-- local replacer = nil +-- local finder = nil +-- +-- function utffilters.decompose(str) -- 3 to 4 times faster than the above +-- if not replacer then +-- if initialize then +-- initialize() +-- end +-- local tree = lpeg.utfchartabletopattern(table.keys(decomposed)) +-- finder = lpeg.finder(tree,false,true) +-- replacer = lpeg.replacer(tree,decomposed,false,true) +-- end +-- if str and str ~= "" and #str > 1 and lpegmatch(finder,str) then +-- return lpegmatch(replacer,str) +-- end +-- return str +-- end + +local p_decompose = nil function utffilters.decompose(str) -- 3 to 4 times faster than the above - if str and str ~= "" and #str > 1 and lpegmatch(finder,str) then - return lpegmatch(replacer,str) + if not p_decompose then + if initialize then + initialize() + end + local tree = lpeg.utfchartabletopattern(table.keys(decomposed)) + p_decompose = lpeg.Cs((tree/decomposed + lpegpatterns.utf8char)^0) + + end + if str and str ~= "" and #str > 1 then + return lpegmatch(p_decompose,str) end return str end +-- utffilters.addgrapheme(utfchar(318),'l','\string~') +-- utffilters.addgrapheme('c','a','b') + +function utffilters.addgrapheme(result,first,second) -- can be U+ 0x string or utf or number + local result = charfromnumber(result) + local first = charfromnumber(first) + local second = charfromnumber(second) + if not graphemes[first] then + graphemes[first] = { [second] = result } + else + graphemes[first][second] = result + end + local pair = first .. second + if not composed[pair] then + composed[pair] = result + p_composed = nil + end +end + +-- -- + +-- local c1, c2, c3 = "a", "̂", "̃" +-- local r2, r3 = "â", "ẫ" +-- local l1 = "ffl" +-- +-- local str = c1..c2..c3 .. " " .. c1..c2 .. " " .. l1 +-- local res = r3 .. " " .. r2 .. " " .. "ffl" +-- +-- local text = io.loaddata("t:/sources/tufte.tex") +-- +-- local function test(n) +-- local data = text .. string.rep(str,100) .. text +-- local okay = text .. string.rep(res,100) .. text +-- local t = os.clock() +-- for i=1,10000 do +-- collapse(data) +-- end +-- print(os.clock()-t,decompose(collapse(data))==okay,decompose(collapse(str))) +-- end +-- +-- test(050) +-- test(150) + +-- -- + local sequencers = utilities.sequencers if sequencers then diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 512dbb282..63fe35cd1 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{2014.06.06 23:52} +\newcontextversion{2014.06.11 15:52} %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 index 6bf00b133..7ffefbcfc 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 1290a7d92..8a91ce755 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -28,7 +28,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2014.06.06 23:52} +\edef\contextversion{2014.06.11 15:52} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/file-lib.lua b/tex/context/base/file-lib.lua index 3311321c5..409559cd3 100644 --- a/tex/context/base/file-lib.lua +++ b/tex/context/base/file-lib.lua @@ -25,7 +25,46 @@ local function defaultfailure(name) report_files("asked name %a, not found",name) end -function commands.uselibrary(specification) -- todo; reporter +-- function commands.uselibrary(specification) -- todo; reporter +-- local name = specification.name +-- if name and name ~= "" then +-- local patterns = specification.patterns or defaultpatterns +-- local action = specification.action or defaultaction +-- local failure = specification.failure or defaultfailure +-- local onlyonce = specification.onlyonce +-- local files = utilities.parsers.settings_to_array(name) +-- local truename = environment.truefilename +-- local done = false +-- for i=1,#files do +-- local filename = files[i] +-- if not loaded[filename] then +-- if onlyonce then +-- loaded[filename] = true -- todo: base this on return value +-- end +-- for i=1,#patterns do +-- local somename = format(patterns[i],filename) +-- if truename then +-- somename = truename(somename) +-- end +-- local foundname = resolvers.getreadfilename("any",".",somename) or "" +-- if foundname ~= "" then +-- action(name,foundname) +-- done = true +-- break +-- end +-- end +-- if done then +-- break +-- end +-- end +-- end +-- if failure and not done then +-- failure(name) +-- end +-- end +-- end + +function commands.uselibrary(specification) -- todo: reporter local name = specification.name if name and name ~= "" then local patterns = specification.patterns or defaultpatterns @@ -34,13 +73,15 @@ function commands.uselibrary(specification) -- todo; reporter local onlyonce = specification.onlyonce local files = utilities.parsers.settings_to_array(name) local truename = environment.truefilename - local done = false for i=1,#files do local filename = files[i] - if not loaded[filename] then + if loaded[filename] then + -- next one + else if onlyonce then loaded[filename] = true -- todo: base this on return value end + local done = false for i=1,#patterns do local somename = format(patterns[i],filename) if truename then @@ -53,13 +94,10 @@ function commands.uselibrary(specification) -- todo; reporter break end end - if done then - break + if failure and not done then + failure(name) end end end - if failure and not done then - failure(name) - end end end diff --git a/tex/context/base/file-mod.lua b/tex/context/base/file-mod.lua index 2f34d9dd2..39274ceef 100644 --- a/tex/context/base/file-mod.lua +++ b/tex/context/base/file-mod.lua @@ -35,8 +35,25 @@ local iterator = utilities.parsers.iterator -- modules can have a specific suffix or can specify one -local prefixes = { "m", "p", "s", "x", "v", "t" } -local suffixes = { "mkvi", "mkiv", "tex", "cld", "lua" } -- order might change and how about cld +local prefixes = { + "m", -- module, extends functionality + "p", -- private code + "s", -- styles + "x", -- xml specific modules + -- "v", -- an old internal one for examples + "t", -- third party extensions +} + +-- the order might change and how about cld + +local suffixes = { + "mkvi", -- proprocessed mkiv files + "mkiv", -- mkiv files + "tex", -- normally source code files + "cld", -- context lua documents (often stand alone) + "lua", -- lua files +} + local modstatus = { } local function usemodule(name,hasscheme) @@ -118,6 +135,10 @@ function commands.usemodules(prefix,askedname,truename) end if status then -- ok, don't change + elseif find(truename,"%-") and usemodule(truename) then + -- assume a user namespace + report_modules("using user prefixed file %a",truename) + status = 1 elseif not permit_unprefixed then -- forget about it elseif usemodule(truename) then diff --git a/tex/context/base/hand-ini.mkiv b/tex/context/base/hand-ini.mkiv index 450794d27..16c8b0746 100644 --- a/tex/context/base/hand-ini.mkiv +++ b/tex/context/base/hand-ini.mkiv @@ -51,10 +51,10 @@ \let\pdfadjustspacing\relax \newcount\pdfadjustspacing % a little bit protection \let\pdfprotrudechars\relax \newcount\pdfprotrudechars % a little bit protection -\def\font_expansion_enable {\normalpdfadjustspacing\plustwo } -\def\font_expansion_disable {\normalpdfadjustspacing\zerocount} -\def\font_protruding_enable {\normalpdfprotrudechars\plustwo } -\def\font_protruding_disable{\normalpdfprotrudechars\zerocount} +\def\font_expansion_enable {\normalpdfadjustspacing\plustwo } % these will become normal primitives +\def\font_expansion_disable {\normalpdfadjustspacing\zerocount} % these will become normal primitives +\def\font_protruding_enable {\normalpdfprotrudechars\plustwo } % these will become normal primitives +\def\font_protruding_disable{\normalpdfprotrudechars\zerocount} % these will become normal primitives \appendtoks \font_expansion_disable \to \everyforgetall % Here or not here? \appendtoks \font_protruding_disable \to \everyforgetall % Here or not here? diff --git a/tex/context/base/lpdf-col.lua b/tex/context/base/lpdf-col.lua index 9e483f9b5..924414d40 100644 --- a/tex/context/base/lpdf-col.lua +++ b/tex/context/base/lpdf-col.lua @@ -553,7 +553,7 @@ function lpdf.colorspec(model,ca,default) end function lpdf.pdfcolor(attribute) -- bonus, for pgf and friends - context(lpdfcolor(1,attribute)) + return lpdfcolor(1,attribute) end function lpdf.transparency(ct,default) -- kind of overlaps with transparencycode diff --git a/tex/context/base/lpdf-ini.lua b/tex/context/base/lpdf-ini.lua index eee5e2280..e8bd82cb9 100644 --- a/tex/context/base/lpdf-ini.lua +++ b/tex/context/base/lpdf-ini.lua @@ -56,9 +56,9 @@ local pdf = pdf local factor = number.dimenfactors.bp if pdf.setinfo then --- table.setmetatablenewindex(pdf,function(t,k,v) --- report_blocked("'pdf.%s' is not supported",k) --- end) + -- table.setmetatablenewindex(pdf,function(t,k,v) + -- report_blocked("'pdf.%s' is not supported",k) + -- end) -- the getters are harmless end @@ -103,15 +103,27 @@ local pdfimmediateobject = pdf.immediateobj local pdfdeferredobject = pdf.obj local pdfreferenceobject = pdf.refobj -function pdf.setinfo () report_blocked("'pdf.%s' is not supported","setinfo") end -- use lpdf.addtoinfo etc -function pdf.setcatalog () report_blocked("'pdf.%s' is not supported","setcatalog") end -function pdf.setnames () report_blocked("'pdf.%s' is not supported","setnames") end -function pdf.settrailer () report_blocked("'pdf.%s' is not supported","settrailer") end -function pdf.setpageresources () report_blocked("'pdf.%s' is not supported","setpageresources") end -function pdf.setpageattributes () report_blocked("'pdf.%s' is not supported","setpageattributes") end -function pdf.setpagesattributes() report_blocked("'pdf.%s' is not supported","setpagesattributes") end +-- function pdf.setinfo () report_blocked("'pdf.%s' is not supported","setinfo") end -- use lpdf.addtoinfo etc +-- function pdf.setcatalog () report_blocked("'pdf.%s' is not supported","setcatalog") end +-- function pdf.setnames () report_blocked("'pdf.%s' is not supported","setnames") end +-- function pdf.settrailer () report_blocked("'pdf.%s' is not supported","settrailer") end +-- function pdf.setpageresources () report_blocked("'pdf.%s' is not supported","setpageresources") end +-- function pdf.setpageattributes () report_blocked("'pdf.%s' is not supported","setpageattributes") end +-- function pdf.setpagesattributes() report_blocked("'pdf.%s' is not supported","setpagesattributes") end +-- function pdf.registerannot () report_blocked("'pdf.%s' is not supported","registerannot") end + +local function pdfdisablecommand(command) + pdf[command] = function() report_blocked("'pdf.%s' is not supported",command) end +end -function pdf.registerannot() report_blocked("'pdf.%s' is not supported","registerannot") end +pdfdisablecommand("setinfo") +pdfdisablecommand("setcatalog") +pdfdisablecommand("setnames") +pdfdisablecommand("settrailer") +pdfdisablecommand("setpageresources") +pdfdisablecommand("setpageattributes") +pdfdisablecommand("setpagesattributes") +pdfdisablecommand("registerannot") local trace_finalizers = false trackers.register("backend.finalizers", function(v) trace_finalizers = v end) local trace_resources = false trackers.register("backend.resources", function(v) trace_resources = v end) @@ -784,13 +796,50 @@ local catalog = pdfdictionary { Type = pdfconstant("Catalog") } -- nicer, but wh local info = pdfdictionary { Type = pdfconstant("Info") } -- nicer, but when we assign we nil the Type ----- names = pdfdictionary { Type = pdfconstant("Names") } -- nicer, but when we assign we nil the Type -local function flushcatalog() if not environment.initex then trace_flush("catalog") catalog.Type = nil pdfsetcatalog(catalog()) end end -local function flushinfo () if not environment.initex then trace_flush("info") info .Type = nil pdfsetinfo (info ()) end end --------------- flushnames () if not environment.initex then trace_flush("names") names .Type = nil pdfsetnames (names ()) end end +local function flushcatalog() + if not environment.initex then + trace_flush("catalog") + catalog.Type = nil + pdfsetcatalog(catalog()) + end +end + +local function flushinfo() + if not environment.initex then + trace_flush("info") + info.Type = nil + pdfsetinfo(info()) + end +end -function lpdf.addtocatalog(k,v) if not (lpdf.protectresources and catalog[k]) then trace_set("catalog",k) catalog[k] = v end end -function lpdf.addtoinfo (k,v) if not (lpdf.protectresources and info [k]) then trace_set("info", k) info [k] = v end end --------- lpdf.addtonames (k,v) if not (lpdf.protectresources and names [k]) then trace_set("names", k) names [k] = v end end +-- local function flushnames() +-- if not environment.initex then +-- trace_flush("names") +-- names.Type = nil +-- pdfsetnames(names()) +-- end +-- end + +function lpdf.addtocatalog(k,v) + if not (lpdf.protectresources and catalog[k]) then + trace_set("catalog",k) + catalog[k] = v + end +end + +function lpdf.addtoinfo(k,v) + if not (lpdf.protectresources and info[k]) then + trace_set("info",k) + info[k] = v + end +end + +-- local function lpdf.addtonames(k,v) +-- if not (lpdf.protectresources and names[k]) then +-- trace_set("names",k) +-- names[k] = v +-- end +-- end local names = pdfdictionary { -- Type = pdfconstant("Names") @@ -944,10 +993,11 @@ function lpdf.limited(n,min,max,default) end end --- lpdf.addtoinfo("ConTeXt.Version", tex.contextversiontoks) +-- lpdf.addtoinfo("ConTeXt.Version", environment.version) -- lpdf.addtoinfo("ConTeXt.Time", os.date("%Y.%m.%d %H:%M")) -- :%S -- lpdf.addtoinfo("ConTeXt.Jobname", environment.jobname) -- lpdf.addtoinfo("ConTeXt.Url", "www.pragma-ade.com") +-- lpdf.addtoinfo("ConTeXt.Support", "contextgarden.net") -- if not pdfreferenceobject then -- diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv index 555deca2c..ff7012caf 100644 --- a/tex/context/base/meta-ini.mkiv +++ b/tex/context/base/meta-ini.mkiv @@ -403,18 +403,9 @@ {\begingroup \edef\width {#2\space}\let\overlaywidth \width \edef\height{#3\space}\let\overlayheight\height - \ifcsname\??mpclip#1\endcsname - \meta_start_current_graphic - \xdef\MPclippath{\normalexpanded{\noexpand\ctxlua{metapost.theclippath { - instance = "\currentMPinstance", - format = "\currentMPformat", - data = \!!bs\getvalue{\??mpclip#1}\!!es, - initializations = \!!bs\meta_flush_current_initializations\!!es, - useextensions = "\MPinstanceparameter\s!extensions", - inclusions = \!!bs\meta_flush_current_inclusions\!!es, - method = "\MPinstanceparameter\c!method", - }}}}% - \meta_stop_current_graphic + \edef\currentMPclip{#1}% + \ifcsname\??mpclip\currentMPclip\endcsname + \meta_grab_clip_path_indeed \ifx\MPclippath\empty \xdef\MPclippath{#4}% \fi @@ -423,6 +414,19 @@ \fi \endgroup} +\def\meta_grab_clip_path_indeed + {\meta_start_current_graphic + \xdef\MPclippath{\normalexpanded{\noexpand\ctxlua{metapost.theclippath { + instance = "\currentMPinstance", + format = "\currentMPformat", + data = \!!bs\csname\??mpclip\currentMPclip\endcsname\!!es, + initializations = \!!bs\meta_flush_current_initializations\!!es, + useextensions = "\MPinstanceparameter\s!extensions", + inclusions = \!!bs\meta_flush_current_inclusions\!!es, + method = "\MPinstanceparameter\c!method", + }}}}% + \meta_stop_current_graphic} + %D Since we want lables to follow the document settings, we %D also set the font related variables. diff --git a/tex/context/base/page-txt.mkvi b/tex/context/base/page-txt.mkvi index 6d8d50028..c38b2fd4c 100644 --- a/tex/context/base/page-txt.mkvi +++ b/tex/context/base/page-txt.mkvi @@ -142,11 +142,11 @@ %D \showsetup{noheaderandfooterlines} %D \showsetup{notopandbottomlines} -\def\noheaderandfooterlines +\unexpanded\def\noheaderandfooterlines {\setuplayoutelement[\v!header][\c!state=\v!empty]% \setuplayoutelement[\v!footer][\c!state=\v!empty]} -\def\notopandbottomlines +\unexpanded\def\notopandbottomlines {\setuplayoutelement[\v!top ][\c!state=\v!empty]% \setuplayoutelement[\v!bottom][\c!state=\v!empty]} @@ -418,7 +418,7 @@ %D The following macro has to be called after a page %D is flushed. -\def\resetlayouttextlines % public +\unexpanded\def\resetlayouttextlines % public {\csname\??layouttextsreset\v!top \endcsname \csname\??layouttextsreset\v!header\endcsname \csname\??layouttextsreset\v!text \endcsname @@ -435,7 +435,7 @@ % \settext[header][text][middle][xxx][yyy] -\def\settextcontent +\unexpanded\def\settextcontent {\doquintupleempty\page_layouts_set_text_content} \def\page_layouts_set_text_content[#vertical][#horizontal][#one][#two][#three]% header text middle text/text @@ -456,7 +456,7 @@ \c!rightstyle\c!rightcolor\c!rightwidth{#one}}% \fi\fi\fi} -\def\resettextcontent +\unexpanded\def\resettextcontent {\dotripleempty\page_layouts_reset_text_content} \def\page_layouts_reset_text_content[#vertical][#horizontal][#tag]% header text middle diff --git a/tex/context/base/publ-imp-apa.bib b/tex/context/base/publ-imp-apa.bib deleted file mode 100644 index fe56719f8..000000000 --- a/tex/context/base/publ-imp-apa.bib +++ /dev/null @@ -1,29 +0,0 @@ -% The fields. - -@article {apa-article, - author = "...", - comment = "...", - crossref = "...", - editor = "...", - issue = "...", - journal = "...", - note = "...", - pages = "...", - title = "...", - volume = "...", - year = "...", -} - -@book {apa-book, - author = "...", - comment = "...", - chapter = "...", - crossref = "...", - editor = "...", - series = "...", - pages = "...", - publisher = "...", - volume = "...", - year = "...", -} - diff --git a/tex/context/base/publ-imp-apa.mkvi b/tex/context/base/publ-imp-apa.mkvi index 4d4edfc52..c17fa097e 100644 --- a/tex/context/base/publ-imp-apa.mkvi +++ b/tex/context/base/publ-imp-apa.mkvi @@ -21,6 +21,72 @@ \startbtxrenderingdefinitions[apa] +%D Because we want to mix rendering (in the manual) we need a namespace in label +%D texts: + +\setupbtxlabeltext + [en] + [apa:mastersthesis={Master's thesis}, + apa:phdthesis={PhD thesis}, + apa:technicalreport={Technical report}, + apa:editor=editor, + apa:editors=editors, + apa:edition=edition, + apa:volume=volume, + apa:Volume=Volume, + apa:number=number, + apa:Number=Number, + apa:in=in, + apa:of=of, + apa:In=In, + apa:p=p, + apa:pp=pp, + apa:pages=pages, + apa:and=and, + apa:others={et al.}] + +\setupbtxlabeltext + [fr] + [apa:mastersthesis={Thèse de master (DEA, DESS, master)}, + apa:phdthesis={Thèse de doctorat}, + apa:technicalreport={Rapport technique}, + apa:editor=éditeur, + apa:editors=éditeurs, + apa:edition=édition, + apa:volume=volume, + apa:Volume=Volume, + apa:number=numéro, + apa:Number=Numéro, + apa:in=dans, + apa:of=de, + apa:In=Dans, + apa:p=p, + apa:pp=pp, + apa:pages=pages, + apa:and=et, + apa:others={et al.}] + +\setupbtxlabeltext + [de] + [apa:mastersthesis={Masterarbeit}, + apa:phdthesis={Dissertation}, + apa:technicalreport={Technischer Bericht}, + apa:editor=Herausgeber, + apa:editors=Herausgeber, + apa:edition=Auflage, + apa:volume=Band, + apa:Volume=Band, + apa:number=Numer, + apa:Number=Numer, + apa:in=in, + apa:of=von, + apa:In=In, + apa:p=S, + apa:pp=S, + apa:pages=Seiten, + apa:and=und, + apa:others={et al.}] + %D The variables control the shared code for which we use a tex definition with %D one argument, specifying the field name. @@ -159,9 +225,9 @@ \btxflushauthor{editor} \btxcomma \btxsingularplural {editor} { - \btxlabeltext{editor} + \btxlabeltext{apa:editor} } { - \btxlabeltext{editors} + \btxlabeltext{apa:editors} } } { % weird period @@ -187,9 +253,9 @@ \btxflushauthor{editor} \btxcomma \btxsingularplural {editor} { - \btxlabeltext{editor} + \btxlabeltext{apa:editor} } { - \btxlabeltext{editors} + \btxlabeltext{apa:editors} } } { \btxdoif {key} { @@ -228,7 +294,7 @@ \btxspace \btxflush{pages} \btxspace - \btxlabeltext{p} + \btxlabeltext{apa:p} \btxperiod } \stoptexdefinition @@ -238,7 +304,7 @@ \btxspace \btxflush{pages} \btxspace - \btxlabeltext{pp} + \btxlabeltext{apa:pp} \btxperiod } \stoptexdefinition @@ -246,7 +312,7 @@ \starttexdefinition btx:apa:pages:pages \btxdoif {pages} { \btxcomma - \btxlabeltext{pages} + \btxlabeltext{apa:pages} \btxnbsp \btxflush{pages} } @@ -257,7 +323,7 @@ \btxspace \btxflush{edition} \btxspace - \btxlabeltext{edition} + \btxlabeltext{apa:edition} \btxperiod } \stoptexdefinition @@ -269,7 +335,7 @@ % \btxspace % \btxflush{edition} % \btxspace -% \btxlabeltext{edition} +% \btxlabeltext{apa:edition} % } % \stoptexdefinition @@ -285,12 +351,13 @@ \texdefinition{btx:apa:italic}{journal} } { \btxdoif {crossref} { - \btxlabeltext{In} + \btxlabeltext{apa:In} \btxspace \btxflush{crossref} } } \btxdoifelse {volume} { + \btxspace \texdefinition{btx:apa:italic}{volume} \btxdoif {issue} { \btxlparent @@ -316,19 +383,19 @@ \doifmodeelse {btx:apa:edited-book} { \btxdoifelse {volume} { \btxspace - \btxlabeltext{Number} + \btxlabeltext{apa:Number} \btxnbsp \btxflush{volume} \btxdoifelse {series} { \btxspace - \btxlabeltext{in} + \btxlabeltext{apa:in} \btxnbsp \btxflush{series} \btxperiod } { \btxdoifelse {crossref} { \btxspace - \btxlabeltext{in} + \btxlabeltext{apa:in} \btxlbracket \btxsetup{btx:format:crossref} \btxrbracket @@ -352,22 +419,22 @@ \texdefinition{btx:apa:pages:pages} \btxperiod \btxdoif {volume} { - \btxlabeltext{Volume} + \btxlabeltext{apa:Volume} \btxnbsp \btxflush{volume} \btxspace - \btxlabeltext{of} + \btxlabeltext{apa:of} \btxnbsp } } { \btxdoif {volume} { \btxcomma - \btxlabeltext{volume} + \btxlabeltext{apa:volume} \btxnbsp \btxflush{volume} \btxdoif {series} { \btxspace - \btxlabeltext{of} + \btxlabeltext{apa:of} \btxnbsp \texdefinition{btx:apa:italic}{series} } @@ -395,19 +462,19 @@ \doifmodeelse {btx:apa:edited-book} { \btxdoifelse {volume} { \btxspace - \btxlabeltext{number} + \btxlabeltext{apa:number} \btxnbsp \btxflush{volume} \btxdoifelse {series} { \btxspace - \btxlabeltext{in} + \btxlabeltext{apa:in} \btxnbsp \btxflush{series} \btxperiod } { \btxdoifelse {crossref} { \btxspace - \btxlabeltext{in} + \btxlabeltext{apa:in} \btxlbracket \btxsetup{btx:format:crossref} \btxrbracket @@ -430,11 +497,11 @@ } \texdefinition{btx:apa:pages:pages} \btxdoif {volume} { - \btxlabeltext{Volume} + \btxlabeltext{apa:Volume} \btxnbsp \btxflush{volume} \btxspace - \btxlabeltext{of} + \btxlabeltext{apa:of} \btxnbsp } \btxdoif {crossref} { @@ -445,12 +512,12 @@ } { \btxdoif {volume} { \btxcomma - \btxlabeltext{volume} + \btxlabeltext{apa:volume} \btxnbsp \btxflush{volume} \btxdoif {series} { \btxspace - \btxlabeltext{of} + \btxlabeltext{apa:of} \btxnbsp \texdefinition{btx:apa:italic}{series} } @@ -490,36 +557,48 @@ \startsetups btx:apa:incollection \texdefinition{btx:apa:author-and-year} - \btxdoif {arttitle} { - \btxflush{arttitle}\btxperiod + \btxdoifelse {arttitle} { + \btxflush{arttitle} + \btxperiod + } { + \btxdoif {title} { + \btxflush{title} + \btxperiod + } } - \btxlabeltext{In}\btxspace - \btxdoifelse {title} { - \btxflushauthor{editor} - \btxcomma - \texdefinition{btx:apa:italic}{title} + \btxlabeltext{apa:In} + \btxspace + \btxdoifelse {booktitle} { + \btxdoif {editor} { + \btxflushauthor{editor} + \btxcomma + } + \texdefinition{btx:apa:italic}{booktitle} \btxdoif {series} { \btxdoif {volume} { - \btxcomma - \btxlabeltext{number} + \btxspace + \btxlabeltext{apa:number} \btxspace \btxflush{volume} \btxspace - \btxlabeltext{in} + \btxlabeltext{apa:in} } + \btxspace \btxspace\btxflush{series} + \btxcomma } \btxdoif {chapter} { - \btxcomma - \btxflush{chapter} \btxspace + \btxflush{chapter} } + \btxspace \texdefinition{btx:apa:pages:pages} \btxdoif {edition} { \btxspace \btxflush{edition} \btxspace - \btxlabeltext{edition} + \btxlabeltext{apa:edition} + \btxspace } \texdefinition{btx:apa:wherefrom}{publisher} } { @@ -544,15 +623,16 @@ \btxflush{arttitle} \btxperiod } - \btxlabeltext{In}\btxspace + \btxlabeltext{apa:In} + \btxspace \btxdoifelse {title} { \btxdoif {editor} { \btxflush{btx:apa:format:editors} \btxcomma \btxsingularplural {editor} { - \btxlabeltext{editor} + \btxlabeltext{apa:editor} } { - \btxlabeltext{editors} + \btxlabeltext{apa:editors} } \btxcomma } @@ -560,10 +640,12 @@ \btxdoif {series} { \btxdoif {volume} { \btxcomma - \btxlabeltext{number}\btxspace\btxflush{crossref} + \btxlabeltext{apa:number} + \btxspace + \btxflush{crossref} \btxflush{volume} \btxspace - \btxlabeltext{in} + \btxlabeltext{apa:in} } \btxspace \btxflush{series} @@ -599,11 +681,11 @@ \texdefinition{btx:apa:italic}{title} \btxdoif {volume} { \btxcomma - \btxlabeltext{number} + \btxlabeltext{apa:number} \btxspace \btxflush{volume} \btxspace - \btxlabeltext{in} + \btxlabeltext{apa:in} \btxspace } \btxdoif {chapter} { @@ -624,7 +706,7 @@ \btxdoifelse {type} { \btxflush{type} } { - \btxlabeltext{\currentbtxcategory} + \btxlabeltext{apa:\currentbtxcategory} } \texdefinition{btx:apa:wherefrom}{school} \texdefinition{btx:apa:pages:p} @@ -650,8 +732,9 @@ } } { \btxspace - \btxlabeltext{technicalreport} + \btxlabeltext{apa:technicalreport} } + \btxcomma \texdefinition{btx:apa:wherefrom}{institution} \texdefinition{btx:apa:pages:p} \texdefinition{btx:apa:note} diff --git a/tex/context/base/publ-imp-aps.mkvi b/tex/context/base/publ-imp-aps.mkvi new file mode 100644 index 000000000..7af8efead --- /dev/null +++ b/tex/context/base/publ-imp-aps.mkvi @@ -0,0 +1,890 @@ +%D \module +%D [ file=publ-imp-aps, +%D version=2014.05.25, +%D title=APA bibliography style, +%D subtitle=Publications, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is therefore copyrighted +%D by \PRAGMA. See mreadme.pdf for details. + +\startbtxrenderingdefinitions[aps] + +\setupbtxlabeltext + [en] + [aps:mastersthesis={Master's thesis}, + aps:phdthesis={PhD thesis}, + aps:technicalreport={Technical report}, + aps:editor=editor, + aps:editors=editors, + aps:edition=edition, + aps:volume=volume, + aps:Volume=Volume, + aps:number=number, + aps:Number=Number, + aps:in=in, + aps:of=of, + aps:In=In, + aps:p=p, + aps:pp=pp, + aps:pages=pages, + aps:and=and, + aps:others={et al.}] + +\setupbtxlabeltext + [fr] + [aps:mastersthesis={Thèse de master (DEA, DESS, master)}, + aps:phdthesis={Thèse de doctorat}, + aps:technicalreport={Rapport technique}, + aps:editor=éditeur, + aps:editors=éditeurs, + aps:edition=édition, + aps:volume=volume, + aps:Volume=Volume, + aps:number=numéro, + aps:Number=Numéro, + aps:in=dans, + aps:of=de, + aps:In=Dans, + aps:p=p, + aps:pp=pp, + aps:pages=pages, + aps:and=et, + aps:others={et al.}] + +\setupbtxlabeltext + [de] + [aps:mastersthesis={Masterarbeit}, + aps:phdthesis={Dissertation}, + aps:technicalreport={Technischer Bericht}, + aps:editor=Herausgeber, + aps:editors=Herausgeber, + aps:edition=Auflage, + aps:volume=Band, + aps:Volume=Band, + aps:number=Numer, + aps:Number=Numer, + aps:in=in, + aps:of=von, + aps:In=In, + aps:p=S, + aps:pp=S, + aps:pages=Seiten, + aps:and=und, + aps:others={et al.}] + +% \c!authoretallimit=4, +% \c!editoretallimit=4, +% \c!artauthoretallimit=4, +% \c!authoretaldisplay=1, +% \c!editoretaldisplay=1, +% \c!artauthoretaldisplay=1, +% \c!authoretaltext={ {\it et al.\/}}, +% \c!editoretaltext={ {\it et al.\/}}, +% \c!artauthoretaltext={ {\it et al.\/}}] + +\setvariables + [btx:aps:publisher] + [left=\btxspace, + right=\btxperiod] + +\setvariables + [btx:aps:organization] + [left=\btxspace, + right=\btxperiod] + +\setvariables + [btx:aps:school] + [left=\btxcomma, + right=\btxperiod, + otherwise=\btxperiod] + +\setvariables + [btx:aps:institution] + [left=\btxcomma, + right=\btxperiod, + otherwise=\btxperiod] + +% \def\insertEdition#1#2#3{% +% \begingroup +% \insertedition{#1}{\doifnumberelse{\csname @@pb@edition\endcsname}{% +% \ifcase \csname @@pb@edition\endcsname \or st\or nd\or rd\else th\fi +% }{}#2}{#3}% +% \endgroup +% } + +\starttexdefinition btx:aps:chapter + \btxdoif {chapter} { + \btxcomma + \btxdoifelse {type} { + \btxflush{type} + \btxspace + } { + \btxlabeltext{aps:chapter} + } + \btxspace + \btxflush{chapter} + } +\stoptexdefinition + +\starttexdefinition btx:aps:publisher + \btxdoif {publisher} { + \btxflush{publisher} + } + \btxdoif {city} { + \btxcomma + \btxflush{city} + } + \btxdoif {country} { + \btxcomma + \btxflush{country} + } + \btxperiod +\stoptexdefinition + +\starttexdefinition btx:aps:pages-p-or-pp + \btxoneorrange {pages} { + \btxlabeltext{aps:p} + } { + \btxlabeltext{aps:pp} + } +\stoptexdefinition + +\starttexdefinition btx:aps:pages + \btxif {pages} { + \btxcomma + \btxoneorrange {pages} { + \btxlabeltext{aps:p} + } { + \btxlabeltext{aps:pp} + } + \btxperiod + \btxnbsp + \btxflush{pages} + } +\stoptexdefinition + +\starttexdefinition btx:aps:italic #field + \begingroup + \it + \btxflush{#field} + \italiccorrection + \endgroup +\stoptexdefinition + +\starttexdefinition btx:aps:bold #field + \begingroup + \bf + \btxflush{#field} + \endgroup +\stoptexdefinition + +\disablemode[btx:aps:edited-book] % hm, ugly + +\starttexdefinition btx:aps:note + \btxdoif {note} { + \btxspace + \btxflush{note} + \btxperiod + } +\stoptexdefinition + +\starttexdefinition btx:aps:comment + \btxdoif {comment} { + \btxspace + \btxflush{comment} + \btxperiod + } +\stoptexdefinition + +\startsetups btx:aps:article + \btxdoif {author} { + \btxflushauthor {author} + \btxspace + \btxdoif {key} { + \btxsetup{btx:format:key} + \btxspace + } + } + \btxdoif {title} { + \btxflush{title} + \btxperiod + } + \btxdoifelse {journal} { + \btxcomma + \btxflush{journal} + } + \btxdoifelse {volume} { + \texdefinition{btx:aps:bold}{volume} + \btxdoif {pages} { + \btxcomma + \btxfirstofrange{pages} + } + } { + \btxdoif {pages} { + \btxspace + \btxfirstofrange{pages} + } + } + \btxdoif {year} { + \btxlparent + \btxflush{year} + \btxrparent + } + \btxperiod + \texdefinition{btx:aps:note} + \texdefinition{btx:aps:comment} +\stopsetups + +\disablemode[btx:apa:edited-book] % hm, ugly + +\startsetups btx:aps:book + \btxdoif {author} { + \btxflushauthor {author} + \btxspace + } { + \btxdoifelse {editor} { + \btxflush{editor} + \btxcomma + \btxsingularorplural {editor} { + \btxlabeltext{aps:editor} + } { + \btxlabeltext{aps:editors} + } + \btxspace + \setmode{btx:apa:edited-book} + } { + \btxdoif {key} { + \btxflush{key} + \btxperiod + } + } + } + \btxdoifelse {title} { + \btxcomma + \texdefinition {btx:apa:italic} { + \doifmode {btx:apa:edited-book} { + \resetmode{editedbook} + \btxdoifelse {volume} { + \btxlabeltext{aps:Number} + \btxnbsp + \btxflush{number} + \btxdoifelse {series} { + \btxlabeltext{aps:in} + \btxnbsp + \btxflush{series} + \btxperiod + } { + \btxdoif {crossref} { + \btxlabeltext{aps:in} + \btxnbsp + \btxflush{crossref} + \btxperiod + } + } + } { + \insertseries{ }{.}{} + } + } { + \btxdoif {crossref} { + \texdefinition {btx:aps:chapter} + \btxdoif {pages} { + \btxcomma + \btxflush{pages} + \texdefinition{btx:aps:pages-p-or-pp} + } + \btxperiod + \btxdoif {volume} { + \btxlabeltext{aps:Volume} + \btxnbsp + \btxflush{volume} + \btxspace + \btxlabeltext{aps:of} + \btxnbsp + }% + \btxflush{crossref} + } { + \btxdoif {volume} { + \btxcomma + \btxlabeltext{aps:volume} + \btxnbsp + \btxflush{volume} + \btxdoif {series} { + \btxspace + \btxlabeltext{aps:of} + \btxnbsp + \texdefinition {btx:aps:italic} { + \btxflush{series} + } + } + \btxif {chapter} { + \btxcomma + \btxflush{chapter} + } + \texdefinition{btx:aps:pages} + \btxperiod + } + } + } + } + } { + \btxspace + } + \btxdoif {year} { + \btxlparent + \texdefinition{btx:aps:publisher} + \btxflush{year} + \btxrparent + \btxdoif {edition} { + \btxcomma + \btxflush{edition} + \btxspace + \btxlabeltext{aps:edition}% ed + } + } + \btxperiod + \texdefinition{btx:aps:note} +\stopsetups + +\startsetups btx:aps:inbook + \btxdoifelse {authors} { + \btxflushauthor {author} + } { + \btxdoifelse {editor} { + \btxflush{editor} + \btxcomma + \btxsingularorplural { + \btxlabeltext{aps:editor} + } { + \btxlabeltext{aps:editors} + } + \setmode{btx:aps:edited-book} + } { + \btxdoif {key} { + \btxsetup{btx:format:key} + \btxperiod + } + } + } + \btxdoif {title} { + \btxcomma + \texdefinition{btx:aps:italic}{title} + \btxdoif {year} { + \btxlparent + \texdefinition{btx:aps:publisher} + \btxflush{year} + \btxrparent + \btxif {edition} { + \btxcomma + \btxflush{edition} + \btxspace + \btxlabeltext{aps:edition} + \btxperiod + } + } + \doifmodeelse {btx:aps:edited-book} { + \resetmode{btx:aps:edited-book} + \btxdoifelse {volume} { + \btxspace + \btxlabeltext{aps:volume}% vol. (todo: add period to abbreviation) + \btxnbsp + \btxflush{volume} + \btxdoifelse {series} { + \btxspace + \btxlabeltext{aps:in} + \btxnbsp + \btxflush{series} + } { + \btxdoifelse {crossref} { + \btxspace + \btxlabeltext{aps:in} + \btxnbsp + \btxflush{crossref} + } + } + \btxperiod + } { + {\insertseries{ }{.}{} }% + } + } { + \btxdoifelse {crossref} { + \btxif {chapter} { + \btxcomma + \btxflush{chapter} + } + \texdefinition{btx:aps:pages} + \btxperiod + \btxdoif {volume} { + \btxlabeltext{aps:Volume} + \btxnbsp + \btxflush{volume} + \btxspace + \btxlabeltext{aps:of} + \btxnbsp + } + % weird: + \btxflush{crossref} + } { + \btxdoif {volume} { + \btxcomma + \btxlabeltext{aps:volume}% vol. + \btxnbsp + \btxflush{volume} + \btxif {series} { + \btxnbsp + \btxlabeltext{aps:of} + \btxnbsp + \texdefinition{btx:aps:italic}{ + \btxflush{series} + } + } + } + \btxdoif {chapter} { + \btxcomma + \btxflush{chapter} + } + \btxdoif {pages} { + \btxcomma + \btxflush{pages} + \texdefinition{btx:aps:pages-p-or-pp} + } + \btxperiod + } + } + } + \texdefinition{btx:aps:note} +\stopsetups + +\startsetups btx:aps:booklet + \btxdoif {author} { + \btxflushauthor {author} + \btxspace + } { + \btxdoif {key} { + \btxsetup{btx:format:key} + \btxperiod + } + } + \btxdoif {title} { + \btxflush{title} + \btxdoif {series} { + \btxlparent + \btxflush{series} + \btxrparent + } + \btxperiod + } + \btxdoif {year} { + \btxlparent + \texdefinition{btx:aps:publisher} + \btxflush{year} + \btxrparent + \btxdoif {edition} { + \btxcomma + % todo: st nd rd th + \btxflush{edition} + \btxspace + \btxlabeltext{aps:edition} + } + \btxperiod + } + \btxdoif {pages} { + \btxflush{pages} + \texdefinition{btx:aps:pages-p-or-pp} + \btxperiod + } + \texdefinition{btx:aps:note} +\stopsetups + +\startsetups btx:aps:manual + \btxif {title} { + \texdefinition {btx:aps:italic} { + \btxflush{title} + } + \btxif {series} { + \btxlparent + \btxflush{series} + \btxrparent + } + \btxperiod + } + \btxdoifelse {year} { + \btxlparent + \btxif {organization} { + \btxflush{organization} + \btxcomma + } + \btxif {city} { + \btxflush{organization} + \btxcomma + } + \btxflush{year} + \btxrparent + % st\or nd\or rd\else th\fi + \btxif {edition} { + \btxcomma + \btxflush{edition} + \btxspace + \btxlabeltext{aps:edition}% ed + } + \btxperiod + } + \btxdoif {pages} { + \btxflush{pages} + \texdefinition{btx:aps:pages-p-or-pp} + \btxperiod + } + \texdefinition{btx:aps:note} +\stopsetups + +\startsetups btx:aps:incollection + \btxdoifelse {author} { + \btxflushauthor {author} + } { + \btxif {key} { + \btxsetup{ntx:format:key} + \btxcomma + } + } + \btxdoifelse {title} { + \btxcomma + \btxlabeltext{aps:in} + \btxspace + \texdefinition{btx:aps:italic} {title} + \btxdoifelse {editor} { + \btxcomma + \btxlabeltext{aps:edited} % edited by + \btxspace + \btxflush{edited} + } { + \btxdoif {series} { + \btxdoifelse {volume} { + \btxcomma + \btxlabeltext{aps:number} + \btxspace + \btxflush{volume} + \btxnbsp + \btxlabeltext{aps:in} + } { + \btxspace + } + \btxflush{series} + } + } + \btxif {chapter} { + \btxcomma + \btxflush{chapter} + } + \btxspace + \btxif {year} { + \btxlparent + \btxflush{year} + \btxrparent + \texdefinition{btx:aps:publisher} + \btxif {edition} { + \btxcomma + \btxflush{edition} + \btxlabeltext{aps:edition}% ed. + } + \texdefinition{btx:aps:pages} + } + \btxperiod + } { + \btxlabeltext{aps:In} + \btxif {crossref} { + \btxflush{crossref} + } + \btxif {chapter} { + \btxcomma + \btxflush{chapter} + \btxspace + } + \texdefinition{btx:aps:pages} + \btxperiod + } + \texdefinition{btx:aps:note} +\stopsetups + +\startsetups btx:aps:inproceedings + \btxdoif {author} { + \btxflushauthor{author} + \btxspace + } + \btxdoifelse {title} { + \texdefinition {btx:aps:italic} { + \btxflush{ title} + } + \btxdoif {editor} { + \btxcomma + \btxlabeltext{aps:edited}% edited by + \btxspace + \btxflush{editor} + } + \btxdoif {chapter} { + \btxcomma + \btxflush{chapter} + } + \btxdoif {year} { + \btxlparent + \btxflush{year} + \btxdoifelse {organization} { + \btxcomma + \btxflush{organization} + } + \texdefinition{btx:aps:publisher} + \btxdoif {city} { + \btxcomma + \btxflush{city} + } + \btxrparent + } + \btxdoif {series} { + \btxcomma + \btxdoif {volume} { + \btxlabeltext{aps:volume}% vol. + \btxspace + \btxflush{volume} + \btxspace + \btxlabeltext{aps:of} + } + \texdefinition {btx:aps:italic} { + \btxflush{series} + } + } + \texdefinition{btx:aps:pages} + \btxperiod + } { + \btxspace + \btxlabeltext{aps:In} + \btxdoif {crossref} { + \btxflush{crossref} + } + \btxdoif {chapter} { + \btxcomma + \btxflush{chapter} + } + \texdefinition{btx:aps:pages} + \btxperiod + } + \texdefinition{btx:aps:note} +\stopsetups + +\startsetups btx:aps:proceedings + \btxdoifelse {editor} { + \btxflush{editor} + \btxcomma + \btxsingularorplural {editor} { + \btxlabeltext{aps:editor}% ed + } { + \btxlabeltext{aps:editors}% eds + } + \setmode{btx:aps:edited-book} + } { + \btxdoif {key} { + \btxsetup{btx:format:key} + \btxspace + } + } + \btxdoif {title} { + \texdefinition {btx:aps:italic} { + \btxflush{title} + } + \btxdoif {series} { + \bxtif {volume} { + \btxcomma + \btxlabeltext{aps:number} + \btxspace + \btxflush{volume} + \btxnbsp + \btxlabeltext{aps:in} + } + \btxspace + \btxflush{series} + } + \btxdoif {chapter} { + \btxcomma + \btxflush{chapter} + \btxspace + } + \btxdoif {year} { + \btxlparent + \btxdoif {organization} { + \btxflush{organization} + \btxcomma + } + \texdefinition{btx:aps:publisher} + \btxflush{year} + \btxrparent + } + \texdefinition{btx:aps:pages} + \btxif {city} { + \btxcomma + \btxflush{city} + } + } + \texdefinition{btx:aps:note} +\stopsetups + +\starttexdefinition btx:aps:thesis #field + \btxdoif {author} { + \btxflushauthor {author} + \btxcomma + } + \btxdoifelse {type} { + \btxflush{type} + \btxcomma + } { + \btxlabeltext{aps:#field} + } + \texdefinition{btx:aps:publisher} + \btxdoifelse {year} { + \btxlparent + \btxflush{year} + \btxrparent + } + \btxdoifelse {pages} { + \btxcomma + \btxflush{pages} + } + \texdefinition{btx:aps:note} +\stoptexdefinition + +\startsetups btx:aps:mastersthesis + \texdefinition{btx:aps:thesis}{mastersthesis} +\stopsetups + +\startsetups btx:aps:phdthesis + \texdefinition{btx:aps:thesis}{phdthesis} +\stopsetups + +\startsetups btx:aps:techreport + \btxdoif {author} { + \btxflushauthor{author} + \btxcomma + } + \btxdoif {title} { + \texdefinition {btx:apa:italic} { + \btxflush{title} + \btxdoifelse {series} { + \btxcomma + \btxlparent + \btxflush{series} + \btxrparent + } { + \btxspace + } + } + } + \btxdoifelse {type} { + \btxflush{type} + } { + \btxlabeltext{aps:techreport} + } + \btxdoif {volume} { + \btxspace + \btxflush{volume} + } + \btxcomma + \texdefinition{btx:aps:publisher} + \btxdoif {year} { + \btxlparent + \btxflush{year} + \btxrparent + } + \btxdoif {pages} { + \btxlcomma + \btxflush{pages} + } + \texdefinition{btx:aps:note} +\stopsetups + +\startsetups btx:aps:misc + \btxdoifelse {author} { + \btxflushauthor{author} + \btxdoif {title} { + \btxcomma + \texdefinition {btx:aps:italic} { + \btxflush{title} + } + } + } { + \btxdoifelse {title} { + \btxdoifelse {key} { + \btxsetup{btx:format:key} + \btxcomma + } + \texdefinition {btx:aps:italic} { + \btxflush{title} + } + } { + \btxdoifelse {key} { + \btxsetup{btx:format:key} + } + } + } + \btxdoif {series} { + \btxlparent + \btxflush{series} + \btxrparent + } + \btxdoifelse {year} { + \btxlparent + \texdefinition{btx:aps:publisher} + \btxflush{year} + \btxrparent + } { + \btxif {published} { + \btxcomma + \btxflush{published} + } + } + \btxif {pages} { + \btxcomma + \btxflush{pages} + } + \btxif {print} { + % eprint + \btxcomma + \btxflush{print} + } + \texdefinition{btx:aps:note} +\stopsetups + +\startsetups btx:aps:unpublished + \btxdoif {author} { + \btxflushauthor{author} + } + \btxdoif {title} { + \texdefinition {btx:aps:italic} { + \btxspace + \btxflush{title} + \btxdoif {series} { + \btxlparent + \btxflush{series} + \btxrparent + } + } + } + \btxdoif {type} { + \btxlparent + \btxflush{type} + \btxrparent + } + \btxlparent + \btxlabeltext{aps:unpublished}% new label + \btxdoifelse {year} { + \btxcomma + \btxflush{year} + } + \btxrparent + \btxdoif {pages} { + \btxcomma + \btxflush{pages} + \btxspace + } + \texdefinition{btx:aps:note} +\stopsetups + +\stopbtxrenderingdefinitions diff --git a/tex/context/base/publ-imp-test.bib b/tex/context/base/publ-imp-test.bib new file mode 100644 index 000000000..50e887a88 --- /dev/null +++ b/tex/context/base/publ-imp-test.bib @@ -0,0 +1,63 @@ +% The fields. This file needs to be filled with dummy data. Either fake names +% or maybe something DEK. + +@article {test-article, + author = "...", + comment = "...", + crossref = "...", + editor = "...", + issue = "...", + journal = "...", + note = "...", + pages = "...", + title = "...", + volume = "...", + year = "...", +} + +@book {test-book, + author = "...", + comment = "...", + chapter = "...", + crossref = "...", + editor = "...", + series = "...", + pages = "...", + publisher = "...", + volume = "...", + year = "...", +} + +@inbook {test-inbook, +} + +@booklet {test-booklet, +} + +@manual {test-manual, +} + +@incollection {test-incollection, +} + +@inproceedings {test-inproceedings, +} + +@proceedings {test-proceedings, +} + +@mastersthesis {test-mastersthesis, +} + +@phdthesis {test-phdthesis, +} + +@techreport {test-techreport, +} + +@misc {test-misc, +} + +@unpublished {test-unpublished, +} + diff --git a/tex/context/base/publ-ini.lua b/tex/context/base/publ-ini.lua index 91ace76fa..1ec88521e 100644 --- a/tex/context/base/publ-ini.lua +++ b/tex/context/base/publ-ini.lua @@ -9,7 +9,7 @@ if not modules then modules = { } end modules ['publ-ini'] = { -- we could store the destinations in the user list entries local next, rawget, type, tostring, tonumber = next, rawget, type, tostring, tonumber -local match, gmatch, format, gsub = string.match, string.gmatch, string.format, string.gsub +local match, gmatch, format, gsub, find = string.match, string.gmatch, string.format, string.gsub, string.find local concat, sort, tohash = table.concat, table.sort, table.tohash local utfsub = utf.sub local formatters = string.formatters @@ -431,17 +431,43 @@ local function getdetail(dataset,tag,name) return d and d[name] end -function commands.btxsingularorplural(dataset,tag,name) -- todo: make field dependent +function commands.btxsingularorplural(dataset,tag,name) local d = datasets[dataset].details[tag] if d then d = d[name] end - if d then + if type(d) == "table" then d = #d <= 1 + else + d = false end commands.doifelse(d) end +function commands.oneorrange(dataset,tag,name) + local d = datasets[dataset].luadata[tag] -- details ? + if d then + d = d[name] + end + if type(d) == "string" then + d = find(d,"%-") + else + d = false + + end + commands.doifelse(not d) -- so singular is default +end + +function commands.firstinrange(dataset,tag,name) + local d = datasets[dataset].luadata[tag] -- details ? + if d then + d = d[name] + end + if type(d) == "string" then + context(match(d,"([^%-]+)")) + end +end + -- basic loading function commands.usebtxdataset(name,filename) diff --git a/tex/context/base/publ-ini.mkiv b/tex/context/base/publ-ini.mkiv index 2f25724a0..04c8d4aea 100644 --- a/tex/context/base/publ-ini.mkiv +++ b/tex/context/base/publ-ini.mkiv @@ -977,6 +977,12 @@ \unexpanded\def\btxsingularplural#1% {\ctxcommand{btxsingularorplural("\currentbtxdataset","\currentbtxtag","#1")}} +\unexpanded\def\btxoneorrange#1% + {\ctxcommand{btxoneorrange("\currentbtxdataset","\currentbtxtag","#1")}} + +\unexpanded\def\btxfirstofrange#1% + {\ctxcommand{btxfirstofrange("\currentbtxdataset","\currentbtxtag","#1")}} + \let\btxsingularorplural\btxsingularplural %D Loading variants: diff --git a/tex/context/base/spac-ver.lua b/tex/context/base/spac-ver.lua index 55c135cf6..cfcee0122 100644 --- a/tex/context/base/spac-ver.lua +++ b/tex/context/base/spac-ver.lua @@ -886,14 +886,11 @@ local specialmethod = 1 local properties = nodes.properties.data -specialmethods[1] = function(start,penalty) +specialmethods[1] = function(pagehead,pagetail,start,penalty) -- if penalty < special_penalty_min or penalty > special_penalty_max then return end - -- this can move to the caller - local pagehead = tonut(texlists.page_head) - local pagetail = find_node_tail(pagehead) -- no texlists.page_tail yet-- no texlists.page_tail yet local current = pagetail -- -- nodes.showsimplelist(pagehead,0) @@ -1075,6 +1072,14 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also -- -- todo: keep_together: between headers -- + local function getpagelist() + if not pagehead then + pagehead = tonut(texlists.page_head) + pagetail = find_node_tail(pagehead) -- no texlists.page_tail yet-- no texlists.page_tail yet + end + return pagehead, pagetail + end + -- local function flush(why) if penalty_data then local p = new_penalty(penalty_data) @@ -1112,6 +1117,26 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also penalty_order, penalty_data, natural_penalty = 0, nil, nil parskip, ignore_parskip, ignore_following, ignore_whitespace = nil, false, false, false end + -- + +-- quick hack, can be done nicer +-- local nobreakfound = nil +-- local function checknobreak() +-- local pagehead, pagetail = getpagelist() +-- local current = pagetail +-- while current do +-- local id = getid(current) +-- if id == hlist_code or id == vlist_code then +-- return false +-- elseif id == penalty_code then +-- return getfield(current,"penalty") >= 10000 +-- end +-- current = getprev(current) +-- end +-- return false +-- end + + -- if trace_vsnapping then report_snapper("global ht/dp = %p/%p, local ht/dp = %p/%p", texgetdimen("globalbodyfontstrutheight"), texgetdimen("globalbodyfontstrutdepth"), @@ -1119,9 +1144,15 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also ) end if trace then trace_info("start analyzing",where,what) end + while current do local id = getid(current) if id == hlist_code or id == vlist_code then + +-- if nobreakfound == nil then +-- nobreakfound = false +-- end + -- needs checking, why so many calls if snap then local list = getlist(current) @@ -1167,6 +1198,17 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also -- natural_penalty = getfield(current,"penalty") -- if trace then trace_done("removed penalty",current) end -- head, current = remove_node(head, current, true) + +-- if nobreakfound == nil then +-- nobreakfound = checknobreak() +-- end +-- if nobreakfound and getfield(current,"penalty") <= 10000 then +-- -- if trace then +-- trace_done("removed penalty",current) +-- -- end +-- head, current = remove_node(head, current, true) +-- end + current = getnext(current) elseif id == kern_code then if snap and trace_vsnapping and getfield(current,"kern") ~= 0 then @@ -1182,7 +1224,8 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also local sp = getattr(current,a_skippenalty) -- has no default, no unset (yet) if sp and sc == penalty then if where == "page" then - local p = specialmethods[specialmethod](current,sp) + local pagehead, pagetail = getpagelist() + local p = specialmethods[specialmethod](pagehead,pagetail,current,sp) if p then if trace then trace_skip("previous special penalty %a is changed to %a using method %a",sp,p,specialmethod) @@ -1190,6 +1233,12 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also special_penalty = sp sp = p end + +-- else +-- if nobreakfound == nil then +-- nobreakfound = checknobreak() +-- end + end if not penalty_data then penalty_data = sp @@ -1199,6 +1248,14 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also penalty_data = sp end if trace then trace_skip("penalty in skip",sc,so,sp,current) end + +-- if nobreakfound then +-- penalty_data = 10000 +-- if trace then +-- trace_skip("nobreak found before penalty in skip",sc,so,sp,current) +-- end +-- end + head, current = remove_node(head, current, true) elseif not sc then -- if not sc then if glue_data then diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 2801e2b05..7e431659c 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index dba0dc0b7..2e9d791a6 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/syst-ini.mkiv b/tex/context/base/syst-ini.mkiv index a533f8a6a..e01b8315c 100644 --- a/tex/context/base/syst-ini.mkiv +++ b/tex/context/base/syst-ini.mkiv @@ -1016,12 +1016,18 @@ % \bindprimitive ifabsnum ifpdfabsnum %D We need to make sure that we start up in \DVI\ mode, so, after testing for running -%D \PDFTEX, we default to \DVI. - -\pdfoutput \zerocount -\pdfminorversion \plusfive -\pdfgentounicode \plusone -\pdfinclusioncopyfonts\plusone +%D \PDFTEX, we default to \DVI. Why? + +\pdfoutput \zerocount +\pdfminorversion \plussix +\pdfgentounicode \plusone +\pdfinclusioncopyfonts \plusone +\pdfinclusionerrorlevel \zerocount +\pdfdecimaldigits \plusten +\pdfhorigin 1 true in +\pdfvorigin \pdfhorigin +\pdfimageresolution 300 +\pdfpkresolution 600 \normalprotected\def\nopdfcompression {\pdfobjcompresslevel\zerocount \pdfcompresslevel\zerocount} \normalprotected\def\maximumpdfcompression{\pdfobjcompresslevel\plusnine \pdfcompresslevel\plusnine } diff --git a/tex/context/bib/sample.bib b/tex/context/bib/sample.bib index 3f8df623e..4bb71d3a7 100644 --- a/tex/context/bib/sample.bib +++ b/tex/context/bib/sample.bib @@ -35,4 +35,3 @@ address = {London}, keywords = {general}, } - diff --git a/tex/context/sample/dawkins.tex b/tex/context/sample/dawkins.tex index 3490b79b0..c0acd3157 100644 --- a/tex/context/sample/dawkins.tex +++ b/tex/context/sample/dawkins.tex @@ -8,13 +8,13 @@ individual out. \quotation {Let's first establish,} I said, right half of the lecture hall.} I invited everybody to stand up while my assistant tossed a coin. Everybody on the left of the hall was asked to \quote {will} the coin to -come down head. Everybody on the right had to will it to be +come down heads. Everybody on the right had to will it to be tails. Obviously one side had to lose, and they were asked -to sit down. Then those who remained were divided into two, +to sit down. Then those that remained were divided into two, with half \quote {willing} heads and the other half tails. Again the losers sat down. And so on by successive halvings until, inevitably, after seven or eight tosses, one individual was left standing. \quotation {A big round of applause for our psychic.} He must be psychic, mustn't he, because he successfully influenced the coin eight times in -a row? \ No newline at end of file +a row? diff --git a/tex/context/sample/douglas.tex b/tex/context/sample/douglas.tex index 7d986d484..838c6d24d 100644 --- a/tex/context/sample/douglas.tex +++ b/tex/context/sample/douglas.tex @@ -1,18 +1,18 @@ Donald Knuth has spent the past several years working on a system allowing him to control many aspects of the design -of his forthcoming books, from the typesetting and layout +of his forthcoming books|=|from the typesetting and layout down to the very shapes of the letters! Seldom has an author had anything remotely like this power to control the final appearance of his or her work. Knuth's \TEX\ -typesetting system has become well|-|known and available in +typesetting system has become well|-|known and as available in many countries around the world. By contrast, his \METAFONT\ system for designing families of typefaces has -not become as well known or available. +not become as well known or as available. In his article \quotation {The Concept of a Meta|-|Font}, Knuth sets forth for the first time the underlying philosophy of \METAFONT, as well as some of its products. -Not only is the concept exiting and clearly well executed, +Not only is the concept exciting and clearly well executed, but in my opinion the article is charmingly written as well. However, despite my overall enthusiasm for Knuth's idea and article, there are some points in it that I feel might be diff --git a/tex/context/sample/sample.tex b/tex/context/sample/sample.tex index 5f97ea009..ef31153a1 100644 --- a/tex/context/sample/sample.tex +++ b/tex/context/sample/sample.tex @@ -1,75 +1,21 @@ -\starttext - -The sample directory contains a few files with quotes that can be used -while testing styles. - -I'll complete this file when I've reorganized my books and audio cd's. - -If someone makes a nice bibtex file of these, the quotes can also be -used in testing bibliographic references and citations. - -\starttabulate[|l|l|p|] -\NC \bf file \NC \bf author \NC \bf source \NC \NR -\HL -%NC stork.tex \NC David F. Stork \NC \NC \NR -\NC knuth.tex \NC Donald E. Knuth \NC \NC \NR -\NC tufte.tex \NC Edward R. Tufte \NC \NC \NR -\NC reich.tex \NC Steve Reich \NC \NC \NR -\NC materie.tex \NC Louis Andriessen \NC De Materie \NC \NR -\NC douglas.tex \NC Douglas R. Hofstadter \NC \NC \NR -\NC dawkins.tex \NC Dawkins \NC \NC \NR -\NC ward.tex \NC Peter D. Ward \NC The Life and Death of Planet Earth \NC \NR -\NC zapf.tex \NC Hermann Zapf \NC About micro-typography and the hz-program, \endgraf - Electronic Publishing, vol. 6(3), \endgraf - 283-288 (September 1993) \NC \NR -\NC bryson.tex \NC Bill Bryson \NC A Short History of Nearly Everything, \endgraf - Random House, 2003 \NC \NR -\NC davis.tex \NC Kenneth C. Davis \NC Don't Know Much About History, \endgraf - Everything You Need to Know About American - History but Never Learned, \endgraf - HarperCollins, 2003 \NC \NR -\NC thuan.tex \NC Trinh Xuan Thuan \NC Chaos and Harmony, Perspectives on Scientific - Revolutions of the Twentieth Century, \endgraf - Oxford University Press, 2001 \NC \NR -\NC hawking.tex \NC Steve W. Hawking \NC The Universe in a Nutshell, Bantam Books - Random House, 2001 \NC \NR -\NC linden.tex \NC Eugene Linden \NC The Winds of Change, Climate, Weather, and the - Destruction of Civilizations, \endgraf - Simon \& Schuster, 2006, p.106 \NC \NR -\NC weisman.tex \NC Alan Weisman \NC The World Without Us, \endgraf - Thomas Dunne Books, 2007, p.160 \NC \NR -\NC montgomery.tex \NC David R Montgomery \NC Dirt, The Erosion of Civilizations, \endgraf - University of California Press, 2007, p.199 \NC \NR -\NC carrol.tex \NC Sean B. Carrol \NC The Making of the Fittest, \endgraf - Quercus, London, 2006 \NC \NR -%NC schwarzenegger.tex \NC Arnold Schwarzenegger \NC Several place on the World Wide Web. \NC \NR -\stoptabulate +% this original file has been renamed to samples.tex and describes the +% short quotes that can be used in test files -% Tufte: This quote will always produce hyphenated text, apart from the content, -% it's a pretty good test case for protruding. - -% Ward: I should find a quote in the extremely well written Rare Earth as well. All Wards -% books excell. - -% A Short History of Nearly Everything: I wish that I had the memory to remember this book -% verbatim. - -% Chaos and Harmony: very nice and well written book, but the typography is rather bad: -% quite visible inter-character spacing in a text that can be typeset quite well by \TeX. +\starttext -% The Universe in a Nutshell: a beautiful designed book, (companion of A Short History -% of Time). +see \type {samples.tex} -% The World Without Us: A properly typeset, very readable book. Read it and you'll look at -% the world around you differently (and a bit more freightened). +\blank -% Dirt, The Erosion of Civilizations: one of those books that you buy immediately after -% reading a few sentences. Also one of those books that every politician should read. +\startluacode + context("see \\type {samples.tex}") +\stopluacode -% The Making of the Fittest: nice sample for color ans subsentence testing. A very -% readable book but unfortunately it has inter-character spacing. +\blank -% The Schwarzenegger letter was originally typeset at a width equivalent to 16.1cm in -% a default ConTeXt setup. +\startMPcode + draw textext("see \type {samples.tex}") ; + draw boundingbox currentpicture enlarged 2pt ; +\stopMPcode \stoptext diff --git a/tex/context/sample/samples.bib b/tex/context/sample/samples.bib new file mode 100644 index 000000000..e54092aae --- /dev/null +++ b/tex/context/sample/samples.bib @@ -0,0 +1,29 @@ +% The following entries were provided by Rik Kabel: + +@book{dawkins2000unweaving, + title = {Unweaving the Rainbow: Science, Delusion and the Appetite for Wonder}, + author = {Dawkins, R.}, + isbn = {9780547347356}, + url = {http://books.google.com/books?id=ZudTchiioUoC}, + year = {2000}, + publisher = {Houghton Mifflin Harcourt}, + pages = {145--146}, +} + +@book{Hofstadter:1985:MTQ:537101, + author = {Hofstadter, Douglas R.}, + title = {Metamagical Themas: Questing for the Essence of Mind and Pattern}, + year = {1985}, + isbn = {0465045405}, + publisher = {Basic Books, Inc.}, + address = {New York, NY, USA}, +} + +@book{Tufte:1990:EI:78223, + author = {Tufte, Edward}, + title = {Envisioning Information}, + year = {1990}, + isbn = {0-9613921-1-8}, + publisher = {Graphics Press}, + address = {Cheshire, CT, USA}, +} diff --git a/tex/context/sample/samples.tex b/tex/context/sample/samples.tex new file mode 100644 index 000000000..d8640055a --- /dev/null +++ b/tex/context/sample/samples.tex @@ -0,0 +1,77 @@ +\starttext + +The sample directory contains a few files with quotes that can be used +while testing styles. + +I'll complete this file when I've reorganized my books and audio cd's. + +If someone makes a nice bibtex file of these, the quotes can also be +used in testing bibliographic references and citations. + +\starttabulate[|l|l|p|] +\NC \bf file \NC \bf author \NC \bf source \NC \NR +\HL +%NC stork.tex \NC David F. Stork \NC \NC \NR +\NC knuth.tex \NC Donald E. Knuth \NC \NC \NR +\NC tufte.tex \NC Edward R. Tufte \NC \NC \NR +\NC reich.tex \NC Steve Reich \NC City Life (1995) \NC \NR +\NC materie.tex \NC Louis Andriessen \NC De Materie \NC \NR +\NC douglas.tex \NC Douglas R. Hofstadter \NC \NC \NR +\NC dawkins.tex \NC Dawkins \NC \NC \NR +\NC ward.tex \NC Peter D. Ward \NC The Life and Death of Planet Earth \NC \NR +\NC zapf.tex \NC Hermann Zapf \NC About micro-typography and the hz-program, \endgraf + Electronic Publishing, vol. 6(3), \endgraf + 283-288 (September 1993) \NC \NR +\NC bryson.tex \NC Bill Bryson \NC A Short History of Nearly Everything, \endgraf + Random House, 2003 \NC \NR +\NC davis.tex \NC Kenneth C. Davis \NC Don't Know Much About History, \endgraf + Everything You Need to Know About American + History but Never Learned, \endgraf + HarperCollins, 2003 \NC \NR +\NC thuan.tex \NC Trinh Xuan Thuan \NC Chaos and Harmony, Perspectives on Scientific + Revolutions of the Twentieth Century, \endgraf + Oxford University Press, 2001 \NC \NR +\NC hawking.tex \NC Steve W. Hawking \NC The Universe in a Nutshell, Bantam Books + Random House, 2001 \NC \NR +\NC linden.tex \NC Eugene Linden \NC The Winds of Change, Climate, Weather, and the + Destruction of Civilizations, \endgraf + Simon \& Schuster, 2006, p.106 \NC \NR +\NC weisman.tex \NC Alan Weisman \NC The World Without Us, \endgraf + Thomas Dunne Books, 2007, p.160 \NC \NR +\NC montgomery.tex \NC David R Montgomery \NC Dirt, The Erosion of Civilizations, \endgraf + University of California Press, 2007, p.199 \NC \NR +\NC carrol.tex \NC Sean B. Carrol \NC The Making of the Fittest, \endgraf + Quercus, London, 2006 \NC \NR +%NC schwarzenegger.tex \NC Arnold Schwarzenegger \NC Several place on the World Wide Web. \NC \NR +\stoptabulate + +% Tufte: This quote will always produce hyphenated text, apart from the content, +% it's a pretty good test case for protruding. + +% Reich: This is a list of the voice samples from Steve Reich's 1995 composition City Life. + +% Ward: I should find a quote in the extremely well written Rare Earth as well. All Wards +% books excell. + +% A Short History of Nearly Everything: I wish that I had the memory to remember this book +% verbatim. + +% Chaos and Harmony: very nice and well written book, but the typography is rather bad: +% quite visible inter-character spacing in a text that can be typeset quite well by \TeX. + +% The Universe in a Nutshell: a beautiful designed book, (companion of A Short History +% of Time). + +% The World Without Us: A properly typeset, very readable book. Read it and you'll look at +% the world around you differently (and a bit more freightened). + +% Dirt, The Erosion of Civilizations: one of those books that you buy immediately after +% reading a few sentences. Also one of those books that every politician should read. + +% The Making of the Fittest: nice sample for color ans subsentence testing. A very +% readable book but unfortunately it has inter-character spacing. + +% The Schwarzenegger letter was originally typeset at a width equivalent to 16.1cm in +% a default ConTeXt setup. + +\stoptext diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 0f4cdc112..1330b0ab3 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 : 06/06/14 23:52:32 +-- merge date : 06/11/14 15:52:46 do -- begin closure to overcome local limits and interference -- cgit v1.2.3