Rosetta Code:Village Pump/Syntax highlighting: Difference between revisions

Line 63:
::: As you see, a line break directly after the pre tag is removed.
::: One thing I previously got wrong it that this deletion is only if there's ''only'' a newline, any extra whitespace after the pre or before the /pre causes the newline not to be removed. But then, this should simplify the algorithm considerably: Instead of general trimming, one has only to check whether the first resp. last character of the text inside tags is a newline, and if so, remove it. --[[User:Ce|Ce]] 08:39, 11 October 2009 (UTC)
:::: Looking at the HTML source of the page, I now noticed several things:
:::: * GeSHi already uses pre tags internally, but:
:::: * it adds an <em>additional</em> &amp;nbsp; to the first and last (empty) line. This space is ''not'' in the source, and I'd therefore consider it a bug in its own right.:::: * it replaces all newline characters by &lt;br /&gt; which is not only a waste of bandwidth (because pre already honors newline characters), but also defeats the pre tag handling of newlines at the beginning/end.
:::: So the fix would probably to just remove the two latter points.
:::: BTW, whitespace highlighting currently seems broken anyway, because it doesn't currently highlight newlines:
<lang whitespace>
<-_just_three_spaces
<-_a_newline,_followed_by_three_more_spaces
</lang>
:::: (my comments apply to what I think <em>should</em> be highlighted; from your interpretation, you'd expect two additional newlines at the beginning/end to be highlighted) Note that the extra spaces in the extra lines (although not highlighted) will break the whitespace code when doing copy/paste, even if using your interpretation. --[[User:Ce|Ce]] 09:03, 11 October 2009 (UTC)
 
=Java5 Highlighting=
973

edits