type and typing comments for TeX and Lua
Hans, sorry for insisting, but I really need this. I have the following sample: \definetype[context][option=tex] \definetype[lua][option=lua] \starttext \startTEXpage[offset=2em] a \TEX\ inline comment: \context{ag%befe} \Lua\ inline comment: \lua{agb --efe} \startTEX This is text. % a comment, not \comment \stopTEX \startXML <p>This is text.<!--and this is a comment--></p> \stopXML \startLUA if code=="code" then --this is a comment \stopLUA \stopTEXpage \stoptext Would it be possible that all comments in type and typing (at least, for Lua, XML and TeX) would have the same formatting for the whole comment contents, including the comment signs? Sorry, but with the current output, it is hard to see (for total newbies) what is part of the comment and what not. And the text editor will display something different. I’m afraid that the scite module isn’t an option for me. Many thanks for your help, Pablo -- http://www.ousia.tk
On Mon, 18 Dec 2017, Pablo Rodriguez wrote:
\definetype[context][option=tex] \definetype[lua][option=lua] \starttext \startTEXpage[offset=2em]
a \TEX\ inline comment: \context{ag%befe}
\Lua\ inline comment: \lua{agb --efe}
\startTEX This is text. % a comment, not \comment \stopTEX
\startXML <p>This is text.<!--and this is a comment--></p> \stopXML
\startLUA if code=="code" then --this is a comment \stopLUA \stopTEXpage \stoptext
Would it be possible that all comments in type and typing (at least, for Lua, XML and TeX) would have the same formatting for the whole comment contents, including the comment signs?
Sorry, but with the current output, it is hard to see (for total newbies) what is part of the comment and what not. And the text editor will display something different.
I’m afraid that the scite module isn’t an option for me.
t-vim parses this correctly, but IIRC, you don't want to use the vim module either, right? Aditya
On 12/19/2017 08:26 PM, Aditya Mahajan wrote:
On Mon, 18 Dec 2017, Pablo Rodriguez wrote:
[...] Would it be possible that all comments in type and typing (at least, for Lua, XML and TeX) would have the same formatting for the whole comment contents, including the comment signs?
Sorry, but with the current output, it is hard to see (for total newbies) what is part of the comment and what not. And the text editor will display something different.
I’m afraid that the scite module isn’t an option for me.
t-vim parses this correctly, but IIRC, you don't want to use the vim module either, right?
Aditya, I checked your t-vim module months ago and I don’t remember which were the problems, but I had to discard it. I reported this issue three times before (twice in August and once in October). What strikes me most is not why it hasn’t been fixed yet, but which is the rationale behind this behavior. I was writing an (Spanish) introduction to ConTeXt and I had to stop it because I couldn’t explain comments having a different color scheme in text than the display in a text editor (TeXworks to name the most simple one). But I hope this can be fixed in the future. Many thanks for your help, Pablo -- http://www.ousia.tk
On Tue, 19 Dec 2017, Pablo Rodriguez wrote:
On 12/19/2017 08:26 PM, Aditya Mahajan wrote:
On Mon, 18 Dec 2017, Pablo Rodriguez wrote:
[...] Would it be possible that all comments in type and typing (at least, for Lua, XML and TeX) would have the same formatting for the whole comment contents, including the comment signs?
Sorry, but with the current output, it is hard to see (for total newbies) what is part of the comment and what not. And the text editor will display something different.
I’m afraid that the scite module isn’t an option for me.
t-vim parses this correctly, but IIRC, you don't want to use the vim module either, right?
Aditya,
I checked your t-vim module months ago and I don’t remember which were the problems, but I had to discard it.
Just try your document with t-vim. It should be as simple as subsituting \usemodule[vim] \definevimtyping[context][syntax=context] \definevimtyping[lua][syntax=lua] instead of the \setuptyping commands. If you have a lot of code snippets, create an subdirectory called output and also set \setupvimtyping[directory=output] Let me know if there are any errors and I can look into it (except if the error is related to a windows configuration issue. I don't have a windows machine to test the module). Aditya
On 12/20/2017 12:20 AM, Aditya Mahajan wrote:
On Tue, 19 Dec 2017, Pablo Rodriguez wrote:
[...] I checked your t-vim module months ago and I don’t remember which were the problems, but I had to discard it.
Just try your document with t-vim. It should be as simple as subsituting
\usemodule[vim]
Many thanks for your reply, Aditya. My scenario is much more complex: I typeset XML (HTML4 or HTML5) generated from Markdown sources via pandoc. My commands are \xmlinlineprettyprinttext{#1}{tex} and \xmlprettyprinttext{#1}{tex}. I don’t remember which were the options in t-vim, but I need the options from \setuptyping and \setuptype. Many thanks for your help again, Pablo -- http://www.ousia.tk
On Thu, 21 Dec 2017, Pablo Rodriguez wrote:
On 12/20/2017 12:20 AM, Aditya Mahajan wrote:
On Tue, 19 Dec 2017, Pablo Rodriguez wrote:
[...] I checked your t-vim module months ago and I don’t remember which were the problems, but I had to discard it.
Just try your document with t-vim. It should be as simple as subsituting
\usemodule[vim]
Many thanks for your reply, Aditya.
My scenario is much more complex: I typeset XML (HTML4 or HTML5) generated from Markdown sources via pandoc.
My commands are \xmlinlineprettyprinttext{#1}{tex} and \xmlprettyprinttext{#1}{tex}.
I don’t remember which were the options in t-vim, but I need the options from \setuptyping and \setuptype.
Currently vim does not support these primarily because I don't use XML so I never thought of this. Could you send me a minimal example showing how \xmlprettyprinttext is used and I can check how to create an interface for t-vim. Aditya
On 12/21/2017 08:05 PM, Aditya Mahajan wrote:
On Thu, 21 Dec 2017, Pablo Rodriguez wrote:
[...] I don’t remember which were the options in t-vim, but I need the options from \setuptyping and \setuptype.
Currently vim does not support these primarily because I don't use XML so I never thought of this.
Could you send me a minimal example showing how \xmlprettyprinttext is used and I can check how to create an interface for t-vim.
Aditya, many thanks for your help. The goodie (as per lxml-ini.mkiv) reads as follow: \def\xmltempbuffername{xml-temp} \unexpanded\def\prettyprintbuffer#1#2% only used here {\ifdefined\scitebuffer \scitebuffer[#2][#1]% \else \typebuffer[#1][\c!option=#2]% \fi} %~ \unexpanded\def\xmlprettyprint#1#2% %~ {\xmltobufferverbose{#1}{.}{\xmltempbuffername}% %~ \prettyprintbuffer\xmltempbuffername{#2}} \unexpanded\def\xmlprettyprinttext#1#2% {\xmltobuffertextonly{#1}{.}{\xmltempbuffername}% \prettyprintbuffer\xmltempbuffername{#2}} \unexpanded\def\inlineprettyprintbuffer#1#2% only used here {\ifdefined\sciteinlinebuffer \sciteinlinebuffer[#2][#1]% \else \typeinlinebuffer[#1][\c!option=#2]% \fi} %~ \unexpanded\def\xmlinlineprettyprint#1#2% %~ {\xmltobufferverbose{#1}{.}{\xmltempbuffername}% %~ \inlineprettyprintbuffer\xmltempbuffername{#2}} \unexpanded\def\xmlinlineprettyprinttext#1#2% {\xmltobuffertextonly{#1}{.}{\xmltempbuffername}% \inlineprettyprintbuffer\xmltempbuffername{#2}} \xmltobuffertextonly is required to clean HTML hightlighted code, such as in https://shorturl.at/pS124. This is why only adapting both \xmlprettyprinttext and \xmlinlineprettyprint gets the fuctionality for the other two commands. The commands are invoked in this way: \xmlinlineprettyprinttext{#1}{tex} \xmlprettyprinttext{#1}{lua} Maybe adapting \prettyprintbuffer and \inlineprettyprintbuffer to the t-vim module works fine. (But this code is all Greek to me.) Many thanks for your help again, Pablo -- http://www.ousia.tk
On Thu, 21 Dec 2017, Pablo Rodriguez wrote:
On 12/21/2017 08:05 PM, Aditya Mahajan wrote:
On Thu, 21 Dec 2017, Pablo Rodriguez wrote:
[...] I don’t remember which were the options in t-vim, but I need the options from \setuptyping and \setuptype.
Currently vim does not support these primarily because I don't use XML so I never thought of this.
Could you send me a minimal example showing how \xmlprettyprinttext is used and I can check how to create an interface for t-vim.
Aditya,
many thanks for your help.
The goodie (as per lxml-ini.mkiv) reads as follow:
\def\xmltempbuffername{xml-temp}
\unexpanded\def\prettyprintbuffer#1#2% only used here {\ifdefined\scitebuffer \scitebuffer[#2][#1]% \else \typebuffer[#1][\c!option=#2]% \fi}
%~ \unexpanded\def\xmlprettyprint#1#2% %~ {\xmltobufferverbose{#1}{.}{\xmltempbuffername}% %~ \prettyprintbuffer\xmltempbuffername{#2}}
\unexpanded\def\xmlprettyprinttext#1#2% {\xmltobuffertextonly{#1}{.}{\xmltempbuffername}% \prettyprintbuffer\xmltempbuffername{#2}}
\unexpanded\def\inlineprettyprintbuffer#1#2% only used here {\ifdefined\sciteinlinebuffer \sciteinlinebuffer[#2][#1]% \else \typeinlinebuffer[#1][\c!option=#2]% \fi}
%~ \unexpanded\def\xmlinlineprettyprint#1#2% %~ {\xmltobufferverbose{#1}{.}{\xmltempbuffername}% %~ \inlineprettyprintbuffer\xmltempbuffername{#2}}
\unexpanded\def\xmlinlineprettyprinttext#1#2% {\xmltobuffertextonly{#1}{.}{\xmltempbuffername}% \inlineprettyprintbuffer\xmltempbuffername{#2}}
\xmltobuffertextonly is required to clean HTML hightlighted code, such as in https://shorturl.at/pS124.
This is why only adapting both \xmlprettyprinttext and \xmlinlineprettyprint gets the fuctionality for the other two commands.
The commands are invoked in this way:
\xmlinlineprettyprinttext{#1}{tex}
\xmlprettyprinttext{#1}{lua}
Maybe adapting \prettyprintbuffer and \inlineprettyprintbuffer to the t-vim module works fine. (But this code is all Greek to me.)
Many thanks for your help again,
Can you post a minimal working example. I don't use XML so it is difficult for me to understand how these commands are used in practice. Thanks, Aditya
On 12/21/2017 10:53 PM, Aditya Mahajan wrote:
[...] Can you post a minimal working example. I don't use XML so it is difficult for me to understand how these commands are used in practice.
Aditya, many thanks for your reply and your help. A minimal sample would be: \startbuffer[demo] <doc> <p>b</p> <code><a class="sourceLine" id="cb1-1" data-line-number="1"> <span class="kw"><p></span>a<span class="kw"></p></span> <span class="co"><!--comment--></span></a></code> </doc> \stopbuffer \startxmlsetups xml:initialize \xmlsetsetup{#1}{doc|p|code}{xml:*} \stopxmlsetups \xmlregistersetup{xml:initialize} \startxmlsetups xml:doc \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:p \startpar\xmlflush{#1}\stoppar \stopxmlsetups \startxmlsetups xml:code \xmlprettyprinttext{#1}{xml} \stopxmlsetups \starttext \xmlprocessbuffer{main}{demo}{} \stoptext But if this is too tricky to you, maybe it isn’t a good idea to extend the module to XML usage. There are (at least) two reasons for that: - I’m the only user who asked for this (too much trouble for a single user). - Easier alternatives would be to improve the ConTeXt core or the context-highlight module. Many thanks for your help again, Pablo -- http://www.ousia.tk
On Tue, 26 Dec 2017, Pablo Rodriguez wrote:
On 12/21/2017 10:53 PM, Aditya Mahajan wrote:
[...] Can you post a minimal working example. I don't use XML so it is difficult for me to understand how these commands are used in practice.
Aditya,
many thanks for your reply and your help.
A minimal sample would be:
\startbuffer[demo] <doc> <p>b</p> <code><a class="sourceLine" id="cb1-1" data-line-number="1"> <span class="kw"><p></span>a<span class="kw"></p></span> <span class="co"><!--comment--></span></a></code> </doc> \stopbuffer
\startxmlsetups xml:initialize \xmlsetsetup{#1}{doc|p|code}{xml:*} \stopxmlsetups
\xmlregistersetup{xml:initialize}
\startxmlsetups xml:doc \xmlflush{#1} \stopxmlsetups
\startxmlsetups xml:p \startpar\xmlflush{#1}\stoppar \stopxmlsetups
\startxmlsetups xml:code \xmlprettyprinttext{#1}{xml} \stopxmlsetups
\starttext \xmlprocessbuffer{main}{demo}{} \stoptext
But if this is too tricky to you, maybe it isn’t a good idea to extend the module to XML usage.
There are (at least) two reasons for that:
- I’m the only user who asked for this (too much trouble for a single user).
- Easier alternatives would be to improve the ConTeXt core or the context-highlight module.
It isn't too difficult to support this. See attached file. This will clutter your PWD with temp files. To avoid that, create a subdirectory called "output" and set \setupvimtyping[directory=output] Then all the temp files will be stored in the directory "output".
On 12/18/2017 11:50 PM, Pablo Rodriguez wrote:
Hans,
sorry for insisting, but I really need this.
I have the following sample:
\definetype[context][option=tex] \definetype[lua][option=lua] \starttext \startTEXpage[offset=2em]
a \TEX\ inline comment: \context{ag%befe}
\Lua\ inline comment: \lua{agb --efe}
\startTEX This is text. % a comment, not \comment \stopTEX
\startXML <p>This is text.<!--and this is a comment--></p> \stopXML
\startLUA if code=="code" then --this is a comment \stopLUA \stopTEXpage \stoptext
Would it be possible that all comments in type and typing (at least, for Lua, XML and TeX) would have the same formatting for the whole comment contents, including the comment signs?
Sorry, but with the current output, it is hard to see (for total newbies) what is part of the comment and what not. And the text editor will display something different.
It depends on the lexer ... % \usemodule[scite] % use editor logic % DIffers per lexer: \definestartstop [XmlSnippetComment] [color=, style=]
I’m afraid that the scite module isn’t an option for me. Then you need to configure the highligheters yourself
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 -----------------------------------------------------------------
On 12/20/2017 12:53 PM, Hans Hagen wrote:
On 12/18/2017 11:50 PM, Pablo Rodriguez wrote:
[...] % Differs per lexer:
\definestartstop [XmlSnippetComment] [color=, style=]
I’m afraid that the scite module isn’t an option for me.
Then you need to configure the highligheters yourself
Many thanks for your reply, Hans. I don’t mind to set up the highlighters myself, but the problem is the following. XmlSnippetComment only contains the text inside the comment, but not the marks (<!-- -->). LuaSnippetComment contains the marker (only --), but not the text. TexSnippetComment contains the marker (%), but not the text. Would it be possible that there are two SnippetComments for all lexers: SnippetCommentMark and SnippetCommentText? Many thanks for your help, Pablo -- http://www.ousia.tk
On 12/20/2017 8:45 PM, Pablo Rodriguez wrote:
On 12/20/2017 12:53 PM, Hans Hagen wrote:
On 12/18/2017 11:50 PM, Pablo Rodriguez wrote:
[...] % Differs per lexer:
\definestartstop [XmlSnippetComment] [color=, style=]
I’m afraid that the scite module isn’t an option for me.
Then you need to configure the highligheters yourself
Many thanks for your reply, Hans.
I don’t mind to set up the highlighters myself, but the problem is the following.
XmlSnippetComment only contains the text inside the comment, but not the marks (<!-- -->).
LuaSnippetComment contains the marker (only --), but not the text.
TexSnippetComment contains the marker (%), but not the text.
Would it be possible that there are two SnippetComments for all lexers: SnippetCommentMark and SnippetCommentText? very low priority ... there is some logic behind these that i don't want to break
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 -----------------------------------------------------------------
On 12/20/2017 10:18 PM, Hans Hagen wrote:
On 12/20/2017 8:45 PM, Pablo Rodriguez wrote:
[...] Would it be possible that there are two SnippetComments for all lexers: SnippetCommentMark and SnippetCommentText? very low priority ... there is some logic behind these that i don't want to break
Then I will have to wait for that implementation. Sorry for not being able to provide the patch myself. scite is great for coloring, but it lacks the options from \setuptype and \setuptyping. I don’t need escapes, but many of the other options. I need both complete comment coloring (otherwise it is really hard for newbies to see what a comment may be) and \setuptyping (and \setuptype) options. BTW, I’m afraid there is a bug with multiline comments in Lua. The first line break is removed in multiline: %~ \usemodule[scite] % to check the bug \starttext \startTEXpage[offset=2em] \startLUA --[[ multiline comment ]]-- ---[[ multiline comment ]]--- \stopLUA \stopTEXpage \stoptext Many thanks for your help again, Pablo -- http://www.ousia.tk
participants (3)
-
Aditya Mahajan
-
Hans Hagen
-
Pablo Rodriguez