highlight for TeX?
Christoph,
I would love to contribute the module myself, but I have tried to adapt buff-imp-tex.lua
to your t-highlight-tex.lua
and I miserably failed (all was blue, except comments [all in gray]).
Would it be possible (when you have time), that you adapt buff-imp-tex.*
to the module?
Many thanks for your help,
Pablo
Comments (9)
-
repo owner -
reporter Hi Christoph,
many thanks for the fixes for both TeX and Lua comments.
There is still an issue with multiline comments in Lua:
\starttext \startTEXpage[offset=2em] \startLUA --[[ multiline comment --]] ---[[ multiline, but not a comment --]] \stopLUA \stopTEXpage \stoptext
Many thanks for your help »und einen guten Rutsch ins Neujahr«,
Pablo
-
repo owner Thank you for the "Rutsch ins Neujahr" and a happy new year to you too!
Now, the multi-line comments in Lua are a little bit more involved. You have to do two replacements in
buff-imp-lua.lua
.Replace
local comment = P("--")
with
local comment = P("--") * (patterns.anything - patterns.newline)^0 local commentopen = P("--[[") local commentclose = P("--]]") local commentinterior = patterns.utf8char - commentclose - patterns.newline
And replace
comment = makepattern(handler,"comment",comment) * (V("space") + V("content"))^0,
with
comment = makepattern(handler, "comment", commentopen) * ( makepattern(handler, "comment", commentinterior) + V("whitespace") )^0 * makepattern(handler, "comment", commentclose) + makepattern(handler,"comment",comment),
Does that work?
-
reporter Many thanks for your help, Christopher.
It worked perfectly fine (in the samples I used).
Since you use a different coloring scheme than the standard ConTeXt core, how about adding the
buff-imp-*.*
(well, only for TeX, Lua and MP) in your module?Many thanks for your help again (and excuse my delay in replying),
Pablo
-
repo owner Dear Pablo,
Thank you for your feedback. Note that you can customize the colors in the highlight-module. E.g. for XML:
\setupstartstop[XmlSnippetName][color=...] \setupstartstop[XmlSnippetKey][color=...] \setupstartstop[XmlSnippetBoundary][color=...] \setupstartstop[XmlSnippetEntity][color=...] \setupstartstop[XmlSnippetString][color=...] \setupstartstop[XmlSnippetEqual][color=...] \setupstartstop[XmlSnippetComment][color=...] \setupstartstop[XmlSnippetCdata][color=...] \setupstartstop[XmlSnippetInstruction][color=...] \setupstartstop[XmlSnippetAttrVal][color=...]
Would this be sufficient for you?
I am not sure when I will find the time to include TEX, MP, and LUA in the highlight-module.
Cheers, Christoph
-
reporter Sorry for my delayed reply, Christoph.
I think I can make a pull request with TeX and Lua highlight (I didn’t use MP more than twice). But consider before accepting:
-
I’ve copied and pasted code from the ConTeXt core (with your patches).
-
I have tested the new files, but not extensively (I don’t have so many documents to test them with).
-
I have never made a pull request in Bitbucket, so I hope I don’t break anything.
Of course, you can always reject the pull request.
Many thanks for your help,
Pablo
-
-
repo owner Dear Pablo,
If you like you also can just send me the files directly via email and I will integrate them into the highlight module. By the way: Did you ask whether Hans Hagen would be willing to patch the syntax highlighting for tex and lua directly in the ConTeXt sources? (Just a thought.)
Kind regards,
Christoph
-
reporter Dear Christoph,
I had the idea after you send the patches.
I will send the patches to the ConTeXt development mailing list (of course, referring to this issue and attributing the code to you) and see if Hans wants to merge them.
The only objection to that merge would be the internal logic that he wants to preserve (as he mentioned in the mailing list).
But having TeX and Lua highlighting in your module is also good.
Many thanks for your help,
Pablo
-
reporter - changed status to resolved
Closiing the issue myself.
- Log in to comment
Hi Pablo,
Try in
buff-imp-tex.lua
to replace the linewith
Similarly, you could in
buff-imp-lua.lua
replacewith
Do you then get the desired effect (without the highlight module)? (Don't forget to run
context --make
after editing the above files.)Christoph