Re: [NTG-context] How can I remove a blank leading line from a buffer

2018-08-16 Thread Rik

On 8/16/2018 10:55, Aditya Mahajan wrote:

On Wed, 15 Aug 2018, Rik Kabel wrote:

I suspect that the issue in the larger project has to do with quoting 
for the RE ("^\\relax") since compilation fails with:


  %% \stopAttribution ...getcontent("Attribution"),"^\\
  %% relax","")))}\stopparagrap...

Any pointers on such quoting would be appreciated.


Please create a MWE.

Aditya 


I cannot at this point, and may well have misinterpreted what I saw.

--
Rik
___
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] Logo in the margin at the bottom of the page

2018-08-16 Thread Wolfgang Schuster



Fabrice Couvreur schrieb am 16.08.18 um 11:20:

Hi Henry,
Sorry for the late response. In fact, I want a margin of 20 mm around 
the text box. In addition, playing with the options weight = and 
height = some images are distorted, including the one that I join.

Thank you
Fabrice

[...]

\setupfooter[margin][strut=no]


This has no effect because the strut for the pagenumber text effects all 
entries in the footer area.


The following example to demonstrates this (line 2):

\starttext

\ruledhbox to \hsize{\hbox{A}\hss\hbox{B}}

\ruledhbox to \hsize{\hbox{\strut A}\hss\hbox{B}}

\ruledhbox to \hsize{\hbox{Q}\hss\hbox{B}}

\ruledhbox to \hsize{\hbox{\smash[d]{Q}}\hss\hbox{B}}

\stoptext


\setupfootertexts
[margin]
[]
[{\externalfigure[logo.png][height=]}]
[]
[{\externalfigure[logo.png][height=]}]


\setupfootertexts[{Page \pagenumber\ of \goto{\lastpagenumber}[lastpage]}]

\setupfootertexts
  [margin]
  []
  [{\offset[y=\strutdp]{\externalfigure[logo.png][factor=max]}}]
  []
  [{\offset[y=\strutdp]{\externalfigure[logo.png][factor=max]}}]


or


\setupfooter[strut=no]

\setupfootertexts[\undepthed{Page \pagenumber\ of 
\goto{\lastpagenumber}[lastpage]}]


\setupfootertexts
  [margin]
  []
  [{\externalfigure[logo.png][factor=max]}]
  []
  [{\externalfigure[logo.png][factor=max]}]


or


\setupfooter[strut=no]

\setupfootertexts[{\framed[frame=off,offset=0pt]{Page \pagenumber\ of 
\goto{\lastpagenumber}[lastpage]}}]


\setupfootertexts
  [margin]
  []
  [{\externalfigure[logo.png][factor=max]}]
  []
  [{\externalfigure[logo.png][factor=max]}]


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] How can I remove a blank leading line from a buffer

2018-08-16 Thread Aditya Mahajan

On Wed, 15 Aug 2018, Rik Kabel wrote:


On 8/15/2018 03:07, Hans Hagen wrote:

On 8/15/2018 5:31 AM, Aditya Mahajan wrote:

On Tue, 14 Aug 2018, Rik Kabel wrote:

I really think, though, that a buffers.strip function would be the way to 
go, instead of futzing after the damage is done.


In lua, buffers.getcontent('name') gives the contents of the buffer 
labelled 'name'. You can post-process this in whatever way you want. For 
example, you could write a lua function userdata.strip that strips the 
leading and ending black spaces from a string, and then call


context(userdata.strip(buffers.getcontent('name)))

local s = [[

foo

bar


bar

]]

print(string.fullstrip(s))


So, it looks likethe following is closer to working for me in a simple test 
harness, but not in my full-blown work:


  
\dontleavehmode{\llap{StripA~}}\ctxlua{context(utilities.strings.striplines(string.gsub(buffers.getcontent("TestBuffer"),"^\\relax",""),"prune"))}

(or similar with string.fullstrip).

However, it fails when the buffer starts with an unescaped left square 
bracket. That is probably why the \relax is inserted, and I can see that it 
is not a simple job to handle this. So, I will accept that I must either 
append [] or get rid of the open layout for these cases.


I suspect that the issue in the larger project has to do with quoting for the 
RE ("^\\relax") since compilation fails with:


  %% \stopAttribution ...getcontent("Attribution"),"^\\
  %% relax","")))}\stopparagrap...

Any pointers on such quoting would be appreciated.


Please create a MWE.

Aditya
___
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] The dimensions of the first page are not taken into account Hello, I want to create a template with a header on the first page for student testing. If the document contains text that is

2018-08-16 Thread Fabrice Couvreur
Hello,
I want to create a template with a header on the first page for student
testing. If the document contains text that is on more than one page, it
works perfectly. On the other hand, if the document has text on one page,
it does not work.
Thanks.
Fabrice

\setuppagenumbering[alternative=,location=]

  \showframe

  \definelayout
[firstpage]
[topspace=10mm,
 header=10mm,
 footer=10mm,
 height=middle,
 backspace=20mm,
 width=middle]

  \definelayout
[first]
[firstpage]

  \setuplayout
   [topspace=10mm,
header=\zeropoint,
footer=10mm,
height=middle,
backspace=20mm,
width=middle]

  \setupbackgrounds
   [header]
   [text]
   [frame=off,
topframe=on,
bottomframe=on,
framecolor=red,
rulethickness=1pt]

  \setupheadertexts
[First page]

  \starttext
  \dorecurse{8}{\input knuth}  % ok

%  \dorecurse{8}{\input knuth}  no ok
  \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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] Logo in the margin at the bottom of the page

2018-08-16 Thread Fabrice Couvreur
Hi Henry,
Sorry for the late response. In fact, I want a margin of 20 mm around the
text box. In addition, playing with the options weight = and height = some
images are distorted, including the one that I join.
Thank you
Fabrice

\setuppagenumbering[alternative=doublesided,location=]

  \showframe

  \definelayout
[firstpage]
[topspace=10mm,
 header=10mm,
 footer=10mm,
 height=middle,
 backspace=20mm,
 width=middle]

  \definelayout
[first]
[firstpage]

  \setuplayout
   [topspace=10mm,
header=\zeropoint,
footer=10mm,
height=middle,
backspace=20mm,
width=middle]

  \setupbackgrounds
   [header]
   [text]
   [frame=off,
topframe=on,
bottomframe=on,
framecolor=,
rulethickness=1pt]

  \setupinteraction[state=start]

  \setupfooter[margin][strut=no]

  \setupfootertexts[{Page \pagenumber\ of \goto{\lastpagenumber}[lastpage]}]

  \setupfootertexts
[margin]
[]
[{\externalfigure[logo.png][height=]}]
[]
[{\externalfigure[logo.png][height=]}]

  \starttext
   \dorecurse{20}{\input knuth}
  \stoptext


[image: logo.png]

Le mer. 15 août 2018 à 06:10, Henri Menke  a écrit :

> You have to use the correct margin width, i.e. \rightmarginwidth in the
> right margin and vice versa in the left margin.  You should also scale
> the margins to fit in the backspace/cutspace because by default they
> don't and run off the paper.
>
> \showframe
> \useMPlibrary[dum]
> \setuplayout
>[height=middle,
> width=middle,
> backspace=2cm,
> topspace=10mm,
> bottomspace=10mm,
> header=10mm,
> footer=10mm,
> footerdistance=10mm,
> headerdistance=10mm,
>
>
> leftmargin=\dimexpr\layoutparameter{backspace}-\layoutparameter{leftmargindistance}\relax,
>
>
> cutspace=\dimexpr\layoutparameter{rightmargin}+\layoutparameter{rightmargindistance}\relax]
>
> \setupfooter[margin][strut=no]
>
> \setupfootertexts
>[margin]
>[]
>[{\externalfigure[dummy][width=\rightmarginwidth,height=\footerheight]}]
>[]
>[{\externalfigure[dummy][width=\leftmarginwidth,height=\footerheight]}]
>
> \starttext
> \dorecurse{10}{\page[dummy]}
> \stoptext
>
>
> On 14/08/18 22:50, Fabrice Couvreur wrote:
> > Hi Henri,
> > Thank you for your suggestion.
> > However, I believe that my way of doing should not be the best because
> > fixing width=\marginwidth the image is cropped.
> > Fabrice
> >
> >
> > \showframe
> > \useMPlibrary[dum]
> > \setuplayout
> >[height=middle,
> > width=middle,
> > backspace=2cm,
> > topspace=10mm,
> > bottomspace=10mm,
> > header=10mm,
> > footer=10mm,
> > footerdistance=10mm,
> > headerdistance=10mm]
> >
> > \setupfooter[margin][strut=no]
> >
> > \setupfootertexts
> >  [margin]
> >  []
> >  [{\externalfigure[dummy][width=,height=\footerheight]}]
> >  []
> >  [{\externalfigure[dummy][width=\marginwidth,height=\footerheight]}]
> >
> >  \starttext
> >  \dorecurse{10}{\page[dummy]}
> >  \stoptext
> >
> >
> > Le mar. 14 août 2018 à 12:18, Henri Menke  > > a écrit :
> >
> >
> >
> > On 14/08/18 22:13, Fabrice Couvreur wrote:
> >  > Hello,
> >  > I wish to place a small logo at the bottom of the page.
> >  > It works almost but it is not very well adjusted.
> >  > How to cure it ?
> >  > Thank you.
> >  > fabrice
> >  >
> >  > \showframe
> >  > \useMPlibrary[dum]
> >  > \setuplayout
> >  >[height=middle,
> >  > width=middle,
> >  > backspace=2cm,
> >  > topspace=10mm,
> >  > bottomspace=10mm,
> >  > header=10mm,
> >  > footer=10mm,
> >  > footerdistance=10mm,
> >  > headerdistance=10mm]
> >  >
> >
> > \setupfooter[margin][strut=no]
> >
> >  > \setupfootertexts
> >  >  [margin]
> >  >  []
> >  >
> > [{\externalfigure[dummy][width=\marginwidth,height=\footerheight]}]
> >  >  []
> >  >
> > [{\externalfigure[dummy][width=\marginwidth,height=\footerheight]}]
> >  >
> >  >  \starttext
> >  >  \dorecurse{10}{\page[dummy]}
> >  >  \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://context.aanhet.net
> >  > archive  : https://bitbucket.org/phg/context-mirror/commits/
> >  > wiki : http://contextgarden.net
> >  >
> >
>  
> ___
> >  >
> >
>  
> ___
> > If your question is of