Edgewall Software
Modify

Opened 17 years ago

Closed 17 years ago

#4471 closed defect (wontfix)

Highlighter for sql comment mishighlights contained apostrophe

Reported by: brian.derocher@… Owned by: Christian Boos
Priority: normal Milestone:
Component: version control/browser Version: 0.10.3
Severity: minor Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Apostrophe in SQL comment should not activate HTML class="code-string" in syntax highlighting.

Attachments (0)

Change History (4)

comment:1 by Tim Hatch, 17 years ago

Summary: syntax highlight SQL commentHighlighter for sql comment mishighlights contained apostrophe

I can't reproduce your bug using the sql renderer from Enscript, SilverCity, or Pygments. From your description, it sounds like you're saying that the following snippet mishighlights.

select * from table; /* comment 'still a comment' */

I do not believe this to be a bug in Trac, and code-string makes me think you're using Enscript… can you provide a minimal example so we can make sure it's not an issue in Trac? (if it is, I'm guessing #3262)

comment:2 by brian.derocher@…, 17 years ago

Pardon me for being picky. Above you use single quotes. While they are the same character as apostrophes, they are different things.

SQL comments can also be made like this, sorry for not being explicit:

-- This comment doesn't work.

After previewing this comment, i'm not sure why it's working here. But where i really see the problem is with browse source, when the source file is SQL.

I don't manage this installation of trac, so i'm not sure what it's using for syntax highlighting. Only enscript is intalled as a package (debian sid) and trac.ini refers to it, though i'm not sure if

enscript_path = enscript

means trac is using it. BTW trac is not installed via debian.

On a philosophical note, i do believe trac is responsible for this bug. My reasoning is, as a user, i don't care if trac uses libx, liby, enscript, libz. I'm using trac not enscript, so that's where i'll file the bug. I hope you forward this bug upstream if needed.

It does look like the culprit is enscript:

echo "-- Doesn't work" | enscript --highlight=sql -p - -whtml

<PRE>
-- Doesn<B>'t work
</B></PRE>

(Whoa! What's with the pre and bold tags anyway. XHTML was recommended in 2001.)

I don't see where <span class='code-string' /> comes from, but that bold tag should not be there.

My installation is on our intranet, but here's an example.

http://umdb.urania.be/trac/browser/live/geminids2006/functions.sql

comment:3 by Tim Hatch, 17 years ago

Yes, you're using Enscript. This site uses SilverCity. And will soon use Pygments.

I did some custom lexer work with Enscript before and it's a relatively simple fix. The issue is actually that -- doesn't start a comment for it as it's designed for the sybase dialect (according to a comment).

You can patch sql.st possibly located in /usr/local/share/enscript/hl to support this. I also suggest emailing the author of Enscript or the listed author for sql.st, however I have never gotten a response from the author myself. Another option is to use a different highlighter, such as Pygments (tested and known to understand this syntax) or SilverCity (appears to work on t.e.o).

  • .st

    old new  
    3636    call (sql_comment);
    3737    comment_face (false);
    3838  }
     39  /--/ {
     40    comment_face (true);
     41    language_print ($0);
     42    call (eat_one_line);
     43    comment_face (false);
     44  }
    3945
    4046  /* String constants. */
    4147  /\"/ {

For future reference, Trac arrives the css classes by first highlighting with --color (example using an unpatched state file):

$ echo "-- Doesn't work" | enscript pt --color -h -q --language=html -p Esql
...
<PRE>
-- Doesn<B><FONT COLOR="#BC8F8F">'t work
</FONT></B></PRE>
...

Then some regexps in EnscriptDeuglifier transform those colors into named classes - see source:trunk/trac/mimeview/enscript.py@4451#L78

Proposing to close as invalid since Enscript's source as packaged by various distros is not something we have any control over, and for milestone:0.11 we'll use Pygments by default.

in reply to:  2 comment:4 by Matthew Good, 17 years ago

Resolution: wontfix
Status: newclosed

Replying to brian.derocher@mitretek.org:

On a philosophical note, i do believe trac is responsible for this bug. My reasoning is, as a user, i don't care if trac uses libx, liby, enscript, libz. I'm using trac not enscript, so that's where i'll file the bug. I hope you forward this bug upstream if needed.

Unfortunately there's not really an "upstream" to forward this to since enscript has not made a release since early 2003. Your best bet for getting this fixed in enscript is to file a bug against the Debian package.

Enscript's lack of updates is one of the reasons SilverCity and Pygments are preferred. Pygments will be officially supported in 0.11, but you can also use it on Trac 0.10 via the plugin: th:TracPygmentsPlugin

I'm closing as wontfix since we can't actually fix the issue in enscript, but you're encouraged to install one of the preferred highlighters.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.