From 608cf07d5f08dd7230016dadfe688239f35e7f81 Mon Sep 17 00:00:00 2001
From: Hans Hagen <pragma@wxs.nl>
Date: Mon, 11 Oct 2010 01:11:00 +0200
Subject: beta 2010.10.11 01:11

---
 tex/context/base/cont-new.tex               |  2 +-
 tex/context/base/context.tex                |  2 +-
 tex/context/base/lxml-aux.lua               |  2 +-
 tex/context/base/lxml-tex.lua               | 14 +++++---
 tex/context/base/page-txt.mkiv              | 16 +++++++++
 tex/context/base/strc-itm.mkiv              | 50 ++++++++++++++++++++++++-----
 tex/context/base/strc-reg.lua               | 17 +++++-----
 tex/context/base/strc-reg.mkiv              | 10 +++---
 tex/context/base/strc-sec.mkiv              | 46 ++++++++++++++++++++------
 tex/generic/context/luatex-fonts-merged.lua |  2 +-
 10 files changed, 122 insertions(+), 39 deletions(-)

(limited to 'tex')

diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index 1ec2bd3f8..3020a29c8 100644
--- a/tex/context/base/cont-new.tex
+++ b/tex/context/base/cont-new.tex
@@ -11,7 +11,7 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\newcontextversion{2010.10.10 14:25}
+\newcontextversion{2010.10.11 01:11}
 
 %D This file is loaded at runtime, thereby providing an
 %D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex
index e08f3528a..d2c821541 100644
--- a/tex/context/base/context.tex
+++ b/tex/context/base/context.tex
@@ -20,7 +20,7 @@
 %D your styles an modules.
 
 \edef\contextformat {\jobname}
-\edef\contextversion{2010.10.10 14:25}
+\edef\contextversion{2010.10.11 01:11}
 
 %D For those who want to use this:
 
diff --git a/tex/context/base/lxml-aux.lua b/tex/context/base/lxml-aux.lua
index f01478dbe..7392afabb 100644
--- a/tex/context/base/lxml-aux.lua
+++ b/tex/context/base/lxml-aux.lua
@@ -378,7 +378,7 @@ local function stripelement(e,nolines,anywhere)
                     end
                 end
             end
-            if #edt > 1 then
+            if #edt > 0 then
                 -- strip end
                 local str = edt[#edt]
                 if type(str) ~= "string" then
diff --git a/tex/context/base/lxml-tex.lua b/tex/context/base/lxml-tex.lua
index a90844d2e..407d5eda8 100644
--- a/tex/context/base/lxml-tex.lua
+++ b/tex/context/base/lxml-tex.lua
@@ -988,18 +988,24 @@ local function text(collected)
     end
 end
 
-local function stripped(collected)
+local function ctxtext(collected)
     if collected then
         for c=1,#collected do
-            cprint(xml.stripelement(collected[c]))
+            texsprint(ctxcatcodes,collected[1].dt)
         end
     end
 end
 
-local function ctxtext(collected)
+--~     local str = xmltext(getid(id),pattern) or ""
+--~     str = gsub(str,"^%s*(.-)%s*$","%1")
+--~     if nolines then
+--~         str = gsub(str,"%s+"," ")
+--~     end
+
+local function stripped(collected) -- tricky as we strip in place
     if collected then
         for c=1,#collected do
-            texsprint(ctxcatcodes,collected[1].dt)
+            cprint(xml.stripelement(collected[c]))
         end
     end
 end
diff --git a/tex/context/base/page-txt.mkiv b/tex/context/base/page-txt.mkiv
index 3885b4bce..2ac9cb6b9 100644
--- a/tex/context/base/page-txt.mkiv
+++ b/tex/context/base/page-txt.mkiv
@@ -392,12 +392,28 @@
 
 \newbox\scratchpagebox
 
+% \newbox\collectedprepagecontent % only for delayed stuff
+
+% \def\flushcollectedpagecontent
+%   {\ifvoid\collectedprepagecontent \else
+%      \smashbox\collectedprepagecontent
+%      \box\collectedprepagecontent
+%    \fi}
+
+% \def\delaytillpageisflushhed#1%
+%   {\global\setbox\collectedprepagecontent\hbox
+%      {\ifvoid\collectedprepagecontent \else
+%         \unhbox\collectedprepagecontent
+%       \fi % ignore and remove not really needed
+%       \ignorespaces#1\removeunwantedspaces}}
+
 \def\gettextboxes
   {\setbox\scratchpagebox\vbox
      {\dontcomplain
       \calculatereducedvsizes
       \swapmargins
       \offinterlineskip
+%       \flushcollectedpagecontent
       \vskip\dimexpr-\topheight-\topdistance\relax
       \the\toptextcontent
       \vskip\dimexpr\topheight+\topdistance\relax
diff --git a/tex/context/base/strc-itm.mkiv b/tex/context/base/strc-itm.mkiv
index 6211fd9b6..d0cf8817f 100644
--- a/tex/context/base/strc-itm.mkiv
+++ b/tex/context/base/strc-itm.mkiv
@@ -15,6 +15,9 @@
 
 \registerctxluafile{strc-itm}{1.001}
 
+% this will be reimplemented: \startitem ... \stopitem will be the main macros and
+% \item will then call them
+
 \unprotect
 
 \newconditional\sublistitem            \setfalse\sublistitem
@@ -70,6 +73,7 @@
 
 \def\dohandleitemreference % we will make a decent number helper
   {\ifx\currentitemreference \empty \else
+\iftrialtypesetting \else
      \setnextinternalreference
      \ctxlua {structures.references.setandgetattribute("\s!full", "\referenceprefix","\currentitemreference",
         {
@@ -105,9 +109,9 @@
      }%
      \xdef\currentitemattribute{\number\lastdestinationattribute}%
      \begingroup\attribute\destinationattribute\currentitemattribute\kern\zeropoint\endgroup % todo, apply attribute to symbol
+\fi
    \fi}
 
-
 % \startitemize[n,packed]
 % \item test \item test \item test
 % \stopitemize
@@ -578,7 +582,7 @@
 
 \@EA\long\@EA\def\@EA\collectitemgroupitem\@EA#\@EA1\csname\e!stop\v!item\endcsname
   {\increment\itemcollectcounter
-   \long\setvalue{\v!item*\itemcollectcounter}{\item#1\par}}
+   \long\setvalue{\v!item*\itemcollectcounter}{\startitemgroupitem#1\stopitemgroupitem}}
 
 \def\flushcollecteditems
   {\ifconditional\randomizeitems
@@ -654,6 +658,9 @@
    \doifinsetelse\v!random  {#1}{\settrue\randomizeitems   }{\setfalse\randomizeitems   }%
    \doifinsetelse\v!continue{#1}{\settrue\continuelistitems}{\setfalse\continuelistitems}%
    % == \doifinsetelse\v!intro{#1}\settrue\setfalse\introlistitem
+\iftrialtypesetting
+    \savestructurecounter[\currentitemgroupcounter]%[\currentitemlevel]% todo: per level
+\fi
    \global\advance\noflists\plusone
    \currentnoflists\noflists
    \noflistelements\zerocount
@@ -766,6 +773,11 @@
 % \item \input ward \item \input ward \item \input ward
 % \stopitemize \blank
 
+\def\dorestoreitemgroup
+  {\restorestructurecounter[\currentitemgroupcounter]% [\currentitemlevel]% todo: per level
+   \global\advance\noflists\minusone
+   \currentnoflists\noflists}
+
 \unexpanded\def\stopitemgroup
   {\stopcollectitems
    \ifconditional\textlistitem
@@ -776,8 +788,8 @@
    \dolistreference
    \ifconditional\firstlistitem
    \else
-\dostoptagged
-\dostoptagged
+     \dostoptagged
+     \dostoptagged
      \endgroup
    \fi % toegevoegd, eerste \som opent groep
    \ifnum\itemcolumndepth=\currentitemlevel\relax
@@ -801,6 +813,9 @@
      \fi
    \fi
    % new test, needed in sidefloats (surfaced in volker's proceedings)
+\iftrialtypesetting
+  \dorestoreitemgroup
+\fi
    \ifconditional\textlistitem % else forgotten
      \endgroup
      \global\advance\itemdepth-\itemincrement
@@ -899,14 +914,33 @@
 %
 % so we need to keep that property
 
+\let\startitemgroupitem\itemgroupitem
+
+\def\stopitemgroupitem
+  {\ifconditional\textlistitem
+     % nothing
+   \else
+     \endgraf
+   \fi}
+
+\def\startitemgroupitemhead#1%
+  {\itemgrouphead#1\par}
+
+\def\stopitemgroupitemhead
+  {\ifconditional\textlistitem
+     % to be tested
+   \else
+     \endgraf
+   \fi}
+
 \appendtoks
-  \letvalue{\e!start\v!item}\itemgroupitem
-  \letvalue{\e!stop \v!item}\endgraf
+  \letvalue{\e!start\v!item}\startitemgroupitem
+  \letvalue{\e!stop \v!item}\stopitemgroupitem
 \to \itemgroupcommands
 
 \appendtoks
-  \setvalue{\e!start\v!head}#1{\itemgrouphead#1\par}%
-  \letvalue{\e!stop \v!head}\endgraf
+  \letvalue{\e!start\v!head}\startitemgroupitemhead
+  \letvalue{\e!stop \v!head}\stopitemgroupitemhead
 \to \itemgroupcommands
 
 % \startitemize
diff --git a/tex/context/base/strc-reg.lua b/tex/context/base/strc-reg.lua
index 899339b5c..e2fbb9527 100644
--- a/tex/context/base/strc-reg.lua
+++ b/tex/context/base/strc-reg.lua
@@ -227,6 +227,7 @@ local tagged = { }
 local function preprocessentries(rawdata)
     local entries = rawdata.entries
     if entries then
+--~ table.print(rawdata)
         local e, k = entries[1] or "", entries[2] or ""
         local et, kt, entryproc, pageproc
         if type(e) == "table" then
@@ -236,7 +237,7 @@ local function preprocessentries(rawdata)
             et = lpegmatch(entrysplitter,e)
         end
         if type(k) == "table" then
-            kt = e
+            kt = k
         else
             pageproc, k = processor_split(k)
             kt = lpegmatch(entrysplitter,k)
@@ -529,14 +530,14 @@ function registers.flush(data,options,prefixspec,pagespec)
                     if text then
                         local w = words[text]
                         if w then
-                            local wr = w.references
-                            local dr = d.references
-                            if wr.seeindex then
-                                dr.seeindex = wr.seeindex
+                            local wr = w.references -- the referred word
+                            local dr = d.references -- the see word
+                            if wr.seeparent then
+                                dr.seeindex = wr.seeparent
                             else
                                 seeindex = seeindex + 1
+                                wr.seeparent = seeindex
                                 dr.seeindex = seeindex
-                                wr.seeindex = seeindex
                             end
                         end
                     end
@@ -577,9 +578,9 @@ function registers.flush(data,options,prefixspec,pagespec)
                             end
                         end
                         local internal = entry.references.internal or 0
-                        local seeindex = entry.references.seeindex or ""
+                        local seeparent = entry.references.seeparent or ""
                         if metadata then
-                            texsprint(ctxcatcodes,"\\registerentry{",internal,"}{",seeindex,"}{")
+                            texsprint(ctxcatcodes,"\\registerentry{",internal,"}{",seeparent,"}{")
                             local proc = entry.processors and entry.processors[1]
                             if proc then
                                 texsprint(ctxcatcodes,"\\applyprocessor{",proc,"}{")
diff --git a/tex/context/base/strc-reg.mkiv b/tex/context/base/strc-reg.mkiv
index 88c9dcca5..f4782d477 100644
--- a/tex/context/base/strc-reg.mkiv
+++ b/tex/context/base/strc-reg.mkiv
@@ -237,9 +237,9 @@
             own      = "\registerparameter\c!alternative", % can be used instead of pagenumber
         \fi
             xmlroot  = \ifx\currentreferencecoding\s!xml "\xmldocument" \else nil \fi, % only useful when text
-\ifx\currentregisterxmlsetup\empty \else
-    xmlsetup = "\currentregisterxmlsetup",
-\fi
+        \ifx\currentregisterxmlsetup\empty \else
+            xmlsetup = "\currentregisterxmlsetup",
+        \fi
         },
         references = {
             internal = \nextinternalreference,
@@ -742,7 +742,7 @@
    \ifx\currentregisterseeindex\empty
      \registerseeword{#3}%
    \else
-[>\currentregisterseeindex]%
+% [>\currentregisterseeindex]%
      \registerseeword{\goto{#3}[seeindex:\currentregisterseeindex]}%
    \fi
    \dostoptagged}
@@ -751,7 +751,7 @@
   {\dostarttagged\t!registerentry\empty
    \ifx\currentregisterseeindex\empty \else
      \dontleavehmode
-[<\currentregisterseeindex]%
+% [<\currentregisterseeindex]%
      \pagereference[seeindex:\currentregisterseeindex]% maybe some day we will support an area
    \fi
    \registerparameter\c!textcommand{\limitedregisterentry{\registerparameter\c!deeptextcommand{#1}}}%
diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv
index 496d95b67..17846aec0 100644
--- a/tex/context/base/strc-sec.mkiv
+++ b/tex/context/base/strc-sec.mkiv
@@ -345,16 +345,41 @@
      % use  : \currentstructureheadincrement as spec
    \fi}
 
+% \def\setstructureheadplacement
+%   {\setfalse\structureheadleaveempty
+%    \settrue \structureheaddoplace
+%    \setfalse\structureheadhidden
+%    \processaction
+%      [\structureheadparameter\c!placehead]
+%      [  \v!yes=>,
+%       \v!empty=>\settrue\structureheadleaveempty,
+%          \v!no=>\settrue\structureheadleaveempty\setfalse\structureheaddoplace,
+%      \v!hidden=>\settrue\structureheadleaveempty\setfalse\structureheaddoplace\settrue\structureheadhidden]}
+
+\setvalue{\??nh:\c!placehead:\v!yes}%
+  {\setfalse\structureheadleaveempty
+   \settrue \structureheaddoplace
+   \setfalse\structureheadhidden}
+
+\setvalue{\??nh:\c!placehead:\v!empty}%
+  {\settrue \structureheadleaveempty
+   \settrue \structureheaddoplace
+   \setfalse\structureheadhidden}
+
+\setvalue{\??nh:\c!placehead:\v!no}%
+  {\settrue \structureheadleaveempty
+   \setfalse\structureheaddoplace
+   \setfalse\structureheadhidden}
+
+\setvalue{\??nh:\c!placehead:\v!hidden}%
+  {\settrue \structureheadleaveempty
+   \setfalse\structureheaddoplace
+   \settrue \structureheadhidden}
+
 \def\setstructureheadplacement
-  {\settrue\structureheaddoplace
-   \setfalse\structureheadleaveempty
-   \setfalse\structureheadhidden
-   \processaction
-     [\structureheadparameter\c!placehead]
-     [  \v!yes=>,
-      \v!empty=>\settrue\structureheadleaveempty,
-         \v!no=>\settrue\structureheadleaveempty\setfalse\structureheaddoplace,
-     \v!hidden=>\settrue\structureheadhidden\settrue\structureheadleaveempty\setfalse\structureheaddoplace]}
+  {\executeifdefined
+     {\??nh:\c!placehead:\structureheadparameter\c!placehead}
+     {\getvalue{\??nh:\c!placehead:\v!yes}}}
 
 \def\setstructureheaddisplay
   {\doifelsevalue{\??nh:\structureheadparameter\c!alternative}\v!horizontal
@@ -577,7 +602,8 @@
 
 \unexpanded\def\placestructureheadhidden
   {\setxvalue{\currentstructurehead:sync}%
-     {\noexpand\pagetype[\currentstructureheadcoupling]% hm also number
+     {\noexpand\setgvalue{\currentstructurehead:sync}{}%
+      \noexpand\pagetype[\currentstructureheadcoupling]% hm also number
       \noexpand\setmarking[\currentstructureheadcoupling]{\currentstructurelistnumber}%
       \currentstructuresynchronize}}
 
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index f2fc970f7..23e16c428 100644
--- a/tex/generic/context/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
 -- merged file : luatex-fonts-merged.lua
 -- parent file : luatex-fonts.lua
--- merge date  : 10/10/10 14:25:57
+-- merge date  : 10/11/10 01:11:52
 
 do -- begin closure to overcome local limits and interference
 
-- 
cgit v1.2.3