[NTG-context] ConTeXt, KeenWrite, Markdown, and XHTML
How would you convert the first class attribute of XHTML div elements to ConTeXt LMTX-specific start/stop environments? For example: Whose woods these are I think I know. And miles to go before I sleep. Becomes (the equivalent of?): \startpoem \startstanza Whose woods these are I think I know. \stopstanza \startstanza And miles to go before I sleep. \stopstanza \stoppoem In case this is an XY problem, background details follow. In a nutshell: convert a processed Markdown file that includes interpolated variables, arbitrary classes, and output from R functions into a format that ConTeXt can typeset. Background Details Pandoc's fenced div syntax is now supported by my text editor, allowing users to write "paragraph classes" in Markdown, such as: ::: {.poem .dark} ::: stanza Whose woods these are I think I know. ::: ::: This gets converted to XHTML (as shown above), which is to be rendered using ConTeXt LMTX. Rendering via ConTeXt needs the following tool chain: Editor (.md) -> run Pandoc (.tex) -> run ConTeXt (.pdf) Generating XHTML means Pandoc can be removed, simplifying the chain: Editor (.md -> magic -> .xhtml) -> run ConTeXt (.pdf) The Lua code to generate start/stop environments with Pandoc is described in Part 8 of my Typesetting Markdown series. https://dave.autonoma.ca/blog/2020/04/28/typesetting-markdown-part-8/#annotations The XML-MKIV documentation shows how to map a specific setup to a particular attribute: \xmlsetsetup{demo}{resource[@type='figure']}{xml:demo:figure} In Schmitz' XHTML-oriented My Way from 2010 there's a getmeas Lua function defined on page 9 that parses a width attribute. That's great for the opening div, but how would you close/stop the correct environment for nested divs? Would ConTeXt automatically track these on a stack, for example? Additional Ideas Given that the text editor converts Markdown to XHTML and has an XSLT engine, the following is possible: Editor (.md -> .xhtml) -> XSLT (.tex) -> run ConTeXt (.pdf) Piping XHTML directly into ConTeXt would be ideal, though. Well, piping CommonMark plus fenced div extensions to ConTeXt would be optimal, but my understanding is that support isn't quite there yet. Aditya wrote a Markdown filter that runs: pandoc -t context -o \externalfilteroutputfile\space \externalfilterinputfile This still needs Pandoc, though. There's also a dependency-free Markdown module. A few problems though. First, the module isn't ported to ConTeXt LMTX, yet? Second, it doesn't support element attributes beyond enabling content slicing. (Third, the module has LaTeX support tightly bundled within, which bloats a pure ConTeXt solution.) Related Links https://dl.contextgarden.net/myway/tas/xhtml.pdf https://www.pragma-ade.com/general/manuals/xml-mkiv.pdf https://github.com/DaveJarvis/keenwrite#screenshots https://github.com/adityam/filter/blob/master/README.md https://mirror.its.dal.ca/ctan/macros/generic/markdown/markdown.html#header-attributes https://github.com/Witiko/markdown/ ___ 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] Footnotes in columns
Hello Hans, with fresh LMTX footnotes are still missing in \startcolumns as Clyde reported: \starttext \startcolumns \input knuth\footnote{D. E. Knuth} \stopcolumns \stoptext Tried columnsets. Footnotes are overlapping text and some text at the column break disappeared: \starttext \startcolumnset \dorecurse{10}{\input knuth\footnote{D. E. Knuth}\ } \stopcolumnset \stoptext We are running out of options :) Could you, please, have a look at it when your metafun mode is over? Thanks, Jano ConTeXt ver: 2021.03.05 19:14 LMTX fmt: 2021.3.6 On Mon, Jan 25, 2021 at 10:05 PM Clyde Johnston wrote: > I can no longer print the footnotes when I using columns in LTMX. If I > remove the \{start|stop}columns, it works fine. This works on my old MKIV > 2018.07.02 14:39 version. > > > > \setupcolumns[n=2,rule=off,balance=no] > > > > \starttext > > \startcolumns > > \input ward\footnote{A small footnote here} > > \stopcolumns > > \stoptext > > > > Context Version: 2021.01.24 16:07 > > > > Clyde > > > > ___ > 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] conditional formatting, checking the context (SOLVED)
> Am 06.03.2021 um 13:46 schrieb Pablo Rodriguez : > > Sorry for the delayed reply, Hraban. Thank you, but there was no need to reply. > If only bookmarks are affected, you only have to preroll them: > > \enabledirectives[references.bookmarks.preroll] Thank you, I knew that. But my highlighting macro inserted some font stuff that messed up the bookmarks, so I really needed that conditional in my macro. 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 ___
Re: [NTG-context] Write to tuc file
On 3/6/2021 1:56 PM, Pablo Rodriguez wrote: On 3/5/21 11:13 PM, Hans Hagen wrote: On 3/5/2021 10:38 PM, denis.ma...@ub.unibe.ch wrote: Thanks for this as well, Hans. Looks promising. So, this is to select pages or page-ranges for processing? assuming that you have either marked pages or proper refs for chapters you can use the reported values and feed them into whatever i could add something to the select style but i guess then there is no uniformity in how users do this Many thanks for the new stuff, Hans. This could be an approach: \starttext \completecontent \dorecurse{10} {\startchapter\markpage[start-\recurselevel] \dorecurse{\randomnumber{0}{1000}} {\input knuth\par} \markpage[stop-\recurselevel]\stopchapter} \stoptext "start-" and "stop-" could define page ranges when the same identifier is used. The select style could generate from start-identifier and stop-identifier, the result "identifier.pdf". \startchapter[reference=whatever,title=foo] \stopchapter \startchapter[reference=moreover,title=oof] \stopchapter and --pages=whatever,moreover will give you the info you need to call context --extra=copy or whatever with the right arguments - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Write to tuc file
On 3/5/21 11:13 PM, Hans Hagen wrote: > On 3/5/2021 10:38 PM, denis.ma...@ub.unibe.ch wrote: >> Thanks for this as well, Hans. Looks promising. >> So, this is to select pages or page-ranges for processing? > assuming that you have either marked pages or proper refs for chapters > you can use the reported values and feed them into whatever > > i could add something to the select style but i guess then there is no > uniformity in how users do this Many thanks for the new stuff, Hans. This could be an approach: \starttext \completecontent \dorecurse{10} {\startchapter\markpage[start-\recurselevel] \dorecurse{\randomnumber{0}{1000}} {\input knuth\par} \markpage[stop-\recurselevel]\stopchapter} \stoptext "start-" and "stop-" could define page ranges when the same identifier is used. The select style could generate from start-identifier and stop-identifier, the result "identifier.pdf". I think this is a simple approach. Many thanks for your help, Pablo -- http://www.ousia.tk ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] conditional formatting, checking the context (SOLVED)
On 3/5/21 12:06 PM, Henning Hraban Ramm wrote: > Hi, > > in the example below I’m using a custom highlighting macro in > titles. > > Now I don’t want this highlighting in the ToC or in bookmarks (in my > real world example the changes affect bookmarks, not in the MWE). Sorry for the delayed reply, Hraban. If only bookmarks are affected, you only have to preroll them: \enabledirectives[references.bookmarks.preroll] \setupinteraction[state=start] \placebookmarks[chapter,title] \starttext \chapter{This {\bf and} That} \stoptext And this is only required in MkIV, LMTX does it automagically. Just in case it helps, Pablo -- http://www.ousia.tk ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Center a text (Metafun)
On 3/6/2021 11:17 AM, Fabrice Couvreur wrote: Hi Hans, Some time ago, you offered this code to respond to a specific request from me. I used this code again and wanted to know if it was possible for the title "Algorithm" to be automatically centered based on the content. Thank you See Wolfgangs answer. If your using lmtx ... \startuseMPgraphic{MyFrame} picture p ; p := lmt_text [ width = OverlayWidth, height = OverlayHeight, text = "\bfx\framedtextparameter{Title}", color = "white", align = "normal", ] ; p := anchored.ulft (p, ulcorner OverlayBox shifted (0,EmWidth)) ; fill OverlayBox withcolor "MyBlue" ; fill boundingbox p enlarged .5EmWidth withcolor "maincolor" ; draw p ; setbounds currentpicture to OverlayBox ; \stopuseMPgraphic watch how also maincolor is accessed as string. Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Center a text (Metafun)
Fabrice Couvreur schrieb am 06.03.2021 um 11:17: Hi Hans, Some time ago, you offered this code to respond to a specific request from me. I used this code again and wanted to know if it was possible for the title "Algorithm" to be automatically centered based on the content. Thank you Fabrice \definecolor[MyBlue][c=0.2 , m=0.03, y=0.00, k=0.00] \definecolor[maincolor] [b=.5] \defineframedtext [MyFrame] [frame=off, background=MyFrame, width=fit, height=fit, style=small] \startuseMPgraphic{MyFrame} path b; picture p; p := textext.rt("\tfx\bf\white\framedtextparameter{Title}"); p := p shifted (2BodyFontSize,OverlayHeight-ypart center p+.25ExHeight); p := textext.t("\tfx\bf\white\framedtextparameter{Title}"); p := p shifted (OverlayWidth/2,OverlayHeight-ypart center p+.25ExHeight); Wolfgang ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] Center a text (Metafun)
Hi Hans, Some time ago, you offered this code to respond to a specific request from me. I used this code again and wanted to know if it was possible for the title "Algorithm" to be automatically centered based on the content. Thank you Fabrice \definecolor[MyBlue][c=0.2 , m=0.03, y=0.00, k=0.00] \definecolor[maincolor] [b=.5] \defineframedtext [MyFrame] [frame=off, background=MyFrame, width=fit, height=fit, style=small] \startuseMPgraphic{MyFrame} path b; picture p; p := textext.rt("\tfx\bf\white\framedtextparameter{Title}"); p := p shifted (2BodyFontSize,OverlayHeight-ypart center p+.25ExHeight); b := boundingbox p leftenlarged .5EmWidth rightenlarged .5EmWidth topenlarged .5EmWidth bottomenlarged .5EmWidth ; fill OverlayBox withcolor "MyBlue" ; fill b withcolor \MPcolor{maincolor} ; draw p ; setbounds currentpicture to boundingbox currentpicture enlarged 2mm ; \stopuseMPgraphic \defineoverlay [MyFrame] [\useMPgraphic{MyFrame}] \starttext \MyFrame[Title=Algorithme]{% \m{a\gets 2x-1} \m{b\gets a²-1} \m{c\gets b\div 4} \m{d\gets c-a+x} } \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] filter module / externalizing TikZ graphics
Finally coming back to this. > Am 31.01.2021 um 07:39 schrieb Aditya Mahajan : > >> I’m not yet sure what would make the most sense for this project (at least >> sorting by chapter/component would), but I have an use case with LilyPond >> where I could save several LilyPond compile runs if I could influence the >> naming: >> >> I got ~500 songs in their own component files, and I use them in different >> songbooklets with the same layout. E.g. there’s one containing all the songs >> and several with a subject (e.g. winter & christmas, children, medieval & >> fantasy, some author...). >> They all use [name=\currentcomponent]. If I could avoid the JOBNAME part of >> the file name, all booklets would use the same note PDFs. Now, the temp >> directory contains literally thousands of files. >> Since this is just for fun, the additional space and compile time is just a >> bit annoying and doesn’t affect others, but I like to streamline my >> workflows... > > This is a relatively simple feature to add. I have pushed a new branch with > this feature: https://github.com/adityam/filter/tree/prefix > > I have added a new `prefix` option: you can use > > \defineexternalfilter[][prefix=whatever] > > and then the filter module will write the temp name as `whateverfilter0.ext` > `whateverfilter1.ext`. The default value of prefix is \jobname-temp- (note > trailing dash), so there should be no difference in the default output, but > now you can configure the prefix if you want. That’s good, so if I set "prefix=,", I get "FILTER-COMPONENT.*", e.g. "lilypond-mysong-1.pdf" (LilyPond adds the number for each system). In the rare cases where component names collide or I need more than one filter environment per component, I can fix that manually. > I am also open to making filter name as part of the prefix, so that you can > have the ability to remove it if you wish. But I am hesitant to do so because > it can lead to hard to debug errors if there is a clash in the prefix of two > different filters. Not needed IMO. > I haven't tested it beyond simple tests to make sure that nothing breaks. > You can copy t-filter.mkiv from > https://raw.githubusercontent.com/adityam/filter/prefix/t-filter.mkiv to your > working directory and test if works for your situation. Works for me. Thank you very much! For the TikZ setup I’ll copy some of your code and sacrifice most of the configurability. Will report back... 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 ___