[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: xmlpos values doubled

2023-11-21 Thread Benjamin Buchmuller
Hi list,

I came across this old thread as I was trying to use \xmlpos{#1} to 
"dynamically" create references such as \item[mystep:\xmlpos{#1}] to be 
referenced when other elements of this node are parsed at a later point. 

In fact, it seems that \xmlpos{#1} returns duplicate values. This might indeed 
be the intended meaning of \xmlpos{#1} as it seems related to the XML query 
foo/bar/index() which only looks up the position in the parent node. (I noticed 
that if I run this repeatedly, I get somehow different values from times to 
times. I can't say why.)

Anyways, I was wondering if there is a TeX command to access the absolute 
position of an element in the tree? Similar to foo/bar[rootposition()] (or 
foo/bar[order()]? – Can't make sense of the entry in the XML manual.)

Thank you for your help!


Benjamin


> Hi Ben,
> 
> I think that both \xmlpos and \xmldepth give weird results.
> 
> With this minimal sample:
> 
> \startbuffer[text]
> first level
> second level
> third level
> third level
> 
> second level
> third level
> third level
> 
> second level
> third level
> third level
> 
> 
> \stopbuffer
> 
> \startxmlsetups xml:text
> \xmlsetsetup{#1}{doc|s|ss}{xml:*}
> \stopxmlsetups
> 
> \xmlregistersetup{xml:text}
> 
> \startxmlsetups xml:doc
> \chapter{\xmlpos{#1}\letterat\xmldepth{#1}: \xmlflush{#1}}
> \stopxmlsetups
> 
> \startxmlsetups xml:s
> \section{\xmlpos{#1}\letterat\xmldepth{#1}: \xmlflush{#1}}
> \stopxmlsetups
> 
> \startxmlsetups xml:ss
> \subsection{\xmlpos{#1}\letterat\xmldepth{#1}: \xmlflush{#1}}
> \stopxmlsetups
> 
> \setuphead[chapter,section,subsection][before=,after=,]
> \starttext
> \xmlprocessbuffer{main}{text}{}
> \stoptext
> 
> \xmldepth shows values that I think are +1 than they should be.
> 
> \xmlpos counts in pairs and not in units (as you wrote, 2, 4, 6...).
> 
> Hans, could you check whether this is working as expected?
> 
> Sorry, but if this isn’t a bug, I have no idea of what I may be missing.
> 
> Pablo
> 
___
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: It works after a few changes but ..

2023-11-21 Thread Bruce Horrocks


> On 20 Nov 2023, at 08:54, Ursula Hermann  wrote:
> 
> Dear Bruce, 
> 
> Yes, I need also margintext. 

What do you want to appear in the margin: the theorem number or the section 
number of the current section?

In other words, what should replace the "hard coded" 2.1.1 that you have in 
your example?

> 
> 
>> On 17 Nov 2023, at 14:06, Ursula Hermann  wrote:
>> 
>> \margintext{2.1.1}{\starttheorem {The square on the hypotenuse is 
>> equal to the sum of the squares on the other two sides. Ach is das 
>> schön, dass du da bist} \stoptheorem
> 
> The spurious parentheses seem to be a side-effect of having unmatched curly 
> brackets in the bit that I have quoted.
> 
> The following eliminates them:
> 
> \definemargindata  [MyInMargin][inright] 
> \definemarginframed[MyInMargin][topframe=on,bottomframe=on,rulethickness=1pt,width=1cm]
> \margintext{\blackrule[color=black, height=0.25ex, 
> width=1cm]\\}\blackrule[color=black, height=0.25ex, width=7cm] 
> \setupenumerations  [ before={\blank[big]},
>   after={\blank[big]},
>   location=serried,
>   width=broad,
>   distance=0.5em,
>   headstyle=bold,
>   titlestyle=normal,
>   way=bytext,
>   conversion=numbers]
> \defineenumeration
> [theorem]
> [text=Theorem,
> title=yes,
> style=italic,
>  list=all,
>  listtext={Theorem }]
> \starttext
> \margintext{2.1.1}{\starttheorem The square on the hypotenuse is equal to the 
> sum of the squares on the other two sides. Ach is das schön, dass du da bist 
> \stoptheorem } \stoptext
> 
> I see also in this thread that you have sad "yes" to Aditya's suggestion. But 
> that doesn't have the margintext. Do you still want/need margintext?

—
Bruce Horrocks
Hampshire, UK

___
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: (again) wrong destination types?

2023-11-21 Thread Bruce Horrocks


> On 20 Nov 2023, at 18:01, Pablo Rodriguez via ntg-context 
>  wrote:
> 
> Dear list,
> 
> sorry for insisting, but this is important for my documents.
> 
> I have the following sample:
> 
> \setupinteraction[state=start, page=name, focus=standard]
>  \starttext
>  a\footnote{b}
>  \stoptext
> 
> If page is set to anything different than no in \setupinteractionscreen,
> focus=standard will not work (it will be used as focus=fit).
> 
> Could anyone confirm the issue or explain me what I’m doing wrong?
> 
> Many thanks for your help
> 

I changed your example to the following:

\setupinteraction[state=start, page=name, focus=standard]
\starttext
\input knuth \par
a\footnote{b} \par
\input knuth \par
\input knuth \par
\input knuth \par
\input knuth \par
\input knuth \par
\input knuth \par
\input knuth \par
\stoptext

Using Preview on the Mac I see the following behaviour:
a) The doc opens at page 1, in continuous scroll mode, with the table of 
contents sidebar open. I'm pretty sure it's opening at 100% zoom but it's 
surprisingly hard to verify that in Preview.

b) When I click on the superscript 1 in the main body of the text nothing 
happens. This is because the footnote text is already visible.

c) When I click on the superscipt 1 in the footnote then the view changes and 
the document is scrolled so that the superscript 1 line in the main text is at 
the top of the window.

This is what I would expect for focus=standard as described on the Wiki.

Adobe Acrobat Reader is the same except that the opening view is different - I 
think it is defaulting to my preferences which is to have a double-page view.

—
Bruce Horrocks
Hampshire, UK

___
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: Strange behavior with anglestriped()

2023-11-21 Thread Fabrice Couvreur
Hi Fabrice,
Exactly, thanks for the correction.
Fabrice

Le lun. 20 nov. 2023 à 19:43, Fabrice L  a écrit :

> Hi,
>
> Fabrice, you have a problem with the definition of the path b: this path
> include q and b. To see this, replace your lines with :
>
>draw q anglestriped (1,45,2) withcolor cyan;
>draw b anglestriped (1,45,2) withcolor red;
>
> And you will see that the path b is drawn twice : once in red, once in
> cyan. So if you change your instructions to :
>
>draw q anglestriped (1,45,2) withcolor cyan;
>draw r anglestriped (1,45,2) withcolor cyan;
>
> This will correct the problem, because each path is now drawn only once.
>
> Fabrice.
>
> Le 20 nov. 2023 à 14:47, Fabrice Couvreur  a
> écrit :
>
> Hi Otared,
> It's true that the color seems identical.
> Thanks.
> Fabrice
>
> Le dim. 19 nov. 2023 à 21:55, Otared Kavian  a écrit :
>
>> Hi Fabrice,
>>
>> It seems to me the colors are the same, although they may appear
>> different at first sight because the « with » of the lines are different
>> (the width is larger in the lower rectangle).
>>
>> I attach the PDF created with your code.
>>
>> Best regards: Otared
>>
>>
>>
>> On 19 Nov 2023, at 18:56, Fabrice Couvreur 
>> wrote:
>>
>> Hi,
>> I don't understand why the hatching of the two rectangles is not the same
>> color.
>> Thanks for your help.
>> Fabrice
>>
>> \starttext
>> \setupbodyfont[8pt]
>> \startMPcode
>>path p, q, r, b ;
>>
>>z[0] = (2cm,0cm) ;
>>z[1] = (2cm,2cm) ;
>>z[2] = (0cm,2cm) ;
>>
>>p := unitsquare xyscaled (9cm, 5cm) ;
>>q := llcorner p--z[0]--z[1]--z[2]--cycle ;
>>r := unitsquare xyscaled (7cm,3cm) shifted(2cm,2cm) ;
>>b := z[2]--z[1]--ulcorner r--urcorner p--lrcorner r--z[1]--
>>z[0]--llcorner p--cycle ;
>>
>>
>>draw b anglestriped (1,45,2) withcolor cyan;
>>draw q anglestriped (1,45,2) withcolor cyan;
>>
>>draw p ;
>>
>>label.llft("A", p) ;
>>label.lrt("D", p) ;
>>label.ulft("B", p) ;
>>label.urt("C", p) ;
>>label.lft("M", z[2]) ;
>>label.ulft("N", z[1]) ;
>>label.bot("P", z[0]) ;
>>label.top("J", ulcorner r) ;
>>label.rt("I", lrcorner r) ;
>>label.bot(btex $x$ etex,(llcorner p+z[0])/2);
>>label.lft(btex $x$ etex,(llcorner p+z[2])/2);
>> \stopMPcode
>>
>> \stoptext
>>
>>
>> ___
>> 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
>>
>> ___
>>
>>
>> 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://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
>>
>> ___
>>
>
> ___
> 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
>
> ___
>
>
>
> ___
> 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
>
> ___
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl /