Village Pump:Home/Syntax Highlighting ( archived 2009-06-18 ): Difference between revisions
Content added Content deleted
(→Whitespace: Replaced code and pre blocks with lang blocks. WHITESPACE highlighting works?!) |
|||
Line 146: | Line 146: | ||
==Whitespace== |
==Whitespace== |
||
If anyone ever feels like putting whitespace code on here (unlikely but possible) they may have trouble highlighting it: |
If anyone ever feels like putting whitespace code on here (unlikely but possible) they may have trouble highlighting it: |
||
< |
<lang whitespace> |
||
</ |
</lang> |
||
Taking out the nowiki tags eliminates the code: |
Taking out the nowiki tags eliminates the code: |
||
< |
<lang whitespace> |
||
</ |
</lang> |
||
Not sure if that can be fixed or not. --[[User:Mwn3d|Mwn3d]] 18:58, 23 January 2009 (UTC) |
Not sure if that can be fixed or not. --[[User:Mwn3d|Mwn3d]] 18:58, 23 January 2009 (UTC) |
||
: I guess it comes from the code removing those superfluous (in other languages) lines at the beginning and end (e.g. instead of the ugly |
: I guess it comes from the code removing those superfluous (in other languages) lines at the beginning and end (e.g. instead of the ugly |
||
⚫ | |||
<pre> |
|||
⚫ | |||
{ |
{ |
||
}</ |
}</lang> |
||
</pre> |
|||
: you can write a more reasonable |
: you can write a more reasonable |
||
< |
<lang c> |
||
<code c> |
|||
int main() |
int main() |
||
{ |
{ |
||
} |
} |
||
</ |
</lang> |
||
</pre> |
|||
: without getting empty lines at the beginning/end. |
: without getting empty lines at the beginning/end. |
||
: Note that in Whitespace, every non-whitespace character is a comment, so you can simply write any non-whitespace stuff at the beginning/end: |
: Note that in Whitespace, every non-whitespace character is a comment, so you can simply write any non-whitespace stuff at the beginning/end: |
||
< |
<lang whitespace> |
||
code: |
code: |
||
end |
end |
||
</ |
</lang> |
||
: (note that this probably isn't a valid whitespace program; I just randomly added spaces/tabs). |
: (note that this probably isn't a valid whitespace program; I just randomly added spaces/tabs). |
||
: However, last friday, whitespace got nicely colored (tabs were bright red and spaces bright blue, IIRC). Now it's just white. Looking at the generated HTML, it seems classes "re2" (space) and "re3" (tab) are responsible for whitespace hilighting. Setting the background property for them should re-enable whitespace highlighting. --[[User:Ce|Ce]] 11:57, 26 January 2009 (UTC) |
: However, last friday, whitespace got nicely colored (tabs were bright red and spaces bright blue, IIRC). Now it's just white. Looking at the generated HTML, it seems classes "re2" (space) and "re3" (tab) are responsible for whitespace hilighting. Setting the background property for them should re-enable whitespace highlighting. --[[User:Ce|Ce]] 11:57, 26 January 2009 (UTC) |
||
:: I've now found a trick to get Whitespace highlighting without any (visible) text around it: Use the Unicode character U+FEFF (ZERO WIDTH NO-BREAK SPACE) to mark the start/end of the code: |
:: I've now found a trick to get Whitespace highlighting without any (visible) text around it: Use the Unicode character U+FEFF (ZERO WIDTH NO-BREAK SPACE) to mark the start/end of the code: |
||
< |
<lang whitespace> |
||
|
|
||
Line 192: | Line 188: | ||
|
|
||
</ |
</lang> |
||
:: Note that U+FEFF renders as absolutely nothing, and is not whitespace as defined by Whitespace (although it ''is'' whitespace according to Unicode), and therefore should be ignored as "comment" by whitespace interpreters (I didn't test that, though). It apparently also isn't considered whitespace by the start/end line removing code, therefore it's not removed. --[[User:Ce|Ce]] 15:22, 26 January 2009 (UTC) |
:: Note that U+FEFF renders as absolutely nothing, and is not whitespace as defined by Whitespace (although it ''is'' whitespace according to Unicode), and therefore should be ignored as "comment" by whitespace interpreters (I didn't test that, though). It apparently also isn't considered whitespace by the start/end line removing code, therefore it's not removed. --[[User:Ce|Ce]] 15:22, 26 January 2009 (UTC) |
||
: Whitespace hightlighting now works as expected. I updated the code in this section to reflect the new lang tag, and I'm amazed that it works, myself... --[[User:Short Circuit|Short Circuit]] 08:09, 30 January 2009 (UTC) |
|||
==Another problem with eating whitespace characters== |
==Another problem with eating whitespace characters== |