Re: inlining pretty-printed XML
I've looked at the verb-XML module, and verb-ini module, and have have seen hints that it may be possible to typeset XML code snippets, such as <table> into the main text. Is it possible to inline such XML expressions into the main text, using the same color setup as has been defined in the verb-XML macros?
I'm seem to be using this mailing list as private correspondence, I'll try to keep my posting down in future. But.. Following up on my question on how to inline XML code, I vaguely remember reading that the TeX primitive \par, has no effect in restricted horizontal mode, (I think that's what it's called, anyways the horizontal mode that's not paragraph mode). So on that assumption, I forced the verbatim pretty printer to operate inside an \hbox, with the following code: -------------------------------------------------- %output=pdf \definetyping [XMLtag] [option=XML] \setuptyping [XMLtag] [before={\ \hbox\bgroup}, after={\egroup\ }, palet=colorpretty] \setupcolors[state=start] \starttext This is a \startXMLtag <TABLE/> \stopXMLtag tag inline; and this is a comment \startXMLtag <!-- comment --> \stopXMLtag \startXML <!-- This is displayed XML --> <TABLE/> \stopXML \stoptext --------------------------------------------------
At 05:03 PM 2/16/2003 +0800, Guy Worthington wrote:
I'm seem to be using this mailing list as private correspondence, I'll try to keep my posting down in future. But..
Following up on my question on how to inline XML code, I vaguely remember reading that the TeX primitive \par, has no effect in restricted horizontal mode, (I think that's what it's called, anyways the horizontal mode that's not paragraph mode). So on that assumption, I forced the verbatim pretty printer to operate inside an \hbox, with the following code:
--------------------------------------------------
%output=pdf \definetyping [XMLtag] [option=XML] \setuptyping [XMLtag] [before={\ \hbox\bgroup}, after={\egroup\ }, palet=colorpretty]
\setupcolors[state=start]
\starttext
This is a \startXMLtag <TABLE/> \stopXMLtag tag inline; and this is a comment \startXMLtag <!-- comment --> \stopXMLtag
\startXML <!-- This is displayed XML --> <TABLE/> \stopXML
\stoptext
did you try: \setupcolors[state=start] \definetype[typeXML][option=XML,palet=colorpretty] test \typeXML{<what/>} test \startXML <what> \stopXML (ps i just found out that the palet is not predefined here, but the previous code should work ok) Another nice one is: %\setupXMLfile[level=2] %\showXMLlin[here,there] %\showXMLwrd[whow] (ign,lin,wrd,par,txt,nop,emp) \startbuffer <here> <there> <whow> oeps </whow> </there> </here> \stopbuffer \showXMLbuffer there is also \showXMLfile i'll add an \showXMLtext{<here> <there> <whow> oeps </whow> </there> </here>} \showXMLtext{<here><there><whow>oeps</whow></there></here>} this trickery is used in: texexec --pdf --use=xml-01 somexmlfile [--mode=packed,wide] : use pdftotext afterwards and you'll have a prettier xml file texexec --pdf --use=xml-02 somexmlfile : pretty print (recognized xsd, rlg, xml, exa) Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
Hans Hagen wrote:
[to inline xml] try:
\setupcolors[state=start]
\definetype[typeXML][option=XML,palet=colorpretty]
test \typeXML{<what/>} test
The code works, and, as usual, you've upstaged me with a much cleaner interface.
Another nice one is:
%\setupXMLfile[level=2] %\showXMLlin[here,there] %\showXMLwrd[whow]
(ign,lin,wrd,par,txt,nop,emp)
\startbuffer <here> <there> <whow> oeps </whow> </there> </here> \stopbuffer
\showXMLbuffer
there is also \showXMLfile
Hans, you make life hard. I've been playing around with this, this afternoon, it's like magic. But now I've got to rethink how I format XML to exploit the pretty-printing capability, especially how I should group elements.
this trickery is used in:
$ texexec --pdf --use=xml-01 somexmlfile [--mode=packed,wide]
use pdftotext afterwards and you'll have a prettier xml file
Do you wake up in the morning and think to yourself I'll build a better version of lgrind? This I can use immediately. Thankyou.
$ texexec --pdf --use=xml-02 somexmlfile
pretty print (recognized xsd, rlg, xml, exa)
And it also comes in colour.
At 09:23 PM 2/18/2003 +0800, Guy Worthington wrote:
Hans, you make life hard. I've been playing around with this, this afternoon, it's like magic. But now I've got to rethink how I format XML to exploit the pretty-printing capability, especially how I should group elements.
Say that you use relax ng, have the following def's in, say, eximple.rng: <?xml version="1.0" ?> <?context-block begin grammar ?> <grammar xmlns="http://relaxng.org/ns/structure/1.0"> <?context-block end grammar ?> <?context-block begin framework ?> <start> <choice> <ref name="request"/> <ref name="reply"/> </choice> </start> <?context-block end framework ?> ..... <?context-block begin grammar ?> </grammar> <?context-block end grammar ?> then you can say: \definefilesynonym [eximple] [eximple.rng] and later on pick up the components: \showRNGcomponent[eximple][framework] saves you some work and make documentation in a separate file easier Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
participants (2)
-
Guy Worthington
-
Hans Hagen