[NTG-context] Typesetting Markdown – Part 5: Interpolation

Thangalin thangalin at gmail.com
Tue Jul 9 20:06:19 CEST 2019


That's another intriguing approach, Andrés, thank you.

The approach faces some hurdles. First, the template file (main.tex) is
written in ConTeXt, so it never sees the YAML variables, nor can it be used
to interpret pandoc's conditional expressions. Second, moving the
\completecontent macro out of main.tex and into Markdown (e.g., 01.md,
being the first chapter) so that the conditional expression can be
evaluated using pandoc mixes content with presentation logic.

Modes are a good approach in this case because the "context" command can
take a "mode" command-line argument. This provides presentation controls
that neither the YAML nor the Markdown need consider. Adding presentation
logic to the ConTeXt template (i.e., introducing \startmode and
\startnotmode into main.tex) is acceptable because ConTeXt is wholly
responsible for the appearance of the final document. See:
https://wiki.contextgarden.net/Modes

This then allows development of command-line arguments from shell scripts
to control how the document is presented when built, which is a little bit
more flexible than maintaining YAML variables. Also, ideally, the YAML
variables would be used for controlling only content, not presentation
logic.

Thanks again, Andrés.

On Mon, Jul 8, 2019 at 11:27 AM Andres Conrado <elandi at chiquitico.org>
wrote:

> You can do it on the template... you can use a yaml variable to determine
> if the toc should be printed or not. Like so:
>
> yaml file:
> ---
> toc: true
> ...
>
> template file:
> %%%%%%%
> $if(toc)$
> \completecontent
> $endif$
> %%%%%%%
>
>
> Andrés Conrado Montoya
> http://chiquitico.org
>
>
> El lun., 8 jul. 2019 a las 2:52, <ntg-context-request at ntg.nl> escribió:
>
>> Send ntg-context mailing list submissions to
>>         ntg-context at ntg.nl
>>
>> To subscribe or unsubscribe via the World Wide Web, visit
>>         https://mailman.ntg.nl/mailman/listinfo/ntg-context
>> or, via email, send a message with subject or body 'help' to
>>         ntg-context-request at ntg.nl
>>
>> You can reach the person managing the list at
>>         ntg-context-owner at ntg.nl
>>
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of ntg-context digest..."
>>
>>
>> Today's Topics:
>>
>>    1. Re:  Typesetting Markdown – Part 5: Interpolation
>>       (Aditya Mahajan)
>>    2. Re:  Typesetting Markdown – Part 5: Interpolation (Thangalin)
>>    3. Re:  Typesetting Markdown – Part 5: Interpolation
>>       (Aditya Mahajan)
>>    4. request for \definefontfamily and \definefallbackfamily
>>       (Pablo Rodriguez)
>>    5. Re: crappy names in the fontloader (Hans Hagen)
>>    6. problems with images, layers and crop marks (Henning Hraban Ramm)
>>    7. Re: problems with images, layers and crop marks (Hans Hagen)
>>
>>
>> ----------------------------------------------------------------------
>>
>> Message: 1
>> Date: Sun, 7 Jul 2019 10:17:31 -0400 (EDT)
>> From: Aditya Mahajan <adityam at umich.edu>
>> To: mailing list for ConTeXt users <ntg-context at ntg.nl>
>> Subject: Re: [NTG-context]  Typesetting Markdown – Part 5:
>>         Interpolation
>> Message-ID: <nycvar.YAK.7.76.1907071012590.13567 at nqv-guvaxcnq>
>> Content-Type: text/plain; charset=US-ASCII; format=flowed
>>
>> On Sat, 6 Jul 2019, Thangalin wrote:
>>
>> > Hello again!
>> >
>> > This part of the series describes how to reference *interpolated*
>> strings
>> > inside Markdown documents.
>> > https://dave.autonoma.ca/blog/2019/07/06/typesetting-markdown-part-5/
>> >
>> > There's a section at the end about eliminating the table of contents
>> from a
>> > reusable document template. I would have preferred using setups, rather
>> > than redefining the \completecontent macro, but didn't see an obvious
>> way
>> > to do so.
>>
>> Why not simply omit \compltecontent from the pandoc template?
>>
>> Aditya
>>
>>
>>
>> ------------------------------
>>
>> Message: 2
>> Date: Sun, 7 Jul 2019 11:58:12 -0700
>> From: Thangalin <thangalin at gmail.com>
>> To: mailing list for ConTeXt users <ntg-context at ntg.nl>
>> Subject: Re: [NTG-context]  Typesetting Markdown – Part 5:
>>         Interpolation
>> Message-ID:
>>         <CAANrE7qd81BudwSHBWufu=MpDDUPn5fh8ZBM63qLVZ160gZH=
>> g at mail.gmail.com>
>> Content-Type: text/plain; charset="utf-8"
>>
>> Thank you Aditya.
>>
>> The main.tex file is meant to be reusable for different document styles.
>> By
>> removing \completecontent altogether from the main template, it would
>> preclude a different document from reusing the main.tex template with a
>> table of contents. I'd like the template to be "reusable"; making
>> modifications to "main.tex" --- or creating a copy --- would subvert that
>> goal.
>>
>> On Sun, Jul 7, 2019 at 7:17 AM Aditya Mahajan <adityam at umich.edu> wrote:
>>
>> > On Sat, 6 Jul 2019, Thangalin wrote:
>> >
>> > > Hello again!
>> > >
>> > > This part of the series describes how to reference *interpolated*
>> strings
>> > > inside Markdown documents.
>> > > https://dave.autonoma.ca/blog/2019/07/06/typesetting-markdown-part-5/
>> > >
>> > > There's a section at the end about eliminating the table of contents
>> > from a
>> > > reusable document template. I would have preferred using setups,
>> rather
>> > > than redefining the \completecontent macro, but didn't see an obvious
>> way
>> > > to do so.
>> >
>> > Why not simply omit \compltecontent from the pandoc template?
>> >
>> >
>> >
>> -------------- next part --------------
>> An HTML attachment was scrubbed...
>> URL: <
>> http://mailman.ntg.nl/pipermail/ntg-context/attachments/20190707/25ca6215/attachment-0001.html
>> >
>>
>> ------------------------------
>>
>> Message: 3
>> Date: Sun, 7 Jul 2019 15:17:50 -0400 (EDT)
>> From: Aditya Mahajan <adityam at umich.edu>
>> To: mailing list for ConTeXt users <ntg-context at ntg.nl>
>> Subject: Re: [NTG-context]  Typesetting Markdown – Part 5:
>>         Interpolation
>> Message-ID: <nycvar.YAK.7.76.1907071512000.13567 at nqv-guvaxcnq>
>> Content-Type: text/plain; charset=US-ASCII; format=flowed
>>
>>
>> On Sun, 7 Jul 2019, Thangalin wrote:
>>
>> > Thank you Aditya.
>> >
>> > The main.tex file is meant to be reusable for different document
>> styles. By
>> > removing \completecontent altogether from the main template, it would
>> > preclude a different document from reusing the main.tex template with a
>> > table of contents. I'd like the template to be "reusable"; making
>> > modifications to "main.tex" --- or creating a copy --- would subvert
>> that
>> > goal.
>>
>> Pandoc allows that. For example, see line 140 of the default context
>> template:
>>
>> https://github.com/jgm/pandoc-templates/blob/master/default.context
>>
>> I don't remember the exact command line parameters for pandoc that set
>> the toc flag to true.
>>
>> An equivalent method will be to control this using a ConTeXt mode.
>> Redefining \completecontent to \empty seems too drastic.
>>
>> Aditya
>>
>>
>>
>> ------------------------------
>>
>> Message: 4
>> Date: Sun, 7 Jul 2019 21:29:49 +0200
>> From: Pablo Rodriguez <oinos at gmx.es>
>> To: mailing list for ConTeXt users <ntg-context at ntg.nl>
>> Subject: [NTG-context] request for \definefontfamily and
>>         \definefallbackfamily
>> Message-ID: <857b6e26-0b65-c2a4-6569-e664f0111d1e at gmx.es>
>> Content-Type: text/plain; charset=utf-8
>>
>> Hi Wolfgang,
>>
>> I have two requests to be implemented in \definefontfamily.
>>
>> The first one is that is able to load fonts not defined as entries in
>> the font database.
>>
>> Here you have a minimal sample:
>>
>>     \definefont[Test][file:texgyrepagella-regular.otf at 10pt]
>>     \definefont[TestOne][file:texgyrepagella-regular-500.otf at 10pt]
>>
>>     \definefontfamily [mainface] [rm] [Pagella]
>>         [tf={file:texgyrepagella-regular.otf},
>>          bf={file:texgyrepagella-regular-500.otf}]
>>
>>     \setupbodyfont[mainface]
>>     \starttext
>>     normal\\
>>     \bf bold not working\\
>>
>>     \Test this works
>>     \TestOne this works
>>     \stoptext
>>
>>  The second one would be to allow method=uppercase to
>> \definefallbackfamily, so it could be used to fake small caps (such as
>> in https://mailman.ntg.nl/pipermail/ntg-context/2018/092878.html.
>>
>> Many thanks for your help,
>>
>> Pablo
>> --
>> http://www.ousia.tk
>>
>>
>> ------------------------------
>>
>> Message: 5
>> Date: Sun, 7 Jul 2019 23:42:11 +0200
>> From: Hans Hagen <j.hagen at xs4all.nl>
>> To: ntg-context at ntg.nl
>> Subject: Re: [NTG-context] crappy names in the fontloader
>> Message-ID: <ea884d13-5c0e-9772-8f69-c2f13ddb224e at xs4all.nl>
>> Content-Type: text/plain; charset=utf-8; format=flowed
>>
>> On 7/6/2019 6:36 PM, Marcel Fabian Krüger wrote:
>> > Hi everyone,
>> >
>> > under default settings, the fontloaders discards all glyph names which
>> > are considered "crappy", meaning matching the "p_crappyname" pattern in
>> > "font-oup.lua". For some names this makes a lot of sense. For example
>> > the name "uni0303" is considered "crappy" and it really provides no
>> > useful information. Then there are other names like "t_uni0303" which
>> > are still considered "crappy" while they actually aren't completely
>> > useless. So I think there would be some value in preserving them. Of
>> > course, you can always enable "otf.keepnames" if you need names like
>> > this.
>> >
>> > But I actually want to talk about another class of names: Look at
>> > "Udotbelow". This is IMHO a perfectly normal and useful name, but the
>> > fontloader still considers it "crappy" because it starts with a "U"
>> > followed by a letter which could be a hexadecimal number.
>> >
>> > I think this is a bit over-agressive. Maybe the "p_crappyname" pattern
>> > could be changed to only look for "u<hexadecimal>" if followed by
>> > "p_done", marking the end of a component?
>> i'll look into it (irr in generic mode (latex etc) one can disable that
>> 'feature' which i thought happened)
>>
>> 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
>> -----------------------------------------------------------------
>>
>>
>> ------------------------------
>>
>> Message: 6
>> Date: Sun, 07 Jul 2019 23:06:56 +0000
>> From: Henning Hraban Ramm <texml at fiee.net>
>> To: ntg-context at ntg.nl
>> Subject: [NTG-context] problems with images, layers and crop marks
>> Message-ID:
>>         <20190707230656.Horde.IVjTQk9tNtFVGH0IBsHNXDk at webmail.fiee.net>
>> Content-Type: text/plain; charset=utf-8; format=flowed; DelSp=Yes
>>
>> Hi all,
>> I’m quite quiet at the moment, because I can access my mailing list
>> address only via inconvenient webmail; since I updated MacOS, neither
>> Apple Mail nor Thunderbird will take my password anymore... :-((
>> Besides, I’m currently well paid for working with LaTeX, and my other
>> projects get less time.
>>
>>
>> Anyway, one of our authors finally submitted her final corrections,
>> and "of course" my ConTeXt setup that still worked well in May doesn’t
>> behave any more:
>>
>> * stacked layers won’t work on the first page (there should be a title
>> bar above an image; it works on the back cover, but not on the front;
>> but I can enable one of both layers)
>>
>> That might be related to:
>>
>> * on some right pages, including p.1 (cover), crop marks are shifted
>> one page width to the right.
>>
>> * on some pages, crop marks are shifted vertically; might be related
>> to using \offset for image placement.
>>
>> I’m trying to cook up MWEs, but the behaviour is so strange and
>> irregular, that I don’t know if I can reproduce it in a simpler
>> environment... I suspect my combined use of postponing, makeups,
>> layers and \offset might have grown side effects since May.
>>
>> Any ideas?
>>
>>
>> Greetlings, Hraban
>>
>>
>> Greetlings, Hraban
>> Grüßlinge, Hraban
>> ---
>> https://www.fiee.net
>> http://wiki.contextgarden.net
>> https://www.dreiviertelhaus.de
>> GPG Key ID 1C9B22FD
>>
>>
>>
>> ------------------------------
>>
>> Message: 7
>> Date: Mon, 8 Jul 2019 09:52:51 +0200
>> From: Hans Hagen <j.hagen at xs4all.nl>
>> To: mailing list for ConTeXt users <ntg-context at ntg.nl>, Henning
>>         Hraban Ramm <texml at fiee.net>
>> Subject: Re: [NTG-context] problems with images, layers and crop marks
>> Message-ID: <26b17c1c-04b7-7398-4c5f-f514c942671e at xs4all.nl>
>> Content-Type: text/plain; charset=utf-8; format=flowed
>>
>> On 7/8/2019 1:06 AM, Henning Hraban Ramm wrote:
>> > Hi all,
>> > I’m quite quiet at the moment, because I can access my mailing list
>> > address only via inconvenient webmail; since I updated MacOS, neither
>> > Apple Mail nor Thunderbird will take my password anymore... :-((
>> > Besides, I’m currently well paid for working with LaTeX, and my other
>> > projects get less time.
>> >
>> >
>> > Anyway, one of our authors finally submitted her final corrections, and
>> > "of course" my ConTeXt setup that still worked well in May doesn’t
>> > behave any more:
>> >
>> > * stacked layers won’t work on the first page (there should be a title
>> > bar above an image; it works on the back cover, but not on the front;
>> > but I can enable one of both layers)
>> >
>> > That might be related to:
>> >
>> > * on some right pages, including p.1 (cover), crop marks are shifted
>> one
>> > page width to the right.
>> >
>> > * on some pages, crop marks are shifted vertically; might be related to
>> > using \offset for image placement.
>> >
>> > I’m trying to cook up MWEs, but the behaviour is so strange and
>> > irregular, that I don’t know if I can reproduce it in a simpler
>> > environment... I suspect my combined use of postponing, makeups, layers
>> > and \offset might have grown side effects since May.
>> >
>> > Any ideas?
>> afaik nothing fundamental changed in these areas (ok, maybe you operate
>> out of the formal functionality) ... of course, if you're using lmtx it
>> might be that something got fixed in there, as at that moment it was
>> more experimental than it is now
>>
>> 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
>> -----------------------------------------------------------------
>>
>>
>> ------------------------------
>>
>> Subject: Digest Footer
>>
>>
>> ___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to
>> the Wiki!
>>
>> maillist : ntg-context at ntg.nl /
>> http://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
>> archive  : https://foundry.supelec.fr/projects/contextrev/
>> wiki     : http://contextgarden.net
>>
>> ___________________________________________________________________________________
>>
>>
>> ------------------------------
>>
>> End of ntg-context Digest, Vol 181, Issue 8
>> *******************************************
>>
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context at 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
>
> ___________________________________________________________________________________
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20190709/ce53bcde/attachment-0001.html>


More information about the ntg-context mailing list