[go: up one dir, main page]

Menu

#115 Coloring issues with LaTeX

colorer-take5
closed-fixed
HRC codes (39)
5
2007-01-09
2007-01-03
No

I know, TeX/LaTeX is probably one of the harder formats to colorize correctly, but overall colorer does quite a good job there.

Since, $ starts math mode in LaTeX nad thus appropriate highlighting in Colorer and it can be used nearly everywhere, especially in code, this can lead to the following quirk:

\documentclass{article}
\begin{document}
\begin{verbatim}
$var = "blah";
\end{verbatim}
\end{document}

where math mode extends beyond the verbatim block, same works for lstlisting as well and for $$, \[ or \(. However,

\verb#$#

does work correctly and won't trigger math mode highlighting. I've looked into the HRC but couldn't come up with a quick fix to this problem. Solution would be, to disable different highlighting modes in verbatim and similar blocks (lstlisting is one of them), though I'm unable to do that :)

Discussion

  • Igor Russkih

    Igor Russkih - 2007-01-09
    • assigned_to: nobody --> lomecb
    • status: open --> closed-fixed
     
  • Igor Russkih

    Igor Russkih - 2007-01-09

    Logged In: YES
    user_id=313042
    Originator: NO

    Johannes,

    Thanks for reporting this,

    This particular problem is fixed in Revision 860
    http://svn.sourceforge.net/colorer/?rev=860&view=rev

    Patch is

    Modified: trunk/colorer/hrc/scripts/tex.hrc

    --- trunk/colorer/hrc/scripts/tex.hrc 2007-01-06 20:23:26 UTC (rev 859)
    +++ trunk/colorer/hrc/scripts/tex.hrc 2007-01-06 20:27:22 UTC (rev 860)
    @@ -104,6 +104,12 @@

    <block start="/\\begin\{comment\}/" end="/\\end\{comment\}/" scheme="Comment"
    region="Comment" region00="PairStart" region10="PairEnd"/>
    +
    + <block start="/(\\begin\s*\{)(verbatim)(\})/" end="/(\\end\s*\{)(verbatim)(\})/x" scheme="def:Comment" region="Bracket"
    + region00="PairStart" region10="PairEnd"
    + region01="Word" region11="Word"
    + region02="LargeBracket" region12="LargeBracket"
    + region03="Word" region13="Word"/>

    Please report any other TeX issues if find them. I'm now tightly working with TeX so trying to fix everything on the way ;)

    Igor

     
  • Johannes Rössel

    Logged In: YES
    user_id=926044
    Originator: YES

    \begin{lstlisting}
    s = string.gsub(s, "\\(%a+){(.-)}", "<%1>%2</%1>")
    \end{lstlisting}

    for instance still trips. I don't know how much semantic highlighting you desire, especially due to the multitude of packages out there that possibly do something nasty with commands. But I think I saw lstlisting mentioned elsewhere in the hrc, so maybe you give some commonly used commands special behaviour.

     

Log in to post a comment.