Edgewall Software
Modify

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#1649 closed defect (fixed)

Extra lines w/ Silvercity mime formatting

Reported by: Emmanuel Blot Owned by: Christopher Lenz
Priority: low Milestone: 0.9
Component: wiki system Version: devel
Severity: minor Keywords:
Cc: Branch:
Release Notes:
API Changes:

Description

I think there is a trouble with the current SilverCity formatting, as per [1764]

<pre> blocks are appended to the formatted HTML stream, which creates two extra linefeed inside each code-block, i.e. a empty line appears between the code block and the first quoted line, as well as between the last quoted line and the end of the code-block. This does look good.

Removing the two last REs br_re and span_default_re, as well as the <pre> tag in the api.py file helps, but I guess there are here on purpose ;-), and that this trick will break another formatting.

BTW, I think there is a typo with the second <pre> tag after the code block which should be a </pre> tag (ending tag instead of opening tag).

Attachments (0)

Change History (9)

comment:1 by Emmanuel Blot, 14 years ago

Typo: I meant "this doesn't look good".

comment:2 by Christopher Lenz, 14 years ago

Owner: changed from Jonas Borgström to Christopher Lenz
Priority: normallow
Severity: normalminor
Status: newassigned

comment:3 by Christopher Lenz, 14 years ago

Hmm, it works correctly here AFAICT. What version of SilverCity are you using, and what kind of file are you trying to display?

comment:4 by Emmanuel Blot, 14 years ago

I tried several file types, such as C and PERL.

(I'm not sure how to get the actual SilverCity release, so) I've just updated to 0.9.5

With the following Wiki sample:

{{{
#!perl
use strict;
print "Hello World";
}}}

I get the following HTML code:

<div class="code-block"><pre><span class="pl_word">use</span><span class="pl_default"> </span><span class="pl_identifier">strict</span><span class="pl_operator">;</span><span class="pl_default">

</span><span class="pl_word">print</span><span class="pl_default"> </span><span class="pl_string">"Hello World"</span><span class="pl_operator">;</span><span class="pl_default">
</span>
<pre></div>

which displays as:

use strict;

print "Hello World";

On my computer (WinXP SP1 FireFox 1.0.4), the extra lines appear in this very bug report.

comment:5 by Emmanuel Blot, 14 years ago

This default appears on this page with Firefox 1.0.4, and IE 6.0.2800

comment:6 by Emmanuel Blot, 14 years ago

Can somebody confirm that the extra lines appear in this very report ?

I can see them w/ MacOS 10.4.2/Safari, as well as Firefox 1.0.6 (both under WinXP SP2 and Mac OsX)

comment:7 by Shun-ichi Goto <gotoh@…>, 14 years ago

I think this is a bug of SilverCity around CRLF issue. I noticed same behaviour on viewing C++ file in source browser. SilverCity seems to generates extra line in some type of line like comment or #include (in C++) with CRLF end-of-lne.

I made a patch for workaround by converting CRLF to LF:

--- silvercity.py	(revision 2017)
+++ silvercity.py	(working copy)
@@ -90,6 +90,11 @@
             err = "No SilverCity lexer found for mime-type '%s'." % mimetype
             raise Exception, err
 
+        # SilverCity generates extra empty line against some types of
+        # the line such as comment or #include with CRLF. So we
+        # standardize to LF end-of-line style before call.
+        crlf_re = re.compile('\r$', re.MULTILINE)
+        content = crlf_re.sub('', content)
         buf = StringIO()
         generator().generate_html(buf, content)

I'm using Trac r2017 and SilverCity 0.9.5 served on WindowsXP + Apache + mod_python.

comment:8 by Christopher Lenz, 14 years ago

Resolution: fixed
Status: assignedclosed

Patch applied in [2056]. Thanks!

comment:9 by Christopher Lenz, 14 years ago

testing notification

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christopher Lenz.
The resolution will be deleted. Next status will be 'reopened'.
to as closed The owner will be changed from Christopher Lenz 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.