Re: [NTG-context] What is the replacement for the 'stop_run' callback?

2010-10-19 Thread Tad Ashlock
On Sun, Oct 17, 2010 at 10:24, Hans Hagen  wrote:

> On 17-10-2010 4:06, Tad Ashlock wrote:
>
>  I'm trying to update a ConTeXt module of mine.  It does some data
>> gathering
>> during the ConTeXt run, and then processes it after the run is complete.
>>  This used to work last year:
>>
>> local id, err = callback.register('stop_run', new_stop_run_function)
>>
>> But now err is set to "callback 'stop_run' is frozen (actions performed at
>> the end of a run)".
>>
>
> indeed
>
>
>  After trying various approaches for a couple of hours, I'm calling for
>> help.
>> :)
>>
>
>  Here's what I ended up with:
>>
>> \startluacode
>> print('%%% TEST1')
>> local function after_run (head, groupcode)
>> print('%%% TEST2')
>> return head, true
>> end
>> nodes.tasks.appendaction('finalizers','after','after_run')
>> \stopluacode
>> \starttext
>> \input knuth
>> \stoptext
>>
>> In the output, I see the TEST1 line, but not the TEST2 line.
>>
>
> because after_run is not seen,
>
> function myprivatenamespace.after_run ...
>
>
> nodes.tasks.appendaction('finalizers','after','myprivatenamespace.after_run')
>
>
>  I don't know what "head" and "groupcode" are, but those seem to be the
>> expected parameters for an action.  I don't know why it returns "head,
>> true", but that was recommended in a posting (
>> http://archive.contextgarden.net/message/20100410.005025.76ac9efd.en.html
>> ).
>>
>
> whatever, it's not the place to hook in your finalizer as there finalizers
> are just a specific place in node list processing
>
>
>  I have no idea if 'finalizers' is the right parameter, but I didn't see
>> any
>> others that looked like it could be synonymous with 'stop_run'.
>>
>
> You can use (preferable no messages there):
>
>  luatex.registerstopactions(yourfunction)
>
> or for messages:
>
>  statistics.register("banner",function() return "text" end)
>
> in this case returning false (or nil) will not show the statistic which
> makes sense if there's nothing useful to report.
>
> At some point there will be a formal description for this.
>
> Hans
>
> -
>  Hans Hagen | PRAGMA ADE
>  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
> | www.pragma-pod.nl
> -
>

Hans,

The registerstopactions() function was the solution I was looking for, but
I've verified that both of the solutions work as expected.  I tested them
with both a single ConTeXt source file and a set of files in a Project ->
Product -> Component structure.

I'll wiki this soon.

Thanks,
Tad
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] What is the replacement for the 'stop_run' callback?

2010-10-17 Thread Tad Ashlock
Hi All,

I'm trying to update a ConTeXt module of mine.  It does some data gathering
during the ConTeXt run, and then processes it after the run is complete.
 This used to work last year:

local id, err = callback.register('stop_run', new_stop_run_function)

But now err is set to "callback 'stop_run' is frozen (actions performed at
the end of a run)".

I see from the mailing list archive that registering user callbacks was
disallowed in February of this year (2010).  I also saw some advice for
installing other new user processing (like 'pre_linebreak_filter'), but no
general advice for adapting to the lack of callbacks.  (
http://archive.contextgarden.net/message/20100219.130524.b3857a0a.en.html)

After trying various approaches for a couple of hours, I'm calling for help.
:)

Here's what I ended up with:

\startluacode
print('%%% TEST1')
local function after_run (head, groupcode)
print('%%% TEST2')
return head, true
end
nodes.tasks.appendaction('finalizers','after','after_run')
\stopluacode
\starttext
\input knuth
\stoptext

In the output, I see the TEST1 line, but not the TEST2 line.

I don't know what "head" and "groupcode" are, but those seem to be the
expected parameters for an action.  I don't know why it returns "head,
true", but that was recommended in a posting (
http://archive.contextgarden.net/message/20100410.005025.76ac9efd.en.html).

I have no idea if 'finalizers' is the right parameter, but I didn't see any
others that looked like it could be synonymous with 'stop_run'.
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] Split Table Footnotes Problem

2010-01-29 Thread Tad Ashlock
Hi All,

If a split table includes a footnote then the footnote is constrained
to the same width as the first column of the table, not the page
width.

Example (also attached as tadtest5.tex):


\automigrateinserts % or else footnotes don't show up at all

\starttext

\dorecurse{3}{\input knuth\par}

\placetable[split]{Table Caption}%
{ \bTABLE[split=repeat]%
  \bTR\bTD table cell with footnote\footnote{This footnote is
constrained to the width of the first table column.} \eTD
  \dorecurse{3}{\bTD table cell \eTD}\eTR
  \dorecurse{10}{\bTR\dorecurse{4}{\bTD table cell \eTD}\eTR}
  \bTR\bTD table cell footnote 2\footnote{This is another
footnote that is constrained to the width of the first
table column.} \eTD
  \dorecurse{3}{\bTD table cell \eTD}\eTR
  \eTABLE}

\stoptext


Does this have something to do with the \automigrateinserts command or
is there something I'm not doing right?

Thanks,
Tad


tadtest5.tex
Description: TeX document
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] Unexpected Consequence of Turning Off Subsubsection Numbering

2010-01-29 Thread Tad Ashlock
Hi All,

If I setup the table caption numbering to be 'bychapter' and then turn
off the numbering of subsubsections, any table within a subsubsection
won't have the chapter number as part of the table number.

Example (also attached as tadtest4.tex):


\setupcaption[table][way=bychapter]
\setuphead[subsubsection][number=no]

\starttext

\chapter{Chapter Name}

\placetable[split]{First Table}%
{\bTABLE\bTR\bTD table row \eTD\eTR\eTABLE}

\section{Section Name}

\placetable[split]{Second Table}%
{\bTABLE\bTR\bTD table row \eTD\eTR\eTABLE}

\subsection{Subsection Name}

\placetable[split]{Third Table}%
{\bTABLE\bTR\bTD table row \eTD\eTR\eTABLE}

\subsubsection{Subsubsection Name}

\placetable[split]{Fourth Table}%
{\bTABLE\bTR\bTD table row \eTD\eTR\eTABLE}

\stoptext


The example above has "Table 4" instead of "Table 1.4".

Is this unintentional behavior, or am I doing it wrong?

Thanks,
Tad


tadtest4.tex
Description: TeX document
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] Split Table Numbering

2010-01-29 Thread Tad Ashlock
Hi All,

How do I go about getting split tables to be numbered as, for example,
1.3a and 1.3b, instead of 1.3 and 1.4?  I'm using "bychapter"
numbering.

Example (also attached as tadtest3.tex):


\setupcaption[table][way=bychapter]

\starttext

\chapter{Chapter Name}

\dorecurse{3}{\input knuth\par}

\placetable[split]{Table Caption}%
{ \bTABLE[split=repeat]%
  \bTABLEhead
  \bTR\bTH Table Header \eTH\eTR
  \eTABLEhead
  \bTABLEbody
  \dorecurse{10}{\bTR\bTD table row \eTD\eTR}
  \eTABLEbody
  \eTABLE}

\stoptext


The problem with the current numbering scheme is that it doesn't
indicate that a single, split table is different than two separate
tables.

Another problem is that the tables end up getting numbered differently
for different output formats (e.g. print vs. screen).  So for
instance, you can't refer to "table 4.7" in an e-mail, because you
might be looking at the presentation version of the document, but
others might be looking at the printed version.

Thanks,
Tad


tadtest3.tex
Description: TeX document
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] New Section Causes the Previous Page to Break Differently

2010-01-29 Thread Tad Ashlock
Hi All,

I can create a document with text that ends at the bottom of a page.
Like so (also attached as tadtest2a.tex):


\showframe

\starttext

\section{section 1}

\input bryson\par\blank
\input davis\par\blank
\input linden\par\blank
\input weisman\par
\input linden

This should be a the top of page 2.

\stoptext


(I hope the vertical spacing works out the same on your machine as it
does on mine.  I'm using the latest minimals, 2010.01.25 11:09.)

But if I happen to start a new section after that text, then part of
the last paragraph from the first page gets pushed to the second page,
leaving the text on page 1 short.

Here is an example (also attached as tadtest2b.tex):


\showframe

\starttext

\section{section 1}

\input bryson\par\blank
\input davis\par\blank
\input linden\par\blank
\input weisman\par
\input linden

\section{section 2}

This should be the first sentence of page 2, but it's not.

\stoptext


This also happens for itemized lists.  First the full page version
(also attached as tadtest2c.tex):


\showframe

\starttext

\section{section 1}

\startitemize[n]
\item \input bryson
\item \input davis
\item \input dawkins
\item \input weisman
\stopitemize

This should be a the top of page 2.

\stoptext


Now the "spill-over" version (also attached as tadtest2d.tex):


\showframe

\starttext

\section{section 1}

\startitemize[n]
\item \input bryson
\item \input davis
\item \input dawkins
\item \input weisman
\stopitemize

\section{section 2}

This should be the first sentence of page 2, but it's not.

\stoptext


If this is the expected behavior, is there any way to disable it?

Thanks,
Tad


tadtest2a.tex
Description: TeX document


tadtest2b.tex
Description: TeX document


tadtest2c.tex
Description: TeX document


tadtest2d.tex
Description: TeX document
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] Problem With an Enumeration After a Forced Float

2010-01-29 Thread Tad Ashlock
Hi All,

Here's a corner case for you:  place a figure with the 'force' option,
followed by an enumeration with a background.  Like this (also
attached as tadtest1.tex):


\defineenumeration[enum][before={\startbackground},after={\stopbackground}]

\starttext

\dorecurse{3}{\input knuth\par}

\placefigure[force]{Moo}{\externalfigure[cow.pdf][width=.7\textwidth]}

\startenum
The contents of a test enumeration.
\stopenum

\stoptext


The enumeration will start at the top of the next page (after the
figure) even though there's plenty of room below the figure on the
same page.

If you take the background away from the enumeration (delete the
'before' and 'after' options), OR take the 'force' option off the
\placefigure command, then the problem goes away.

I suspect that this isn't the expected behavior. :-)

Thanks,
Tad


tadtest1.tex
Description: TeX document
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Verbatim Text with Embedded Formatting Commands (MkIV)

2010-01-29 Thread Tad Ashlock
Hans Hagen wrote:
> On 9-1-2010 0:52, Tad Ashlock wrote:
>
> > ...
>
> you can try the beta with
>
> \enabletrackers[buffers.visualize]
>
> \starttext
>
> \definetyping[C] % [option=C]
> \setuptyping[C][escape=yes]
>
> \startC
> #include 
> int main(){
>return 0;
>/BTEX{\em unreachedCode;}/ETEX
> }
> \stopC
>
> \setuptyping[escape=yes]
>
> \startTEX
> /BTEX\em sometex/ETEX
> /BTEX\em sometex/ETEX \after
> \before /BTEX\em sometex/ETEX
> \before /BTEX\em sometex/ETEX \after
> \before /BTEX\em sometex/ETEX \inbetween /BTEX\em sometex/ETEX \after
> \before \after
> \stopTEX
>
> \setuptyping[TEX][escape=no]
>
> \startTEX
> /BTEX\em sometex/ETEX
> /BTEX\em sometex/ETEX \after
> \before /BTEX\em sometex/ETEX
> \before /BTEX\em sometex/ETEX \after
> \before /BTEX\em sometex/ETEX \inbetween /BTEX\em sometex/ETEX \after
> \before \after
> \stopTEX
>
> \stoptext


I did try the beta with that example and it worked, of course.  But if
I add a second \startC ... \stopC section, then it breaks.  For
example, this code (also attached as tadtest0.tex):


\enabletrackers[buffers.visualize]

\starttext

\definetyping[C] % [option=C]
\setuptyping[C][escape=yes]

\startC
#include 
int main(){
return 0;
/BTEX{\em unreachedCode;}/ETEX
}
\stopC

\startC
printf("The second C segment doesn't work.\n");
\stopC

\stoptext


Produces this output:


systems : begin file test.tex at line 3
!buffers: mapping 'c' visualizer onto 'typing'
!buffers: setting escape range for visualizer 'C' to /BTEX -> /ETEX
! LuaTeX error ...text/tex/texmf-context/tex/context/base/buff-ini.lua:705:
attempt to index local 'visualizer' (a number value)
stack traceback:
...text/tex/texmf-context/tex/context/base/buff-ini.lua:705: in
function 'set_escape'
:1: in main chunk.
\setupcommandsintype ...rameter \c!escape \!!es )}

\doinitializeverbatim ...\everyinitializeverbatim
  \relax
\nododowithbuffer ->\egroup \doinitializeverbatim
  \beginofverbatimlines \ctx...
l.18 \stopC


Tad


tadtest0.tex
Description: TeX document
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Verbatim Text with Embedded Formatting Commands (MkIV)

2010-01-08 Thread Tad Ashlock

Hans Hagen wrote:

On 13-12-2009 12:26, Tad Ashlock wrote:

As noted at
http://wiki.contextgarden.net/Verbatim_text#Embedded_formatting_commands, 
the

embedded formatting commands in verbatim text don't work in MkIV.

Are there any plans to fix this capability soon? I'm planning on working
on a project on over the holiday break that will need it.


the beta has:

\starttext

\setuptyping[TEX][escape=yes]

\startTEX
/BTEX\em sometex/ETEX
/BTEX\em sometex/ETEX \after
\before /BTEX\em sometex/ETEX
\before /BTEX\em sometex/ETEX \after
\before /BTEX\em sometex/ETEX \inbetween /BTEX\em sometex/ETEX \after
\before \after
\stopTEX

\setuptyping[TEX][escape={[[,]]}]

\startTEX
[[\em sometex]]
[[\em sometex]] \after
\before [[\em sometex]]
\before [[\em sometex]] \after
\before [[\em sometex]] \inbetween [[\em sometex]] \after
\before \after
\stopTEX

\setuptyping[TEX][escape=//]

\startTEX
//\em sometex
\before //\em sometex
\stopTEX

\stoptext

so, in mkiv option-commands is gone and escape no longer is an escape 
character but a condition (range or start)


please wikify this

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-



Ok, I'm (finally) getting back to this subject.

Is this supposed to work for any verbatim environment besides 
\startTEX...\stopTEX?  I can't get it to work for 'C' or even basic 
'typing'.  They don't pick up on the embedded formatting, everything is 
typeset verbatim.


Tad

PS: Here are my test cases:


\definetyping[C][option=C]
\setuptyping[C][escape=yes]
\starttext
\startC
#include 
int main(){
   return 0;
   /BTEX{\em unreachedCode;}/ETEX
}
\stopC
\stoptext



\starttext
\setuptyping[escape=yes]
\starttyping
/BTEX\em sometex/ETEX
/BTEX\em sometex/ETEX \after
\before /BTEX\em sometex/ETEX
\before /BTEX\em sometex/ETEX \after
\before /BTEX\em sometex/ETEX \inbetween /BTEX\em sometex/ETEX \after
\before \after
\stoptyping
\stoptext


___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Automated Quotation/Punctuation Placement

2010-01-08 Thread Tad Ashlock

Khaled Hosny wrote:

On Fri, Jan 08, 2010 at 09:27:37AM -0700, Tad Ashlock wrote:


==
\startluacode
function move_end_punctuation (text, punc, cmd_start, cmd_mid, cmd_end)
   context(cmd_start .. text .. cmd_mid)
   if string.find('.,!?', punc, 1, true) then
   context(punc .. cmd_end)
   else
   context(cmd_end .. ' ' .. punc)
   end
end
\stopluacode

\def\Var#1#2{\ctxlua{move_end_punctuation([==[#1]==],[==[#2]==],
   '\\quote{\\type{','}','}')}}

\starttext

This is \Var{var_name}, a variable.

\stoptext
==

What about:


\def\Var#1#2{'\type{#1}%
\directlua{
if "#2" == "," then
  tex.sprint("#2'")
else
  tex.sprint("'#2")
end}}


\Var{555}, hello \Var{666}. \Var{666}\par




Thank you, Khaled, for the response.  This solution works as is.  But it 
has a problem as soon as you want to put double quotes around the 
variable name.


Simply replacing the single quotes with double quotes in your solution 
doesn't produce open- and close-quotes pairs:


==
\def\Var#1#2{"\type{#1}%
\directlua{
if "#2" == "," then
 tex.sprint('#2"')
else
 tex.sprint('"#2')
end}}
==

In order to do that, you need (I think) to use the \quotation{} command:

==
\def\Var#1#2{\quotation{\type{#1}%
\directlua{
if "#2" == "," then
 tex.sprint("#2}")
else
 tex.sprint("}#2")
end}}
==

resulting in:

==
! Too many }'s.
l.7 end}}
==

I also tried \bgroup...\egroup:

==
\def\Var#1#2{\quotation\bgroup\type{#1}%
\directlua{
if "#2" == "," then
 tex.sprint("#2\egroup ")
else
 tex.sprint("\egroup #2")
end}}
==

giving:

==
! Missing } inserted.

   }

  \normalend
l.18 \stoptext
==

Thanks again!
Tad

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Automated Quotation/Punctuation Placement

2010-01-08 Thread Tad Ashlock

Wolfgang Schuster wrote:

Am 08.01.2010 um 17:27 schrieb Tad Ashlock:Hi All,



\startluacode
function move_end_punctuation (text, punc, cmd_start, cmd_mid, cmd_end)
  context(cmd_start .. text .. cmd_mid)
  if string.find('.,!?', punc, 1, true) then
  context(punc .. cmd_end)
  else
  context(cmd_end .. ' ' .. punc)
  end
end
\stopluacode

\def\Var#1#2{\ctxlua{move_end_punctuation([=#1]==],[==[#2]==],
  '\\quote{\\type{','}','}')}}

\starttext

This is \Var{var_name}, a variable.

\stoptext


This works, until the \Var{} macro appears in the argument of another macro.  
For example, make the text:

\framed{This is \Var{var_name}, a variable.}


\nonknuthmode % make '_' a normal character in text mode

\define[1]\Var
  {\doifnextcharelse{,}{\doVar{#1,}\gobbleoneargument}{\noVar{#1}}}

\define[1]\doVar
  {\mono{#1}}

\define[1]\noVar
  {\mono{#1}%
   \doifnextcharelse{;} % \autoinsertnextspace is no longer available in MkIV :(
 {\donothing}
 {\doifnextcharelse{.}
{\donothing}
{\space}}}

\starttext

This is \Var{var_name}, a variable.

This is \Var{var_name,} a variable.

\framed{This is \Var{var_name}, a variable.}

\stoptext

Wolfgang



Thanks for responding Wolfgang.  But this solution has some problems.

The first problem is that it only works for commas.  I'm sure I can 
figure out how to next the \doifnextcharelse commands to add periods, 
question marks, and exclamation points, but then the command becomes 
rather unwieldy.  Not really a problem for a single command, but this 
leads to...


Problem number 2 is that I'm going to need many of these commands for 
different types of things.  I'd like to abstract out the "punctuation 
swapping" so that it doesn't have to be repeated for each command.


But the show-stopper is problem number 3: this solution still breaks in 
other places, like captions:



\starttext
\placefigure
[left]
{This is \Var{var_name}, a variable.}
{\framed{And \Var{another_var_name} is yet another variable.}}
\stoptext


results in:



! Argument of \gobbleoneargument has an extra }.

\par

   }
\doifnextcharelse ...token =#1\def \!!stringa {#2}
  \def \!!stringb 
{#3}\futur...

\@@kjfiguretitle ->This is \Var {var_name}
  , a variable.
\doif #1#2->\edef \!!stringa {#1
}\edef \!!stringb {#2}\ifx \!!stringa 
\!!str...

\dostructurecountercomponent ...\c!title }\v!none
  {\setfalse 
\hasstructureco...

...
l.47 ...other_var_name} is yet another variable.}}
 
?



This is the sort of problem I was flailing around with.  I'd get a 
definition that worked in one case, but broke in another.  One attempt 
broke when I included a table of contents.


Thanks again!
Tad
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] Automated Quotation/Punctuation Placement

2010-01-08 Thread Tad Ashlock

Hi All,

I'm trying to create a command that will apply a consistent style to a 
word or phrase.  For example, when documenting source code, I'd like to 
be able to mark variables with \Var{var_name}.  Then if I want the 
variable names to be in mono, I can \def\Var#1{\type{#1}}.  No problem 
there.  If I want variable names to be in quotes, then 
\def\Var#1{\quote{#1}}.


The problem is that in my ConTeXt code I'd write "This is 
\Var{var_name}, a variable."  Which would get typeset as "This is 
'var_name', a variable." where punctuation convention (at least in 
American English) would have the comma inside the quote like this: "This 
is 'var_name,' a variable."


I've tried four different ways of implementing this, but none of them 
work consistently.  Here's my last attempt:


==
\startluacode
function move_end_punctuation (text, punc, cmd_start, cmd_mid, cmd_end)
   context(cmd_start .. text .. cmd_mid)
   if string.find('.,!?', punc, 1, true) then
   context(punc .. cmd_end)
   else
   context(cmd_end .. ' ' .. punc)
   end
end
\stopluacode

\def\Var#1#2{\ctxlua{move_end_punctuation([==[#1]==],[==[#2]==],
   '\\quote{\\type{','}','}')}}

\starttext

This is \Var{var_name}, a variable.

\stoptext
==

This works, until the \Var{} macro appears in the argument of another 
macro.  For example, make the text:


\framed{This is \Var{var_name}, a variable.}

and the following error results:
==
systems : begin file test.tex at line 16
! Missing $ inserted.

   $

  _
l.1 ...spaces quote{unskip  ignorespaces type{var_
 name}
\Var ...=],[==[#2]==], '\\quote{\\type{','}','}')}

l.18 \framed{This is \Var{var_name},

a variable.}
?
==

I think my problem has to do with parameter expansion, but I don't 
understand the intricacies enough to solve this.  I flailed away, 
unsuccessfully, with various combinations of \unexpanded, 
\normalunexpanded, luaescapestring, etc.


Does anyone have a solution or a pointer in the right direction?

Thank you,
Tad



___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] The problem with structure of heads in MkIV

2009-12-31 Thread Tad Ashlock

Wolfgang Schuster wrote:

Am 31.12.2009 um 12:47 schrieb Tad Ashlock:

  

Yanrui Li wrote:


2009/12/31 Tad Ashlock mailto:taas...@cyberdude.com>>


   The attached sample doesn't meet the original poster's criteria.
It produces headings like "1.1 alpha" and "1.1.1 a" instead of
   the requested "1 alpha" and "1.1 a".  Is there any way of
   achieving this?  (Under "Part 1", of course.  That's the trick.)


Hi Tad,

The attached sample works ok for me. Can you give me your result which the 
sample prodeces?


--
Best regards,

Li Yanrui
  

They are attached as "test.tex" (the test input), "test.pdf" and "test.log".  Notice how the 
chapter numbers are "x.y" (where 'x' =Part #') instead of just "y" as originally requested.  I point this out 
because I've tried to get ConTeXt to do structure numbering like this in the past and have had to postpone it due to lack of time.



Look at Joshuas example and the sectionsegments settings.

Wolfgang


Ahhh...  The problem was that I came at Joshua's message from the online 
mailing list 
<http://archive.contextgarden.net/message/20091230.023239.56a1e396.en.html> 
and the only "attached sample" was the code in the message.  Apparently 
attachments aren't accessible on the mailing list website?


Sorry about wasting your time.
Tad
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] The problem with structure of heads in MkIV

2009-12-31 Thread Tad Ashlock

Yanrui Li wrote:


2009/12/31 Tad Ashlock <mailto:taas...@cyberdude.com>>



The attached sample doesn't meet the original poster's criteria.
 It produces headings like "1.1 alpha" and "1.1.1 a" instead of
the requested "1 alpha" and "1.1 a".  Is there any way of
achieving this?  (Under "Part 1", of course.  That's the trick.)


Hi Tad,

The attached sample works ok for me. Can you give me your result which 
the sample prodeces?



--
Best regards,

Li Yanrui



They are attached as "test.tex" (the test input), "test.pdf" and 
"test.log".  Notice how the chapter numbers are "x.y" (where 'x' = 'Part 
#') instead of just "y" as originally requested.  I point this out 
because I've tried to get ConTeXt to do structure numbering like this in 
the past and have had to postpone it due to lack of time.


Thanks,
Tad
\starttext

\placelist[part,chapter,section,subsection][criterium=all]

\part{first}
\chapter{alpha}
\section{a}
\section{b}
\subsection{x}
\subsection{y}
\chapter{beta}

\part{second}
\chapter{gamma}
\section{a}
\section{b}
\subsection{x}
\subsection{y}
\chapter{delta}

\stoptext
(c:/pub/projects/psicc2/book/test.tex

ConTeXt  ver: 2009.12.30 20:27 MKIV  fmt: 2009.12.30  int: english/english

system  : cont-new loaded
(C:/context/tex/texmf-context/tex/context/base/cont-new.tex
systems : beware: some patches loaded from cont-new.tex
(C:/context/tex/texmf-context/tex/context/base/cont-new.mkiv))
system  : cont-fil loaded
(C:/context/tex/texmf-context/tex/context/base/cont-fil.tex
loading : ConTeXt File Synonyms
)
system  : cont-sys.rme loaded
(C:/context/tex/texmf-context/tex/context/user/cont-sys.rme 
(C:/context/tex/texmf-context/tex/context/base/type-lua.tex) 
(C:/context/tex/texmf-context/tex/context/base/type-tmf.tex 
(C:/context/tex/texmf-context/tex/context/base/type-tmf.mkiv)) 
(C:/context/tex/texmf-context/tex/context/base/type-siz.tex 
(C:/context/tex/texmf-context/tex/context/base/type-siz.mkiv)) 
(C:/context/tex/texmf-context/tex/context/base/type-otf.tex 
(C:/context/tex/texmf-context/tex/context/base/type-otf.mkiv)))
system  : test.top loaded
%
%   begin of optionfile
%
%   % runtime options files (command line driven)
%   \unprotect
%   % special commands, mostly for the ctx development team
%   % feedback and basic job control
%   % handy for special styles
%   \startluacode
%   document = document or { }
%   document.arguments={
%["autopdf"]=true,
%   }
%   document.files={
%"c:/pub/projects/psicc2/book/test.tex",
%   }
%   \stopluacode
%   % process info
%   \setupsystem[inputfile=c:/pub/projects/psicc2/book/test.tex]
%   \setupsystem[\c!n=2,\c!m=3]
%   % modes
%   % options (not that important)
%   \startsetups *runtime:options
%   \setupoutput[pdftex]
%   \stopsetups
%   % styles and modules
%   \startsetups *runtime:modules
%   \stopsetups
%   % done
%   \protect \endinput
%
%   end of optionfile
%
(test.top)
fonts   : preloading latin modern fonts
bodyfont: 12pt rm is loaded
language: language en is active
systems : begin file c:/pub/projects/psicc2/book/test.tex at line 1
fonts   : resetting map file list
{C:/context/tex/texmf-context/fonts/map/pdftex/context/original-empty.map}
fonts   : using map file: original-base
{C:/context/tex/texmf-context/fonts/map/pdftex/context/original-base.map}
fonts   : using map file: original-ams-base
{C:/context/tex/texmf-context/fonts/map/pdftex/context/original-ams-base.map}
fonts   : using map file: original-ams-euler
{C:/context/tex/texmf-context/fonts/map/pdftex/context/original-ams-euler.map}
fonts   : using map file: original-public-lm
{C:/context/tex/texmf-context/fonts/map/pdftex/context/original-public-lm.map}
fonts   : using map file: lm-math
{C:/context/tex/texmf/fonts/map/dvips/lm/lm-math.map}
fonts   : using map file: lm-rm
{C:/context/tex/texmf/fonts/map/dvips/lm/lm-rm.map}
!pages  : flushing realpage 1, userpage 1, subpage 1
structure   : part @ level 1 : 1 -> first
!pages  : flushing realpage 2, userpage 2
structure   : chapter @ level 2 : 1.1 -> alpha
structure   : section @ level 3 : 1.1.1 -> a
structure   : section @ level 3 : 1.1.2 -> b
structure   : subsection @ level 4 : 1.1.2.1 -> x
structure   : subsection @ level 4 : 1.1.2.2 -> y
!pages  : flushing realpage 3, userpage 3
structure   : chapter @ level 2 : 1.2 -> beta
!pages  : flushing realpage 4, userpage 4
structure   : part @ level 1 : 2 -> second
!pages  : flushing realpage 5, userpage 5
structure   : chapter @ level 2 : 2.1 -> 

Re: [NTG-context] The problem with structure of heads in MkIV

2009-12-30 Thread Tad Ashlock

Joshua Lee wrote:

Hi Yanrui,
How about the attached sample?


Best regards,
Joshua


On Wed, 30 Dec 2009, Yanrui Li wrote:

hi all,

For  example:


\starttext

\placelist[part,chapter,section,subsection][criterium=all]

\part{first}
  \chapter{alpha}
\section{a}
\section{b}
  \subsection{x}
  \subsection{y}
  \chapter{beta}

\part{second}
  \chapter{gamma}
\section{a}
\section{b}
  \subsection{x}
  \subsection{y}
  \chapter{delta}

\stoptext


how to get the following head structure in MkIV ?

Part 1  first

1 alpha
  1.1 a
  1.2 b
 1.2.1 x
 1.2.2 y
2 beta

Part 2  second

3 gamma
  3.1 a
  3.2 b
3.2.1 x
3.2.2 y
4 delta

--
Best regards,

Li Yanrui



The attached sample doesn't meet the original poster's criteria.  It 
produces headings like "1.1 alpha" and "1.1.1 a" instead of the 
requested "1 alpha" and "1.1 a".  Is there any way of achieving this?  
(Under "Part 1", of course.  That's the trick.)


Thanks,
Tad
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] Overfull \hbox in Every Footnote

2009-12-13 Thread Tad Ashlock
ory usage  - 50 MB (ctx: 51 MB)
mkiv lua stats : runtime   - 1.250 seconds, 0 processed 
pages, 1 shipped pages, 0.800 pages/second
MTXrun | run 1: luatex 
--fmt="C:/context/tex/texmf-cache/luatex-cache/context/2fea56f92e5267d7cc9662e4d5f52e1e/formats/cont-en" 
--lua="C:/context/tex/texmf-cache/luatex-cache/context/2fea56f92e5267d7cc9662e4d5f52e1e/formats/cont-en.lui" 
--backend=pdf "./test"
MTXrun | pdfview methods: default okular xpdf, current method: default, 
MTX_PDFVIEW_METHOD=

MTXrun | total runtime: 1.438

ConTeXt Full finished at Sun Dec 13 04:33:14

Thanks,
Tad Ashlock
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] Verbatim Text with Embedded Formatting Commands (MkIV)

2009-12-13 Thread Tad Ashlock
As noted at 
http://wiki.contextgarden.net/Verbatim_text#Embedded_formatting_commands, 
the embedded formatting commands in verbatim text don't work in MkIV.


Are there any plans to fix this capability soon?  I'm planning on 
working on a project on over the holiday break that will need it.


I'm not pushing to change your priorities.  If it's not going to be 
fixed soon, then I'll implement a simple verbatim module that supports 
embedded formatting commands that will do until the official module 
works.  I just don't want to waste that effort if verbatim is going to 
be fixed soon anyway.


Thanks,
Tad Ashlock
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] ConTeXt Ver 2009.08.14 Crashes with \reference

2009-08-15 Thread Tad Ashlock
The following code causes the 2009.08.14 version of ConTeXt to crash (see
below).  But it works in the 2009.07.23 version of ConTeXt.
\setupinteraction[state=start]
\starttext
\reference[ref:UsersMan]{User's manual}
\input tufte\par
User's manual~\at[ref:UsersMan]
\stoptext
=
> This is LuaTeX, Version beta-0.42.0-2009071712
>  \write18 enabled.
> (test.tex
>
> ConTeXt  ver: 2009.08.14 10:48 MKIV  fmt: 2009.8.14  int: english/english
>
> system  : cont-new loaded
> (C:/context/tex/texmf-context/tex/context/base/cont-new.tex
> systems : beware: some patches loaded from cont-new.tex
> (C:/context/tex/texmf-context/tex/context/base/cont-new.mkiv))
> system  : cont-fil loaded
> (C:/context/tex/texmf-context/tex/context/base/cont-fil.tex
> loading : ConTeXt File Synonyms
> )
> system  : cont-sys.rme loaded
> (C:/context/tex/texmf-context/tex/context/user/cont-sys.rme
(C:/context/tex/texmf-context/tex/context/base/type-tmf.tex
(C:/context/tex/texmf-context/tex/context/base/type-tmf.mkiv))
(C:/context/tex/texmf-context/tex/context/base/type-siz.tex
(C:/context/tex/texmf-context/tex/context/base/type-siz.mkiv))
(C:/context/tex/texmf-context/tex/context/base/type-otf.tex
(C:/context/tex/texmf-context/tex/context/base/type-otf.mkiv)))
> system  : test.top loaded
> (test.top)
> fonts   : preloading latin modern fonts
> bodyfont: 12pt rm is loaded
> language: language en is active
> systems : begin file test at line 2
> (C:/context/tex/texmf-context/tex/context/sample/tufte.tex)
> fonts   : resetting map file list
> {C:/context/tex/texmf-context/fonts/map/pdftex/context/original-empty.map}
> fonts   : using map file: original-base
> {C:/context/tex/texmf-context/fonts/map/pdftex/context/original-base.map}
> fonts   : using map file: original-ams-base
>
{C:/context/tex/texmf-context/fonts/map/pdftex/context/original-ams-base.map}
> fonts   : using map file: original-ams-euler
>
{C:/context/tex/texmf-context/fonts/map/pdftex/context/original-ams-euler.map}
> fonts   : using map file: original-public-lm
>
{C:/context/tex/texmf-context/fonts/map/pdftex/context/original-public-lm.map}
> fonts   : using map file: lm-math
> {C:/context/tex/texmf/fonts/map/dvips/lm/lm-math.map}
> fonts   : using map file: lm-rm
> {C:/context/tex/texmf/fonts/map/dvips/lm/lm-rm.map}
> ! LuaTeX error ...text/tex/texmf-context/tex/context/base/node-ref.lua:47:
attempt to call upvalue 'list_dimensions' (a nil value)
> stack traceback:
>  ...text/tex/texmf-context/tex/context/base/node-ref.lua:47: in function
'dimensions'
>  ...text/tex/texmf-context/tex/context/base/node-ref.lua:71: in function
'inject_range'
>  ...text/tex/texmf-context/tex/context/base/node-ref.lua:302: in function
'inject_area'
>  ...text/tex/texmf-context/tex/context/base/node-ref.lua:299: in function
'inject_area'
>  ...text/tex/texmf-context/tex/context/base/node-ref.lua:299: in function
'inject_area'
>  ...text/tex/texmf-context/tex/context/base/node-ref.lua:299: in function
'inject_area'
>  ...text/tex/texmf-context/tex/context/base/node-ref.lua:299: in function
'inject_area'
>  ...text/tex/texmf-context/tex/context/base/node-ref.lua:299: in function
'inject_area'
>  ...text/tex/texmf-context/tex/context/base/node-ref.lua:299: in function
'inject_area'
>  ...text/tex/texmf-context/tex/context/base/node-ref.lua:299: in function
'inject_area'
>  ...
>  ...text/tex/texmf-context/tex/context/base/node-ref.lua:299: in function
'inject_area'
>  ...text/tex/texmf-context/tex/context/base/node-ref.lua:299: in function
'inject_area'
>  ...text/tex/texmf-context/tex/context/base/node-ref.lua:299: in function
'inject_area'
>  ...text/tex/texmf-context/tex/context/base/node-ref.lua:299: in function
'inject_area'
>  ...text/tex/texmf-context/tex/context/base/node-ref.lua:299: in function
<...text/tex/texmf-context/tex/context/base/node-ref.lua:279>
>  (tail call): ?
>  :14: in function
<:10>
>  (tail call): ?
>  (tail call): ?
>  :1: in main chunk.
> \finalizeshipoutbox ..._page(tex.box[\number #1])}
>
> \actualshipout ...0\hbox {#1}\finalizeshipoutbox 0
>   \setbox \scratchbox
\hbox ...
> \myshipout ...\@@ppmethod }\gobbleoneargument {#1}
>   \setnextrealpageno
\afters...
> \dofinaloutput ...hbox {\vbox {\dopagebody #1#2}}}
>   \the \everyaftershipout
\a...
> \finaloutput ...EAEAEA \dofinaloutput \fi \fi #1#2
>   \resetselectiepagina
\incr...
> \sidefloatoutput ...e \else \finalsidefloatoutput
>   \global \sidefloatvsize
\n...
> ...
> l.6 \stoptext
>
> ?
=
Thanks,
Tad
PS: By 

Re: [NTG-context] How to Determine the Current File Name and Line Number in the ConTeXt Source?

2009-07-07 Thread Tad Ashlock

Taco Hoekwater wrote:

Tad Ashlock wrote:
>
> Looks like we're always getting the xstrdup() branch of the conditional.

Probably because you are not reading from a file at that level,
but from a token list. Do you want filename to be a file even
if the current input is not directly from a file at all
(doable, but less meaningful)?

Best wishes,
Taco


Hi Taco,

I'm far from an expert in this realm, but since you asked what *I* 
want... :)


My intention is to associate status.filename and status.linenumber 
together.  That is, I would read and save their values consecutively in 
the same Lua function so that they would refer to the ConTeXt source 
line currently being processed by the ConTeXt engine.


Now you say that ConTeXt may not be reading from a file at that level. 
That I can accept (being a non-expert), but status.linenumber always 
returns the correct line number for the ConTeXt file being processed 
(even if the file is being \input from another file).  It seems to me 
that if the line number within the source file is accurate, then the 
file's name should be accurate, too.


Thank you,
Tad



___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] How to Determine the Current File Name and Line Number in the ConTeXt Source?

2009-07-03 Thread Tad Ashlock

Hans Hagen wrote:
> Tad Ashlock wrote:
> > Is there a convenient way within a Lua block to determine the current
> > file name and line number of the source file being processed by 
ConTeXt?


[snip]

> i have no time now to figure out while filenames are not known but
> here's a (wikifyable) hack:
[snip]
> line = status.linenumber,
> file = status.filename

From the luatex 0.40.6 sources
(luatex/source/texk/web2c/luatexdir/lua/lstatslib.c):
--
/* hack, I really should implement the makecstring */
char *getfilename(void)
{
   integer t;
   t = get_current_name();
   if (t > (1 << 21))
   return makecstring(t);
   else
   return xstrdup("");
}
--

Looks like we're always getting the xstrdup() branch of the conditional.

Hans, would you like me to submit this as a luatex bug?

Tad

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] How to Determine the Current File Name and Line Number in the ConTeXt Source?

2009-07-01 Thread Tad Ashlock
Is there a convenient way within a Lua block to determine the current 
file name and line number of the source file being processed by ConTeXt?


For example: (test.tex)
-
\def\ShowLineNumber{%
   \ctxlua{print('current line number:', tex.current_line_number())
  print('current file:', tex.current_file_name())}}
\starttext
a line
\ShowLineNumber
another line

\ShowLineNumber
\stoptext
-

With the following displayed:
-
current line number: 6
current file: test.tex
current line number: 9
current file: test.tex
-

I've considered hooking into the open_read_file callback and tracking 
the file name and line number (via reader) myself.  But that seems a bit 
heavy handed if the file name and line number information are available 
more directly.  And since that information is needed for error 
reporting, I'm thinking there's a good chance it is accessible.


(Just in case you're interested, the purpose of this is to be able to 
assemble code segments during the ConTeXt processing into external files 
with #line directives ala the C preprocessor.  That way if the 
subsequent compilation of the external file results in an error, the 
error message can refer back to the line of code in the ConTeXt source 
file.  This is part of the literate programming module that Kevin 
Robbins has been describing in another thread.)


Thanks,
Tad
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] Referencing Broken in MKIV?

2009-06-28 Thread Tad Ashlock

From  (\reference):

\starttext
See page \ref[p][myref 1] and \ref[p][myref 2].
\page
\reference[myref 1]{} This is the first reference.
\page
\reference[myref 2]{} This is the second one.
\stoptext


Works in MKII (at least on ConTeXt online), but produces the following 
first page in MKIV:


-
See page and .
-

MTXrun | current version: 2009.06.14 21:01
This is LuaTeX, Version beta-0.40.6-2009062621 (Web2C 2009) luatex.web 
>= v13958


Thanks,
Tad
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] \usemodule question

2009-02-26 Thread Tad Ashlock

Thomas A. Schmitz wrote:

On Feb 26, 2009, at 11:55 AM, Alan Stone wrote:


Doesn't \usemodule issue a search in parent directories when the
module is not found in the working directory ?


Why should it?


From the ConTeXt Manual (page 18):

"A file that is not available on the working directory is searched for 
on the parent directories."


Just answering your question. :)

Tad

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Using defaults and indexes

2009-01-21 Thread Tad Ashlock

Cecil Westerhof wrote:
[snip]

Found the problem.
 \doifelsenothing{#1}
   {\doletterclosing{Hoogachtend,}{Cecil Westerhof}}%
should be:
 \doifelsenothing{#1}
   {\doletterclosing{Hoogachtend,}{Cecil Westerhof}}%

Now it seems to do what I want.


I don't see the difference.  Would you point it out for me?

Thanks,
Tad

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] Problem Passing \starttabulate into Lua

2008-12-27 Thread Tad Ashlock
I'm trying to create a ConTeXt macro (mkiv) that will manipulate the 
macro argument's text with Lua and then feed it back into ConTeXt with 
tex.print().  My approach worked correctly until I called the macro with 
\starttabulate ... \stoptabulate in the macro's argument.  So I started 
reducing the problem down to a minimum example which surprisingly turned 
out to have nothing to do with the manipulations I was performing.


Here is the working example (without \starttabulate):

\long\def\testmacro#1{\directlua0{d='\luaescapestring{#1}'}}
\starttext
Hello, world!
\testmacro{%
   testing}
\stoptext


Here is the broken example:

\long\def\testmacro#1{\directlua0{d='\luaescapestring{#1}'}}
\starttext
Hello, world!
\testmacro{%
   testing
   \starttabulate
 \NC 0 \NC testing tabulate. \NC \NR
   \stoptabulate}
\stoptext

Here's the output:
=
MtxRun | loading configuration for C:/context/tex/texmf/web2c from 
C:/context/tex/texmf-cache/luatex-cache/context/2fea56f92e5267d7cc9662e4d5f52e1e/trees/53ad5f8b88994bdd02baa17501789699
MtxRun | run 1: luatex 
--fmt="C:/context/tex/texmf-cache/luatex-cache/context/2fea56f92e5267d7cc9662e4d5f52e1e/formats/cont-en" 
--lua="C:/context/tex/texmf-cache/luatex-cache/context/2fea56f92e5267d7cc9662e4d5f52e1e/formats/cont-en.lua" 
"./test.tex"

(test.tex

ConTeXt  ver: 2008.10.31 13:58 MKIV  fmt: 2008.12.24  int: english/english

language   : language en is active
system : cont-new loaded
(C:/context/tex/texmf-context/tex/context/base/cont-new.tex
systems : beware: some patches loaded from cont-new.tex
(C:/context/tex/texmf-context/tex/context/base/cont-new.mkiv) 
(C:/context/tex/texmf-context/tex/context/base/cont-mtx.tex))

system : cont-fil loaded
(C:/context/tex/texmf-context/tex/context/base/cont-fil.tex
loading: Context File Synonyms
)
system : cont-sys.rme loaded
(C:/context/tex/texmf-context/tex/context/user/cont-sys.rme 
(C:/context/tex/texmf-context/tex/context/base/type-tmf.tex) 
(C:/context/tex/texmf-context/tex/context/base/type-siz.tex) 
(C:/context/tex/texmf-context/tex/context/base/type-otf.tex))

bodyfont   : 12pt rm is loaded
specials   : pdftex loaded
system : test.top loaded
(test.top) (test.tuo) (test.tuo)
systems: begin file test at line 2
! Argument of \dodoubletestempty has an extra }.

   \par

  }
\doifnextcharelse ...token =#1\def \!!stringa {#2}
 \def \!!stringb 
{#3}\futur...

 testing \starttabulate
 \NC 0 \NC testing tabulate. \NC \NR 
\stopt...

\testmacro ...\directlua 0{d='\luaescapestring {#1
 }'}
l.8 \stoptabulate}

?
=

I've tried all sorts of variations on the above example including using 
\ctxlua, \startlua, \startluacode, etc.  I tried using '[[...]]' and 
'[===[...]===]' instead of \luaescapestring.  I tried \def with and 
without \long.  I tried other \start* ... \stop* commands (different 
errors, but still broken).  Plus many more variations.


At this point I'm convinced that there's something fundamental that I'm 
not understanding.  What is the general method for taking any chunk of 
ConTeXt code and passing it into Lua so that it can be written back out 
with tex.print()?


Info: running on Windows XP, SP3 -- ConTeXt: 2008.10.31 -- LuaTeX, 
Version snapshot-0.31.2-2008121200, build 1659


(The older versions of ConTeXt and LuaTeX are necessary because of the 
problem the latest Windows versions are having.  See the "Serious Bug?" 
thread.)


Thank you,
Tad Ashlock




___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Serious bug?

2008-12-22 Thread Tad Ashlock

On Mon, Dec 22, 2008 at 8:35 AM, Mojca Miklavec wrote:

On Mon, Dec 22, 2008 at 8:26 AM, Mojca Miklavec wrote:

On Mon, Dec 22, 2008 at 2:53 AM, Fengnan Gao wrote:


What version of LuaTeX is in Windows distribution? Maybe I forgot to
update it. I'll check tomorrow (you can try to fetch the version from
W32TeX).

Mojca


C:\Users\fnsteed>luatex --credits
This is LuaTeX, Version snapshot-0.31.2-2008121200, build 1659

...

Hope that'll help.


I'm clueless then. If version mismatch doesn't explain it and if there
are no error messages, then I'm running out of ideas.

What happens if you run first-setup.bat again, delete the contents of
D:/context/tex/texmf-cache, open cmd, go to the folder with your
document, and then type:


D:\context\tex\setuptex
luatools --generate
context --make
context test.tex


There's one more thing that you can try. In case that rsync is
problematic, there's a way to circumvent it, but I doubt that it would
do a difference.

Download
http://minimals.contextgarden.net/pragma/justtex.zip
http://minimals.contextgarden.net/pragma/mswin.zip
Unzip both of them together, for example into D:\context2, run
> D:\context2\tex\setuptex
> mktexlsr
> luatools --generate
> context make
> context test.tex

Mojca


I'm having the same problem, and I have some more information.

First, I have context-minimals installed on Windows XP, SP2, Intel 
Pentium D (3.2GHz), 2GB of RAM.  My current ConTeXt version is 
"2008.11.10 21:40".


I don't have the problem when I run "texexec test.tex", only when I run 
"texexec --lua text.tex" or "context text.tex".


I previously had something like 2008.10.31 installed.  That version did 
not have this problem.


I tried both of Mojca's suggested sequences above and neither had any 
effect on the problem.  With a test.tex file of this:


\starttext
Hello, world!
\stoptext

the resulting PDF file has two pages.  The first has "H e l" spread 
across the middle of the page, and the second has "l o , w" spread 
across the page.  The characters are of the expected size, just spread out.


If I add "\setupbodyfont[lbr,6pt]" at the beginning of test.tex, then I 
get a single page with "Hello," and "world!" spread out across the page 
in two lines of small characters.


If I add "\showgrid", then the resulting page has only one full-width 
horizontal grid line where without the --lua option, I get 41 horizontal 
grid lines.  (At the default font size.)


I hope this helps,
Tad

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___