Village Pump:Home/Syntax Highlighting ( archived 2009-06-18 ): Difference between revisions

Line 197:
==Another problem with eating whitespace characters==
I just noted another problem with eating whitespace characters, which is related to the Whitespace language problem, but exists for all languages: If the first line is indented, the indentation is eaten. Example:
<codelang cpp>
int i = 1;
++i;
return i;
</codelang>
In the source, all lines are indented with two spaces. In the resulting page, the indentation of the first line is gone.
 
IMHO whitespace characters should only be eaten up to and including the first newline. I guess currently there's a regexp like <tt><nowiki>[ \t\n]*</nowiki></tt> for eating the initial whitespace. This should be changed to <tt><nowiki>[ \t]*\n</nowiki></tt>. --[[User:Ce|Ce]] 16:12, 26 January 2009 (UTC)
:Fixed. GeshiCodeTag was feeding the source block through trim() prior to passing it on to GeSHi. I removed the call to trim(). --[[User:Short Circuit|Short Circuit]] 22:00, 29 January 2009 (UTC)
::That introduces another "problem". People seem to like moving the lang tags to the lines before and after the code. Before it didn't add an extra line before and after, but now it does. Compare the cpp example above (with the tags separate from the code) to the code below (with the tags inline with code):
::<lang cpp> int i = 1;
++i;
return i;</lang>
::--[[User:Mwn3d|Mwn3d]] 22:34, 29 January 2009 (UTC)
 
==D problem==
Anonymous user