[NTG-context] Custom XML Pretty Printer

Renaud AUBIN aubin at nibua-r.org
Mon Jan 17 20:42:06 CET 2011


Hi Aditya and happy ConTeXters,

I've worked at the beginning to include those spaces in the different
syntax highlighting groups but failed. Considering the definition of
Comment in the grammar provided by t-pretty-ra-xml.lua:

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
we have the following lua code:
Comment =
    makepattern(handler,"comment", Comment_open) *
    (
        V("line") +
        V("whitespace") +
        makepattern(handler, "comment", Comment_content)
    )^0 *
    makepattern(handler,"comment", Comment_close),

Here I use the fallback mechanism to the default grammar, defined in
v-default.lua, with V("line") and V("whitespace").

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
To circumvent the problem described by Aditya, I assumed that I could do
(since I cannot remember my first experiments, ante git versioning):

local line =  patterns.newline * (patterns.emptyline)^0 * patterns.beginline
local whitespace = (patterns.space + line)^1
[…]
Comment =
    makepattern(handler,"comment", Comment_open) *
    (
        makepattern(handler, "comment", line + whitespace +
Comment_content)
    )^0 *
    makepattern(handler,"comment", Comment_close),

The newlines are no more detected… I've tried some other code but
everything failed…

I don't know if this is related but, as you have probably noticed, I
don't manage multiple empty lines too.

I'm out of ideas, good as bad…


Hans, or another Guru, to the rescue? More than a solution for Aditya,
it would be nice to give me some line/space stuffs' tricks since the
resulting code could be cleaner and leaner too…

Cheers,

Renaud

Le 16/01/2011 23:06, Aditya Mahajan a écrit :
> On Sun, 16 Jan 2011, Renaud AUBIN wrote:
>
>> Now available on tlcontrib:
>> http://tlcontrib.metatex.org/cgi-bin/package.cgi/ruid=4591828845/action=view/id=388
>>
>
> Any particular reasons why the spaces are not part of the syntax
> highlighting group? For example just add
>
> \def\RaXmlSnippetComment#1{«#1»}
>
> and observe the output:
>
> «<!--» «T»«h»«a»«t» «i»«s» «a» «t»«e»«s»«t» «-->»
>
> I want to use a different syntax highlighting scheme that provides
> background colors and such. For that, it will be much nicer if the
> output were
>
> «<!-- That is a test -->»
>
> Is that possible?
>
> Aditya
>
>
> ___________________________________________________________________________________
> 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  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________



More information about the ntg-context mailing list