Re: [NTG-context] interfaces.definecommand fails with brackets inside string arguments
On 7/8/2019 5:18 PM, mf wrote: Hello list, i've played a bit with interfaces.definecommand, that lets you define TeX macros from lua (see the "ConTeXt Lua Documents", 7.3 User interfacing). I found that the commands defined by interfaces.definecommand fail when you pass string arguments that contain brackets. I think cldf-int.lua needs a patch to support those kind of arguments. In the meantime it's possible to bypass the problem passing arguments with brackets inside double braces, as in the MWE attached. catched in next beta - 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] interfaces.definecommand fails with brackets inside string arguments
> On 8 Jul 2019, at 17:18, mf wrote: > > Hello list, > i've played a bit with interfaces.definecommand, that lets you define TeX > macros from lua (see the "ConTeXt Lua Documents", 7.3 User interfacing). > > I found that the commands defined by interfaces.definecommand fail when you > pass string arguments that contain brackets. > > I think cldf-int.lua needs a patch to support those kind of arguments. FYI, it fails because definecommand() creates a \myCommand that is equivalent to this: \def\myCommand#1{\ctxlua {_clmm_('myCommand',[[#1]])}} The [[…]] is the lua multi-line string syntax, like /* */ in C. So if the #1 expands into \blank[line], that produces [[\blank[line]]] resulting in a trailing extra ‘]’, which is a lua syntax error. > > In the meantime it's possible to bypass the problem passing arguments with > brackets inside double braces, as in the MWE attached. Adding a space at the end also works, but a core patch makes sense to me. Taco ___ 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] interfaces.definecommand fails with brackets inside string arguments
On 7/9/2019 10:37 AM, Taco Hoekwater wrote: On 8 Jul 2019, at 17:18, mf wrote: Hello list, i've played a bit with interfaces.definecommand, that lets you define TeX macros from lua (see the "ConTeXt Lua Documents", 7.3 User interfacing). I found that the commands defined by interfaces.definecommand fail when you pass string arguments that contain brackets. I think cldf-int.lua needs a patch to support those kind of arguments. FYI, it fails because definecommand() creates a \myCommand that is equivalent to this: \def\myCommand#1{\ctxlua {_clmm_('myCommand',[[#1]])}} The [[…]] is the lua multi-line string syntax, like /* */ in C. So if the #1 expands into \blank[line], that produces [[\blank[line]]] resulting in a trailing extra ‘]’, which is a lua syntax error. In the meantime it's possible to bypass the problem passing arguments with brackets inside double braces, as in the MWE attached. Adding a space at the end also works, but a core patch makes sense to me. i'll re-implment it in a more modern way 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] Typesetting Markdown – Part 5: Interpolation
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 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, escribió: > >> Send ntg-context mailing list submissions to >> ntg-context@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-requ...@ntg.nl >> >> You can reach the person managing the list at >> ntg-context-ow...@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 >> To: mailing list for ConTeXt users >> Subject: Re: [NTG-context] Typesetting Markdown – Part 5: >> Interpolation >> Message-ID: >> 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 >> To: mailing list for ConTeXt users >> Subject: Re: [NTG-context] Typesetting Markdown – Part 5: >> Interpolation >> Message-ID: >> > g...@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 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 \completeco
Re: [NTG-context] Typesetting Markdown – Part 5: Interpolation
Thank you. I still don't really understand why can't you have a "presentational" yaml file and a "content" yaml file (I do it like that... I have a "variables.yaml" file for content and a "settings.yaml" file for presentational stuff, and use a "template.context" file with all my mapped variables within the ConTeXt code, and compile everything using pandoc). But I guess you want to do it this way. Or maybe I'm not really understanding your process. It's quite interesting in any case, and I'm learning a lot. Thanks for sharing. Andrés Conrado Montoya http://chiquitico.org ___ 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] Is it possible to define a float environment that uses 2 captions? (and another question)
I'm working on a book that uses tables and figures, but the editors want to use to diffferent captions for each figure: one as usual, with the float description and number, and another one with a "Source" for said float. Something like: - | | | Float | | | - Figure 1: The float description. Source: The float source. I know i can do it by hand, inserting line breaks in the caption and so on. But I was wondering if there is a programmatic way to do it, so I can, for example, change the "Caption" position to be above the float, but have the "Source" below it. LIke: Figure 1: The float description. - | | | Float | | | - Source: The float source. I've been reviewing the Wiki, but so far I have no idea how to approach it. Any recommendation will be very appreciated. Thank you for your time. Andrés Conrado Montoya Andi Kú andresconr...@gmail.com http://sesentaycuatro.com http://messier87.com http://chiquitico.org Los fines no justifican los medios, porque la medida verdadera de nuestro carácter está dada por los medios que estamos dispuestos a utilizar, no por los fines que proclamamos. “You develop an instant global consciousness, a people orientation, an intense dissatisfaction with the state of the world, and a compulsion to do something about it. From out there on the moon, international politics look so petty. You want to grab a politician by the scruff of the neck and drag him a quarter of a million miles out and say, ‘Look at that, you son of a bitch.’” — Apollo 14 astronaut Edgar Mitchell ___ 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] reference containing parentheses causes trouble
Dear List, Warning: The following may be a bug or feature or just my misunderstanding! It seems that parentheses cause trouble in references. MNWE: \starttext \section[sec:one(two)]{One} As you see in sec.~\in[sec:one(two)], \stoptext The "in sec.~\in[sec:one(two)]" typesets as "in sec. ??" and the log shows: references > start missing references references >1 [][sec:one(two)] references > stop missing references (It all works fine upon deleting "(two)" throughout.) Is this behavior known and expected? If it is, I'll add a note to the "References" page on the wiki. -Sanjoy ___ 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] index page ranges where start page == end page
The following probably well known minimal example \starttext \startregister[index][key1]{an entry}\input knuth\stopregister[index][key1] \placeindex \stoptext produces the index entry "an entry 1--1", where the page range should be just a single page. A question (and then two workarounds): Could ConTeXt automatically change such page ranges to the single page ("an entry 1")? Meanwhile, a couple of workarounds: In the MkII (pre-lua) days, I wrote a shell/sed/awk/perl script that converted the .pdf file to text, grepped for (strings that are likely to be) page ranges, and spat out lines where the page range should be a page. (Those days were so long ago that I've forgotten the script's language.) Then I would manually find and change the corresponding \startregister[index] in the source to a plain \index (and delete the corresponding \stopregister). In these MkIV days, with the index data in a lua table, I've been playing with the following python2 script that parse the .tuc file to spit out the same information slightly more reliably. In the next step, coming soon, the script will check that each \seeindex entry points to an actual entry and also that each \seeindex{also ...} entry originates from an actual entry (otherwise it shouldn't be "also"). The script requires the slpp package; pip install git+https://github.com/SirAnthony/slpp The parser in the script has a bug in that it doesn't handle minus signs in the lua table, maybe everywhere or maybe only some of them, so the script replaces them with "_" before sending the data to the parser (a terrible hack). To run the script: python check-index.py < file.tuc Here is check-index.py: # parse lua-format index-entry table extracted from book.tuc to check # that each xref points to an actual entry, and that, further, "see # also" src entries have at least one page ref (perhaps in subtree) # due to bug in slpp parser: replace "-" (minus signs) in data with "_" from slpp import slpp as lua from sys import stdin,stderr import re def tuclist2entry(l): return '+'.join(l) data = [] intro_re = r'utilitydata.structures.registers.collected\s*=' in_register_data = False for l in stdin: if re.match(intro_re, l): in_register_data = True data.append(re.sub(intro_re,'',l)) elif in_register_data: data.append(l) if re.match(r'}$', l): in_register_data = False data = re.sub("-", "_", ''.join(data)) dict = lua.decode(data) index = dict['index'] entries = [] xrefs = [] for entry in index['entries']: src = [x[0] for x in entry['list']] refs = entry['references'] if 'seeword' in entry: dest = entry['seeword']['text'] xrefs.append((src,dest)) else: page = refs['realpage'] if refs.get('lastrealpage',None) == page: print "silly range:", tuclist2entry(src) entries.append(src) for xref in xrefs: print tuclist2entry(xref[0]),'->', xref[1] ___ 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 ___