Re: [NTG-context] Chapter numbering after \part

2020-08-20 Thread Wolfgang Schuster

jbf schrieb am 21.08.2020 um 04:27:
By default, chapter numbers coming after \part are numbered 1.1... 
2.1... and so on. But in my case I need them to still be simply 1,2... 
for each part. Is there a way I can get this numbering to occur? I 
thought I could do it using ownnumber=, but that doesn't work. Then I 
tried a makeup, because I thought that would create a 'Part' page 
independent of chapter numbers - but that doesn't work either:-).  Am 
sure it is achievable, however


\setuphead
  [chapter]
  [sectionsegmments=chapter]

Wolfgang

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Chapter numbering after \part

2020-08-20 Thread jbf
By default, chapter numbers coming after \part are numbered 1.1... 
2.1... and so on. But in my case I need them to still be simply 1,2... 
for each part. Is there a way I can get this numbering to occur? I 
thought I could do it using ownnumber=, but that doesn't work. Then I 
tried a makeup, because I thought that would create a 'Part' page 
independent of chapter numbers - but that doesn't work either:-).  Am 
sure it is achievable, however


Julian

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Chapter heading with rules

2020-08-20 Thread jbf
Have achieved a Chapter title with rules either side (see below - not an 
original invention!) but I want the chapter number to be part of 'My 
Chapter Title'; instead, the following MWE means it comes before the 
ChapterLeftRule. I know I can do it by actually putting the number 
before My Chapter title (e.g. 1 My Chapter Title), since the proper 
numbered version still appears in the TOC, but my preference would be to 
include a command in the \setuphead, if possible (so long as it still 
allows the numbered chapter to appear in the TOC of course). Possible?


\definefiller
  [ChapterRule]
  [alternative=rule,
   color=gray,
   height=0.8ex,
   depth=-0.6ex]

\definefiller
  [ChapterLeftRule]
  [ChapterRule]
  [left=\zerowidthnobreakspace,
   right=\quad]

\definefiller
  [ChapterRightRule]
  [ChapterRule]
  [left=\quad,
   right=\zerowidthnobreakspace]

\setuphead
  [chapter]
  [%align=middle,
   textstyle={\setcharactercasing[WORD]\ssa},
textcommand=\groupedcommand{\filler[ChapterLeftRule]}{\filler[ChapterRightRule]}]

\starttext

\chapter{My Chapter Title}

\stoptext

Julian

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] custom header/footer for 1st/other pages of section

2020-08-20 Thread Mike Cooper
Thank you Wolfgang!!

I was taken away to other work for several days and just got back to this now.

Works great!
THANKS!



> -Original Message-
> From: Wolfgang Schuster [mailto:wolfgang.schuster.li...@gmail.com]
> Sent: Tuesday, August 11, 2020 12:07 PM
> To: mailing list for ConTeXt users
> Cc: Mike Cooper
> Subject: Re: [NTG-context] custom header/footer for 1st/other pages of section
> 
> Mike Cooper schrieb am 11.08.2020 um 19:20:
> >
> >
> >> -Original Message-
> >> From: Wolfgang Schuster [mailto:wolfgang.schuster.li...@gmail.com]
> >> Sent: Tuesday, August 11, 2020 10:07 AM
> >> To: mailing list for ConTeXt users
> >> Cc: Mike Cooper
> >> Subject: Re: [NTG-context] custom header/footer for 1st/other pages of 
> >> section
> >>
> >>
> >> Mike Cooper schrieb am 10.08.2020 um 23:40:
> >>>
> >>>
> >>> Thank you Wolfgang!
> >>>
> >>> I tried to change your code from chapters to sections (since that's what 
> >>> I was
> >> already using) but it didn't work.  So, I switched my sections to chapters 
> >> and it
> >> works great!  But it also caused me to run into other things I'd set up 
> >> manually
> that
> >> I'm having to figure out---good way to learn!  Haha!
> >>
> >> You can only set header or footer settings when the section starts on a
> >> new page. Permitting these two values for every section without this
> >> restrictions can lead to problems because there can be cases where you
> >> have different section levels on the same page and the setting from the
> >> last command on the page counts.
> >
> > That makes sense.  I wasn't really thinking of my sections as "chapters" 
> > per se.
> And I was forcing sections (each >5 pages) to start on new (odd) pages.  But
> switching to chapters is fine and takes care of some other stuff I was 
> forcing.
> 
> 
> You don't have to use \chapter as first level section which starts on a
> new page, you can do the same with \section when you use
> 
>\setuphead
>  [section]
>  [page={yes,odd}]
> 
> 
> >>> One thing I *CANNOT* figure out:  I've been using \doifoddpageelse to put 
> >>> in a
> >> blank/empty page at the end of a section (if needed) so that new sections
> always
> >> start on an odd page.  This is still working with the change to chapters 
> >> from
> >> sections, EXCEPT for the first chapter (after TOC)!  Totally stuck with 
> >> that one...
> >>
> >> Let me guess you divide your document into section blocks (frontmatter,
> >> bodymatter etc.).
> >>
> >> When this is the case you have to first disable the page setting for
> >> these blocks because they interfere with the header/footer setting. To
> >> disable the page breaks add
> >>
> >> \setupsectionblock
> >>   [frontpart,bodypart]
> >>   [page=no]
> >>
> >> to your document setups.
> >
> > How does this interact with \startsectionblockenvrironment?  I found this on
> wiki.contextgarden.net/Table_of_Contents for suppressing header/footer on 
> TOC.  I
> did not specify frontmatter before, but moving the header/footer content into 
> the
> environment file messed up my formerly clean TOC page.  :-)   So, I've 
> currently
> got:
> >
> > \startsectionblockenvironment[frontpart]
> >\setupheader[state=none]
> >\setupfooter[state=none]
> > \stopsectionblockenvironment
> >
> > Do I keep this and also include your code above?  Or can both things be 
> > taken
> care of together somehow?
> 
> 
> Both a different setups for different purposes.
> 
> 
> In my setup I tell ConTeXt not to force a page break when it encounters
> \startfrontmatter or \stopfrontmatter because I insert the break with
> \chapter.
> 
> 
> With the sectionblockenvironment-environment you can set a list of
> settings which are inserted at the start of block, i.e. your settings
> above do the same as
> 
>\startfrontmatter
> 
>\setupheader[...]
>\setupfooter[...]
> 
>...
> 
>\stopfrontmatter
> 
> where I added the setting to the start of the block. The advantage of
> \startsectionblockenvironment is that you have separated the layout from
> the content.
> 
> Wolfgang
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] removing word in filtered XML

2020-08-20 Thread Pablo Rodriguez
On 8/20/20 1:10 PM, Hans Hagen wrote:
> On 8/20/2020 12:38 PM, Pablo Rodriguez wrote:
>> [...]
>> This time, I have to remove two words, such as in:
>>
>>string.gsub([[\xmlraw{#1}{.}]]," del ", " "):gsub(" de la ", " ")}
>>
>> But they could be more (and replacements might be added to that list).
>>
>> Is there a more elegant way than appending :gsub()?
>>
>> Is there also a proper way for word scanning?
>>
>> A "word" can be "Word ", " word " " word." " word?" (and so on). I would
>> like to avoid having to code all combinations (of course, if this were
>> already available).
>
> old stuff present for a long time ... probaly documented somewhere ...
> if not than you have to wikify it ...

Many thanks for your reply, Hans.

It is already wikified
(https://wiki.contextgarden.net/Ligatures#Replacements).

I wonder whether \replaceword could be extended to replace multiple
words and also to remove them.

  \starttext

  \replaceword[whatever][this or][no]
  \replaceword[whatever][that][]

  \startlines
  it is this or that
  {\setreplacements[whatever]it is this or that}
  {\setreplacements[whatever]it is this or that}
  it is this or that
  \stoplines

  \stoptext

Many thanks for your help,

Pablo
--
http://www.ousia.tk
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] [BUG] \registerexternalfigure doesn't work

2020-08-20 Thread Wolfgang Schuster

Henri Menke schrieb am 20.08.2020 um 07:05:

Dear list,

To get properties of a figure without actually typesetting it, it is
handy to use \registerexternalfigure.  However, trying to use it fails.
Consider the following MWE:

 \starttext
 \registerexternalfigure[cow.pdf]
 \stoptext


Wrong command, use \getfiguredimensions[...]


Looking at the definition in grph-inc.mkiv reveals that is it complete
bogus.


Is this necessary?

Wolfgang
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Wiki New Extension: ConTeXtXML

2020-08-20 Thread Taco Hoekwater
Hi,

As announced last week, I have been working on a wiki extension to control the 
editing of /Command pages. That extension is now installed on the main wiki.

In short, we will switch to XML as the page model for newly created /Command 
pages. This makes editing a bit harder, but it allows much better quality 
control and (fairly) easy export and import.

The goal is to eventually be able to easily export all of the reference 
documentation in the wiki to a separate system (for instance, Paul Mazaitis 
plans to create a full-blown reference manual). In the current situation, this 
is nearly impossible because there is so much variation in the content and 
quality of the wiki /Command pages (not to mention that many are missing). We 
also want it to be possible to merge improvements to the interface xml 
definitions by Wolfgang without loosing any existing documentation work.

The documentation pages are here:

   https://wiki.contextgarden.net/Command
   https://wiki.contextgarden.net/Help:Command
   https://wiki.contextgarden.net/Extension:ConTeXtXML

After reading those, have a look at the three ‘work pages’:

   https://wiki.contextgarden.net/Document_level_commands_work_page
   https://wiki.contextgarden.net/Style_level_commands_work_page
   https://wiki.contextgarden.net/System_level_commands_work_page 

All the bright red links are currently undocumented commands. Clicking on one 
should bring you to the edit screen automatically, with a blob of XML 
preloaded, ready for you to start writing.

All the dark red links are existing /Command pages. All of those are 
traditional wiki text pages. Following those links will bring you to a normal 
/Command page just like on the main wiki. If you want to see how one of those 
pages would look like in the new system, you’ll have to rename the existing 
page first (as explained in 
https://wiki.contextgarden.net/Command#Pre-existing_pages ) 

If you do some work, please update those work pages!


Comments, suggestions and bug reports are more than welcome. 

Please direct those to me personally or (better) to the wiki mailing list:

https://lists.contextgarden.net/mailman/listinfo/wiki

Have fun!

Taco


___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] removing word in filtered XML

2020-08-20 Thread Hans Hagen

On 8/20/2020 12:38 PM, Pablo Rodriguez wrote:

On 8/20/20 11:27 AM, Hans Hagen wrote:

On 8/19/2020 6:10 PM, Pablo Rodriguez wrote:

[...]
Is there any way to remove " of " and " of the " in the filtered content
(xml:special)?

Sorry, Lua code is crap for sure.

[...]
\startxmlsetups xml:initialize
  \xmlsetsetup{#1}{html}{xml:gen}
  \xmlsetsetup{#1}{span[@class='special']}{xml:span:special}
\stopxmlsetups
[...]
\startxmlsetups xml:span:special
  (\cldcontext{(string.gsub([[\xmlraw{#1}{.}]]," of the ", ""))})
\stopxmlsetups


Many thanks for your reply, Hans.

I now see that \xmlraw is the way to go.

I have two questions in word replacement and Lua (maybe there is some
lpeg magic that could be used).

This time, I have to remove two words, such as in:

   string.gsub([[\xmlraw{#1}{.}]]," del ", " "):gsub(" de la ", " ")}

But they could be more (and replacements might be added to that list).

Is there a more elegant way than appending :gsub()?

Is there also a proper way for word scanning?

A "word" can be "Word ", " word " " word." " word?" (and so on). I would
like to avoid having to code all combinations (of course, if this were
already available).
old stuff present for a long time ... probaly documented somewhere ... 
if not than you have to wikify it ...


\starttext

\replaceword[whatever][this][that]
\replaceword[whatever][that][this]

\startlines
it is this or that
{\setreplacements[whatever]it is this or that}
it is this or that
\stoplines

\stoptext



-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] removing word in filtered XML

2020-08-20 Thread Pablo Rodriguez
On 8/20/20 11:27 AM, Hans Hagen wrote:
> On 8/19/2020 6:10 PM, Pablo Rodriguez wrote:
>> [...]
>> Is there any way to remove " of " and " of the " in the filtered content
>> (xml:special)?
>>
>> Sorry, Lua code is crap for sure.
> [...]
> \startxmlsetups xml:initialize
>  \xmlsetsetup{#1}{html}{xml:gen}
>  \xmlsetsetup{#1}{span[@class='special']}{xml:span:special}
> \stopxmlsetups
> [...]
> \startxmlsetups xml:span:special
>  (\cldcontext{(string.gsub([[\xmlraw{#1}{.}]]," of the ", ""))})
> \stopxmlsetups

Many thanks for your reply, Hans.

I now see that \xmlraw is the way to go.

I have two questions in word replacement and Lua (maybe there is some
lpeg magic that could be used).

This time, I have to remove two words, such as in:

  string.gsub([[\xmlraw{#1}{.}]]," del ", " "):gsub(" de la ", " ")}

But they could be more (and replacements might be added to that list).

Is there a more elegant way than appending :gsub()?

Is there also a proper way for word scanning?

A "word" can be "Word ", " word " " word." " word?" (and so on). I would
like to avoid having to code all combinations (of course, if this were
already available).

Many thanks for your help,

Pablo
--
http://www.ousia.tk
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] removing word in filtered XML

2020-08-20 Thread Pablo Rodriguez
On 8/20/20 11:08 AM, Taco Hoekwater wrote:
> [...]
> There is pretty much always ‘a way’, but I do not know of a ’nice’ way.
> Your problem is that lxml.flush() and friends do not return a value,
> they just do a direct context(‘’) call behind the scenes with no
> return string for you to modify.

Many thanks for your explanation, Taco.

> Also, the special (catcode, space handling) rules for setups and \cldcontext
> do not help you.
>
> That does not mean it can’t be done. As I don’t know a of a nice way,
> here is a low-level ‘ugly' way:
>
> \startluacode
> function filter(a)
> local div = lxml.getid(a)
> process(div)
> lxml.flush(div)
> end
> function process(div)
> for c=1,#div.dt do
> if type(div.dt[c]) == 'string' then
> div.dt[c] = string.gsub(div.dt[c], " of the ", "")
> else
> process(div.dt[c])
> end
> end
> end
> \stopluacode
>
>  \startxmlsetups xml:special
>\ctxlua{filter([[#1]])}
>  \stopxmlsetups
>
> process() is recursive because your xml:special gets the whole .
> Not sure if you intended it that way. And if it can be done nicer, I
> am sure someone will correct me :)

You’re right, my xml:special wasn’t intended to get the whole . I
was tinkering with a previous sample. And I removed an \xmlfilter. Since
I got no output, I didn’t see what I was missing.

Many thanks for your help,

Pablo
--
http://www.ousia.tk
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] removing word in filtered XML

2020-08-20 Thread Hans Hagen

On 8/19/2020 6:10 PM, Pablo Rodriguez wrote:

Dear list,

I have the following sample:

   \startbuffer[demo]
   
 
   
 This is
   One of the best a paragraph.
 This is another paragraph.
 This is another
   Two of the best paragraph.
 This is another
   Three paragraph.
 This is another
   Four of five paragraph.
   
 
   
   \stopbuffer

   \startxmlsetups xml:initialize
 \xmlsetsetup{#1}{html}{xml:gen}
   \stopxmlsetups

   \xmlregistersetup{xml:initialize}

   \startxmlsetups xml:gen
  \xmlfilter{#1}{/**/div/command(xml:special)}
   \stopxmlsetups

   \startxmlsetups xml:special
 %~ \startitem
 \cldcontext{string.gsub(lxml.flush([[#1]]),
" of the ", "")}\stopitem
   \stopxmlsetups

   \starttext
 \xmlprocessbuffer{main}{demo}{}
   \stoptext

Is there any way to remove " of " and " of the " in the filtered content
(xml:special)?

Sorry, Lua code is crap for sure.

\startbuffer[demo]
  

  
This is One of the best a 
paragraph.

This is another paragraph.
This is another Two of the best 
paragraph.
This is another Three 
paragraph.
This is another Four of five 
paragraph.

  
  
This is One of the best a 
paragraph.

This is another paragraph.
This is another Two of the best 
paragraph.
This is another Three 
paragraph.
This is another Four of five 
paragraph.

  

  
\stopbuffer

\startxmlsetups xml:initialize
\xmlsetsetup{#1}{html}{xml:gen}
\xmlsetsetup{#1}{span[@class='special']}{xml:span:special}
\stopxmlsetups

\xmlregistersetup{xml:initialize}

\startxmlsetups xml:gen
\startitemize
\xmlfilter{#1}{/**/div/command(xml:special)}
\stopitemize
\stopxmlsetups

\startxmlsetups xml:special
\startitem
<\xmlflush{#1}>
\stopitem
\stopxmlsetups

\startxmlsetups xml:span:special
(\cldcontext{(string.gsub([[\xmlraw{#1}{.}]]," of the ", ""))})
\stopxmlsetups

\starttext
\xmlprocessbuffer{main}{demo}{}
\stoptext

Or make a finalizer as Taco posted.

Hans



-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] removing word in filtered XML

2020-08-20 Thread Taco Hoekwater


> On 19 Aug 2020, at 18:10, Pablo Rodriguez  wrote:
> 
> Dear list,
> 
> I have the following sample:
> 
>  \startbuffer[demo]
>  
>
>  
>This is
>  One of the best a paragraph.
>This is another paragraph.
>This is another
>  Two of the best paragraph.
>This is another
>  Three paragraph.
>This is another
>  Four of five paragraph.
>  
>
>  
>  \stopbuffer
> 
>  \startxmlsetups xml:initialize
>\xmlsetsetup{#1}{html}{xml:gen}
>  \stopxmlsetups
> 
>  \xmlregistersetup{xml:initialize}
> 
>  \startxmlsetups xml:gen
> \xmlfilter{#1}{/**/div/command(xml:special)}
>  \stopxmlsetups
> 
>  \startxmlsetups xml:special
>%~ \startitem
>\cldcontext{string.gsub(lxml.flush([[#1]]),
>   " of the ", "")}\stopitem
>  \stopxmlsetups
> 
>  \starttext
>\xmlprocessbuffer{main}{demo}{}
>  \stoptext
> 
> Is there any way to remove " of " and " of the " in the filtered content
> (xml:special)?

There is pretty much always ‘a way’, but I do not know of a ’nice’ way. 
Your problem is that lxml.flush() and friends do not return a value,
they just do a direct context(‘’) call behind the scenes with no
return string for you to modify.

Also, the special (catcode, space handling) rules for setups and \cldcontext
do not help you.

That does not mean it can’t be done. As I don’t know a of a nice way,
here is a low-level ‘ugly' way:

\startluacode
function filter(a)
local div = lxml.getid(a)
process(div)
lxml.flush(div)
end
function process(div)
for c=1,#div.dt do
if type(div.dt[c]) == 'string' then
div.dt[c] = string.gsub(div.dt[c], " of the ", "")
else 
process(div.dt[c]) 
end
end
end
\stopluacode

 \startxmlsetups xml:special
   \ctxlua{filter([[#1]])}
 \stopxmlsetups


process() is recursive because your xml:special gets the whole . Not sure 
if you intended it that way.
And if it can be done nicer, I am sure someone will correct me :)

Best wishes,
Taco
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___