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

no edit summary
(→‎Old code used the right way: code tag is alright now.)
No edit summary
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>&lt;mylang&gt;some_code&lt;mylang&gt;</nowiki> need to be changed to <nowiki>&lt;lang mylang&gt;some_code&lt;/lang&gt;</nowiki>. So this block:
<lang cpp>#include <stdio>
int main()
{
std::cout << "Hi!" << std::endl;
return 0;
}</cpplang>
 
: Should be rewrapped like this:
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)
:::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><codett>text</codett></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 &amp;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)
Line 95:
==Problem with Lisp==
There is something wrong with the highlighting of certain keywords in Lisp, for example:
<lang lisp>defun</lisplang>
<lang lisp>list</lisplang>
<lang lisp>length</lisplang>
--[[User:Spoon!|Spoon!]] 09:03, 3 November 2008 (UTC)
 
Line 116:
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)
<lang c>if</clang>
<lang c>If</clang>
<lang c>iF</clang>
<lang c>IF</clang>
: Fixed. I'll send the relevant changes upstream. --[[User:Short Circuit|Short Circuit]] 00:53, 23 January 2009 (UTC)
 
Line 125:
--[[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:
<lang php>'COMMENT_REGEXP' => array(1 => '/\/\/(?:\\\\\\\\|\\\\\\n|.)*$/m'),</phplang>
: 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:
: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><lang modula3></nowiki> and even <source lang="modula3">. --[[User:Mbishop|Mbishop]]
 
::: <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)
::::: 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><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 &lt;div&gt;. --[[User:Short Circuit|Short Circuit]] 00:22, 23 January 2009 (UTC)