[luatex] Adding a callback before trailing spaces are removed from a line of input

Vítek Novotný witiko at mail.muni.cz
Thu Dec 30 01:11:30 CET 2021


To give some closure to the thread, support for trailing spaces in
ConTeXt MkIV and later has just been added to the Markdown package and
will be published in the 2.12.0 release of the Markdown package:

    https://github.com/witiko/markdown/commit/b67ed50

Best,
Vitek

On Mon, Aug 30, 2021 at 08:25:25AM +0200, Hans Hagen wrote:
> On 8/30/2021 1:34 AM, Vítek Novotný wrote:
> 
> > thank you, I had no idea that ConTeXt MkIV funneled all input through
> > its own line input handler, although I am not surprised. For now, I will
> 
> it doesn't, all input goes via a file handler and this is just a plugin
> mechanism into that; it has always been there so that we can deal with mixed
> input encodings, but i think all users use utf now; these are the oldest bit
> of code in mkiv (and optimized for low overhead)
> 
> > apply this solution to the markdown module for ConTeXt in hope that we
> > can have a format-agnostic solution in the future.
> This basically uses the file callback so any other solution would be
> similar. You cannot expect all formats to offer the ssamer interface to
> callbacks. First of all, context was the first to support callbacks and no
> other macro packages does it the same way. Then, there is order: macro
> packagesd can assume actions to be applied in some order so context also
> enforces that. Finally, most (and some day probably all) callback are
> protected so one cannot even set one (in context) unless by using the given
> interface.
> 
> Anyway, it's not that many lines is it? Of course one could for for:
> 
> \def\startmarkdown{}
> \def\stopmarkdown {}
> 
> \startluacode
> local markingdown = false
> 
> function document.markdownize(str)
>     if string.find(str,"\\startmarkdown") then
>         markingdown = true
>     elseif string.find(str,"\\stopmarkdown") then
>         markingdown = false
>     elseif markingdown then
>         str = string.gsub(str,"  $","\\par")
>         print(str)
>     end
>     return str
> end
> 
> resolvers.installinputlinehandler(document.markdownize)
> \stopluacode
> 
> \startmarkdown
>     test test
>     test test
> 
>     test test
>     test test
> \stopmarkdown
> 
> which in the end is more fragile. I saw the message on the luatex list about
> the latex way but i'm not going to provide such mechanism (most latex 'ways'
> don't apply to context I fear.)
> 
> Thanks,
> 
> 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
> -----------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://tug.org/pipermail/luatex/attachments/20211230/a9a54853/attachment.sig>


More information about the luatex mailing list.