In-line syntax highlighting for type
Hi, How can I define a command that is the inline version of \startTEX ... \stopTEX. (I need to show inline commands in color). There had been a discussion on this in the past, and Taco had suggested a solution http://archive.contextgarden.net/thread/20050907.093522.baf795f5.en.html which is also posted on the wiki. http://wiki.contextgarden.net/Verbatim_text#In-line_text However, due to the recent changes in verbatim code, that solution no longer works. Can anyone suggest how to fix it? Thanks, Aditya
Aditya Mahajan wrote:
Hi,
How can I define a command that is the inline version of \startTEX ... \stopTEX. (I need to show inline commands in color). There had been a discussion on this in the past, and Taco had suggested a solution
http://archive.contextgarden.net/thread/20050907.093522.baf795f5.en.html
which is also posted on the wiki.
http://wiki.contextgarden.net/Verbatim_text#In-line_text
However, due to the recent changes in verbatim code, that solution no longer works. Can anyone suggest how to fix it?
\setupcolors[state=start] \setuptype[option=TEX] \definetype[typeTEX][option=tex] \starttext \type+\type{\type is a wonderful macro}+, isn't it? \typeTEX+\typeTEX{\typeTEX is a wonderful macro}+, isn't it? \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Wed, 25 Oct 2006, Hans Hagen wrote:
Aditya Mahajan wrote:
Hi,
How can I define a command that is the inline version of \startTEX ... \stopTEX. (I need to show inline commands in color). There had been a discussion on this in the past, and Taco had suggested a solution
http://archive.contextgarden.net/thread/20050907.093522.baf795f5.en.html
which is also posted on the wiki.
http://wiki.contextgarden.net/Verbatim_text#In-line_text
However, due to the recent changes in verbatim code, that solution no longer works. Can anyone suggest how to fix it?
\setupcolors[state=start]
\setuptype[option=TEX]
\definetype[typeTEX][option=tex]
\starttext
\type+\type{\type is a wonderful macro}+, isn't it?
\typeTEX+\typeTEX{\typeTEX is a wonderful macro}+, isn't it?
\stoptext
Thanks, that looks easy :-) However, there seems to be a bug, sometimes the color spills across the type boundary. \setupcolors[state=start] \setuptype[option=TEX] \definetype[typeTEX][option=tex] \starttext The options \type+before=\startsolutionbackground+ and \type+after=\stopsolutionbackground+ take care of putting a frame, which can {\black The options \typeTEX+before=\startsolutionbackground+ and \typeTEX+after=\stopsolutionbackground+ take care of putting a frame, which can } \stoptext Aditya
On Wed, 25 Oct 2006, Aditya Mahajan wrote:
On Wed, 25 Oct 2006, Hans Hagen wrote:
Aditya Mahajan wrote:
Hi,
How can I define a command that is the inline version of \startTEX ... \stopTEX. (I need to show inline commands in color). There had been a discussion on this in the past, and Taco had suggested a solution
http://archive.contextgarden.net/thread/20050907.093522.baf795f5.en.html
which is also posted on the wiki.
http://wiki.contextgarden.net/Verbatim_text#In-line_text
However, due to the recent changes in verbatim code, that solution no longer works. Can anyone suggest how to fix it?
\setupcolors[state=start]
\setuptype[option=TEX]
\definetype[typeTEX][option=tex]
\starttext
\type+\type{\type is a wonderful macro}+, isn't it?
\typeTEX+\typeTEX{\typeTEX is a wonderful macro}+, isn't it?
\stoptext
Thanks, that looks easy :-)
However, there seems to be a bug, sometimes the color spills across the type boundary.
Is is possible that everything written with \tex{command} is also printed in color? I do not want to change \tex{command} to \type{\command} since \tex is more robust (No catcode trickery and stuff). Aditya
On 10/25/06, Aditya Mahajan
On Wed, 25 Oct 2006, Aditya Mahajan wrote:
On Wed, 25 Oct 2006, Hans Hagen wrote:
Aditya Mahajan wrote:
Hi,
How can I define a command that is the inline version of \startTEX ... \stopTEX. (I need to show inline commands in color).
\setupcolors[state=start]
\setuptype[option=TEX]
\definetype[typeTEX][option=tex]
\starttext
\type+\type{\type is a wonderful macro}+, isn't it?
\typeTEX+\typeTEX{\typeTEX is a wonderful macro}+, isn't it?
\stoptext
Thanks, that looks easy :-)
However, there seems to be a bug, sometimes the color spills across the type boundary.
I wanted to warn you about that, but you were faster. A workaround is to create an additional space: so to \type{\commands }like that. There are many bugs in \type-ing code, but the code is rather complex ... even Taco complaind about complexity. Hopefully lua will be able to do the task better ;) Mojca
Mojca Miklavec wrote:
On 10/25/06, Aditya Mahajan
wrote: On Wed, 25 Oct 2006, Aditya Mahajan wrote:
On Wed, 25 Oct 2006, Hans Hagen wrote:
Aditya Mahajan wrote:
Hi,
How can I define a command that is the inline version of \startTEX ... \stopTEX. (I need to show inline commands in color).
\setupcolors[state=start]
\setuptype[option=TEX]
\definetype[typeTEX][option=tex]
\starttext
\type+\type{\type is a wonderful macro}+, isn't it?
\typeTEX+\typeTEX{\typeTEX is a wonderful macro}+, isn't it?
\stoptext
Thanks, that looks easy :-)
However, there seems to be a bug, sometimes the color spills across the type boundary.
I wanted to warn you about that, but you were faster. A workaround is to create an additional space: so to \type{\commands }like that.
There are many bugs in \type-ing code, but the code is rather complex .... even Taco complaind about complexity.
Hopefully lua will be able to do the task better ;)
actually, the mkiv code does it completely different already, but that's on my machine -) Hans -- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Mojca Miklavec wrote:
There are many bugs in \type-ing code, but the code is rather complex .... even Taco complaind about complexity.
hm, that many? well, keep in mind that everything that involves catcode changes combined with arguments will be messy; also, much of this code evolved when mem and speed were issues, and of course there was this \type+crap+ kind of syntax to deal with as well Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Aditya Mahajan wrote:
However, there seems to be a bug, sometimes the color spills across the type boundary.
the problem is that we cannot mess around too much with egroup because otherwise we get into problems with alignments (which have their own idea about these things Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Wed, 25 Oct 2006, Hans Hagen wrote:
Aditya Mahajan wrote:
However, there seems to be a bug, sometimes the color spills across the type boundary.
the problem is that we cannot mess around too much with egroup because otherwise we get into problems with alignments (which have their own idea about these things
I understand that this is one of the more tricky things in TeX. Right now, Mojca's workaround of adding a space after the comand works most of the time. If there is a punctuations after the type+...+ one does not want a space between the type and the punctuation. \unskip and friends make the output look alright, but with a horrible looking source. I hope that lua will make doing these things a bit easier. Aditya
Aditya Mahajan wrote:
I understand that this is one of the more tricky things in TeX. Right now, Mojca's workaround of adding a space after the comand works most of the time. If there is a punctuations after the type+...+ one does not want a space between the type and the punctuation. \unskip and friends make the output look alright, but with a horrible looking source.
I hope that lua will make doing these things a bit easier.
in that case the whole pretty printing is done in lua ; in tex we have to use aftergroup stuff and the problem is that info is lost on the way (ok, there is a solution, but it involves messy macros because we want to use all that stuff nested as well) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (3)
-
Aditya Mahajan
-
Hans Hagen
-
Mojca Miklavec