ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Custom pretty printer pass option to buff-imp-<mycustomformat>.lua
@ 2017-01-22 19:35 Lorenz
  2017-01-22 21:49 ` Lorenz
  0 siblings, 1 reply; 2+ messages in thread
From: Lorenz @ 2017-01-22 19:35 UTC (permalink / raw)
  To: ntg-context

I'm customizing a pretty printer and referencing the buff-imp-lua.lua
and buff-imp-lua.mkiv files.  

I'd like to add a conditional to the .lua file say buff-imp-custom.lua. 
What is a good way to pass an option from my .tex file to conditionally
format with the pretty printer?   I'd like to use the same
buff-imp-custom.lua and .mkiv pairs of files instead of creating
multiple files.

The .mkiv file defines e.g.:

    \definetyping
        [CUSTOM1]
        [\c!option=custom]

I'd like to add say CUSTOM2 but pass an option that would be visible to
the same buff-imp-custom.lua file.  Perhaps something like this?:

    \definetyping
        [CUSTOM2]
        [\c!option=custom,<option visible to same lua file as CUSTOM1?>]


Thanks 

--
Lorenz
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Custom pretty printer pass option to buff-imp-<mycustomformat>.lua
  2017-01-22 19:35 Custom pretty printer pass option to buff-imp-<mycustomformat>.lua Lorenz
@ 2017-01-22 21:49 ` Lorenz
  0 siblings, 0 replies; 2+ messages in thread
From: Lorenz @ 2017-01-22 21:49 UTC (permalink / raw)
  To: ntg-context

It looks like the solution is to add another visualizers.register() to
the .lua file.  

    visualizers.register("custom", { parser = parser, handler = handler,
    grammar = grammar } )
    visualizers.register("customb", { parser = parser2, handler =
    handler2, grammar = grammar2 } )

Then in .mkiv:

    \definetyping
        [CUSTOM]
        [\c!option=custom]

    \definetyping
        [CUSTOMB]
        [\c!option=customb]


I'll just need to work out how to define only the changes I want to make
to handler2, grammar2 without copy/paste from handler, grammar.  I want
to share most of the options with the original and override select
options.


On Sun, Jan 22, 2017, at 02:35 PM, Lorenz wrote:
> I'm customizing a pretty printer and referencing the buff-imp-lua.lua
> and buff-imp-lua.mkiv files.  
> 
> I'd like to add a conditional to the .lua file say buff-imp-custom.lua. 
> What is a good way to pass an option from my .tex file to conditionally
> format with the pretty printer?   I'd like to use the same
> buff-imp-custom.lua and .mkiv pairs of files instead of creating
> multiple files.
> 
> The .mkiv file defines e.g.:
> 
>     \definetyping
>         [CUSTOM1]
>         [\c!option=custom]
> 
> I'd like to add say CUSTOM2 but pass an option that would be visible to
> the same buff-imp-custom.lua file.  Perhaps something like this?:
> 
>     \definetyping
>         [CUSTOM2]
>         [\c!option=custom,<option visible to same lua file as CUSTOM1?>]
> 
> 
> Thanks 
> 
> --
> Lorenz
> ___________________________________________________________________________________
> 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-22 21:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-22 19:35 Custom pretty printer pass option to buff-imp-<mycustomformat>.lua Lorenz
2017-01-22 21:49 ` Lorenz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).