Village Pump:Home/Syntax Highlighting ( archived 2009-06-18 ): Difference between revisions
Content added Content deleted
(→Old code used the right way: code tag is alright now.) |
No edit summary |
||
Line 25: | Line 25: | ||
: It's happened! I've replaced the GeSHiSyntaxHighlight Mediawiki extension with the GeSHiCodeTag extension. The old tag format works (for now), but it ''will'' be removed as soon as possible. All tags of <nowiki><mylang>some_code<mylang></nowiki> need to be changed to <nowiki><lang mylang>some_code</lang></nowiki>. So this block: |
: It's happened! I've replaced the GeSHiSyntaxHighlight Mediawiki extension with the GeSHiCodeTag extension. The old tag format works (for now), but it ''will'' be removed as soon as possible. All tags of <nowiki><mylang>some_code<mylang></nowiki> need to be changed to <nowiki><lang mylang>some_code</lang></nowiki>. So this block: |
||
<cpp>#include <stdio> |
<lang cpp>#include <stdio> |
||
int main() |
int main() |
||
{ |
{ |
||
std::cout << "Hi!" << std::endl; |
std::cout << "Hi!" << std::endl; |
||
return 0; |
return 0; |
||
}</ |
}</lang> |
||
: Should be rewrapped like this: |
: Should be rewrapped like this: |
||
Line 42: | Line 42: | ||
:: When the <nowiki><lang></nowiki> tags are removed, [[Special:Version]] will not any more list all the languages in the tags section, right? Maybe there should be a (perhaps auto-generated) page listing all supported languages (or maybe it's even possible to include them in [[Special:Version]] as separate section). Or maybe there's already such a list somewhere, which I simply didn't notice? --[[User:Ce|Ce]] 08:18, 23 January 2009 (UTC) |
:: When the <nowiki><lang></nowiki> tags are removed, [[Special:Version]] will not any more list all the languages in the tags section, right? Maybe there should be a (perhaps auto-generated) page listing all supported languages (or maybe it's even possible to include them in [[Special:Version]] as separate section). Or maybe there's already such a list somewhere, which I simply didn't notice? --[[User:Ce|Ce]] 08:18, 23 January 2009 (UTC) |
||
:::You mean [[Help:GeSHi#Supported_source_tags|this]]? --[[User:Mwn3d|Mwn3d]] 13:27, 23 January 2009 (UTC) |
:::You mean [[Help:GeSHi#Supported_source_tags|this]]? --[[User:Mwn3d|Mwn3d]] 13:27, 23 January 2009 (UTC) |
||
::: Another problem I just noticed: The old meaning of <nowiki>< |
::: Another problem I just noticed: The old meaning of <nowiki><tt>text</tt></nowiki> is now changed (it now creates a div block instead of inline text). Those tags might have been used already in this wiki. Maybe it would have been a better idea to use a tag which didn't yet have a meaning (say, <nowiki><source></nowiki>). I'm not sure whether it's a good idea to change the GeSHi tag now, or to find and change all previous usages of <nowiki><code></nowiki> instead. --[[User:Ce|Ce]] 08:50, 23 January 2009 (UTC) |
||
:::: I just noticed this too (when writing my task [[N distinct objects]]). Since &code> being inline is defined by the HTML specification, to be inline, we should not redefine it to be block. --[[User:Kevin Reid|Kevin Reid]] 00:48, 29 January 2009 (UTC) |
:::: I just noticed this too (when writing my task [[N distinct objects]]). Since &code> being inline is defined by the HTML specification, to be inline, we should not redefine it to be block. --[[User:Kevin Reid|Kevin Reid]] 00:48, 29 January 2009 (UTC) |
||
:::::You should use the <nowiki><tt></nowiki> tag instead. --[[User:Mwn3d|Mwn3d]] 01:57, 29 January 2009 (UTC) |
:::::You should use the <nowiki><tt></nowiki> tag instead. --[[User:Mwn3d|Mwn3d]] 01:57, 29 January 2009 (UTC) |
||
Line 95: | Line 95: | ||
==Problem with Lisp== |
==Problem with Lisp== |
||
There is something wrong with the highlighting of certain keywords in Lisp, for example: |
There is something wrong with the highlighting of certain keywords in Lisp, for example: |
||
<lisp>defun</ |
<lang lisp>defun</lang> |
||
<lisp>list</ |
<lang lisp>list</lang> |
||
<lisp>length</ |
<lang lisp>length</lang> |
||
--[[User:Spoon!|Spoon!]] 09:03, 3 November 2008 (UTC) |
--[[User:Spoon!|Spoon!]] 09:03, 3 November 2008 (UTC) |
||
Line 116: | Line 116: | ||
While adding some example for C, I noticed the following oddities: |
While adding some example for C, I noticed the following oddities: |
||
* the parser is not case sensitive (C is!), since it hl-ed '''If''' as the keyword '''if'''--[[User:ShinTakezou|ShinTakezou]] 14:25, 17 December 2008 (UTC) |
* the parser is not case sensitive (C is!), since it hl-ed '''If''' as the keyword '''if'''--[[User:ShinTakezou|ShinTakezou]] 14:25, 17 December 2008 (UTC) |
||
<c>if</ |
<lang c>if</lang> |
||
<c>If</ |
<lang c>If</lang> |
||
<c>iF</ |
<lang c>iF</lang> |
||
<c>IF</ |
<lang c>IF</lang> |
||
: Fixed. I'll send the relevant changes upstream. --[[User:Short Circuit|Short Circuit]] 00:53, 23 January 2009 (UTC) |
: Fixed. I'll send the relevant changes upstream. --[[User:Short Circuit|Short Circuit]] 00:53, 23 January 2009 (UTC) |
||
Line 125: | Line 125: | ||
--[[User:ShinTakezou|ShinTakezou]] 14:25, 17 December 2008 (UTC) |
--[[User:ShinTakezou|ShinTakezou]] 14:25, 17 December 2008 (UTC) |
||
: It looks like GeSHi handles preprocessor directives by identifying the # as a single-line comment character. In order to use a single # for a multi-line comment, one would need to modify the custom regex field: |
: It looks like GeSHi handles preprocessor directives by identifying the # as a single-line comment character. In order to use a single # for a multi-line comment, one would need to modify the custom regex field: |
||
<php>'COMMENT_REGEXP' => array(1 => '/\/\/(?:\\\\\\\\|\\\\\\n|.)*$/m'),</ |
<lang php>'COMMENT_REGEXP' => array(1 => '/\/\/(?:\\\\\\\\|\\\\\\n|.)*$/m'),</lang> |
||
: Adding another regex to the array to handle multiline preprocessor directives should fix that. My regex is rusty, though. --[[User:Short Circuit|Short Circuit]] 00:53, 23 January 2009 (UTC) |
: Adding another regex to the array to handle multiline preprocessor directives should fix that. My regex is rusty, though. --[[User:Short Circuit|Short Circuit]] 00:53, 23 January 2009 (UTC) |
||
Line 138: | Line 138: | ||
:I think if you do it right, languages you add to the syntax highlighting will show up in the "Parser extension tags" [[Special:Version|here]]. I'm not quite sure though. --[[User:Mwn3d|Mwn3d]] 13:48, 22 January 2009 (UTC) |
:I think if you do it right, languages you add to the syntax highlighting will show up in the "Parser extension tags" [[Special:Version|here]]. I'm not quite sure though. --[[User:Mwn3d|Mwn3d]] 13:48, 22 January 2009 (UTC) |
||
::I can't seem to get the Modula-3 highlighting to work? I tried <nowiki><modula3></nowiki> and even <source lang="modula3">. --[[User:Mbishop|Mbishop]] |
::I can't seem to get the Modula-3 highlighting to work? I tried <nowiki><lang modula3></nowiki> and even <source lang="modula3">. --[[User:Mbishop|Mbishop]] |
||
::: <nowiki><modula3></nowiki> isn't listed in the parser extension tags on [[Special:Version]]. I guess something has to be inserted somewhere in the MediaWiki code, so it knows that <nowiki><modula3></nowiki> stuff has to be handed to GeSHi. --[[User:Ce|Ce]] 18:45, 22 January 2009 (UTC) |
::: <nowiki><lang modula3></nowiki> isn't listed in the parser extension tags on [[Special:Version]]. I guess something has to be inserted somewhere in the MediaWiki code, so it knows that <nowiki><lang modula3></nowiki> stuff has to be handed to GeSHi. --[[User:Ce|Ce]] 18:45, 22 January 2009 (UTC) |
||
:::: Perhaps, I know the language file works (tested it on my own apache), but I didn't test with mediawiki, not sure what needs to be done there. --[[User:Mbishop|Mbishop]] 19:52, 22 January 2009 (UTC) |
:::: Perhaps, I know the language file works (tested it on my own apache), but I didn't test with mediawiki, not sure what needs to be done there. --[[User:Mbishop|Mbishop]] 19:52, 22 January 2009 (UTC) |
||
::::: The Mediawiki extension I'm using may have a specific list of supported languages. I'll check to see what exactly is going on... --[[User:Short Circuit|Short Circuit]] 23:42, 22 January 2009 (UTC) |
::::: The Mediawiki extension I'm using may have a specific list of supported languages. I'll check to see what exactly is going on... --[[User:Short Circuit|Short Circuit]] 23:42, 22 January 2009 (UTC) |
||
:::::: Indeed, that was the problem. Changed. <nowiki><modula3></nowiki> should now work. But now the namespace seems to have conflicts. The contribution copyright warning seems to be being parsed as a language. This is the kind of thing I was worried about with the namespace pollution. Working on it... --[[User:Short Circuit|Short Circuit]] 00:04, 23 January 2009 (UTC) |
:::::: Indeed, that was the problem. Changed. <nowiki><lang modula3></nowiki> should now work. But now the namespace seems to have conflicts. The contribution copyright warning seems to be being parsed as a language. This is the kind of thing I was worried about with the namespace pollution. Working on it... --[[User:Short Circuit|Short Circuit]] 00:04, 23 January 2009 (UTC) |
||
::::::: Fixed. Apparently, there's a language whose GeSHi tag would be <div>. --[[User:Short Circuit|Short Circuit]] 00:22, 23 January 2009 (UTC) |
::::::: Fixed. Apparently, there's a language whose GeSHi tag would be <div>. --[[User:Short Circuit|Short Circuit]] 00:22, 23 January 2009 (UTC) |
||