[NTG-context] externalfigure regression?

2023-12-03 Thread Thangalin
Hi,

>From the wiki :

"When the file extension is .auto or method=auto is used, ConTeXt reads the
first few bytes of the file to determine the filetype. Such an
auto-discovery is useful for remote images that do not have a file
extension."

current version: 2023.09.26 18:19

Code:

% SOT
\starttext
  \startplacefigure
\externalfigure[https://placekitten.com/408/287][method=auto]
  \stopplacefigure
\stoptext
% EOT

Expected: Cute kitten photo.
Actual: Error.

Is this a regression? Or has the syntax changed (stale wiki)?

Specifying the type works (I'd've thought it not necessary to specify the
method at all, given both magic headers and HTTP content-type could
determine the type):

% SOT
\starttext
  \startplacefigure
\externalfigure[https://placekitten.com/408/287][method=jpg]
  \stopplacefigure
\stoptext
% EOT

See also:

https://gitlab.com/DaveJarvis/KeenWrite/-/blob/main/src/main/java/com/keenwrite/io/MediaTypeSniffer.java#L53

https://gitlab.com/DaveJarvis/KeenWrite/-/blob/main/src/main/java/com/keenwrite/io/MediaType.java#L218
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Converting XHTML captions to ConTeXt captions

2023-11-26 Thread Thangalin
I'd like to capture a caption and apply it to the block-level element that
immediately follows. In the MWE, is there a more "ConTeXt way" to
accomplish the task of adding captions to tables, figures, blockquotes, etc?

% SOT
\startbuffer[demo]

Caption 1 
table 1 with caption
table 2 without caption
Caption 3 
table 3 with caption

\stopbuffer

\startxmlsetups xml:demo
  \xmlsetsetup{\xmldocument}{*}{-}
  \xmlsetsetup{\xmldocument}{a|p|body|table}{xml:*}
  \xmlsetsetup{\xmldocument}{span[@class='caption']}{xml:span}

  \define\CaptionText{}
  \define\AnchorXref{}
\stopxmlsetups

\startxmlsetups xml:span
  \define\CaptionText{\xmlflush{#1}}
\stopxmlsetups

\startxmlsetups xml:a
  \define\AnchorXref{\xmlatt{#1}{data-type}-\xmlatt{#1}{name}}
\stopxmlsetups

\startxmlsetups xml:body \xmlflush{#1} \stopxmlsetups
\startxmlsetups xml:p \xmlflush{#1}\par \stopxmlsetups
\startxmlsetups xml:table
  \blank
  \doifelsetext{\CaptionText}{%
\startplacetable[
  title={\ignorespaces\CaptionText{}\removeunwantedspaces.},
  reference={\AnchorXref}
]

\define\CaptionText{}
\define\AnchorXref{}
  }{
\startplacetable
  }

\startembeddedxtable
  \startxtablebody[body]
\startxrow
  \startxcell
\xmlflush{#1}
  \stopxcell
\stopxrow
  \stopxtablebody
\stopembeddedxtable
  \stopplacetable
  \blank
\stopxmlsetups

\xmlregistersetup{xml:demo}

\starttext
  \xmlprocessbuffer{demo}{demo}{}
\stoptext
% EOT
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Markdown to HTML cross-references

2023-11-21 Thread Thangalin
Hi list,

I'm looking to implement a consistent syntax for cross-references in
KeenWrite  and am wondering what you think would
make the most sense for translating into ConTeXt commands.

First, some background (the first two give an overview, the others are
cross-reference references for various syntaxes):

   - https://talk.commonmark.org/t/cross-references-and-citations/4013/7
   - https://thesynack.com/posts/markdown-captions
   - https://quarto.org/docs/authoring/cross-references.html
   - https://mystmd.org/guide/cross-references
   - https://lierdakil.github.io/pandoc-crossref
   - https://github.com/tomduck/pandoc-eqnos

I'm leaning towards the following syntax:

Markdown Item (table, blockquote, TeX block, figure, code, R chunk, etc.)

: caption text {#type:label}

See [@type:label] for details.

There's a unit test that shows what's currently being generated with a
number of examples for images, tables, blockquotes, internationalization,
and so on:

https://gitlab.com/DaveJarvis/KeenWrite/-/blob/main/src/test/java/com/keenwrite/processors/markdown/extensions/references/CrossReferencesExtensionTest.java#L51

The code is a work-in-progress; so the tests may have changed depending on
if/when you view the Java source code. Presently, the captions produce
anchor references, mostly. The following seems easier to typeset using
ConTeXt:

Meschiya Lake - Lucky Devil 

This diverges from the HTML specification for tables (table/caption) and
figures (figure/figcaption). It would also mean having to write ConTeXt
macros that flip the spans and anchors to produce a caption such as:

*Lyrics 1.1.* Meschiya Lake - Lucky Devil

While there are plenty of ways of presenting captions (e.g., multi-column
images with sub-figure numbers) the majority of cross-references are to a
single "thing" with a single "caption".

What are your thoughts on this proposal? (Keeping in mind I'm the only
person working on KeenWrite and while I'm trying to keep the syntax
compatible with pandoc, implementing the full pandoc-crossref syntax is out
of scope for me.

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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: Pass string into text background graphic

2023-08-13 Thread Thangalin
Hi again,

you could remove the \localcontrolled around the advance
>

I thought I tried that, but the counter incremented to 6, instead of 4.
Using higher-level primitives seems more like the ConTeXt way.


> why twice ? you only have to typeset the text once, right?
> >
> {text:\number\numexpr1+\rawcountervalue[ConcurrentTextGetCounter]/2\relax}}
>

I don't know why the counter is incremented twice for each concurrent
environment; the document is typeset once, in three passes. Dividing by two
solves the issue, if there's a deeper issue, I'm at a loss to explain it.

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___

[NTG-context] Re: Pass string into text background graphic

2023-08-12 Thread Thangalin
Thanks Hans.

The \newinteger approach would always increment the value, regardless of
conditionals within the MetaPost code (i.e., it was like legend :=
"\ConcurrentTextGet" would always invoke the macro just be referencing the
MPgraphic and nothing would prevent its execution). This meant that the Get
indexes would not correspond to the Set indexes. Switching to \definenumber
resolved the issue. There were a few other oddities, such as the "Get"
counter incrementing twice. Here's the code:

\definenumber[ConcurrentTextSetCounter][prefix=no]
\definenumber[ConcurrentTextGetCounter][prefix=no]

\setnumber[ConcurrentTextSetCounter][0]
\setnumber[ConcurrentTextGetCounter][0]

% Map each label as global key/value pairs.
\def\ConcurrentTextSet#1{%
  \incrementnumber[ConcurrentTextSetCounter]%
  \setxvariable
{concurrent}
{text:\rawcountervalue[ConcurrentTextSetCounter]}
{#1}}

% Account for the counter incrementing twice and the index being 1-based.
\def\ConcurrentTextGet{%
  \incrementnumber[ConcurrentTextGetCounter]%
  \getvariable
{concurrent}

{text:\number\numexpr1+\rawcountervalue[ConcurrentTextGetCounter]/2\relax}}

\startuseMPgraphic{GraphicConcurrent}
  numeric index;
  index := 1;

  % Differentiate between new text blocks and those crossing pages.
  if (multikind[ index ] = "single") or (multikind[ index ] = "first"):
string legend;
legend := "\ConcurrentTextGet";

% For new text blocks, write the title.
picture p;
p := textext.rt( legend )
  shifted ulcorner multipars[ index ]
  shifted (1cm, 0);

% Draw the horizontal rule only for the initial text block.
draw
  ulcorner multipars[ index ] shifted (1mm + xpart lrcorner p, 0) --
  urcorner multipars[ index ];

% Draw the vertical rule for the initial text block.
draw
  llcorner multipars[ index ] --
  ulcorner multipars[ index ] --
  ulcorner multipars[ index ] shifted (9mm, 0);

draw p;
  else:
% Draw only the vertical rule only when crossing page boundaries.
draw
  llcorner multipars[ index ] --
  ulcorner multipars[ index ];
  fi
\stopuseMPgraphic

\definetextbackground[TextConcurrentFrame][
  mp=GraphicConcurrent,
  frame=off,
  topoffset=1em,
  leftoffset=1em,
  before=\blank[2*big],
  after=\blank,
  location=paragraph,
]

\startsetups concurrent:before
  \ConcurrentTextSet{%
% Be sure to format "a.m." and other special phrases.
\expandafter\TextReplacement{%
  \xmlatt{\getvariable{div}{concurrent}}{data-title}%
}
  }
  \startTextConcurrentFrame
\stopsetups

\startsetups concurrent:after
  \stopTextConcurrentFrame
\stopsetups

\definestartstop[concurrent][
  before=\directsetup{concurrent:before},
  after=\directsetup{concurrent:after}
]

This allows for typesetting a wider range of pandoc-style Markdown
annotations, such as:

::: {.concurrent title="Terminal Berth 5, 3:17 a.m."}
text goes here
:::

With these changes, the titles now only appear at the start of the
demarcated text, in any combination of "concurrent" annotation instances
spanning any number of pages.

Much appreciated.

Cheers!
P.S.
The following line requires KeenWrite themes:

\expandafter\TextReplacement{ ... }

For details, see:

   -
   https://github.com/DaveJarvis/keenwrite-themes/blob/main/xhtml/xml-blocks.tex
   -
   https://github.com/DaveJarvis/keenwrite-themes/blob/main/boschet/replace.tex


concurrent.pdf
Description: Adobe PDF document
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___

[NTG-context] Pass string into text background graphic

2023-08-11 Thread Thangalin
Hi list,

I'm attempting to make a stylized border around paragraphs that can span
pages. The border runs along the side and the top. (Ideally the top border
wouldn't repeat, but that's a minor issue.) The issue I'm having is that
the title for the text doesn't always appear. Instead, there's a small gap
along the top border where the title should be.

Am I going about this the wrong way?

% SOT
\startbuffer[demo]



Text Goes Here


Different Text Goes Here


\stopbuffer
\startxmlsetups xml:xhtml
  \xmlsetsetup{\xmldocument}{*}{-}
  \xmlsetsetup{\xmldocument}{html|body}{xml:*}
  \xmlsetsetup{\xmldocument}{div}{xml:*}\stopxmlsetups
\xmlregistersetup{xml:xhtml}
\startxmlsetups xml:html
  \xmlflush{#1}\stopxmlsetups
\startxmlsetups xml:body
  \xmlflush{#1}\stopxmlsetups
\startxmlsetups xml:div
  \setvariable{div}{\xmlatt{#1}{class}}{#1}
  \start[\xmlatt{#1}{class}]\xmlflush{#1}\stop\stopxmlsetups
\startusableMPgraphic{GraphicConcurrent}
  begingroup;
string legend;

picture title;
picture border;
picture bg;

numeric tw;
numeric th;

legend := \MPstring{concurrent};

title := nullpicture;
border := nullpicture;
bg := textext( "\strut " & legend );

tw := xpart lrcorner bg - xpart llcorner bg;
th := ypart ulcorner bg - ypart llcorner bg;

addto title also image(
  fill unitsquare
xysized (tw + 8, th)
shifted ulcorner multipars[1]
shifted 28 right
shifted 8 down
withcolor white;

  draw
textext.drt( legend )
shifted ulcorner multipars[1]
shifted 32 right
shifted 3 down;
);

addto border also image(
  for i = 1 upto nofmultipars:
draw
  llcorner multipars[i] --
  ulcorner multipars[i] shifted 8 down ..
  ulcorner multipars[i] shifted 8 right --
  urcorner multipars[i]
  withpen pencircle scaled 0.75 withcolor black;
  endfor;
);

draw image(
  draw border;
  draw title;
);
  endgroup;\stopusableMPgraphic
\definetextbackground[TextConcurrentFrame][
  mp=GraphicConcurrent,
  frame=off,
  topoffset=1em,
  leftoffset=1em,
  location=paragraph,
]
\definestartstop[concurrent][
  before={%
\blank[big]%
LEGEND: \xmlatt{\getvariable{div}{concurrent}}{data-title}%
\blank[big]%
\setMPtext{concurrent}{\xmlatt{\getvariable{div}{concurrent}}{data-title}}
\startTextConcurrentFrame},
  after={\stopTextConcurrentFrame\blank[big]},
]
\starttext
  \xmlprocessbuffer{main}{demo}{}\stoptext
% EOT

If I change the following line:

legend := \MPstring{concurrent};

to:

legend := "some string";

Then the title "some string" is repeated. It seems like the value for
\MPstring{concurrent} is being cached in some situations and ignored in
others.

Essentially, I'm trying to visually offset multiple paragraphs using a
left-hand vertical rule along with a top horizontal rule that has a title.
Each new "concurrent" section needs its own header that doesn't repeat.

Is there a ConTeXt-way to accomplish this feat?

Cheers!


t.pdf
Description: Adobe PDF document
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___

[NTG-context] Re: Why overbar is so big

2023-08-11 Thread Thangalin
Looks fine to me.

Current version: 2023.08.10 02:59

Running on Linux.

What fonts are you using?

On Fri, Aug 11, 2023 at 12:38 PM Xavier B.  wrote:

> If you run
>
> \starttext
>
> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
> tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
> veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
> commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
> velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
> cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
> est laborum.
> $\overbar{OA} = 4,2$
> \stoptext
>
> Then the overbar has the bar in a very long altitude.
> Can you please, see the output attached.
>
> Thanks in advance,
> Xavier
>
> PS: I use context version:mtx-context | ConTeXt Process Management 1.04
> mtx-context |
> mtx-context | main context file:
> /usr/share/texmf-dist/tex/context/base/mkiv/context.mkiv
> mtx-context | current version: 2023.03.10 12:15
> mtx-context | main context file:
> /usr/share/texmf-dist/tex/context/base/mkxl/context.mkxl
> mtx-context | current version: 2023.03.10 12:15
>
> ___
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
>
> ___


t.pdf
Description: Adobe PDF document
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___

[NTG-context] Re: upload

2023-08-11 Thread Thangalin
That works Hans, thank you.

line 802 in core-env should be:
>
> \permanent\tolerant\protected\def\setupenv
>{\syst_variables_set\getrawparameters[\s!environment]}
>
> (seems i forgot that one when doing some cleanup)
>
> 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 /
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
>
> ___
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___

[NTG-context] Re: upload

2023-08-10 Thread Thangalin
Did arguments regress in 2023.08.10 02:59?

$ cat u.tex
\starttext
Feisty arguments
\stoptext
$ context u.tex
$  ls -la *.pdf
-rw-r--r-- 1 username username 6279 Aug 10 18:28 u.pdf
$ context --arguments=x=y u.tex | grep error
tex error   > tex error on line 13 in file : Use of \getrawparameters
doesn't match its definition
mtx-context | fatal error: return code: 1

This was working with the previous release.

On Wed, Aug 9, 2023 at 8:43 AM Hans Hagen  wrote:

> Hi,
>
> I uploaded a new lmtx. There are some new features that wil be revealed
> in the future (likely after the meeting) but here is one:
>
> \starttext
>
>  \defineoverlay
>[test]
>[\color
>   [blue]
>   {TEST
>\inframed
>  [foregroundcolor=red]
>  {xxx}
>TEST}]
>
>  \framed
>[background=test,
> foregroundstyle=\switchtobodyfont[small]]
>{test}
>
> \stoptext
>
>  From now on many commands accept (properly) nested [] inside commands
> that use [] as fences (like the setup commands) where it makes sense. It
> is up to the user to decide to use {} (as before) or not but it is less
> error prone.
>
> It is now also possible to nest setups as in
>
> \starttext
>
> \startsetups one
>  \startsetups [three]
>  HERE
>  \stopsetups
> \stopsetups
>
> \startsetups two
>  \startsetups [three]
>  THERE
>  \stopsetups
> \stopsetups
>
> \setups[one] \setups[three]
>
> \setups[two] \setups[three]
>
> \stoptext
>
> As part of the ongoing improvements on math rendering we added some
> classic lm/cm kerns (between upperacse and periods / commas) in the
> goodie files.
>
> Some lowlevel manuals have been extended, explaining experimental 'named
> cross macro nesting parameter referencing' and 'constrained cq. retained
> assignments', but that is only relevant for those interested in
> overcoming some limitations in the traditional engines.
>
> 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 /
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
>
> ___
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___

[NTG-context] Re: Map XML attributes to variables, dynamically

2023-08-10 Thread Thangalin
Here's an MWE:

% SOT
\startbuffer[demo]



Text Goes Here


Different Text Goes Here



\stopbuffer

\startxmlsetups xml:xhtml
  \xmlsetsetup{\xmldocument}{*}{-}
  \xmlsetsetup{\xmldocument}{html|body}{xml:*}
  \xmlsetsetup{\xmldocument}{div}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:xhtml}

\startxmlsetups xml:html
  \xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:body
  \xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:div
  \setvariable{div}{\xmlatt{#1}{class}}{#1}
  \start[\xmlatt{#1}{class}]\xmlflush{#1}\stop
\stopxmlsetups

\definestartstop[concurrent][
  before={TITLE: \xmlatt{\getvariable {div} {concurrent} {title}}},
]

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

It doesn't look like the variables are taking, regardless of whether
{title} or {data-title} are used.

On Thu, Aug 10, 2023 at 12:44 AM Hans Hagen  wrote:

> On 8/10/2023 9:10 AM, Thangalin wrote:
>
> > Environments for the DIV element gets translated using:
> >
> > \startxmlsetups xml:div
>
> \setvariable {div} {\xmlatt{#1}{class}} {#1}
>
> >\start[\xmlatt{#1}{class}]\xmlflush{#1}\stop
> > \stopxmlsetups
> > \setMPtext{1}{\usermap[concurrent.title]}
> > \setMPtext{2}{\usermap[concurrent.location]}
>
> \setMPtext{1}{%
>\xmlatt {\getvariable {div} {concurrent} {title}%
> }
>
> > I can verify the attribute values exist by exporting them to the
> document:
> something like that .. untested as no mwe
>
> 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 /
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
>
> ___
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___

[NTG-context] Map XML attributes to variables, dynamically

2023-08-10 Thread Thangalin
Hello!

A Markdown document resembles the following:

::: {.concurrent title="Berth 5" location="San Diego"}
Text Goes Here
:::

::: {.concurrent title="Road" location="Beale AFB"}
Different Text Goes Here
:::

The XHTML generated from that document resembles:


Text Goes Here


Different Text Goes Here


Environments for the DIV element gets translated using:

\startxmlsetups xml:div
  \start[\xmlatt{#1}{class}]\xmlflush{#1}\stop
\stopxmlsetups

This creates "\startconcurrent" and "\stopconcurrent", which are later
defined using "\definestartstop[concurrent]".

I'd like to dynamically define all the data- attributes to make key/value
pairs accessible from the document. For example, I have this:

\definestartstop[concurrent][
  before={%
\blank[big]%
\setMPtext{1}{Berth 5}%
\startTextConcurrentFrame},
  after={\stopTextConcurrentFrame\blank[big]},
]

I'd like to replace \setMPText calls with a reference to a dynamically
created variable reference. For example:

\setMPtext{1}{\usermap[concurrent.title]}
\setMPtext{2}{\usermap[concurrent.location]}

I can verify the attribute values exist by exporting them to the document:

\startxmlsetups xml:div
  title:\xmlatt{#1}{data-title} location:\xmlatt{#1}{data-location}
  \start[\xmlatt{#1}{class}]\xmlflush{#1}\stop
\stopxmlsetups

How would you change the xml:div setup to create a map of its attributes as
key/value pairs?

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___

[NTG-context] Parallel columns using start/stop setups

2023-08-08 Thread Thangalin
Two concurrent situations can happen, which I'd like to typeset as two
parallel columns while keeping the overall page layout (i.e., headers,
footers, margins, and such).

current version: 2023.07.18 22:07

I'd like to find a way to set up start/stop environments, if possible, to
come up with a general-purpose solution (i.e., the prose itself is not
changed).

Here are a few examples. In the first, a "concurrent" environment is
created with two "timelines":

% SOT
\definestartstop[concurrent][
  before={\startcolumns[n=2, align={verytolerant,stretch}, separator=rule]},
  after=\stopcolumns,
]

\definestartstop[timelinea][
  after=\column,
]

\definestartstop[timelineb][]

\starttext
  \startconcurrent
\starttimelinea
  \dorecurse{5}{\input ward}
\stoptimelinea

\starttimelineb
  \dorecurse{5}{\input knuth}
\stoptimelineb
  \stopconcurrent
\stoptext
% EOT

The ward and knuth texts end up in the same column because one is shorter
than the other. Here's another attempt:

% SOT
\defineparagraphs[concurrent][n=2]

\definestartstop[timelinea][
  before=\concurrent,
  after=\concurrent,
]

\definestartstop[timelineb][
  before=\concurrent,
]

\starttext
  \startconcurrent
\starttimelinea
  \dorecurse{5}{\input ward}
\stoptimelinea

\starttimelineb
  \dorecurse{5}{\input knuth}
\stoptimelineb
  \stopconcurrent
\stoptext
% EOT

This loses much of the input text.

Can this be accomplished using LMTX and what would be the best approach?
Would this setupparagraphs, definecolumnset, synchronizestreams, or
possibly incomplete/experimental functionality?

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___

[NTG-context] Re: Why is the fonts database not updated?

2023-07-07 Thread Thangalin
I've used the following without any troubles for a few years now:

$ cat ~/bin/fontcache
#!/usr/bin/env bash

fc-cache -fv
mtxrun --generate
mtxrun --script fonts --reload
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___

Re: [NTG-context] Protect the lettrine

2023-06-25 Thread Thangalin via ntg-context
Thanks Hans.

I've updated the wiki. I'm wondering if there's a way to also control the
indenting? Max's solution removed any indenting, allowing the text for the
second paragraph to be flush. It looks a little strange to see text
indented next to a drop-cap. The test case is the same, but with the
addition of an indenting setup:

% SOT
\setupinitial[n=2, continue=yes]

\setupindenting[medium, yes]

\setuphead[chapter][
  after={\placeinitial},
  page=no,
]

\starttext
\chapter{one}
Kermit Ruffins

Meet me at the second line.

\chapter{two}
\input knuth

Meet me at the second line.
\stoptext
% EOT
This produces an unintended side-effect, as well, whereby the following
chapter heading is indented.

See https://i.ibb.co/n8cMkM9/unintended-indented.png

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Protect the lettrine

2023-06-14 Thread Thangalin via ntg-context
It's a tough problem for sure.

I'm wondering if there's a general solution?

That is, a way to tell ConTeXt to "protect the lettrine" regardless of the
source document text? Nothing can be hard-coded because the setups (take a
look at keenwrite themes
https://github.com/DaveJarvis/keenwrite-themes/tree/main/boschet) don't
"know" anything about the source document text.

That's why I stated that nothing between \starttext and \stoptext may
change.

In effect, we don't know if the text is going to be "Kermit Ruffins" or
"Yankee Doodle Dandy" or "We believe these truths to be self-evident." All
we know is that we want the first letter to be a lettrine and the
subsequent paragraph not to overlap the lettrine.

Cheers!


> \setuphead[chapter][
>   after={\placeinitial\vbox to 1cm{\relax {K{\hskip 2pt \lower 5pt
> \hbox{ermit MUffins \vbox to -0.055cm {\hskip -2.8cm \raise 1pt \hbox{meet
> me at the second
> line}}},
>   page=no,
> %]
>
> \starttext
>
> \startchapter[1]
> \stopchapter
>
> \forgetinitial \par
>
> \startchapter[2]
> \input knuth
> \stopchapter
>
> \stoptext
>
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Protect the lettrine

2023-06-13 Thread Thangalin via ntg-context
Thank you for taking the time to reply, linguafalsa, I appreciate it.

The source document is written in Markdown using KeenWrite, my Markdown
editor. Inserting typesetting instructions into the document would defeat
the software's architecture, hence being untenable. After the Markdown is
transformed into XHTML, a specific theme instructs ConTeXt how to typeset
the XHTML.

Here's a video showing how theme selection works:

https://youtu.be/3QpX70O5S30?list=PLB-WIt1cZYLm1MMx2FBG9KWzPIoWZMKu_=14

I hope this explains the situation more clearly about why changing the code
between \starttext and \stoptext isn't an option, as you've done with
introducing and using a macro.

Greets!

On Tue, Jun 13, 2023 at 7:33 PM linguafalsa--- via ntg-context <
ntg-context@ntg.nl> wrote:

> On Tue, Jun 13, 2023 at 02:01:14PM -0700, Thangalin via ntg-context wrote:
> > Thanks Otared,
> >
> > Unfortunately, that's adding content between \starttext and \stoptext,
> > which isn't tenable in my situation. The user is writing in Markdown,
> which
> > is automatically converted to XHTML then passed to ConTeXt, and so the
> > setups need to account for this scenario without modifying the source
> > document.
> >
>
> Yeah yeah yeah, tenable. A lot of things aren't tenable. Anyhow,
> What source document are you talking about here?
>
> You're already sourcing the lines after chapter one. As a matter of
> fact, if you weren't sourcing, then you'd have zilch, nada, zero, empty,
> null, void, an space, a separation, an abstract
>
> Just define Kermit Muffins and it should be good to go
>
>
> \setupinitial[n=2]
>
> \def\KermitMuffins{\vbox{Kermit Muffins\par\hskip 1.3cm \tfd Meet me at
> the second line}}
>
> \setuphead[chapter][
>   after={\placeinitial},
>   page=no,
> ]
>
> \starttext
> \chapter{one}
> \KermitMuffins
>
> \chapter{two}
> \input knuth
>
> Meet me at the second line.
> \stoptext
>
>
>
> > Cheers!
> >
> > On Tue, Jun 13, 2023 at 1:30 AM Otared Kavian via ntg-context <
> > ntg-context@ntg.nl> wrote:
> >
> > > Hi,
> > >
> > > Adding \hfill\break to the short line solves the issue, but probably
> there
> > > is a better way to achieve the correct result.
> > >
> > > \setupinitial[n=2]
> > >
> > > \setuphead[chapter][
> > >   after={\placeinitial},
> > >   page=no,
> > > ]
> > >
> > > \starttext
> > > \chapter{one}
> > > Kermit Ruffins \hfill\break % <---
> > >
> > > Meet me at the second line.
> > >
> > > \chapter{two}
> > > \input knuth
> > >
> > > Meet me at the second line.
> > > \stoptext
> > >
>
>
>
>
> > >
> > > Best regards: Otared
> > >
> > > On 13 Jun 2023, at 04:43, Thangalin via ntg-context <
> ntg-context@ntg.nl>
> > > wrote:
> > >
> > > I'm using KeenWrite Themes (specifically, Boschet) to typeset a chapter
> > > wherein the first letter is a lettrine. When the first paragraph is too
> > > short, the second paragraph overlaps the lettrine.
> > >
> > > % SOT
> > > \setupinitial[n=2]
> > >
> > > \setuphead[chapter][
> > >   after={\placeinitial},
> > >   page=no,
> > > ]
> > >
> > > \starttext
> > > \chapter{one}
> > > Kermit Ruffins
> > >
> > > Meet me at the second line.
> > >
> > > \chapter{two}
> > > \input knuth
> > >
> > > Meet me at the second line.
> > > \stoptext
> > > % EOT
> > >
> > > Produces: https://i.stack.imgur.com/kNDqw.png
> > >
> > > How would you instruct ConTeXt to "protect" the lettrine such that
> > > regardless of whether the first paragraph spans multiple lines, a short
> > > first paragraph will still prevent the second paragraph from
> overlapping
> > > the lettrine?
> > >
> > > That is, the setups should work in both cases, without any knowledge
> about
> > > the first paragraph length being added between \starttext and
> \stoptext.
> > >
> > > ConTeXt LMTX version: 2023.06.04 18:58
> > >
> > > Thank you!
> > >
> > >
> ___
> > > If your question is of interest to others as well, please add an entry
> to
> > > the Wiki!
> > >
> > > maillist : ntg-context@ntg.nl /
> > >

Re: [NTG-context] Protect the lettrine

2023-06-13 Thread Thangalin via ntg-context
Here's the output I'm looking to achieve:

https://i.stack.imgur.com/XeZQS.png

Note how the second line honours the lettrine's width and padding, in the
same way that the second line of the first paragraph in Knuth's quote
respects the width and padding.

On Tue, Jun 13, 2023 at 2:01 PM Thangalin  wrote:

> Thanks Otared,
>
> Unfortunately, that's adding content between \starttext and \stoptext,
> which isn't tenable in my situation. The user is writing in Markdown, which
> is automatically converted to XHTML then passed to ConTeXt, and so the
> setups need to account for this scenario without modifying the source
> document.
>
> Cheers!
>
> On Tue, Jun 13, 2023 at 1:30 AM Otared Kavian via ntg-context <
> ntg-context@ntg.nl> wrote:
>
>> Hi,
>>
>> Adding \hfill\break to the short line solves the issue, but probably
>> there is a better way to achieve the correct result.
>>
>> \setupinitial[n=2]
>>
>> \setuphead[chapter][
>>   after={\placeinitial},
>>   page=no,
>> ]
>>
>> \starttext
>> \chapter{one}
>> Kermit Ruffins \hfill\break % <---
>>
>> Meet me at the second line.
>>
>> \chapter{two}
>> \input knuth
>>
>> Meet me at the second line.
>> \stoptext
>>
>>
>> Best regards: Otared
>>
>> On 13 Jun 2023, at 04:43, Thangalin via ntg-context 
>> wrote:
>>
>> I'm using KeenWrite Themes (specifically, Boschet) to typeset a chapter
>> wherein the first letter is a lettrine. When the first paragraph is too
>> short, the second paragraph overlaps the lettrine.
>>
>> % SOT
>> \setupinitial[n=2]
>>
>> \setuphead[chapter][
>>   after={\placeinitial},
>>   page=no,
>> ]
>>
>> \starttext
>> \chapter{one}
>> Kermit Ruffins
>>
>> Meet me at the second line.
>>
>> \chapter{two}
>> \input knuth
>>
>> Meet me at the second line.
>> \stoptext
>> % EOT
>>
>> Produces: https://i.stack.imgur.com/kNDqw.png
>>
>> How would you instruct ConTeXt to "protect" the lettrine such that
>> regardless of whether the first paragraph spans multiple lines, a short
>> first paragraph will still prevent the second paragraph from overlapping
>> the lettrine?
>>
>> That is, the setups should work in both cases, without any knowledge
>> about the first paragraph length being added between \starttext and
>> \stoptext.
>>
>> ConTeXt LMTX version: 2023.06.04 18:58
>>
>> Thank you!
>>
>> ___
>> If your question is of interest to others as well, please add an entry to
>> the Wiki!
>>
>> maillist : ntg-context@ntg.nl /
>> https://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>> wiki : https://contextgarden.net
>>
>> ___
>>
>>
>> Otared Kavian
>> e-mail: ota...@gmail.com 
>> Phone: +33 6 88 26 70 95
>>
>>
>>
>>
>>
>> ___
>> If your question is of interest to others as well, please add an entry to
>> the Wiki!
>>
>> maillist : ntg-context@ntg.nl /
>> https://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>> wiki : https://contextgarden.net
>>
>> ___
>>
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Protect the lettrine

2023-06-13 Thread Thangalin via ntg-context
Thanks Otared,

Unfortunately, that's adding content between \starttext and \stoptext,
which isn't tenable in my situation. The user is writing in Markdown, which
is automatically converted to XHTML then passed to ConTeXt, and so the
setups need to account for this scenario without modifying the source
document.

Cheers!

On Tue, Jun 13, 2023 at 1:30 AM Otared Kavian via ntg-context <
ntg-context@ntg.nl> wrote:

> Hi,
>
> Adding \hfill\break to the short line solves the issue, but probably there
> is a better way to achieve the correct result.
>
> \setupinitial[n=2]
>
> \setuphead[chapter][
>   after={\placeinitial},
>   page=no,
> ]
>
> \starttext
> \chapter{one}
> Kermit Ruffins \hfill\break % <---
>
> Meet me at the second line.
>
> \chapter{two}
> \input knuth
>
> Meet me at the second line.
> \stoptext
>
>
> Best regards: Otared
>
> On 13 Jun 2023, at 04:43, Thangalin via ntg-context 
> wrote:
>
> I'm using KeenWrite Themes (specifically, Boschet) to typeset a chapter
> wherein the first letter is a lettrine. When the first paragraph is too
> short, the second paragraph overlaps the lettrine.
>
> % SOT
> \setupinitial[n=2]
>
> \setuphead[chapter][
>   after={\placeinitial},
>   page=no,
> ]
>
> \starttext
> \chapter{one}
> Kermit Ruffins
>
> Meet me at the second line.
>
> \chapter{two}
> \input knuth
>
> Meet me at the second line.
> \stoptext
> % EOT
>
> Produces: https://i.stack.imgur.com/kNDqw.png
>
> How would you instruct ConTeXt to "protect" the lettrine such that
> regardless of whether the first paragraph spans multiple lines, a short
> first paragraph will still prevent the second paragraph from overlapping
> the lettrine?
>
> That is, the setups should work in both cases, without any knowledge about
> the first paragraph length being added between \starttext and \stoptext.
>
> ConTeXt LMTX version: 2023.06.04 18:58
>
> Thank you!
>
> ___
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
>
> ___
>
>
> Otared Kavian
> e-mail: ota...@gmail.com 
> Phone: +33 6 88 26 70 95
>
>
>
>
>
> ___
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
>
> ___
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] Protect the lettrine

2023-06-12 Thread Thangalin via ntg-context
I'm using KeenWrite Themes (specifically, Boschet) to typeset a chapter
wherein the first letter is a lettrine. When the first paragraph is too
short, the second paragraph overlaps the lettrine.

% SOT
\setupinitial[n=2]

\setuphead[chapter][
  after={\placeinitial},
  page=no,
]

\starttext
\chapter{one}
Kermit Ruffins

Meet me at the second line.

\chapter{two}
\input knuth

Meet me at the second line.
\stoptext
% EOT

Produces: https://i.stack.imgur.com/kNDqw.png

How would you instruct ConTeXt to "protect" the lettrine such that
regardless of whether the first paragraph spans multiple lines, a short
first paragraph will still prevent the second paragraph from overlapping
the lettrine?

That is, the setups should work in both cases, without any knowledge about
the first paragraph length being added between \starttext and \stoptext.

ConTeXt LMTX version: 2023.06.04 18:58

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Super slow installation

2023-05-30 Thread Thangalin via ntg-context
>From twelve99.net:


If you’re interested in our IP city prefixes, we have a lookup table on our
website: https://www.arelion.com/our-network/bgp-routing/bgp-communities
Scroll down to “Origin + Communities” and expand that section. You can see
that sea-b1 (your hop 8) is not in Brussels, but is our router in Seattle.



My guess would be that the hostname “us-was” for Liberty Global (aorta.net)
stands for U.S.A. and Washington D.C, not Warsaw. They’re probably using
ICMP tunneling for their MPLS backbone, that’s why the ping times are weird
for you.


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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Super slow installation

2023-05-30 Thread Thangalin via ntg-context
mkdir /tmp/context
cd /tmp/context
wget "lmtx.pragma-ade.com/install-lmtx/context-linux-64.zip"
unzip context-linux-64.zip
sh install.sh

Installation went quite quickly (after downloading the zip files). Ran it
cleanly twice.

Looks like it's back to its previous speed, thank you.
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Super slow installation

2023-05-30 Thread Thangalin via ntg-context
Here's a comparison of miljuschka.nl and lmtx.pragma-ade.com:

$ ping miljuschka.nl
PING miljuschka.nl (162.159.135.42) 56(84) bytes of data.
64 bytes from 162.159.135.42 (162.159.135.42): icmp_seq=1 ttl=59 time=16.5
ms
64 bytes from 162.159.135.42 (162.159.135.42): icmp_seq=2 ttl=59 time=15.6
ms
64 bytes from 162.159.135.42 (162.159.135.42): icmp_seq=3 ttl=59 time=16.2
ms
64 bytes from 162.159.135.42 (162.159.135.42): icmp_seq=4 ttl=59 time=16.4
ms
$ traceroute miljuschka.nl
 3  rc1bb-be150-1.vc.shawcable.net (64.59.147.161)  15.574 ms  15.619 ms
 15.660 ms
 4  24.244.60.185 (24.244.60.185)  16.303 ms  16.509 ms  16.609 ms
 5  24.244.62.57 (24.244.62.57)  17.562 ms  17.878 ms  17.648 ms
 6  rc1bb-be214.vc.shawcable.net (24.244.58.61)  16.742 ms  13.168 ms
 13.281 ms
 7  rc1wt.wa.shawcable.net (66.163.76.66)  15.847 ms  15.384 ms  15.665 ms
 8  six.as13335.com (206.81.81.10)  24.052 ms  24.243 ms  24.509 ms
 9  172.71.144.3 (172.71.144.3)  26.393 ms 172.71.140.3 (172.71.140.3)
 23.617 ms 108.162.243.11 (108.162.243.11)  23.044 ms
10  162.159.135.42 (162.159.135.42)  22.763 ms  23.258 ms  22.567 ms

$ ping lmtx.pragma-ade.com
PING lmtx.pragma-ade.com (213.125.29.165) 56(84) bytes of data.
64 bytes from D57D1DA5.static.ziggozakelijk.nl (213.125.29.165): icmp_seq=1
ttl=51 time=177 ms
64 bytes from D57D1DA5.static.ziggozakelijk.nl (213.125.29.165): icmp_seq=2
ttl=51 time=168 ms
64 bytes from D57D1DA5.static.ziggozakelijk.nl (213.125.29.165): icmp_seq=3
ttl=51 time=169 ms
64 bytes from D57D1DA5.static.ziggozakelijk.nl (213.125.29.165): icmp_seq=4
ttl=51 time=169 ms

$ traceroute lmtx.pragma-ade.com
 3  rc1bb-be150-1.vc.shawcable.net (64.59.147.161)  22.062 ms  22.094 ms
 22.127 ms
 4  24.244.60.185 (24.244.60.185)  23.964 ms  24.273 ms  23.612 ms
 5  24.244.62.57 (24.244.62.57)  24.565 ms  24.926 ms  25.269 ms
 6  rc1bb-be214.vc.shawcable.net (24.244.58.61)  23.201 ms  16.376 ms
 16.637 ms
 7  rc1wt.wa.shawcable.net (66.163.76.66)  20.228 ms  15.492 ms  15.227 ms
 8  sea-b1-link.ip.twelve99.net (213.248.67.224)  24.968 ms  28.435 ms
 24.726 ms
 9  chi-b23-link.ip.twelve99.net (62.115.132.154)  64.194 ms  64.310 ms
 64.081 ms
10  nyk-bb2-link.ip.twelve99.net (62.115.137.58)  80.232 ms
nyk-bb1-link.ip.twelve99.net (80.91.246.163)  80.730 ms
nyk-bb2-link.ip.twelve99.net (62.115.137.58)  80.335 ms
11  nyk-b1-link.ip.twelve99.net (62.115.135.133)  84.971 ms  85.189 ms
 84.776 ms
12  upc-ic-355153.ip.twelve99-cust.net (62.115.190.245)  90.268 ms  90.132
ms  90.416 ms
13  us-was03a-rd1-ae-8-0.aorta.net (84.116.133.98)  165.845 ms  159.578 ms
 161.045 ms
14  nl-ams17b-rc1-lag-105-0.aorta.net (84.116.130.65)  168.328 ms  161.507
ms  162.117 ms
15  asd-rc0001-cr101-be60-2.core.as33915.net (213.51.64.5)  164.180 ms
 168.938 ms  169.739 ms
16  213.51.7.227 (213.51.7.227)  165.693 ms  161.384 ms  161.558 ms
17  * * *

Something is funky on the network.
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Super slow installation

2023-05-30 Thread Thangalin via ntg-context
FWIW, I'm seeing the same slow down issue from three different machines:

   1. My personal computer in Vancouver BC.
   2. A work computer on Vancouver Island (Victoria BC)
   3. Microsoft ADO servers (presumably in Seattle WA).

Is it possible there's a slow pipe from North America to Europe?

On Tue, May 30, 2023 at 10:28 AM Thangalin  wrote:

> Here's the result from downloading a YouTube video using yt-dlp:
>
> [download] 100% of  225.74MiB in 00:00:09 at 24.43MiB/s
>
> 9 seconds for 225 MB.
>
> I haven't touched my router configuration in years.
>
> https://www.speedtest.net/result/14802746497
>
> Download 935 Mbps; Upload 106 MBps.
>
> Looks fine on my side?
>
>
> On Tue, May 30, 2023 at 9:16 AM Thomas A. Schmitz via ntg-context <
> ntg-context@ntg.nl> wrote:
>
>> On 5/30/23 18:07, Thangalin via ntg-context wrote:
>> > Still sluggish. Downloading texmf.zip took 22s for 50MB:
>> >
>> > $ wget http://lmtx.pragma-ade.com/install-lmtx//texmf.zip
>> > <http://lmtx.pragma-ade.com/install-lmtx//texmf.zip>
>> > --2023-05-30 09:02:50--
>> > http://lmtx.pragma-ade.com/install-lmtx//texmf.zip
>> > <http://lmtx.pragma-ade.com/install-lmtx//texmf.zip>
>> > Resolving lmtx.pragma-ade.com <http://lmtx.pragma-ade.com>
>> > (lmtx.pragma-ade.com <http://lmtx.pragma-ade.com>)... 213.125.29.165
>> > Connecting to lmtx.pragma-ade.com <http://lmtx.pragma-ade.com>
>> > (lmtx.pragma-ade.com <http://lmtx.pragma-ade.com>)|213.125.29.165|:80...
>>
>> > connected.
>> > HTTP request sent, awaiting response... 200 OK
>> > Length: 53293716 (51M) [application/zip]
>> > Saving to: ‘texmf.zip’
>> >
>> > texmf.zip   100%[===>]  50.82M  2.48MB/sin
>> 22s
>> >
>> > 2023-05-30 09:03:13 (2.26 MB/s) - ‘texmf.zip’ saved [53293716/53293716]
>> >
>> > In the past, downloading 50MB has been much faster.
>>
>>
>> Couldn't it be something on your side, like a misconfigured router or ad
>> blocker or something? I get faster download times:
>>
>> wget http://lmtx.pragma-ade.com/install-lmtx//texmf.zip
>> --2023-05-30 18:12:43--
>> http://lmtx.pragma-ade.com/install-lmtx//texmf.zip
>> Resolving lmtx.pragma-ade.com (lmtx.pragma-ade.com)... 213.125.29.165
>> Connecting to lmtx.pragma-ade.com
>> (lmtx.pragma-ade.com)|213.125.29.165|:80... connected.
>> HTTP request sent, awaiting response... 200 OK
>> Length: 53293716 (51M) [application/zip]
>> Saving to: ‘texmf.zip’
>>
>> texmf.zip   100%[===>]  50,82M  4,85MB/sin
>> 11s
>>
>> 2023-05-30 18:12:53 (4,82 MB/s) - ‘texmf.zip’ saved [53293716/53293716]
>>
>> Thomas
>>
>> ___
>> If your question is of interest to others as well, please add an entry to
>> the Wiki!
>>
>> maillist : ntg-context@ntg.nl /
>> https://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>> wiki : https://contextgarden.net
>>
>> ___
>>
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Super slow installation

2023-05-30 Thread Thangalin via ntg-context
Here's the result from downloading a YouTube video using yt-dlp:

[download] 100% of  225.74MiB in 00:00:09 at 24.43MiB/s

9 seconds for 225 MB.

I haven't touched my router configuration in years.

https://www.speedtest.net/result/14802746497

Download 935 Mbps; Upload 106 MBps.

Looks fine on my side?


On Tue, May 30, 2023 at 9:16 AM Thomas A. Schmitz via ntg-context <
ntg-context@ntg.nl> wrote:

> On 5/30/23 18:07, Thangalin via ntg-context wrote:
> > Still sluggish. Downloading texmf.zip took 22s for 50MB:
> >
> > $ wget http://lmtx.pragma-ade.com/install-lmtx//texmf.zip
> > <http://lmtx.pragma-ade.com/install-lmtx//texmf.zip>
> > --2023-05-30 09:02:50--
> > http://lmtx.pragma-ade.com/install-lmtx//texmf.zip
> > <http://lmtx.pragma-ade.com/install-lmtx//texmf.zip>
> > Resolving lmtx.pragma-ade.com <http://lmtx.pragma-ade.com>
> > (lmtx.pragma-ade.com <http://lmtx.pragma-ade.com>)... 213.125.29.165
> > Connecting to lmtx.pragma-ade.com <http://lmtx.pragma-ade.com>
> > (lmtx.pragma-ade.com <http://lmtx.pragma-ade.com>)|213.125.29.165|:80...
>
> > connected.
> > HTTP request sent, awaiting response... 200 OK
> > Length: 53293716 (51M) [application/zip]
> > Saving to: ‘texmf.zip’
> >
> > texmf.zip   100%[===>]  50.82M  2.48MB/sin
> 22s
> >
> > 2023-05-30 09:03:13 (2.26 MB/s) - ‘texmf.zip’ saved [53293716/53293716]
> >
> > In the past, downloading 50MB has been much faster.
>
>
> Couldn't it be something on your side, like a misconfigured router or ad
> blocker or something? I get faster download times:
>
> wget http://lmtx.pragma-ade.com/install-lmtx//texmf.zip
> --2023-05-30 18:12:43--
> http://lmtx.pragma-ade.com/install-lmtx//texmf.zip
> Resolving lmtx.pragma-ade.com (lmtx.pragma-ade.com)... 213.125.29.165
> Connecting to lmtx.pragma-ade.com
> (lmtx.pragma-ade.com)|213.125.29.165|:80... connected.
> HTTP request sent, awaiting response... 200 OK
> Length: 53293716 (51M) [application/zip]
> Saving to: ‘texmf.zip’
>
> texmf.zip   100%[===>]  50,82M  4,85MB/sin
> 11s
>
> 2023-05-30 18:12:53 (4,82 MB/s) - ‘texmf.zip’ saved [53293716/53293716]
>
> Thomas
>
> ___
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
>
> ___
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Super slow installation

2023-05-30 Thread Thangalin via ntg-context
Still sluggish. Downloading texmf.zip took 22s for 50MB:

$ wget http://lmtx.pragma-ade.com/install-lmtx//texmf.zip
--2023-05-30 09:02:50--  http://lmtx.pragma-ade.com/install-lmtx//texmf.zip
Resolving lmtx.pragma-ade.com (lmtx.pragma-ade.com)... 213.125.29.165
Connecting to lmtx.pragma-ade.com (lmtx.pragma-ade.com)|213.125.29.165|:80...
connected.
HTTP request sent, awaiting response... 200 OK
Length: 53293716 (51M) [application/zip]
Saving to: ‘texmf.zip’

texmf.zip   100%[===>]  50.82M  2.48MB/sin 22s


2023-05-30 09:03:13 (2.26 MB/s) - ‘texmf.zip’ saved [53293716/53293716]

In the past, downloading 50MB has been much faster.



The following takes about 4 minutes:

mtx-install | unzipping 'texmf.zip'
  69 files of  692 done,6635323 bytes, 0.027 seconds
... snip ...
 692 files of  692 done,   86353557 bytes, 0.477 seconds
mtx-install | installing tex/texmf, 642 files
mtx-install | new  :   0 % :   115868 :
tex/texmf/fonts/data/cms/companion/RalphSmithsFormalScript-Companion.otf
mtx-install | new  :   0 % : 5308 :
tex/texmf/fonts/data/cms/companion/TeXGyreBonumMath-Companion.otf
... snip ...
mtx-install | new  :  22 % :   139508 :
tex/texmf/fonts/data/gust/kurier-math/kurierri.pfb

Previously, getting to 22% was also quite quick.

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] Super slow installation

2023-05-29 Thread Thangalin via ntg-context
Hi,

Installation of a fresh copy of LMTX has gone from a few minutes to
about 30 minutes. Here's what I ran:

1. Open terminal
2. Change to root
3. cd /opt
4. mkdir context-2023-05-29
5. cd context-2023-05-29
6. wget "http://lmtx.pragma-ade.com/install-lmtx//texmf.zip;
7. unzip texmf.zip
8. chmod +x install.sh
9. ./install.sh

mtx-install | unzipping 'texmf-context.zip'
 518 files of 5180 done,   81058499 bytes, 0.403 seconds
 ... snip ...
5180 files of 5180 done,  171691491 bytes, 1.035 seconds
mtx-install | installing tex/texmf-context, 4924 files
mtx-install | new  :   0 % : 2447 :
tex/texmf-context/context-readme.txt
... snip ...
mtx-install | new  :  48 % :21898 :
tex/texmf-context/doc/context/sources/general/manuals/about/still-expanding-10.png

Getting to this point has taken shy of 15 minutes.

Any ideas what's going on or how to fix it?

Note that upgrading against the version prior to 2023.05.29 (i.e.,
without re-installing from scratch), the process happens pretty
quickly.

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] SVG ViewBox figure battle

2023-05-20 Thread Thangalin via ntg-context
Hi again,

I changed tex/texmf-context/tex/context/base/mkiv/grph-con.lua to
replace "" with "--export-area-page" in the inkscapecrop function:

local function inkscapecrop(specification)
return (specification and specification.crop == v_yes) and
"--export-area-drawing" or "--export-area-page"
end

This produces the desired results.

Any ideas on how to force that setting without modifying grph-con.lua?

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] SVG ViewBox figure battle

2023-05-19 Thread Thangalin via ntg-context
Hi there!

The following document contains SVG. Save the SVG as "problem.svg" and
run the document through LMTX version 2023.05.08 17:39:

% SOF
\startbuffer[csvg]

  
  

\stopbuffer

\starttext
  % honours viewbox
  \placefigure[none]{}{\includesvgbuffer[csvg]}
  \page
  % dishonours viewbox
  \externalfigure[problem.svg]
\stoptext
% EOF

The ViewBox is ignored when run through Inkscape. Is this because the
--export-area-page option is not being passed when invoked?

Given identical inputs, would it make sense for placefigure and
externalfigure to produce identical results?

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] KeenType 1.0.0 (NTS fork)

2023-01-22 Thread Thangalin via ntg-context
Hi folks,

I forked the New Typesetting System (NTS) as KeenType. KeenType is a
100% pure Java library/app that can generate SVG diagrams from plain
TeX documents.

Here's a list of the changes (and sample output):

https://github.com/DaveJarvis/KeenType/releases/tag/1.0.0

Here's how typesetting appears in KeenWrite:

https://raw.githubusercontent.com/DaveJarvis/KeenType/main/docs/images/keentype-01.png

Special thanks to Hans and Taco who, no doubt, played important roles
in bringing the original NTS to life. My sincere gratitude to any NTS
developers who may be reading.

For further details, see:

https://github.com/DaveJarvis/KeenType/

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] Download remote SVG images

2023-01-02 Thread Thangalin via ntg-context
Hi list!

% SOT
\starttext
  
\externalfigure[https://upload.wikimedia.org/wikipedia/commons/f/fd/Ghostscript_Tiger.svg]

  
\externalfigure[https://upload.wikimedia.org/wikipedia/commons/thumb/f/fd/Ghostscript_Tiger.svg/1024px-Ghostscript_Tiger.svg.png]
\stoptext
% EOT

Is there a way to have ConTeXt download remote SVG images?

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Radial and linear gradients

2022-12-14 Thread Thangalin via ntg-context
Inkscape can export the gradients to PDF.

I was hoping to eliminate Inkscape as an extra piece of software users
have to download to make sure their SVG images are rendered correctly.
By containerizing ConTeXt, MetaPost can be swapped for Inkscape, so
users won't even know. It is, however, a minor duplication to have two
programs that can convert SVG to PDF. (And Inkscape will bloat the
container size.)

For my images, at least, gradients are one of the last features needed
to render them correctly using MetaPost. The other is font rendering
in some cases will be incorrect (e.g., try using Roboto with weight
100). If we have to use Inkscape to ensure tat all SVG images are
rendered correctly, then we'd only want to use MetaPost if we know
that the images don't contain gradients, or would you recommend
avoiding MetaPost altogether for SVG conversion?

Thank you!

On Wed, Dec 14, 2022 at 12:46 AM Hans Hagen via ntg-context
 wrote:
>
> On 12/14/2022 5:46 AM, Thangalin via ntg-context wrote:
> > Hi there!
> >
> > Any thoughts on implementing SVG gradients in MetaPost?
> >
> > % SOF
> > \startbuffer[csvg]
> > http://www.w3.org/2000/svg;
> > xmlns:xlink="http://www.w3.org/1999/xlink; viewBox="0 0 115.669
> > 115.669"> > cy="167.114" r="57.834" fx="124.515" fy="167.114"
> > gradientTransform="translate(-17.77 -18.4)"
> > gradientUnits="userSpaceOnUse"/> > offset="0"/> > stop-opacity="0"/> > transform="translate(-48.91 -90.879)"> > fill-opacity=".5" d="M48.769 90.936H164.64V206.96H48.769z"/> > cx="106.745" cy="148.713" r="57.834" fill="url(#b)"
> > fill-rule="evenodd"/>
> > \stopbuffer
> >
> > \starttext
> >\placefigure{}{\includesvgbuffer[csvg][conversion=mp]}
> > \stoptext
> > % EOF
> >
> > See attached a comparison of the PDF generated using ConTeXt and the
> > PNG file generated by exporting from Inkscape.
> these gradients definitions get crazier by the day ... does inkscape
> output a bitmap or vector pdf
>
> given what we do with context i'm not sure we should support everything
> that pops up (mapping all onto mp and then pdf ...)
>
> 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 / 
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
> ___


inkscape-gradient.pdf
Description: Adobe PDF document
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] Containerized ConTeXt

2022-12-13 Thread Thangalin via ntg-context
Hi again,

I've added the start of a podman container for invoking ConTeXt that
may be of interest:

https://github.com/DaveJarvis/keenwrite/tree/main/container

The Containerfile sets up ConTeXt to work with my themes:

https://github.com/DaveJarvis/keenwrite-themes

The manage.sh shell script is a wrapper around the podman command to
help build, save, and load the container, as well as connect and run
commands. It's a work-in-progress.

My goal is to simplify the setup and configuration of ConTeXt as well
as make the instructions "cross platform" owing to containerization.
From there, I want to call out to the container from KeenWrite to
typeset PDF documents using one of the themes. Further, I'd like to
have KeenWrite download and install ConTeXt automatically using
podman. I believe this will make it easier for people to generate
high-quality PDFs from (R) Markdown documents because they'd only have
to download KeenWrite, then ask KeenWrite to download/configure
ConTeXt automatically, in a cross-platform fashion.

Thoughts? Suggestions for improvement?
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] Radial and linear gradients

2022-12-13 Thread Thangalin via ntg-context
Hi there!

Any thoughts on implementing SVG gradients in MetaPost?

% SOF
\startbuffer[csvg]
http://www.w3.org/2000/svg;
xmlns:xlink="http://www.w3.org/1999/xlink; viewBox="0 0 115.669
115.669">
\stopbuffer

\starttext
  \placefigure{}{\includesvgbuffer[csvg][conversion=mp]}
\stoptext
% EOF

See attached a comparison of the PDF generated using ConTeXt and the
PNG file generated by exporting from Inkscape.

Many thanks!


gradient.pdf
Description: Adobe PDF document
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] pragma-ade.nl - 404

2022-11-09 Thread Thangalin via ntg-context
Re: https://wiki.contextgarden.net/Installation

I've changed all the download links to use the site
http://lmtx.pragma-ade.com instead of .nl. I haven't tested all the
links.

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] pragma-ade.nl - 404

2022-11-04 Thread Thangalin via ntg-context
Hi,

https://pragma-ade.nl/

We're seeing a bad cert and a 404.

Possible to redirect the .nl to the .com to avoid breaking scripts and
download URLs?

Note that the following page references the .nl TLD for downloads:

https://wiki.contextgarden.net/Installation

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] Lopsided circles

2022-10-18 Thread Thangalin via ntg-context
Using 2022.09.11 20:44, there appears to be a problem with rendering
some circular forms, such as:

% SOT
\startbuffer[circle]



\stopbuffer

\starttext
  \placefigure{}{\includesvgbuffer[circle][conversion=mp]}
\stoptext
% EOT

In Inkscape, this renders as a full circle without any deformation.
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] Perceptrons

2022-10-16 Thread Thangalin via ntg-context
Okay, they aren't _real_ perceptrons, but fancy parameterized trees
connected on a hex grid, coded with MetaFun and Lua.

Big version: https://pdfhost.io/v/piuN04dSq_perceptron

If anyone is interested in the full source code, let me know.

I couldn't get "angle" to work properly. Hans, your simplifications on
the atantwo function also didn't work for all cases. There was a
single edge case that didn't determine the correct angle. Don't know
why.

Cheers!


perceptron-01.pdf
Description: Adobe PDF document


perceptron-02.pdf
Description: Adobe PDF document
\definecolor[HexGridBase][h=E0E0E0]
\definecolor[HexGridNode][h=202020]
\definecolor[HexGridEdge][h=808080]

%\definecolor[HexGridBase][h=1f50da]
%\definecolor[HexGridNode][h=00d687]
%\definecolor[HexGridEdge][h=00d687]

\startluacode
  require "Graph"

  -- Try to generate a different tree each run.
  math.randomseed( math.modf( os.clock() * 1000 ), os.time() )

  userdata = userdata or {}
  ud = userdata

  -- Create a minimally spanning acyclic graph that's mostly connected.
  --
  -- @param r - numeric - The number of rows
  -- @param c - numeric - The number of columns
  -- @param m - numeric The number of edges
  --
  -- @return A handle to the tree instance.
  function tree( r, c, m )
local graph = Graph:new()
local edges = graph:connected( r, c, m )
local source = edges[ math.random( #edges ) ]
local tree = graph:compute( source )

return tree
  end

  -- Extract the first pair of a vertex at the given index inside the tree.
  -- No error checking is performed.
  --
  -- @param graph - object - The tree containing numerous edges.
  -- @param index - non-negative integer - The index for the vertex pair.
  --
  -- @return The (x, y) pair for the first vertex comprising an edge.
  function ud.vertex_a( graph, index )
u = graph[ index ].u
return { u.x, u.y }
  end
  
  -- Extract the second pair of a vertex at the given index inside the tree.
  -- No error checking is performed.
  --
  -- @param graph - object - The tree containing numerous edges.
  -- @param index - non-negative integer - The index for the vertex pair.
  --
  -- @return The (x, y) pair for the second vertex comprising an edge.
  function ud.vertex_b( graph, index )
v = graph[ index ].v
return { v.x, v.y }
  end
  
  -- Return the number of edges in the tree.
  --
  -- @param graph - object - The tree containing numerous nodes.
  --
  -- @return The number of vertex pairs in the tree.
  function ud.count( graph )
return #graph
  end
\stopluacode

\startuseMPgraphic{HexGridBaseGraphic}{side}
  % Set the random seed to the current second.
  randomseed := lua( "os.time()" );

  vardef atantwo( expr ax, ay, bx, by ) =
save theta;

dx := bx - ax;
dy := by - ay;
theta := 0;

if (dx > 0):
  theta := atan( dy / dx );
elseif (dx < 0) and (dy >= 0):
  theta := atan( dy / dx ) + pi;
elseif (dx < 0) and (dy < 0):
  theta := atan( dy / dx ) - pi;
elseif (dx == 0) and (dy > 0):
  theta := pi / 2;
elseif (dx == 0) and (dy < 0):
  theta := -pi / 2;
fi;

theta
  enddef;

  vardef degrees( expr rad ) =
rad * 180 / pi
  enddef;

  vardef distance( expr ax, ay, bx, by ) =
sqrt( ((bx - ax)^2) + ((by - ay)^2) )
  enddef;

  % Set the number of hexagons from top to bottom.
  GRID_C = 124;

  % Set the number of hexagons from left to right.
  GRID_R = 120;

  % Set the number of pathways between nodes (higher is more complexity).
  PATHWAYS = 235;

  % Grid zoom level (smaller is further away).
  SCALE = 5;

  % Hexagon dimensions.
  HEIGHT  = sqrt( 3 );
  HHEIGHT = HEIGHT / 2;
  WIDTH   = 2;

  color colour_base;
  color colour_node;
  color colour_edge;

  colour_base = \MPcolor{HexGridBase};
  colour_node = \MPcolor{HexGridNode};
  colour_edge = \MPcolor{HexGridEdge};

  % Vertex diameters proportional to the hexagon height.
  vertex_sm := HEIGHT / 12;
  vertex_lg := HEIGHT / 5;

  path path_ul;
  path path_ur;
  path path_tp;

  path_ur := dir( 60 * 0 ) -- dir( 60 * 1 );
  path_tp := dir( 60 * 1 ) -- dir( 60 * 2 );
  path_ul := dir( 60 * 2 ) -- dir( 60 * 3 );

  picture hexgrid;
  picture vertices;
  picture perceptrons;
  picture connections;

  hexgrid := nullpicture;
  vertices := nullpicture;
  perceptrons := nullpicture;
  connections := nullpicture;

  % Line width.
  pickup pencircle scaled .05bp;

  addto hexgrid also image(
for c = 1 upto GRID_C:
  for r = 1 upto GRID_R:
offset_c := c * 3 / WIDTH;
offset_r := r * HEIGHT - (c mod 2 * HHEIGHT);

draw path_ul shifted (offset_c, offset_r) withcolor colour_base;
draw path_tp shifted (offset_c, offset_r) withcolor colour_base;
draw path_ur shifted (offset_c, offset_r) withcolor colour_base;

for i = 0 upto 2:
  addto vertices also image(
draw
  point i of path_tp
  shifted (offset_c, offset_r)
  withcolor colour_base

Re: [NTG-context] atan2 function

2022-10-14 Thread Thangalin via ntg-context
That's certainly tighter, thank you, Alan.

Would making the conditional part of the API be useful to others?

Cheers!

On Fri, Oct 14, 2022 at 3:42 PM Alan Braslau  wrote:
>
> On Fri, 14 Oct 2022 11:59:49 -0700
> Thangalin  wrote:
>
> > I don't think an atantwo is needed. I *thought* I had read somewhere
> > that atan( y, x ) was equivalent to calling atan2 in Lua. Ensuring
> > there's no breakage when x == y would be nice, though. It was a little
> > surprising to see angle return degrees rather than radians, but it
> > does simplify my code:
> >
> >   dc := vbc - vac;
> >   dr := vbr - var;
> >   vi := 0;
> >
> >   if not( dc == dr ):
> > vi := round( angle( dc, dr ) / 60 );
> >   fi;
> >
> >   % Compute the direction towards the first segment (to vertex of
> > an edge). vangle := vi * 60 * pi / 180;
> >
> > Even simpler would be:
> >
> >   dc := vbc - vac;
> >   dr := vbr - var;
> >   vi := round( angle( dc, dr ) / 60 ); % returns 0 when dc == dr
> >
> >   % Compute the direction towards the first segment (to vertex of
> > an edge). vangle := vi * 60 * pi / 180;
> >
> > Or accepting a third argument as the return value in the special case:
> >
> >   vi := round( angle( dc, dr, 0 ) / 60 ); % returns 0 when dc ==
> > dr
> >
> > Cheers!
>
> vi := if (dc = dr) : 0 else : round (angle(dc,dr)/60) fi ;
>
> Alan
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] atan2 function

2022-10-14 Thread Thangalin via ntg-context
I don't think an atantwo is needed. I *thought* I had read somewhere
that atan( y, x ) was equivalent to calling atan2 in Lua. Ensuring
there's no breakage when x == y would be nice, though. It was a little
surprising to see angle return degrees rather than radians, but it
does simplify my code:

  dc := vbc - vac;
  dr := vbr - var;
  vi := 0;

  if not( dc == dr ):
vi := round( angle( dc, dr ) / 60 );
  fi;

  % Compute the direction towards the first segment (to vertex of an edge).
  vangle := vi * 60 * pi / 180;

Even simpler would be:

  dc := vbc - vac;
  dr := vbr - var;
  vi := round( angle( dc, dr ) / 60 ); % returns 0 when dc == dr

  % Compute the direction towards the first segment (to vertex of an edge).
  vangle := vi * 60 * pi / 180;

Or accepting a third argument as the return value in the special case:

  vi := round( angle( dc, dr, 0 ) / 60 ); % returns 0 when dc == dr

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] atan2 function

2022-10-13 Thread Thangalin via ntg-context
Thank you, Max.

The angle function doesn't appear to provide the same calculation as
my atantwo in all cases.

https://pdfhost.io/v/Oqj7XmibJ_scaled

The shorter line segment should be directed towards the vertex closest
to the longer line segment. I tried using both:

theta := angle( dx, dy );
theta := angle( dy, dx );

Neither made a difference, in some cases the angle differs from what I'd expect.

My implementation is based on the first version given here:

https://en.wikipedia.org/wiki/Atan2#Definition_and_computation

I have something that works, so this is more of a curiosity as to
there being a difference between my implementation of atantwo and the
angle function.

Here's an example with many lines and the angle function:
https://pdfhost.io/v/1T4jgBnxh_scaled

On Wed, Oct 12, 2022 at 11:42 PM Max Chernoff  wrote:
>
> Hi,
>
> > How is atan2 called? I rolled my own as follows:
>
> > Is atan with two parameters supposed to behave like atan2?
>
> At mp-math.mpxl:167 there is:
>
>vardef atan   primary x = angle(1,x)   enddef ;
>
> The MetaPost manual says:
>
>The angle operator takes a pair and computes the two-argument
>arctangent; i.e., angle is the inverse of the dir operator
>
> So it looks like "angle" is the function that you want for "atan2".
>
> Thanks,
> -- Max
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] atan2 function

2022-10-12 Thread Thangalin via ntg-context
Hi there,

How is atan2 called? I rolled my own as follows:

% SOT
\startuseMPgraphic{HexGridBaseGraphic}
  vardef atantwo( expr ax, ay, bx, by ) =
save theta;

numeric dx;
numeric dy;
numeric theta;

dx := bx - ax;
dy := by - ay;
theta := 0;

if (dx > 0):
  theta := atan( dy / dx );
elseif (dx < 0) and (dy >= 0):
  theta := atan( dy / dx ) + pi;
elseif (dx < 0) and (dy < 0):
  theta := atan( dy / dx ) - pi;
elseif (dx == 0) and (dy > 0):
  theta := pi / 2;
elseif (dx == 0) and (dy < 0):
  theta := -pi / 2;
fi;

%theta := atan( dy, dx );

theta
  enddef;
% EOT

When this runs, the expected result is generated:

https://pdfhost.io/v/xdNxANU18_scaled

When uncommenting "atan( dy, dx )", an unexpected result is generated:

https://pdfhost.io/v/QdfU89IL._scaled

Is atan with two parameters supposed to behave like atan2?

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] Apostrophe entity using \xmltexentity is ignored

2022-10-08 Thread Thangalin via ntg-context
Has the handling for the apostrophe character entity changed recently?

In the following example, the \xmltexentity for apostrophe is ignored,
resulting in a straight apostrophe instead of a curled one:

% SOT
\xmltexentity{apos}{’}
\xmltexentity{lsquo}{‘}
\xmltexentity{rsquo}{’}
\xmltexentity{laquo}{«}
\xmltexentity{raquo}{»}

\startbuffer[document]

  Sylvias spilled wine.

\stopbuffer

\startxmlsetups xml:xhtml
  \xmlsetsetup{\xmldocument}{body}{xml:*}
\stopxmlsetups

\startxmlsetups xml:body
  \xmlflush{#1}
\stopxmlsetups

\xmlregistersetup{xml:xhtml}

\starttext
  \xmlprocessbuffer{xhtml}{document}{}
\stoptext
% EOT

Any ideas on how to fix it?

Thank you.

mtx-context | current version: 2022.09.11 20:44
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] SVG path conversion misalignment

2022-09-11 Thread Thangalin via ntg-context
Hi there,

% SOT
\startbuffer[dna]

\stopbuffer

\starttext
  \placefigure{}{\includesvgbuffer[dna][conversion=mp]}
\stoptext
% EOT

In the PDF that's generated, the curve of the gray semi-circle is malformed
with respect to the blackground. It's like there's a small chip. The
expected result is shown here:

https://i.ibb.co/n7s8GPT/dna.png

Looks like a small precision error in some of the pathing or
transformation/rotation calculations.
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] String substitution using regular expressions and backreferences

2022-08-25 Thread Thangalin via ntg-context
I've attempted to apply Wolfgang's subtle suggestion of using Lua to parse
the input document using a regular expression via lpeg.replacer. The
replacement itself works fine; however, in doing so the XML document
structure is converted to text, which means that it is no longer possible
to "flush" the XML for further processing as XML. The result is that any
unresolved XML tags are written verbatim to the PDF:

https://i.stack.imgur.com/9ZFND.png

There are two other issues with this approach. First is efficiency. Second
is that the processing function would have to be called for every XML
element to capture the replacement.

My original post asked about applying regex word substitution in a ConTeXt
way, such as:

\definereplacement[SubstMac][ match={Mc([A-Z].*)}, replace={\Mac \\1} ]
\definereplacement[SubstPostmeridian][ match={[Pp]\\.[Mm]\\.},
replace={\cap{pm}} ]

That seems like the cleanest approach because it would work on top of XML
or any other source document. Nevertheless, here is what I tried, which
partially works:

\startbuffer[main]

  “Mr. McAnulty, I presume?”
  Regular text. Irregular text.
\stopbuffer
\startxmlsetups xml:xhtml
  \xmlsetsetup{\xmldocument}{*}{-}
  \xmlsetsetup{\xmldocument}{html|p|em}{xml:*}\stopxmlsetups
\startxmlsetups xml:html
  \startdocument
\xmlflush{#1}
  \stopdocument\stopxmlsetups
% Paragraphs are followed by a paragraph break, but only if not
nested.\startxmlsetups xml:p
  \xmlfunction{#1}{p}
  \par\stopxmlsetups
\startxmlsetups xml:em
  \dontleavehmode{\em\xmlflush{#1}}\stopxmlsetups
\startluacode
function xml.functions.p( t )
  rep = { [1] = { "McAnulty", "\\Mac Anulty" } }
  x = lpeg.replacer( rep ):match( tostring( xml.text( t ) ) )

  buffers.assign( "p", context( x ) )
  context.getbuffer{ "p" }
end\stopluacode
\xmlregistersetup{xml:xhtml}
\def\Mac{%
  % Determine the sizes of 'M' and 'c'.
  \newbox\MacMBox%
  \setbox\MacMBox\hbox{M}%
  \newbox\MacCBox%
  \setbox\MacCBox\hbox{c}%
  %
  % Cheat to dynamically derive the kerning size by putting Mc in a box.
  %
  \newbox\MacKernBox%
  \setbox\MacKernBox\hbox{\inframed[offset=\zeropoint, width=fit]{Mc}}%
  \def\MacDelta{\dimexpr\wd\MacKernBox-\wd\MacMBox-\wd\MacCBox\relax}%
  \def\MacUWidth{\dimexpr\wd\MacCBox-.75\MacDelta\relax}%
  \def\MacRule{\vrule width \MacUWidth height .04em depth \zeropoint \relax}%
  \def\MacKern{\dimexpr\wd\MacKernBox-\wd\MacMBox-\wd\MacCBox\relax}%
  \def\MacHeight{\dimexpr\ht\MacMBox-\ht\MacCBox\relax}%
  %
  % Write Mc, where c has a macron, to the document.
  %
  M{%
\dontleavehmode{\raisebox{\MacHeight}\hbox{c}}%
\kern-1.04\MacUWidth
\MacRule
\kern.08\MacUWidth
  }%
}%
\xmlprocessbuffer{main}{main}{}

As shown in the screen shot, this doesn't correctly handle nested XML
elements.

Any ideas on what approach to take to perform a string replacement in
ConTeXt?

Thanks again!


[Your] input is XML which means a lot more can be done than your simple TeX
> based example demonstrates.
>
> Wolfgang
>
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] C with macron

2022-08-24 Thread Thangalin via ntg-context
Here's an attempt with dynamic kerning based on the font, which eliminates
some of the tweaking needed. It's not perfect and, depending on the font, a
little work is needed. For pagella, scholas, termes, and a few other
default fonts, the results are decent.

%\setupbodyfont[pagella]
%\setupbodyfont[scholas]
\setupbodyfont[termes]

\starttext
  \newbox\MacMBox
  \setbox\MacMBox\hbox{M}
  \newbox\MacCBox
  \setbox\MacCBox\hbox{c}
  \newbox\MacKernBox
  \setbox\MacKernBox\hbox{\inframed[offset=\zeropoint, width=fit]{Mc}}

  \def\MacDelta{\dimexpr\wd\MacKernBox-\wd\MacMBox-\wd\MacCBox\relax}
  \def\MacUWidth{\dimexpr\wd\MacCBox-.75\MacDelta\relax}
  \def\MacRule{\vrule width \MacUWidth height .03em depth \zeropoint \relax}
  \def\MacKern{\dimexpr\wd\MacKernBox-\wd\MacMBox-\wd\MacCBox\relax}

  \def\Mac{%
M{%
  \dontleavehmode{\raisebox{\dimexpr\ht\MacMBox-\ht\MacCBox}\hbox{c}}%
  \kern-1.04\MacUWidth
  \MacRule
  \kern.08\MacUWidth
}%
  }

  \scale[scale=5000]{\Mac Anulty}
  \Mac Anulty
\stoptext

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] C with macron

2022-08-24 Thread Thangalin via ntg-context
Another nice solution, Pablo, thank you.

The macron is shifted a little too far to the left and needs a raisebox to
align the top of the C with the M.

https://tex.stackexchange.com/a/364027/2148

Hans' solution is pretty close. Here's what the LaTeX folks made:

https://i.stack.imgur.com/CRaam.png

I've tweaked some numbers to get a pretty decent result for this particular
font:

\starttext
M{\dontleavehmode{\raisebox{.45ex}\hbox{\scale[sx=1.1,sy=1.1]{c\hskip-1ex
{\dontleavehmode{\raisebox{0ex}\hbox{\hl[.4]}}Anulty

Mc̲Anulty
\stoptext
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Curling straight quotation marks

2022-08-24 Thread Thangalin via ntg-context
>
>
> Just use \quotation and \quote, then you have the right settings for
> many languages and can also be sure that quotes get closed and are
> consistent over the whole document.
>

Thanks Hraban.

That won't work with my workflow. I edit in Markdown (plain text),
transform to XML, then pass the XML to ConTeXt. When I edit the document, I
want to use ' and " without tying the document to TeX. This gives me a
complete separation of content from presentation logic.

Figured it might be helpful if others have the same workflow.

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] C with macron

2022-08-24 Thread Thangalin via ntg-context
Are the c and _ supposed to be separated like that?

https://i.ibb.co/0DsPK1P/mc.png

What would I have to change to put the c above the _?

On Wed, Aug 24, 2022 at 12:49 AM Thangalin  wrote:

> Nice!
>
> I had gotten as far as:
>
> \starttext
> M{\dontleavehmode{\raisebox{.55ex}\hbox{c}}}\hskip-1ex
> {\dontleavehmode{\raisebox{.25ex}\hbox{\hl[.45]}}Anulty
> \stoptext
> It looks pretty close to the LaTeX version. Fixing the name in situ is
> much better.
>
> Thank you!
>
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] C with macron

2022-08-24 Thread Thangalin via ntg-context
Nice!

I had gotten as far as:

\starttext
M{\dontleavehmode{\raisebox{.55ex}\hbox{c}}}\hskip-1ex
{\dontleavehmode{\raisebox{.25ex}\hbox{\hl[.45]}}Anulty
\stoptext
It looks pretty close to the LaTeX version. Fixing the name in situ is much
better.

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] C with macron

2022-08-23 Thread Thangalin via ntg-context
Hi again,

Re: https://tex.stackexchange.com/q/364024/2148

How do you typeset a C with a macron below?

\starttext
M\withmacron{c}Anulty
\stoptext

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] Curling straight quotation marks

2022-08-23 Thread Thangalin via ntg-context
Hey folks,

I re-wrote the algorithm KeenWrite uses for curling straight quotes. The
new algorithm is fairly robust with respect to North American and British
English. Could use help finding edge cases:

https://whitemagicsoftware.com/keenquotes/

I use it for preprocessing documents prior to passing them to ConTeXt.

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] String substitution using regular expressions and backreferences

2022-08-01 Thread Thangalin via ntg-context
Good point, Wolfgang.

The Markdown is translated to XHTML then typeset as XML using the setups
listed here:

https://github.com/DaveJarvis/keenwrite-themes/tree/main/xhtml
Having an XML string replacement solution would be great. I suppose that
would help prevent substitutions within pre and code blocks, too, 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 / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] String substitution using regular expressions and backreferences

2022-08-01 Thread Thangalin via ntg-context
Hi list,

I'm looking to perform text replacements.

\definereplacement[SubstPostmeridian][
  match={[Pp].[Mm].]},
  replace={\cap{pm}}
]

The \replaceword command doesn't handle periods well. The translate module
doesn't seem flexible enough to cover edge cases. Consider the following
example document containing both sample inputs and sample outputs:

\starttext
  {\bf Markdown Input}

  Our grandmother clock rang 11 p.m. and we fled.

  Our grandmother clock rang 11 p.m., so we fled.

  Our grandmother clock rang 11 p.m. We fled.

  \blank[big]

  {\bf \ConTeXt{} Output}

  Our grandmother clock rang 11 \cap{pm} and we fled.

  Our grandmother clock rang 11 \cap{pm}, so we fled.

  Our grandmother clock rang 11 \cap{pm}. We fled.
\stoptext

It would be most convenient to write:

% Strip periods from p.m.
\definereplacement[SubstPostmeridianLowercase][
  match={[Pp].[Mm]. ([^:upper:])},
  replace={\cap{pm} \1}
]

% Preserve terminal period for p.m. (e.e. cummings notwithstanding)
\definereplacement[SubstPostmeridianTerminal][
  match={[Pp].[Mm]. ([:upper:])},
  replace={\cap{pm}. \1}
]

% Apply a macron for lowercase 'c' (McAnulty, McGenius, etc.)
% Well, not quite a macron: https://tex.stackexchange.com/q/364024/2148
\definereplacement[SubstMac][
  match={Mc([:upper:]\w)},
  replace={M\macronbelow{c}\1}
]

The \1 may be problematic. Other sigils include $1 and #1, which may also
have issues.

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Set up external figure for particular image type

2022-08-01 Thread Thangalin via ntg-context
Got it working. Complete solution:

\setupexternalfigures[
  location={local,global,default},
  width=\textwidth
]\defineexternalfigure[svg][width=1cm]\defineexternalfigure[jpg][width=2cm]\defineexternalfigure[png][width=4cm]
% Won't be applied because there's no process action.% Default
(\textwidth) is used, as defined
above.\defineexternalfigure[pdf][width=6cm]
\starttexdefinition includegraphics #1
  \splitfilename{#1}

  \processaction[\splitofftype][
jpg=>{\externalfigure[#1][jpg]},
png=>{\externalfigure[#1][png]},
svg=>{\externalfigure[#1][svg][conversion=mp]},
default=>{\externalfigure[#1]},
unknown=>{\externalfigure[#1]}
  ]\stoptexdefinition
\starttext
  \includegraphics{kitten.jpg}
  \includegraphics{mill.png}
  \includegraphics{cow.pdf}
  \includegraphics{tiger.svg}\stoptext

Image files attached.
Thanks again!
<>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Set up external figure for particular image type

2022-07-18 Thread Thangalin via ntg-context
Thank you, Wolfgang.

That looks promising.

SVG files are converted using MetaPost. I thought the following would work:

svg=>{\externalfigure[#1][svg][conversion=mp]}

Is there anything else that needs to happen to ensure SVG files are piped
through MetaPost?

Thanks again!



> \setupexternalfigures [location={local,global,default}]
>
> \defineexternalfigure [jpg] [width=4cm]
> \defineexternalfigure [png] [width=8cm]
>
> \starttexdefinition includegraphics #1
>
> \splitfilename{#1}
>
> \processaction
> [\splitofftype]
> [jpg=>{\externalfigure[#1][jpg]},
>  png=>{\externalfigure[#1][png]},
>  default=>{\externalfigure[#1]},
>  unknown=>{\externalfigure[#1]}]
>
> \stoptexdefinition
>
> \starttext
>
> \includegraphics{hacker.jpg}
>
> \includegraphics{mill.png}
>
> \includegraphics{cow.pdf}
>
> \stoptext
>
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Set up external figure for particular image type

2022-07-18 Thread Thangalin via ntg-context
Of course, you could also use pandoc to go directly to ConTeXt; that is
> currently my preferred way of producing PDF from Markdown.
>

Thanks Albert!

I'm going to stick with my desktop text editor, KeenWrite
, rather than use shell scripts
 and
pandoc.

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Set up external figure for particular image type

2022-07-18 Thread Thangalin via ntg-context
Thanks, Rik.

Not using Pandoc. I was using Pandoc up until 2020:

https://dave.autonoma.ca/blog/2019/05/22/typesetting-markdown-part-1/

I've since authored KeenWrite <https://github.com/DaveJarvis/keenwrite>,
which uses flexmark-java <https://github.com/vsch/flexmark-java> to
generate XHTML documents from Markdown. The only additions I've made to the
library is to add support for Pandoc's annotation syntax (:::).

That said, I'm also a firm believer in not duplicating information. The
information (file name extension) is already available in the documents, so
adding a classification on top of the extension feels redundant.

Thanks for the suggestion!

On Tue, Jul 12, 2022 at 12:18 PM Rik Kabel via ntg-context <
ntg-context@ntg.nl> wrote:

>
> On 2022-07-12 14:11, Thangalin via ntg-context wrote:
>
> Thank you for the suggestion Hraban.
>
> The source comes from Markdown, which is converted to XML, then typeset
> using ConTeXt. There's no Markdown-specific mechanism to relate images to a
> particular external figure definition, unfortunately. All images use the
> same syntax and are treated the same way. The only part that differs is the
> file name extension (and header within the file).
>
> One possibility would be something like:
>
> \setupexternalfigure[
> width=1em,
> height=1em,
> order={svg,pdf,png,jpg},
> location={local,default,global},
> ]
> \defineexternalfigure[png][
> width=\textwidth,
> height=\textheight,
> ]
> \unprotect
> \let\old_externalfigure=\externalfigure
> \tolerant\def\externalfigure[#1]#,[#2]#,[#3]{%
> \doifelseinstring{.png}{#1}{%
> \old_externalfigure[#1][png][#2]%
> }{%
> \doifelsefileexists{#1.png}{%
> \old_externalfigure[#1.png][png][#2]%
> }{%
> \old_externalfigure[#1][#2][#3]%
> }%
> }%
> }\protect
>
> See: https://tex.stackexchange.com/a/650221/2148
>
> I was wondering if there was a simpler or a solution that's more the
> ConTeXt-way?
>
> Thanks again!
>
>
> Assuming that Pandoc markdown is being used, you should be able to set
> class attributes on each image. You can then associate external figure
> definitions with specific classes, and process each individually. (Pandoc
> user guide, link_attributes
> <https://pandoc.org/MANUAL%202.html#extension-link_attributes>)
>
> --
> Rik
>
>
> ___
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
>
> ___
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Set up external figure for particular image type

2022-07-12 Thread Thangalin via ntg-context
Thank you for the suggestion Hraban.

The source comes from Markdown, which is converted to XML, then typeset
using ConTeXt. There's no Markdown-specific mechanism to relate images to a
particular external figure definition, unfortunately. All images use the
same syntax and are treated the same way. The only part that differs is the
file name extension (and header within the file).

One possibility would be something like:

\setupexternalfigure[
width=1em,
height=1em,
order={svg,pdf,png,jpg},
location={local,default,global},
]
\defineexternalfigure[png][
width=\textwidth,
height=\textheight,
]
\unprotect
\let\old_externalfigure=\externalfigure
\tolerant\def\externalfigure[#1]#,[#2]#,[#3]{%
\doifelseinstring{.png}{#1}{%
\old_externalfigure[#1][png][#2]%
}{%
\doifelsefileexists{#1.png}{%
\old_externalfigure[#1.png][png][#2]%
}{%
\old_externalfigure[#1][#2][#3]%
}%
}%
}\protect

See: https://tex.stackexchange.com/a/650221/2148

I was wondering if there was a simpler or a solution that's more the
ConTeXt-way?

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] Set up external figure for particular image type

2022-07-08 Thread Thangalin via ntg-context
A document has a mix of SVG and PNG images. Changing the parameters for
`\setupexternalfigure` affects both SVG and PNG images. Consider the
following code:

\setupexternalfigures[
  order={svg,pdf,png,jpg},
  location={local,default,global},
  directory={images},
  maxwidth=\textwidth,
  maxheight=0.4\textheight
]

I'd like to change the `maxheight` option for only PNG images, such as:

\setupexternalfigure[
  method=png,
  maxwidth=\textwidth,
  maxheight=\textheight,
]

However, this affects SVG images as well.

How do you apply different external figure setups based on image type?

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] SVG text alignment issue

2022-06-29 Thread Thangalin via ntg-context
Here's the formal rule:

https://www.w3.org/TR/SVG11/coords.html#TransformAttribute

rotate( [ ]), which specifies a rotation by
 degrees about a given point. If optional parameters  and
 are not supplied, the rotation is about the origin of the current user
coordinate system. The operation corresponds to the matrix [cos(a) sin(a)
-sin(a) cos(a) 0 0]. If optional parameters  and  are supplied, the
rotation is about the point (cx, cy). The operation represents the
equivalent of the following specification: translate(, )
rotate() translate(-, -).

It looks like cx/cy, if not present, mean to rotate the text about its
origin, which I would take to be width/2 and height/2. They define the
rotation matrix as [cos(a) sin(a) -sin(a) cos(a) 0 0], where a is the angle:

https://www.w3.org/TR/SVG11/coords.html#RotationDefined

It appears as though LMTX is rotating around the baseline, rather than the
central point of the text's bounding box. (I thought that (cap height +
descender height) / 2 was the middle, but I suppose that wouldn't account
for diacritics.)

Thanks for looking into this!

On Wed, Jun 29, 2022 at 2:24 PM Hans Hagen via ntg-context <
ntg-context@ntg.nl> wrote:

> On 6/29/2022 8:48 PM, Thangalin wrote:
>
> > To me, it looks like the text, after a rotational transform, is being
> > written to the baseline rather than (cap height + descender height) / 2,
> > which seems to be a MetaPost conversion issue? There's another, possibly
> > related issue, which I'll provide in a separate thread.
> Where is that rediculous (rather font version sensitive) rule defined?
> In all test i did so far baseline works ok.
>
> Btw, it is sort of baffling what applications spit out when it comes to
> svg (and exp text). The cod being meant for machines "eyes" only is not
> really an excuse.
>
> 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
___


[NTG-context] SVG text clipping issue

2022-06-29 Thread Thangalin via ntg-context
Text that's tight against its viewbox gets clipped:

https://i.ibb.co/BGQVzzx/text-clipped.png

Here's the code:

% SOF
\startbuffer[svg]
http://www.w3.org/2000/svg;
   xmlns:svg="http://www.w3.org/2000/svg;>
  
  16p13.3

\stopbuffer

\starttext
   \placefigure[]{}{\includesvgbuffer[svg][conversion=mp]}
\stoptext
% EOF
___
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] SVG text alignment issue

2022-06-29 Thread Thangalin via ntg-context
Thanks for checking this. Unfortunately, introducing \hbox didn't work; the
text is still off-center with respect to the vertical line:

https://i.ibb.co/hYGfdgZ/text-align.png

For comparison, the SVG file loaded into Inkscape appears similar to:

https://i.ibb.co/KF3PBkw/inkscape-alignment.png

Note how the text is vertically centered above the vertical line.

To me, it looks like the text, after a rotational transform, is being
written to the baseline rather than (cap height + descender height) / 2,
which seems to be a MetaPost conversion issue? There's another, possibly
related issue, which I'll provide in a separate thread.

Here's the code:

% SOF
\pushoverloadmode \unprotect

\permanent\tolerant\protected\def\includesvgfile[#1]#*[#2]%
   {\hbox\bgroup % no \dontleavehmode
\getdummyparameters[\c!offset=\zeropoint,#2]%
\clf_includesvgfile{#1}\dimexpr\dummyparameter\c!offset\relax
\egroup}

\permanent\tolerant\protected\def\includesvgbuffer[#1]#*[#2]%
   {\hbox\bgroup % no \dontleavehmode
\getdummyparameters[\c!offset=\zeropoint,#2]%
\clf_includesvgbuffer{#1}\dimexpr\dummyparameter\c!offset\relax
\egroup}

\protect \popoverloadmode

\startbuffer[svg]
http://www.w3.org/2000/svg;
   xmlns:svg="http://www.w3.org/2000/svg;>
  
  16p13.3

\stopbuffer

\starttext
   \placefigure[]{}{\includesvgbuffer[svg][conversion=mp]}
\stoptext
% EOF
___
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] SVG text alignment issue

2022-06-28 Thread Thangalin via ntg-context
Thanks Aditya,

I tried your suggestion, but the result is the same. Here's the XML setup
for all images in the document:

\startxmlsetups xml:img
  \starttexcode
\placefloat[here,force]{}{%
  \hbox{\externalfigure[\xmlatt{#1}{src}][conversion=mp]}
}
  \stoptexcode
\stopxmlsetups

Here's the Markdown source document:

![](dna-02)

The source document is automatically exported as XHTML:


  


The XHTML is then passed to ConTeXt, whereupon the XML setup for images is
applied. The result is the same: the alignment for the text is off. Here's
an example where you can see the issue on the 16q24.3 text (far right):

https://i.ibb.co/WGh03Sr/genes.png

When the same SVG file is rendered using Apache Batik, the white text is
aligned to the middle of the black box.

Are there aAny other work-arounds?

Thank you!
___
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] SVG text alignment issue

2022-06-28 Thread Thangalin via ntg-context
In the following example, the line and text should be aligned to the
middle  when LMTX converts the SVG figure using MP. (Note that you may have
to install Roboto, but the font isn't the issue.)

% SOF
\startbuffer[svg]
http://www.w3.org/2000/svg;
   xmlns:svg="http://www.w3.org/2000/svg;>
  
  16p13.3

\stopbuffer

\starttext
   \placefigure[]{}{\includesvgbuffer[svg][conversion=mp]}
\stoptext
% EOF
___
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] Contractions in ligature suppression word list

2022-06-06 Thread Thangalin via ntg-context
Here's a short example (version 2022.05.11 11:36):

\setuplanguage[en][goodies={lang-en.llg}]

\starttext
  % Expected: no ligature; actual: as expected
  wolfish

  % Expected: no ligatures; actual: ligature
  wolfing
  wolfin'
  wolfin’
\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] Contractions in ligature suppression word list

2022-06-06 Thread Thangalin via ntg-context
Thanks for the response, Bruce.


1) The file you attached doesn't include the word "wolfing", nor "wolfin".
> I assume they need to be


The suffixes section accounts for this. Wolfing and wolfish both suppress
the ligature correctly.

I removed the comma separators, good catch. No difference, though.

Looks like I edited
/opt/context/tex/texmf-context/tex/context/patterns/mkxl/lang-en.llg
instead of the LMTX file. SMH.

I've now tried both files, lmtx and mkxl:

suffixes = [[
in
in'
in’
ing
]],

Wolfish works fine, the ligature is suppressed as expected. Wolfing,
wolfin, and wolfin' aren't suppressed. I'd have thought that defining the
word "wolf" with a suffix of "ing" (and variations thereof) would suppress
ligatures at the suffix boundary?

Maybe that's not the case. If so, then it means having to define all the
*f-ing words (heh) a few times for the different suffixes (in', in’, and
ing), which seems to defeat the purpose of separating suffixes?

Help is appreciated.
___
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] Contractions in ligature suppression word list

2022-06-05 Thread Thangalin via ntg-context
Attached are tweaked endings for words like "wolf" to include contracted
endings, but they are being ignored. This makes for a minor inconsistency:

  wolfing -- no ligature
  wolfish -- no ligature
  wolfin -- no ligature (incorrect spelling, though)
  wolfin' -- ligature

Any ideas? I tried adding various -in suffixes without luck:

suffixes = [[
in,
in',
in’,
ing
]],

See https://wiki.contextgarden.net/Ligatures#Word_suppression for an
example usage.

Thank you!


lang-en.llg
Description: Binary data
___
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] Typesetting modern Greek (UTF8) with ConTeXt

2022-06-05 Thread Thangalin via ntg-context
Not sure, but have you tried:

\definefallbackfamily [mainface] [serif] [Gentium Plus]
[range=greekandcoptic]

The wiki has a page on fallback fonts:

https://wiki.contextgarden.net/Command/definefontfallback
Searching for "greek" has numerous hits, including greekextended.

Have you verified that the Greek glyphs are in the fallback font you've
selected? Sometimes I'll use a site like FontDrop! to make sure that there
are, in fact, glyphs in the character ranges specified.

https://fontdrop.info/

Good luck!
___
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] Improving pandoc's ConTeXt output

2022-06-05 Thread Thangalin via ntg-context
Hi folks,

I would like to blog about it, but we are still tweaking the process.
>

I put together a multipart series about the process of going from Markdown
to Pandoc to ConTeXt:

https://dave.autonoma.ca/blog/2019/05/22/typesetting-markdown-part-1/

To speed up the "write > typeset > review" process, I developed KeenWrite:

https://github.com/DaveJarvis/keenwrite

Behind the scenes, KeenWrite uses a Java library similar to pandoc with
some additions, such as the ability to use pandoc's annotation syntax.

The biggest issue for rolling this out is providing users a way to easily
install ConTeXt in a cross-platform manner. At the moment, trying to export
from KeenWrite without a local ConTeXt install simply directs the user to
download and install the most appropriate version for their system.

We make use of the yaml preface in the markdown files especially for
> offers. The sales consultant only has to fill out the yaml part and
>

KeenWrite goes a bit beyond this to completely separate YAML variables from
the Markdown files. The text editor also provides a hierarchical editor for
YAML trees along with the ability to reference those YAML variables when
building. This can be accomplished from the user preferences or the
command-line:

https://github.com/DaveJarvis/keenwrite/blob/master/docs/cmd.md

What's more is that the variables can be inserted into documents, isolating
duplicated information to a single location: the externalized YAML data.
Great for templating.

One of the reasons I wrote KeenWrite was so that I could simplify the use
of variables within documents. In the Typesetting Markdown series, the
build script essentially performs:

   1. pandoc document-vars.md + vars.yaml > document-final.md
   2. pandoc document-final.md > document.tex
   3. context document.tex > document.pdf

Using KeenWrite, this process becomes:

keenwrite --input document-vars.md --theme=boschet --variables vars.yaml
--output document.pdf

This ends up converting an annotated Markdown file into XML then uses
ConTeXt to typeset the XML using a particular theme.KeenWrite has a number
of themes, some basic, some advanced:

https://github.com/DaveJarvis/keenwrite-themes/

This allows me to eliminate the dependency on both Pandoc and Inkscape.
I've also encountered some problems with SVG to MP, but Hans is usually
quick to fix the bugs given a minimal working example that pinpoints the
problem. Either way, it's possible to retain the Inkscape step by telling
ConTeXt not to use the MP conversion, as you alluded to, Juh.

There are other handy features built into KeenWrite. For example, it's
possible to separate chapters into individual files. As long as they are
named something natural (ch1.md, ch2.md, a_chap.md, b_chap.md), they'll get
collated in the correct order. From there, Control+P will export to PDF for
the current file and Control+Shift+P will combine all chapters into a
single PDF.

Then there's the F12 button that captures errors and output from ConTeXt.

If you check it out, let me know what you think!

Cheers!
___
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] ignore not closed tags in XML input

2022-05-18 Thread Thangalin via ntg-context
Hey Pablo,

> One of the not irrelevant tasks for me is finding examples of XML code.

To clarify, XHTML documents *are* XML documents. XHTML happens to use a
standardized set of XML element and attribute names. All XHTML examples are
also XML examples.

> But my worries came from having to sanitize HTML sources (which aren’t

That was discussed in the blog post: finding a source of well-formed XHTML
documents. There are a number of tools to sanitize HTML, as mentioned in
the thread. KeenWrite uses the Java-based JSoup library https://jsoup.org/
to sanitize HTML and then create an XHTML version.

All the best!
___
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] ignore not closed tags in XML input

2022-05-17 Thread Thangalin via ntg-context
> I wanted to write an introduction on how to typeset XML sources with
> ConTeXt (at least, in Spanish).
>

See: https://dave.autonoma.ca/blog/2020/04/11/project-gutenberg-projects/

It's English, but describes a fair amount of what you're probably looking
to accomplish, and there are all sorts of free translation services now.


> One of the main issues I face is to find examples.
>

See:

https://wiki.contextgarden.net/XML
https://wiki.contextgarden.net/Getting_Started_with_XML_and_ConTeXt_using_TEXML

And themes for my text editor, KeenWrite, in particular:

https://github.com/DaveJarvis/keenwrite-themes/tree/main/xhtml
https://github.com/DaveJarvis/keenwrite-themes/tree/main/tarmes
https://github.com/DaveJarvis/keenwrite-themes/tree/main/boschet


> Maybe all XML handling is way more complex than I originally thought.
>

It takes some elbow grease. Conceptually, it's essentially mapping XML
elements to xmlsetups, which are used to apply typesetting instructions.

Cheers!
___
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] SVG style ignored after double semicolon

2022-05-09 Thread Thangalin via ntg-context
That's another good idea Heinrich.

I certainly could invoke another application to sanitize the SVG, but that
brings with it a number of additional problems: Does the user have it
installed properly? Is it cross-platform? Additionally, the typesetting
code (in Java) would have to be updated to call out to sanitize the file,
plus introducing more error handling for when sanitizing goes wrong.
Cleaning up the input document feels more like a band-aid than solving the
underlying problem, which is to relax the regex ConTeXt uses to parse the
style attribute.

I'm pretty sure I can provide a patch for the regex, I just need to know
how to get debugging information printed to the console when compiling the
document using the context command.

Any ideas about how to log strings after modifying mlib-svg.lmt? I tried
adding print/report statements, but none of them showed up. Does anyone
know if that's even the right file to change to start looking into the
issue?

Thanks again!
___
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] SVG style ignored after double semicolon

2022-05-09 Thread Thangalin via ntg-context
> gsed ’s/;;/;/g' in.svg > out.svg

If a user has an SVG text element where ";;" goes into the document, then
that'd make for an awfully awkward user experience and obscure bug to fix.
For example: plot(rnorm(5), xlab=";;")

Meaning, the document must be loaded, parsed, and all style/class elements
sanitized. KeenWrite performs real-time rendering of documents. The code to
preview the document is shared by the code that exports to XHTML for
ConTeXt to render. Effectively, this would be parsing the SVG document
twice, which would bog down the previewer.

Changing the regexes in mlib-svg.lmt to forgive empty styles seems like the
most efficient and flexible approach, which follows the robustness
principle: "be conservative in what you send, be liberal in what you
accept."

The specs for CSS styles are ambiguous as to whether property declarations
are required:

https://www.w3.org/TR/2001/PR-SVG-20010719/styling.html#StyleAttribute

I've since learned that Renjin uses JFreeSVG to produce the SVG file. I've
logged a bug against JFreeSVG to avoid the double semicolon. However, this
means waiting for a fix from JFreeSVG and then waiting for that fix to be
integrated into Renjin. It'll probably be months before that'll happen.
(The last release of Renjin was like 10 months ago.)

Thoughts?
___
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] SVG style ignored after double semicolon

2022-05-09 Thread Thangalin via ntg-context
Hi Heinrich,

Use the SVG I provided. R and Renjin use two different SVG generators.
Renjin uses JFreeSVG when exporting as SVG. As you pointed out, there are
no issues with R because it will export an SVG file without any double
semicolons.

In other words, try this:

\startbuffer[svg]

  

\stopbuffer

\starttext
  \placefigure{}{\includesvgbuffer[svg][conversion=mp]}
\stoptext

If you get a black square, that's the bug. If you get a white square, then
there's something different about our environment setups.

Cheers!


On Mon, May 9, 2022 at 1:55 AM Heinrich Paeßens  wrote:

> Hi there
>
> I can compile your example without any tweaks, hence could not reproduce
> any error.
>
> cheers
> Heinrich
>
> ———
>
> R version 4.2.0 (2022-04-22) -- "Vigorous Calisthenics"
> Copyright (C) 2022 The R Foundation for Statistical Computing
> Platform: x86_64-apple-darwin17.0 (64-bit)
>
> [R.app GUI 1.78 (8075) x86_64-apple-darwin17.0]
>
> > svg("/Users/hp/filename.svg");
> > plot(rnorm(200));
> > dev.off()
> null device
>   1
> >
>
> ———
>
> % !TEX program = lmtx
>
> \starttext
>   \externalfigure[/Users/hp/filename.svg][conversion=mp]
> \stoptext
>
> ———
>
>
>
>
> On 9. May 2022, at 08:10, Thangalin via ntg-context 
> wrote:
>
> Here's a screenshot comparing ConTeXt's PDF output (left) with KeenWrite's
> preview for the same SVG document:
>
> https://i.ibb.co/68nqwrg/render-r-plot.png
>
> I've filed a bug against Renjin's SVG exporter.
>
> Any guidance on how to fix this is greatly appreciated.
>
>
> ___
> 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
___


Re: [NTG-context] SVG style ignored after double semicolon

2022-05-09 Thread Thangalin via ntg-context
Here's a screenshot comparing ConTeXt's PDF output (left) with KeenWrite's
preview for the same SVG document:

https://i.ibb.co/68nqwrg/render-r-plot.png

I've filed a bug against Renjin's SVG exporter.

Any guidance on how to fix this is greatly appreciated.
___
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] SVG style ignored after double semicolon

2022-05-08 Thread Thangalin via ntg-context
Hi again,

In tex/texmf-context/tex/context/base/mkxl/mlib-svg.lmt the following regex
appears a few times (line 1502, 1556, and 1570):

gmatch(VAR,"%s*([^:]+):%s*([^;]+);?")

It may be helpful to first normalize the string by appending a semicolon to
the end, allowing for:

for w in (VAR .. ";"):gmatch("([^;]*);") do ...

Splitting 'w' afterwards on the colon within key:value pairs would still be
necessary, so maybe that approach is a wash.

Aside, when I made changes to the file, I couldn't get either a report() or
a print() statement to show up in the output, even when running with
--debug. Any hints on how to sprinkle debug info into the code? Or was I
barking up the wrong source file?

Cheers!

On Sun, May 8, 2022 at 1:33 AM Thangalin  wrote:

> Hey hey,
>
> The following produces a filled square, rather than an empty one:
>
> \startbuffer[svg]
> 
>style="stroke:rgb(0,0,0);;fill:none" />
> 
> \stopbuffer
>
> \starttext
>   \placefigure{}{\includesvgbuffer[svg][conversion=mp]}
> \stoptext
>
> Remove the extra semicolon to get the expected result:
>
> 
>style="stroke:rgb(0,0,0);fill:none" />
> 
>
> It appears that a style immediately following two semicolons is ignored.
>
> The SVG was generated using the following R code:
>
> svg("filename.svg");
> plot(rnorm(200));
> dev.off()
>
> Arguably, R's SVG routines could be a bit tighter. Can the MP SVG parser
> code be relaxed to skip "empty" semicolons?
>
> $ context --version
> mtx-context | current version: 2022.05.02 16:19
>
> Much appreciated.
>
___
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] SVG style ignored after double semicolon

2022-05-08 Thread Thangalin via ntg-context
Hey hey,

The following produces a filled square, rather than an empty one:

\startbuffer[svg]

  

\stopbuffer

\starttext
  \placefigure{}{\includesvgbuffer[svg][conversion=mp]}
\stoptext

Remove the extra semicolon to get the expected result:


  


It appears that a style immediately following two semicolons is ignored.

The SVG was generated using the following R code:

svg("filename.svg");
plot(rnorm(200));
dev.off()

Arguably, R's SVG routines could be a bit tighter. Can the MP SVG parser
code be relaxed to skip "empty" semicolons?

$ context --version
mtx-context | current version: 2022.05.02 16:19

Much appreciated.
___
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] two requests for ConTeXt

2022-04-09 Thread Thangalin via ntg-context
> > The second feature would be the addition of an "emoji" range for font
> > fallbacks.
>
> +2

+π
___
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] Switching fonts changes framedtext justification

2022-04-08 Thread Thangalin via ntg-context
I certainly can't claim credit for the speech bubbles!

https://wiki.contextgarden.net/index.php?title=Speech_bubble
https://mailman.ntg.nl/pipermail/ntg-context/2011/056496.html

I modified Wolfgang's code to provide a control for the tail, and,
thanks to Pablo, a decent font for embedding emojis.

There are a couple of problems with the speech bubbles that could use
fixing. First, the ability to have a fixed offset for the tail (e.g.,
2 em from the left and 2 em from the right). Second, when the speech
bubble is too short (e.g., a single emoji), the tail gets mangled.

Here's a screenshot showing speech bubbles using annotated Markdown:

https://github.com/DaveJarvis/keenwrite/releases

The ::: bubbletx eventually becomes a startbubbletx/stopbubbletx pair.

Greets!

On Fri, Apr 8, 2022 at 12:27 AM Henning Hraban Ramm via ntg-context
 wrote:
>
> Am 08.04.22 um 02:25 schrieb Thangalin via ntg-context:
> > Works flawlessly, thank you!
> >
> > Here's a demo with left and right speech bubbles:
>
> Thank you for the speech bubbles! This is something I need for the
> messenger chats in my novel. Will be a good learning experience to adapt
> your solution to my ideas.
>
> Hraban
> ___
> 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
___


Re: [NTG-context] Switching fonts changes framedtext justification

2022-04-07 Thread Thangalin via ntg-context
Works flawlessly, thank you!

Here's a demo with left and right speech bubbles:

\definefont [TextFontEmoji] [OpenSansEmoji]

\startuseMPgraphic{TextBubble}{side}
  z1 = (0, 0) ;
  z2 = (OverlayWidth, 0) ;
  z3 = (OverlayWidth, OverlayHeight) ;
  z4 = (0, OverlayHeight) ;

  offset := 1 ;
  tail := 1 ;

  % Flip the tail's location and direction.
  if \MPvar{side} = 1:
offset := 5 ;
tail := -1 ;
  fi

  (offset/6)[x1,x2] = x8 + .25cm * tail = x7 + .25cm = x9 - .25cm ;
  y7 =  0cm ;
  y8 = -.5cm ;
  y9 =  0cm ;

  path p ;
  p = (z1--z7--z8--z9--z2--z3--z4--cycle) cornered .25cm ;
  draw p withpen pencircle scaled 0.75 ;

  setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\defineframedtext[TextBubbleFrame][
  style=TextFontEmoji,
  frame=off,
  width=.618\textwidth,
  autowidth=force,
  offset=.75em,
  after={\blank[2*big]},
]

% Receive text (left-facing).
\defineoverlay[TextBubbleRxOverlay][\useMPgraphic{TextBubble}{side=0}]
\defineframedtext[TextBubbleRxFrame][TextBubbleFrame][
  background=TextBubbleRxOverlay,
  location=left,
]

% Send text (right-facing).
\defineoverlay[TextBubbleTxOverlay][\useMPgraphic{TextBubble}{side=1}]
\defineframedtext[TextBubbleTxFrame][TextBubbleFrame][
  background=TextBubbleTxOverlay,
  location=right,
]

% Map XHTML class names to start/stop environments.
\definestartstop[bubblerx][
  before={\startnarrower\startTextBubbleRxFrame},
  after={\stopTextBubbleRxFrame\stopnarrower},
]

\definestartstop[bubbletx][
  before={\startnarrower\startTextBubbleTxFrame},
  after={\stopTextBubbleTxFrame\stopnarrower},
]

\starttext
  \startbubblerx
Welcome to the future, human !  \input zapf
  \stopbubblerx

  \startbubbletx
Welcome to the future, human !  \input zapf
  \stopbubbletx
\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] Switching fonts changes framedtext justification

2022-04-07 Thread Thangalin via ntg-context
Appreciated, Pablo.

The output remains unjustified:

https://i.ibb.co/dM9LFWZ/future-human.png

$ find /usr/share/fonts/ -name "*Emoj*"
/usr/share/fonts/emoji/OpenSansEmoji.otf

$ context --version
mtx-context | current version: 2022.04.01 09:37

$ cat ~/bin/fontcache
#!/usr/bin/env bash

fc-cache -fv
mtxrun --generate
mtxrun --script fonts --reload

$ cat ~/bin/fontgrep
#!/usr/bin/env bash
mtxrun --script fonts --list --all --name $1 | cut -d" " -f1

$ fontgrep emoji
identifier

opensansemoji
opensansemojinormal
opensansemojiregular

Any other suggestions?

Thank you!
___
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] Switching fonts changes framedtext justification

2022-04-04 Thread Thangalin via ntg-context
> The font is too old, but the TTF version works just fine on both Linux
> and Windows.

No dice with LMTX 2022.04.01 09:37 and the TTF file. Using the TTF,
the emojis don't appear, but the text is justified. Using the OTF, the
emojis appear, but the text is unjustified.

What version of ConTeXt are you using, Pablo?
___
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] Switching fonts changes framedtext justification

2022-04-04 Thread Thangalin via ntg-context
Hi again,

> > The .otf file is from:
> > https://github.com/MorbZ/OpenSansEmoji
>
> That’s 9 years old. The linked resources were updated later and are
> still outdated. There must be a better Emoji font out there?

You would think so. I haven't found any that are free for
personal/commercial, open-source, black & white, and work with
ConTeXt. Here's one list of various fonts:

https://graphicdesign.stackexchange.com/a/117696/4902

The Noto Color Emoji font includes Noto B Emojis:

https://github.com/googlefonts/noto-emoji/raw/main/fonts/NotoColorEmoji.ttf

But it seems the Unicode glyphs and Latin glyphs won't appear at the
same time. (Each glyph would have to be wrapped in its own font macro.
Open Sans Emoji has glyphs that are a bit more print-friendly and
supports both Latin and Emoji glyphs.)

Thanks for taking a look.
___
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] Switching fonts changes framedtext justification

2022-04-03 Thread Thangalin via ntg-context
Confirmed there is a font issue with LMTX.

$ context --version
mtx-context | current version: 2022.04.01 09:37

The issue was also present with version 2021.11.30.

> Are you sure it's not a tolerance issue?

Pablo's example also doesn't justify, so \framedtext is a red herring.

The .otf file is from:

https://github.com/MorbZ/OpenSansEmoji

Thanks everyone!
___
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] Switching fonts changes framedtext justification

2022-04-02 Thread Thangalin via ntg-context
Hi all,

The following code produces framed text areas, each having different
justification:

\definefont [TextFontEmoji] [OpenSansEmoji]
\definefontfamily [TextFont] [rm] [LibreBaskerville]
\setupbodyfont [TextFont]

\starttext
  \startframedtext
\TextFontEmoji
\input ward
  \stopframedtext

  \startframedtext
\input ward
  \stopframedtext
\stoptext

How would you ensure that both text areas remain fully justified?

Thank you!
___
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] Typesetting unicode characters

2022-03-31 Thread Thangalin via ntg-context
On the rare chance that someone else stumbles across this problem ...

By default, Java's Xalan transformer for creating XML documents does not
correctly encode emojis. Instead of  for the thumbs up emoji,
Xalan encodes it as . As Arthur pointed out, this is not a
valid entity encoding.

One solution is to use Saxonica's Saxon 11 transformer, which produces the
expected output:

  


  the  emoji

  

In Java, switching to Saxon entails installing the Jar files for Saxonica
and its resolvers. Then set the system property before invoking the XML
transformer: System.setProperty( "javax.xml.transform.TransformerFactory",
"net.sf.saxon.TransformerFactoryImpl" );

ConTeXt handles the emoji from the transformed XML file without any issues.

Thank you, Arthur.
___
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] Typesetting unicode characters

2022-03-30 Thread Thangalin via ntg-context
Hi list,

An XML document includes the  emoji, as shown in the following snippet:


  
  

  Thumbs up emoji: 

  

The document is typeset using ConTeXt, but the thumbs up emoji isn't in the
PDF. Neither Noto Emoji nor Open Sans Emoji fonts will render.

Does anyone have a minimal example that shows how to typeset such escaped
entities?

When the emoji is added directly to a document, it works fine:

\definefont [TextFontEmoji] [opensansemoji]

\starttext
  \TextFontEmoji{Thumbs up emoji: }
\stoptext

Is there something special that needs to be set for ConTeXt to interpret
the escaped unicode values as an emoji?

Thank you!
___
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] Dynamic document variables from metadata

2022-01-02 Thread Thangalin via ntg-context
Thank you, Hans.

Updates are in place:

https://github.com/DaveJarvis/keenwrite/releases
https://github.com/DaveJarvis/keenwrite-themes/releases

On Sun, Jan 2, 2022 at 3:11 AM Hans Hagen  wrote:

> On 1/2/2022 2:54 AM, Thangalin via ntg-context wrote:
> > Happy New Year!
> >
> > How would you implement a mechanism that takes arbitrary XHTML 
> > tags and produces document variables? Consider:
> >
> >  
> >
> > After running XML setups, the following would write "Nature":
> >
> >  \documentvariable{journal}
> >
> > The tricky part is doing this without pre-defining them. Here's a short,
> > self-contained example to help demonstrate:
> >
> > |\startbuffer[xdoc]> name="author"/> 
> > \stopbuffer \startxmlsetups xml:xhtml
> > \xmlsetsetup{\xmldocument}{*}{-}
> > \xmlsetsetup{\xmldocument}{html|body}{xml:*}
> > \xmlsetsetup{\xmldocument}{head}{xml:meta} \stopxmlsetups
> > \xmlregistersetup{xml:xhtml} \startxmlsetups xml:html
> > % "author" is a special setup, not generalized
> > \xmlfilter{#1}{/head/meta[@name='author']/command(xml:author)} % What
> > goes here to make this dynamic?
> > %\xmlfilter{#1}{/head/meta[@name='journal']/command(xml:journal)}
> > \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:author
> > \setupdocument[author={\xmlatt{#1}{content}}]
> > \setupdocument[metadata:author={\xmlatt{#1}{content}}]
> > \setupinteraction[author={\documentvariable{author}}] \stopxmlsetups %
> > How can this be generalized? %\startxmlsetups xml:journal
> > %\setupdocument[journal={\xmlatt{#1}{content}}] %\stopxmlsetups
> > \startxmlsetups xml:body \startdocument Author:
> > \documentvariable{author} \par Journal: \documentvariable{journal}
> > \stopdocument \stopxmlsetups \xmlprocessbuffer{main}{xdoc}{}|
> \startxmlsetups xml:setdocumentvariable
>\setupdocument[\xmlatt{#1}{name}={\xmlatt{#1}{content}}]
> \stopxmlsetups
>
> \startxmlsetups xml:author
>\setupdocument[author={\xmlatt{#1}{content}}]
>\setupdocument[metadata:author={\xmlatt{#1}{content}}]
>\setupinteraction[author={\documentvariable{author}}]
> \stopxmlsetups
>
> \startxmlsetups xml:html
>\xmlfilter{#1}{/head/meta/command(xml:setdocumentvariable)}
>\xmlfilter{#1}{/head/meta[@name='author']/command(xml:author)}
>\startdocument
>\xmlflush{#1}
>\stopdocument
> \stopxmlsetups
>
>
>
> -
>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] Dynamic document variables from metadata

2022-01-01 Thread Thangalin via ntg-context
Happy New Year!

How would you implement a mechanism that takes arbitrary XHTML  tags
and produces document variables? Consider:



After running XML setups, the following would write "Nature":

\documentvariable{journal}

The tricky part is doing this without pre-defining them. Here's a short,
self-contained example to help demonstrate:

\startbuffer[xdoc]


  
  



\stopbuffer
\startxmlsetups xml:xhtml
  \xmlsetsetup{\xmldocument}{*}{-}
  \xmlsetsetup{\xmldocument}{html|body}{xml:*}
  \xmlsetsetup{\xmldocument}{head}{xml:meta}\stopxmlsetups
\xmlregistersetup{xml:xhtml}
\startxmlsetups xml:html
  % "author" is a special setup, not generalized
  \xmlfilter{#1}{/head/meta[@name='author']/command(xml:author)}

  % What goes here to make this dynamic?
  %\xmlfilter{#1}{/head/meta[@name='journal']/command(xml:journal)}

  \xmlflush{#1}\stopxmlsetups
\startxmlsetups xml:author
  \setupdocument[author={\xmlatt{#1}{content}}]
  \setupdocument[metadata:author={\xmlatt{#1}{content}}]
  \setupinteraction[author={\documentvariable{author}}]\stopxmlsetups
% How can this be generalized?%\startxmlsetups xml:journal
  %\setupdocument[journal={\xmlatt{#1}{content}}]%\stopxmlsetups
\startxmlsetups xml:body
  \startdocument
Author: \documentvariable{author}

\par

Journal: \documentvariable{journal}
  \stopdocument\stopxmlsetups
\xmlprocessbuffer{main}{xdoc}{}


Thank you!
___
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] Blank lines discarded when \typing

2021-12-03 Thread Thangalin via ntg-context
Note the presence of double-spaced blank lines in the following document
and in the attached source file:

\setuptyping[numbering=line]
\starttext

\startbuffer[javacode]
try {
  final var num = stack.pop();

  if( num != null ) {
stack.push( blah );
  }


  return true;
}
\stopbuffer

\type{\typebuffer}:
\typebuffer[javacode]

\type{\typing}:
\starttyping
try {
  final var num = stack.pop();

  if( num != null ) {
stack.push( blah );
  }


  return true;
}
\stoptyping

\type{\typefile}:
\typefile{t.java}

\stoptext

There appear to be two issues.

First, \typefile produces what I'd consider the "correct" result, where the
double-spaced lines appear on the page as a double-space. Both the
\typebuffer and \typing commands ignore double-spacing. The double-spacing
is also ignored by \xmldisplayverbatim. How would you configure to give
\typebuffer, \typing, and \xmldisplayverbatim to honour double-spaces the
same way as \typefile?

Second, of lesser importance, is that the blank lines aren't numbered. This
makes the line numbers inconsistent with respect to IDEs. How would you
label all blank lines as well?

Out of curiosity, does the second issue relate to the first?

Thank you!
try {
  final var num = stack.pop();
  
  if( num != null ) {
stack.push( blah );
  }
  
  
  return true;
}
___
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] Syntax highlighting using LMTX

2021-12-02 Thread Thangalin via ntg-context
Hi all,

There are a few technical hurdles with using the t-vim module in LMTX.
First, users need to install the module using externally defined shell
scripts. Second, it's awkward to communicate to users how to install it,
especially for Windows users. Third, it likely requires installing vim, as
a separate step. Fourth, making general-purpose XML setups that optionally
rely on syntax highlighting when it is an optional install is a little
laborious.

If installing a module was as easy as "install.sh --module=t-vim" then that
would leap over most hurdles. Although there'd still be a dependency on
installing vim. Of course, it'd be pretty sweet if ConTeXt itself could
automatically install the necessary module when encountered (or provide a
command-line option to grant permissions to do so), but I understand that
that would be a hefty undertaking.

The following pages discuss creating syntax highlighters:

   - https://wiki.contextgarden.net/Verbatim_text
   - https://wiki.contextgarden.net/Custom_pretty_printer
   - https://tex.stackexchange.com/a/333620/2148

How would you go about creating a syntax highlighter for Java that can work
with LMTX? Specifically, I'd like to know:

   - Where do the files need to be saved? (e.g.,
   tex/texmf-context/tex/context/base/mkiv/)
   - What file name is required? (e.g., buff-imp-java.lua and
   buff-imp-java.mkiv)
   - How is the parser loaded? (e.g., \loadmarkfile{buff-imp-java} or
   \installprettytype[java][java])

Ultimately, this is going to be used with XML snippets along the lines of:

public final class Example {
  public static void main( String args[] ) {
  }
}

Having the ability to dynamically define the requisite start/stop
environments based on the class attribute would be rather convenient.

Thank you!
___
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] xml processing errors after latest upgrade

2021-12-01 Thread Thangalin via ntg-context
Confirmed that the following worked:

   1. Run: rm -rf /tmp/luatex-cache/   (your cache directory location will
   differ)
   2. Edit ./tex/texmf-context/tex/context/base/mkiv/scrn-ref.lua
   3. Replace line 15 to assign the empty function as Hans indicated
   4. Save the file
   5. Run: ./bin/mtxrun --generate
   6. Run: ./tex/texmf-linux-64/bin/context --make

Typesetting XML succeeds again.
___
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] \placeinitial to account for quotation mark

2021-09-25 Thread Thangalin via ntg-context
Henri Menke provided a partial solution:

\defineinitial[two][method={first,auto}]
\setuphead[chapter][
  after={\placeinitial[two]},
  page=no,
]

\starttext
\chapter{Harriet Tubman}
"Every great dream begins with a dreamer. Always remember, you have within
you the strength, the patience, and the passion to reach for the stars to
change the world.
\chapter{Eleanor Roosevelt}
Great minds discuss ideas; average minds discuss events; small minds
discuss people.
\stoptext

However, the leading quotation mark is gobbled. Is there any generic way of
detecting a leading quotation mark while keeping initial caps on the first
character?

Thank you!
___
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] \placeinitial to account for quotation mark

2021-09-06 Thread Thangalin via ntg-context
Hi list,

The following example shows a lettrine that stylizes a quotation mark:

\setuphead[chapter][
  after={\placeinitial},
  page=no,
]
\starttext\chapter{Harriet Tubman}
"Every great dream begins with a dreamer. Always remember, you have within
you the strength, the patience, and the passion to reach for the stars to
change the world.\chapter{Eleanor Roosevelt}
Great minds discuss ideas; average minds discuss events; small minds
discuss people.\stoptext

Without changing the text itself, how would you make the lettrine stylize
the E in Every while making the quotation mark retain the body font (i.e.,
much smaller and hang to the left, possibly protruding into the margin)?

For reference: https://tex.stackexchange.com/q/609544/2148

Thank you!
___
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] Initial caps with short paragraph

2021-07-08 Thread Thangalin
This has come up before on the mailing list, but I was wondering if LMTX
has a more elegant solution than using a transparent/invisible capture of
the drop-cap.

Consider:

\setupinitial[n=2, style=\tfd,
location=text]\setuphead[chapter][after={\placeinitial}]
\starttext
  \chapter

  Hello world!

  \input ward\stoptext

The output shows that the second paragraph is not indented beyond the
bounding box of the drop-cap, resulting in an overlap. This isn't a problem
when the first paragraph spans two or more lines.

Any ideas for how to resolve this without changing the content?

Thank you!
___
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] Straight Quotes / Curly Quotes

2021-06-18 Thread Thangalin
> In HTML you should be able to use  – I know that doesn’t work reliably
in browsers (some add straight quotes to my CSS-configured guillemets).

The Converter class maps token replacements:

https://github.com/DaveJarvis/keenquotes/blob/d6c9761f8fe1ae96391f25dc73be52050a148e37/src/main/java/com/whitemagicsoftware/keenquotes/Converter.java#L15

It'd be trivial to use  and , instead. For my purposes, HTML
entities work.

> Using \quotation / \quote I avoid typing quotation marks in most cases.

When writing plain text documents, adding TeX code or HTML code to
prescribe how the document should be presented is best avoided, so as to
keep the document decoupled from a particular tool chain. YMMV. A deeper
solution allows users to type the correctly curled quotes directly into the
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Straight Quotes / Curly Quotes

2021-06-18 Thread Thangalin
The csquotes package can curl straight quotes:

https://ctan.org/pkg/csquotes

I don't know how smart its smart quote feature is, though, with respect to
apostrophes.
___
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] Straight Quotes / Curly Quotes

2021-06-17 Thread Thangalin
Hraban,

> In what kind of workflows does your program make sense?

Have you looked around the web lately?

KeenWrite (https://github.com/DaveJarvis/keenwrite), my plain text editor,
can neither convert nor easily type curly quotes into the application.
Recently, I added ConTeXt integration for exporting to PDF files. ConTeXt
doesn't curl the quotes, which I found a little surprising (because LaTeX
has a quote curling package). Not seeing an obvious solution, I coded my
own library because all the other libraries I found were either not up to
the task or required a massive natural language parser dependency.

My workflow will be: Edit plain text in KeenWrite, export to XHTML, curl
the quotes, run ConTeXt to typeset XHTML.

Another workflow: Edit plain text in KeenWrite, export to XHTML, curl the
quotes, upload to CMS.

The problem is that when typewriters were invented, curly quotes didn't
make it onto the popular layouts. Then, after Unicode, curly closing single
quotes and curly apostrophes were not made unique. HTML entities get it
right, though, with l/rdquo, l/rsquo, and apos. C'est la vie.
___
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] Straight Quotes / Curly Quotes

2021-06-17 Thread Thangalin
I've written a Java-based lexer/parser that can convert straight quotes to
curly quotes for English prose. It's a one-pass algorithm (O(n)) that uses
neither look-behind nor regex. Here's a list of test cases it handles:

https://raw.githubusercontent.com/DaveJarvis/keenquotes/main/lib/src/test/resources/com/keenwrite/quotes/smartypants.txt

A test harness converted several Project Gutenberg texts quite well. The
folks at PG may be interested in using it themselves to help convert quotes
in older texts en masse. The source code is MIT-licensed:

https://github.com/DaveJarvis/keenquotes/

The code should port to Lua fairly easily, should anyone be interested in
adding a straight/curly quotation mark conversion module to ConTeXt.
(Similar to the LaTeX package, but without using regex.)

Cheers everyone!
___
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] KeenWrite 2.0

2021-05-10 Thread Thangalin
Running from the command-line requires the full edition of Liberica JDK,
which includes JavaFX. See:

https://github.com/DaveJarvis/keenwrite#other
https://bell-sw.com/pages/downloads/?version=java-16

Other OpenJDK versions do not include JavaFX. (JavaFX can be installed
separately for other OpenJDK versions, but it's a bit of a pain.) The
decision to remove JavaFX from the default Java distribution kind of pulled
the rug out from under a number of projects.

https://dave.autonoma.ca/blog/2020/06/29/write-once-build-anywhere/

Cheers!

On Mon, May 10, 2021 at 5:34 AM Hans Hagen  wrote:

> On 5/10/2021 11:46 AM, Floris van Manen wrote:
> >
> >
> > On 10/05/2021 07:40, Thangalin wrote:
> >> https://github.com/DaveJarvis/keenwrite#download
> >> <https://github.com/DaveJarvis/keenwrite#download>
> >>
> >> Stay safe everyone!
> >
> >
> > When launching from
> >
> > Linux vmz 5.11.0-7614-generic #15~1618626693~20.10~ecb25cd-Ubuntu SMP
> > Thu Apr 22 16:00:45 UTC  x86_64 x86_64 x86_64 GNU/Linux
> >
> > I get a warning:
> >
> > $ keenwrite.bin
> > OpenJDK 64-Bit Server VM warning: Option --illegal-access is deprecated
> > and will be removed in a future release.
> on windoes:
>
>  >java.exe --illegal-access=permit -jar keenwrite.jar
> OpenJDK 64-Bit Server VM warning: Option --illegal-access is deprecated
> and will be removed in a future release.
> KeenWrite version 2.0.0
> Copyright 2016-2021 White Magic Software, Ltd.
> Portions copyright 2015-2020 Karl Tauber.
> Exception in thread "main" java.lang.NoClassDefFoundError:
> javafx/beans/property/ReadOnlyProperty
>  at com.keenwrite.Launcher.main(Launcher.java:27)
> Caused by: java.lang.ClassNotFoundException:
> javafx.beans.property.ReadOnlyProperty
>  at
>
> java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)
>  at
>
> java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
>  at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
>  ... 1 more
>
>
>
___
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
___


  1   2   3   4   >