Re: [NTG-context] Making metafun pictures fainter (shading, uncolored clash)

2021-10-10 Thread Gavin via ntg-context
Hi List,

I made good progress producing fainter pictures in metafun. Here is a uniformly 
accelerated cow in the style of my book.



PastedGraphic-2.pdf
Description: Adobe PDF document


I abandoned transparency, since I actually don’t want to see through anything. 
I am using uncolored to get the fade. It works great with a picture that is 
made with fill and draw, but it doesn’t work with shading. The example below 
has a flat disk and a round ball. The disk looks fine, but the shaded ball is 
not surviving the application of inverted / uncolored.


\startMPinclusions
  picture disk, ball;
  disk := image(
fill fullcircle scaled 1cm withcolor .4white;
draw fullcircle scaled 1cm withpen pencircle scaled 0.8pt ;);
  ball := image(
fill fullcircle scaled 1cm
  withshademethod "circular"
  withshadecenter (.25,.25)
  withshadecolors (.8white, black);
draw fullcircle scaled 1cm withpen pencircle scaled 0.8pt ;);
\stopMPinclusions

\startMPpage
   draw inverted (disk uncolored .1white) ;
   draw inverted (disk uncolored .2white) shifted (0.25cm,0) ;
   draw inverted (disk uncolored .5white) shifted (1cm,0) ;
   draw disk shifted (2.25cm,0) ;

   draw inverted (ball uncolored .1white) shifted (0, -2cm) ;
   draw inverted (ball uncolored .2white) shifted (0.25cm, -2cm) ;
   draw inverted (ball uncolored .5white) shifted (1cm, -2cm) ;
   draw ball shifted (2.25cm, -2cm) ;
\stopMPpage



Gracht.pdf
Description: Adobe PDF document


Same result in LMTX and MkIV. (ConTeXt  ver: 2021.09.17 10:01 LMTX  fmt: 
2021.9.21  int: english/english)

I’m pretty happy with this uncolored trick, and will be even happier if I can 
get it to work with the shadings.

Any suggestions?

Gavin___
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] ConTeXt's equivalent of raisebox

2021-10-10 Thread Wolfgang Schuster via ntg-context

noib3 via ntg-context schrieb am 11.10.2021 um 00:16:
How can I make vertical microadjustments to individual characters in 
ConTeXt?


In LaTeX I would do it with

```
\documentclass{article}
\begin{document}
\raisebox{-1pt}{f}oo
\end{document}
```

however the following doesn't work

```
\starttext
\raisebox{-1pt}{f}oo
\stoptext
```


The \raisebox command expects a box for the second argument. A better 
solution is to use the \offset command but in both cases you need 
\dontleavehmode at the start of a paragraph.


 begin example
\starttext

\dontleavehmode\raisebox{1pt}\hbox{f}oo

\dontleavehmode\offset[y=-1pt]{f}oo

\stoptext
 end example

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] ConTeXt's equivalent of raisebox

2021-10-10 Thread noib3 via ntg-context
How can I make vertical microadjustments to individual characters in
ConTeXt?

In LaTeX I would do it with

```
\documentclass{article}
\begin{document}
\raisebox{-1pt}{f}oo
\end{document}
```

however the following doesn't work

```
\starttext
\raisebox{-1pt}{f}oo
\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] SyncTeX does not work with Zathura

2021-10-10 Thread Hans Hagen via ntg-context

On 10/10/2021 7:20 PM, Cezary Drożak wrote:

 > you can play with
 >
 > mtxrun --script synctex
 >
 > and the synctex file to see if it makes sense
I wrote two almost identical files in plain tex and context. When I 
generated the synctex file and ran `mtxrun --script synctex --list 
x.synctex` I got this:


```
$ mtxrun --script synctex --list context.synctex
mtx-synctex | begin page: 1
mtx-synctex | end page: 1

$ mtxrun --script synctex --list tex.synctex
mtx-synctex | begin page: 1
mtx-synctex |   [  72   82   92   82] : 1 : 
/home/nawordar/tests/tex/hello/./tex.tex

mtx-synctex | end page: 1
```

It looks like context generates an incomplete synctext file.


I can't say ... what is missing? Can you figure out what makes Zathura 
unhappy?


The context synctex files are definitely less verbose because (1) we 
avoid clutter, (2) omit auto-generated content like pagenumbers and so, 
(3) collapse ranges (which we can do because we know what we're dealing 
with), (4) don't compress (because it makes no sense), (5) ignore 
styles, (6) also handle xml, etc. There have been some changes between 
synctex 1 and 2 but I don['t keep track of that. Actually, if a 'call 
some command' approach would have been chosen we could have better 
readable files (in our case lua or so).


 > one problem with synctex is that the editors depend on a library and 
there has been changes

 >
 > texshop now uses the more independent method for context i.e. just 
calling "mtxrun --script synctex ..." which not only removes the 
dependency of a library (the dependency on mtxrun is ok as one has 
context anyway) but also permits room for improvement (apart from not 
being tricked by latex specific heuristics in the library)


But that would need a change in Zathura wouldn't it?


sure, so unlikely to happen soon (i have no influence on that)

(but it would have been a better approach anyway, not being dependent on 
libraries that that depend on specific synctex versions in tex as well 
as heuristics; basically now one needs a version of the editor/viewer 
that matches a tex engine); one doesn't hard code a pdf viewer in an 
editor either (btw, the script approach permits two way sync, so in 
texshop one can go from pdf to source and source to pdf)


here with

\starttext
Hello, world!
\stoptext

i get

SyncTeX Version:1
Input:1:oeps.tex
Output:pdf
Magnification:1000
Unit:1
X Offset:0
Y Offset:0
Content:
!103
{1
[0,0:0,0:0,0,0
v0,0:0,55380990:39158276,55380990,0
h1,6:4661756,9176901:4275840,655360,327680
]
!104
}1
!8
Postamble:
Count:3
!22
Post scriptum:

(also with context --synctex oeps)

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] SyncTeX does not work with Zathura

2021-10-10 Thread Cezary Drożak via ntg-context

> you can play with
>
> mtxrun --script synctex
>
> and the synctex file to see if it makes sense
I wrote two almost identical files in plain tex and context. When I 
generated the synctex file and ran `mtxrun --script synctex --list 
x.synctex` I got this:


```
$ mtxrun --script synctex --list context.synctex
mtx-synctex | begin page: 1
mtx-synctex | end page: 1

$ mtxrun --script synctex --list tex.synctex
mtx-synctex | begin page: 1
mtx-synctex |   [  72   82   92   82] : 1 : 
/home/nawordar/tests/tex/hello/./tex.tex

mtx-synctex | end page: 1
```

It looks like context generates an incomplete synctext file.

> one problem with synctex is that the editors depend on a library and 
there has been changes

>
> texshop now uses the more independent method for context i.e. just 
calling "mtxrun --script synctex ..." which not only removes the dependency 
of a library (the dependency on mtxrun is ok as one has context anyway) but 
also permits room for improvement (apart from not being tricked by latex 
specific heuristics in the library)


But that would need a change in Zathura wouldn't it?
___
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] SyncTeX does not work with Zathura

2021-10-10 Thread Hans Hagen via ntg-context

On 10/10/2021 6:11 PM, Cezary Drożak via ntg-context wrote:

Hello,
I have been trying to get SyncTeX to work with ConTeXt and Zathura, but 
nothing

seems to work.

I created a simple `hello.mklx` file and ran `context --synctex=-1 
hello.mklx`.
Then I launched Zathura with `zathura -x "nvr -cc \"call 
vimtex#view#reverse_goto(%{line}, '%{input}')\" --nostart" hello.pdf`.

When I clicked "Hello, world!" while holding a control key it printed the
following error to console:

```
(org.pwmt.zathura:80241): GLib-CRITICAL **: 15:49:12.359: 
g_variant_new_string: assertion 'string != NULL' failed

warning: Failed to obtain data via SyncTeX or data is incomplete.
```

I am attaching the `hello.mklx`, `hello.pdf` files and the generated 
`hello.synctex` file. I am getting the same result with `--synctex=1`.

you can play with

mtxrun --script synctex

and the synctex file to see if it makes sense

one problem with synctex is that the editors depend on a library and 
there has been changes


texshop now uses the more independent method for context i.e. just 
calling "mtxrun --script synctex ..." which not only removes the 
dependency of a library (the dependency on mtxrun is ok as one has 
context anyway) but also permits room for improvement (apart from not 
being tricked by latex specific heuristics in the library)


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] Acrobat doesn’t read imported metadata

2021-10-10 Thread Hans Hagen via ntg-context

On 10/10/2021 5:46 PM, Pablo Rodriguez via ntg-context wrote:

Dear list,

I have the following sample:

   \starttext
   \startluacode
   function document.transfer_metadata(name)
 local main_doc = lpdf.epdf.load(name)
 lpdf.addtoinfo("Title", lpdf.unicode(main_doc.Info.Title),
   lpdf.string(main_doc.Info.Title))
 lpdf.addtoinfo("CreationDate",
   lpdf.string(main_doc.Info.CreationDate))
 lpdf.addtoinfo("ModDate", lpdf.string(main_doc.Info.ModDate),
   main_doc.Info.ModDate)
 lpdf.epdf.unload(name)
   end
   \stopluacode
   \unexpanded\def\TransferMetadata#1%
 {\ctxlua{document.transfer_metadata("#1")}}
   \startTEXpage[offset=1em, align=center]
   \ssbf metadatos\\importados
   \TransferMetadata{metadata.pdf}
   \stopTEXpage
   \stoptext

Being the sample file https://pdf.ousia.tk/metadata.pdf, Acrobat cannot
display the imported title or either the creation or modification dates.

What am I missing to make Acrobat display the imported metadata?

timing, so best use the official methods:

  function document.transfer_metadata(name)
local main_doc = lpdf.epdf.load(name)
context.setupinteraction { title = main_doc.Info.Title }
lpdf.epdf.unload(name)
  end

acrobat looks at the metadata blob

-
  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
___


[NTG-context] undefined command in current latest

2021-10-10 Thread Pablo Rodriguez via ntg-context
Dear list,

I have the following sample:

  \setupheadertexts[{\getmarking[chapter]}]
  \starttext
  \chapter{Chapter}
  \stoptext

It compiles perfectly fine with MkIV from 2021.10.08 20:18, but its LMTX
version triggers the following error message:

  Undefined control sequence \??markingfilter

Previous LMTX version compiled just fine.

I think it might be a bug.

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
___


[NTG-context] SyncTeX does not work with Zathura

2021-10-10 Thread Cezary Drożak via ntg-context

Hello,
I have been trying to get SyncTeX to work with ConTeXt and Zathura, but 
nothing

seems to work.

I created a simple `hello.mklx` file and ran `context --synctex=-1 
hello.mklx`.
Then I launched Zathura with `zathura -x "nvr -cc \"call 
vimtex#view#reverse_goto(%{line}, '%{input}')\" --nostart" hello.pdf`.

When I clicked "Hello, world!" while holding a control key it printed the
following error to console:

```
(org.pwmt.zathura:80241): GLib-CRITICAL **: 15:49:12.359: 
g_variant_new_string: assertion 'string != NULL' failed

warning: Failed to obtain data via SyncTeX or data is incomplete.
```

I am attaching the `hello.mklx`, `hello.pdf` files and the generated 
`hello.synctex` file. I am getting the same result with `--synctex=1`.


Regards,
Cezary Drożak

hello.pdf
Description: Adobe PDF document
SyncTeX Version:1
Output:pdf
Magnification:1000
Unit:1
X Offset:0
Y Offset:0
Content:
!86
{1
[0,0:0,0:0,0,0
v0,0:0,55380990:39158276,55380990,0
]
!60
}1
!7
Postamble:
Count:2
!22
Post scriptum:
\starttext
Hello, world!
\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
___


[NTG-context] Making metafun pictures fainter

2021-10-10 Thread Gavin via ntg-context
Hi list,

I’m trying to produce figures like this, showing motion as a series of 
snap-shots, with the earlier moments more faint.



PastedGraphic-1.pdf
Description: Adobe PDF document


Here are three examples of metafun code using transparency and “decorated".


\startMPinclusions
picture ball;
ball := image(
draw fullcircle scaled 1cm
withshademethod "circular"
withshadecenter (.25,.25)
withcolor "lightgray" shadedinto black;
draw fullcircle scaled 1cm withpen pencircle scaled 0.8pt;);
\stopMPinclusions

\starttext

\startMPpage
draw decorated (draw ball) withtransparency (1,.2);
draw decorated (draw ball shifted (1cm, 0cm)) withtransparency (1,.4);
draw decorated (draw ball shifted (4cm, 0cm)) withtransparency (1,.6);
draw ball shifted (9cm, 0cm);
\stopMPpage

\startMPpage
draw decorated (draw ball) withtransparency (1,.2);
draw decorated (draw ball shifted (0.25cm, 0cm)) withtransparency (1,.4);
draw decorated (draw ball shifted (1cm, 0cm)) withtransparency (1,.6);
draw ball shifted (2.25cm, 0cm);
\stopMPpage

\startMPpage
draw decorated (draw ball) withtransparency (1,.2);
filldraw fullcircle scaled 1cm withcolor white withpen pencircle scaled 0.8pt 
shifted (0.25cm, 0cm);
draw decorated (draw ball shifted (0.25cm, 0cm)) withtransparency (1,.4);
filldraw fullcircle scaled 1cm withcolor white withpen pencircle scaled 0.8pt 
shifted (1cm, 0cm);
draw decorated (draw ball shifted (1cm, 0cm)) withtransparency (1,.6);
draw ball shifted (2.25cm, 0cm);
\stopMPpage

\stoptext


Transparency alone does a good job if the objects don’t overlap (first 
example). If they do overlap, it’s kind of a mess (second example). I get a 
much better result if I put a white circle behind each transparent ball so that 
they look lighter without showing the earlier objects through  them (third 
example). However, that solution is going to be difficult for more complex 
shapes. I tried drawing the shape using “redecorated () withcolor white", to 
draw the white background object, but only the outline appears white. The 
circular shading disappears altogether, leaving the ball fill area transparent.

I also tried to use something like “softened .8” but could not get that to 
produce any output.

Any ideas?

Thanks!
Gavin___
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] Acrobat doesn’t read imported metadata

2021-10-10 Thread Pablo Rodriguez via ntg-context
Dear list,

I have the following sample:

  \starttext
  \startluacode
  function document.transfer_metadata(name)
local main_doc = lpdf.epdf.load(name)
lpdf.addtoinfo("Title", lpdf.unicode(main_doc.Info.Title),
  lpdf.string(main_doc.Info.Title))
lpdf.addtoinfo("CreationDate",
  lpdf.string(main_doc.Info.CreationDate))
lpdf.addtoinfo("ModDate", lpdf.string(main_doc.Info.ModDate),
  main_doc.Info.ModDate)
lpdf.epdf.unload(name)
  end
  \stopluacode
  \unexpanded\def\TransferMetadata#1%
{\ctxlua{document.transfer_metadata("#1")}}
  \startTEXpage[offset=1em, align=center]
  \ssbf metadatos\\importados
  \TransferMetadata{metadata.pdf}
  \stopTEXpage
  \stoptext

Being the sample file https://pdf.ousia.tk/metadata.pdf, Acrobat cannot
display the imported title or either the creation or modification dates.

What am I missing to make Acrobat display the imported metadata?

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] Default values for key-value macros

2021-10-10 Thread Hans Hagen via ntg-context

On 10/10/2021 2:01 PM, noib3 via ntg-context wrote:
The way I've been defining key-value macros is to first pass them to 
Lua, handle the parsing there thanks to 
`utilities.parsers.settings_to_hash` and then assign the resulting Lua 
table to ConTeXt variables.


This worked fine up to now, but I'm having problems with the following MWE:

```
\def\style#1[#2] {
   \ctxlua{userdata.style([==[#2]==])}
   \placestyle
}


here you overload a core macro


\startluacode
   userdata = userdata or {}

   userdata.style = function(keyvals)
     local style = {
       color = nil,
       text = nil,
     }
     args = utilities.parsers.settings_to_hash(keyvals)


use "local args" here ^


     for k, v in pairs(args) do
       style[k] = v
     end
     context.setvariables({'style'}, style)
   end
\stopluacode

\define\placestyle{
   \doiftext
     {\getvariable{style}{text}}
     {\color[\getvariable{style}{color}]{\getvariable{style}{text}}}
}

\starttext

\style[
   text={Some red text},
   color=red,
]

\style[
   color=blue,
]

\stoptext
```

Here I assign a default value of `nil` to every key, and then check if 
the `text` variable is empty before printing it. I would expect the 
second macro not to print anything since its `text` should be nil, 
instead both macros print 'Some red text', the first one in red and the 
second one in blue.


context.setvariables

like any setting, it accumulates unless you group


I have attached a screenshot of the output.

What am I doing wrong?


local style = {
  color = "",
  text  = "",
}

or you can go fancy with:

\startluacode
interfaces.implement {
name  = "MyStyle",
public= true,
protected = true,
arguments = "hash",
actions   = function(a)
if a.text and a.text ~= ""  then
if a.color and a.color ~= "" then
context.color( { a.color }, a.text)
else
context(a.text)
end
end
end
}
\stopluacode

\MyStyle[
  text={Some blue text},
  color=blue,
]

\MyStyle[
  color=blue,
]

\MyStyle[
  text={test \em test},
]



-
  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] Converting LaTeX math to ConTeXt

2021-10-10 Thread Jason Ross via ntg-context

On 10/10/21 3:23 AM, Hans Hagen wrote:


what do you mean with 'quite different'

Hans


Hi Hans,

My current stumbling block is dealing with the `align` environment.
I replace `\begin{align}/\end{align}` with
`\startmathalignment/\stopmathalignment`, and replace all `&` characters
with `\NC` and `\\` with `\NR`, which is simple enough.
However, the two commands work differently - `align` doesn't care
how many columns you have, but `mathalignment` does. This makes dealing
with aligned equations containing matrices hard - you can't just count
how many `&`s you see before you get to a `\\`, because you might be
inside of a matrix in which case they don't count.

Also, `mathalignment` and `matrix` want a leading `\NC` to start each
column, while LaTeX `align` and `matrix` just want `&` as a column
separator.

These are just a couple examples, but in general it's not enough to do
naive string substitution in LaTeX and get valid ConTeXt back, and my
patchwork solutions are starting to smell.

Thanks,

Jason
___
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] Unusual error with \doifinstring in \startbtxrenderingdefinitions ... \stopbtxrenderingdefinitions

2021-10-10 Thread Joey McCollum via ntg-context
Thanks for these replies! Adding \unexpanded or \protected before \def
didn't fix the problem, and surrounding the definition with \unprotect ...
\protect didn't work either. But surrounding it with \pushcatcodetable
\setcatcodetable\ctxcatcodes ... \popcatcodetable worked.

I've never seen these commands before, but I gather from the existing
documentation that the current catcode governs which characters are treated
as special when a buffer is being processed. So here, it looks like I'm
temporarily switching from some other catcode set (it looks like in
publ-ini.mkiv, \catcode\commentasciicode\othercatcode gets invoked
in \publ_set_publication, so perhaps that's what's happening?) to the
default ConTeXt catcodes and then back.

Thanks again!

Joey

On Sun, Oct 10, 2021 at 6:40 AM Wolfgang Schuster <
wolfgang.schuster.li...@gmail.com> wrote:

> Joey McCollum via ntg-context schrieb am 10.10.2021 um 05:42:
>
> The test using \removepunctuation that you provided does what it should be
> doing (it produces 6 instances of "test-test" with the intervening
> punctuation mark in each case removed), but it doesn't do what I'm trying
> to do in the MWE above. I'm trying to take certain punctuation marks that
> follow the \autopuncttest macro and place them before it instead. Looking
> at the typo-chr .lua and .mkiv files, I see that there are \pushpunctuation
> and \poppunctuation methods in addition to the \removepunctuation method.
> These might be useful for this purpose, but in any case, I still have to
> check if the trailing character is one of the characters in a specified
> set/string, and this is where the error is arising.
>
>
> Add \protected (or \unexpanded) to your command definition.
>
> \startbtxrenderingdefinitions[myspec]
> \protected\def\autopuncttest#1#2%
>   {\removeunwantedspaces%
>\doifinstring{#2}{,.!?;:}{#2}%
>\footnote{#1}%
>\doifnotinstring{#2}{,.!?;:}{#2}}
> \stopbtxrenderingdefinitions
>
> 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] Default values for key-value macros

2021-10-10 Thread noib3 via ntg-context
The way I've been defining key-value macros is to first pass them to Lua,
handle the parsing there thanks to `utilities.parsers.settings_to_hash` and
then assign the resulting Lua table to ConTeXt variables.

This worked fine up to now, but I'm having problems with the following MWE:

```
\def\style#1[#2] {
  \ctxlua{userdata.style([==[#2]==])}
  \placestyle
}

\startluacode
  userdata = userdata or {}

  userdata.style = function(keyvals)
local style = {
  color = nil,
  text = nil,
}
args = utilities.parsers.settings_to_hash(keyvals)
for k, v in pairs(args) do
  style[k] = v
end
context.setvariables({'style'}, style)
  end
\stopluacode

\define\placestyle{
  \doiftext
{\getvariable{style}{text}}
{\color[\getvariable{style}{color}]{\getvariable{style}{text}}}
}

\starttext

\style[
  text={Some red text},
  color=red,
]

\style[
  color=blue,
]

\stoptext
```

Here I assign a default value of `nil` to every key, and then check if the
`text` variable is empty before printing it. I would expect the second
macro not to print anything since its `text` should be nil, instead both
macros print 'Some red text', the first one in red and the second one in
blue.

I have attached a screenshot of the output.

What am I doing wrong?
___
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] SciTE configuration Mac

2021-10-10 Thread Hans Hagen via ntg-context

On 10/8/2021 6:39 PM, MANUEL GONZALEZ SUAREZ via ntg-context wrote:

Hi everyone:
Could someone send me a minimal configuration for the SciTE editor of 
the files needed to work with ConTeXt? I work with MaC OS Big Sur.
There are some scite related files in the distribution that you can look 
at (context/data/scite). In principle the built-in lexers (called 
internal there) should work with context (using the keyword lists). The 
external lexers depend on the scintillua dll/so and the latest updats 
drops that (for various reasons) and I now use the OnStyle lua feature 
of scite. However, it still do't work out of the box because they assume 
lpeg to be built in. On my machine I have a version with a few lines 
patch that does that and this is what I'm currently testing with (i can 
put a scite.zip somewhere if needed but that won't help you on osx; if 
lpeg ever makes it into stock scite it should work there too).


You can try to copy the files that ships with context in the scite home 
path and add


import context/scite-context-user

to the global properties files and see what happens

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] Unusual error with \doifinstring in \startbtxrenderingdefinitions ... \stopbtxrenderingdefinitions

2021-10-10 Thread Wolfgang Schuster via ntg-context

Joey McCollum via ntg-context schrieb am 10.10.2021 um 05:42:
The test using \removepunctuation that you provided does what it 
should be doing (it produces 6 instances of "test-test" with the 
intervening punctuation mark in each case removed), but it doesn't do 
what I'm trying to do in the MWE above. I'm trying to take certain 
punctuation marks that follow the \autopuncttest macro and place them 
before it instead. Looking at the typo-chr .lua and .mkiv files, I see 
that there are \pushpunctuation and \poppunctuationmethods in addition 
to the \removepunctuation method. These might be useful for this 
purpose, but in any case, I still have to check if the trailing 
character is one of the characters in a specified set/string, and this 
is where the error is arising.


Add \protected (or \unexpanded) to your command definition.

\startbtxrenderingdefinitions[myspec]
\protected\def\autopuncttest#1#2%
  {\removeunwantedspaces%
   \doifinstring{#2}{,.!?;:}{#2}%
   \footnote{#1}%
   \doifnotinstring{#2}{,.!?;:}{#2}}
\stopbtxrenderingdefinitions

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] Unusual error with \doifinstring in \startbtxrenderingdefinitions ... \stopbtxrenderingdefinitions

2021-10-10 Thread Hans Hagen via ntg-context

On 10/10/2021 5:42 AM, Joey McCollum wrote:
The test using \removepunctuation that you provided does what it should 
be doing (it produces 6 instances of "test-test" with the intervening 
punctuation mark in each case removed), but it doesn't do what I'm 
trying to do in the MWE above. I'm trying to take certain punctuation 
marks that follow the \autopuncttest macro and place them before it 
instead. Looking at the typo-chr .lua and .mkiv files, I see that there 
are \pushpunctuation and \poppunctuationmethods in addition to the 
\removepunctuation method. These might be useful for this purpose, but 
in any case, I still have to check if the trailing character is one of 
the characters in a specified set/string, and this is where the error is 
arising.


maybe you're in protected mode

% assumes \protect earlier

\unprotect
\def\autopuncttest#1#2{%
  \removeunwantedspaces%
  \doifinstring{#2}{,.!?;:}{#2}%
  \footnote{#1}%
  \doifnotinstring{#2}{,.!?;:}{#2}%
}
\protect

% assumes \unprotect later

or something

\pushcatcodetable \setcatcodetable\ctxcatcodes

\def\autopuncttest#1#2{%
  \removeunwantedspaces%
  \doifinstring{#2}{,.!?;:}{#2}%
  \footnote{#1}%
  \doifnotinstring{#2}{,.!?;:}{#2}%
}

\popcatcodetable


Joey

On Sat, Oct 9, 2021 at 12:50 PM Hans Hagen > wrote:


On 10/9/2021 5:40 PM, Joey McCollum via ntg-context wrote:
 > Hi,
 >
 > I'm trying to define concise biblatex-style citation macros for a
custom
 > bibliographic style specification with support for intelligent
placement
 > of trailing punctuation, and I've encountered an unusual error.
If I try
 > to define the macros within the btxrenderingdefinitions environment,
 > then the code for handling trailing punctuation with the
 > \doifinstring and \doifnotinstring macros fails in some cases.
 > Specifically, it correctly detects when the trailing punctuation
is a
 > period, comma, or semicolon, but not when it is a colon, exclamation
 > point, or question mark. The following MWE reproduces the error:
 >
 > ```
\starttext

test,\removepunctuation -test
test;\removepunctuation -test
test:\removepunctuation -test
test?\removepunctuation -test
test!\removepunctuation -test
test.\removepunctuation -test

\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

-




--

-
  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] Undefined control sequence \??markingfilter, with MWE to recreate

2021-10-10 Thread Hans Hagen via ntg-context

On 10/9/2021 9:53 PM, Rik Kabel via ntg-context wrote:

Error with 20211008 ConTeXt:
%\setupheadertexts [][][{\it\getmarking[chapter]}][]  % fails
\setupheadertexts [][][{\getmarking[chapter]}][] % fails
%\setupheadertexts [][][\getmarking[chapter]][]   % succeeds

\starttext

\chapter{abc}
abc
\chapter{def}
def
\stoptext
no failure here, but actually the last one should fail (dummy page) due 
to nested []


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] Converting LaTeX math to ConTeXt

2021-10-10 Thread Hans Hagen via ntg-context

On 10/10/2021 5:45 AM, Jason Ross via ntg-context wrote:

Hello,

I'm trying to provide more support for LaTeX math for an Org Mode
exporter for ConTeXt. LaTeX is the de facto standard for mathematics in
Org Mode. However, the syntax is quite different between LaTeX and
ConTeXt. I have a few ideas, but none that I'm happy about.

1. Export LaTeX to MathML then import that into ConTeXt. I don't know
    how to get this to work. latexmlmath only returns the first row of
    `align` environments (for me anyway). Also, this would require users
    to install another program.
2. Typeset equations with LaTeX as standalone pages and then include
    them as images. This will typeset everything with LaTeX defaults.
    Also, either equation alignment or equation numbering will break.
3. Hack every math environment I can think of to accept LaTeX syntax
    (see https://wiki.contextgarden.net/LaTeX_Math_in_ConTeXt). Lots
    of work, lots of problems as described in the article. End-users
    could add their own hacks to the template preamble for cases I
    don't get to.
4. Manually parse and convert every LaTeX math environment to ConTeXt
    before exporting. Basically a non-starter.

I'm wondering what's the best way to go about this. Surely others have
run into the same problem?

what do you mean with 'quite different'

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] Does the ConTeXt distro come with a PDFViewer?

2021-10-10 Thread Ramkumar KB via ntg-context
All,

Thanks for the tips. SumatraPDF worked well as it updates as the underlying
PDF is refreshed by ConTeXt - which makes the dev-preview cycle really
quick.

I will compile all the tips in this thread into the Wiki.

best regards,
Ramkumar

On Sun, Oct 10, 2021 at 12:53 AM Henri Menke via ntg-context <
ntg-context@ntg.nl> wrote:

> On Sat, 2021-10-09 at 18:47 +0200, Hans Hagen via ntg-context wrote:
> > On 10/9/2021 3:07 PM, Ramkumar KB via ntg-context wrote:
> > > Hello Community,
> > >
> > > If my memory serves me correctly, I might have noticed (in one of the
> > > presentations during the recent ConTeXt meeting) that the distro
> > > comes
> > > with a PDFViewer. Is that a correct assumption?
> > >
> > > I am currently using a VSCode extension for PDFViewing but it does
> > > not
> > > work very reliably.
> > just use an external one, normally it will update automatically (on
> > windows sumatrapdf is pretty ok, on linux i'd probably use okular
> > because mupdf has no real gui)
>
> I know of two muPDF GUIs:
>
> - llpp https://github.com/moosotc/llpp
> - zathura https://pwmt.org/projects/zathura/
>
> Both are fairly minimalistic, but if you only want to display pages
> they do the job. Zathura also supports synctex.
>
> >
> > 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
> > ___
> > 
>
>
>
> ___
> 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 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
___