Wikia

Vim Tips Wiki

JohnBeckett/Syntax highlighting

Talk0
1,610pages on
this wiki

< User:JohnBeckett

Revision as of 12:41, September 13, 2009 by Chikamichi (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

We currently display sample Vim scripts (aka VimL) in <pre> blocks.

The GeSHi Generic Syntax Highlighter extension is now available for use. I suggest we start slowly and try it out. When we work out what we want, I can use my bot to do most of the changes. I'm not sure that we want every pre block (with Vim script) to be replaced by a source block? Is the maintenance effort worthwhile?

I will try this in CSV for a more significant test. Please give it a go and add any comments below (and note that we have to decide whether to use "source" or "syntaxhighlight"). JohnBeckett 11:20, September 10, 2009 (UTC)

InformationEdit

At 2009-09-10:

  • It works – see test below.
  • Special:Version shows GeSHi: SyntaxHighlight (Version 1.0.8.4) is installed.

At 2009-07-29:

  • Special:Version shows GeSHi: SyntaxHighlight (Version r41349) is installed.
  • GeSHi extension implies that GeSHi rev:50696 (17 May 2009) is available, with support for Vim script.

At 2009-08-27:

  • MediaWiki has just been upgraded (from 1.14.1 to 1.15.1).
  • Other stuff has been upgraded.
  • GeSHi release is unchanged, although it now says "releases_200908.4" instead of "releases_200908.2".
  • Vim syntax highlighting does not work.

Test of syntax highlighterEdit

The following wikitext is used below.

<source lang="vim">
function! QuickExample()
  let myvar = 'Hello World'
  if !empty(myvar)
    for i in range(12)
	echo myvar.' '.i
    endfor
  endif
  return myvar
endfunction
call QuickExample()
</source>

And here is how it looks.

function! QuickExample()
  let myvar = 'Hello World'
  if !empty(myvar)
    for i in range(12)
	echo myvar.' '.i
    endfor
  endif
  return myvar
endfunction
call QuickExample()

CommentsEdit

I notice that <source> is deprecated and instead it is recommended that <syntaxhighlight> is used because some languages (e.g. XML) use <source>.

  • Upgraded and tested. (It's lang=vim, not vimscript.) Live next Wednesday or so. If you see code id on special:version changed and still no syntax highlighting (after a page purge etc.) pls. ping me on my talk page. I had to do some lib switching, this may need additional code push after main code gets deployed. Please don't delete this test page till then, it's very helpful - thank you. -- Nef @Wikia (talk) 20:50, September 2, 2009 (UTC)
Thanks for the info. I'll probably keep this page for quite at least a few months.
Do you have an opinion on the "source" versus "syntaxhighlight" tag mentioned just above? Several examples I've seen on Wikipedia use source, which seems a lot simpler. I wonder if using source might cause trouble for some software that could conceivably be used by people who download a database dump (which is xml)? JohnBeckett 01:46, September 3, 2009 (UTC)
Hm, don't know much about XML, but can't it use just about anything as tags (or whatever they are called, you know, the <stuff foo="bar" /> and <stuff foobar="baz">some text</stuff> thingies)? --Tonymec 08:10, September 11, 2009 (UTC)
I think there is a little more info at GeSHi than last time I looked. It now points out that if you use <source> to start a GeSHi code block, then the code you are displaying cannot itself contain a <source> block. I suppose that is the only issue, therefore we can forget about it, and will use "source" as the simplest tag. JohnBeckett 09:26, September 11, 2009 (UTC)

I just tried it on CSV and changed all relevant pre blocks. I do not like the result for some of the blocks (notably the block with text "sort by column 3"), however I'm leaving it for everyone to have a look. No doubt it could be tweaked, but I do not think that is worthwhile unless someone feels like setting up their own dummy MediaWiki system where they can experiment. I imagine that to have a change here, we would have to ask Wikia, then have a look, then ask for another slight tweak, etc. Not going to happen, and I think we should work with it as is unless someone comes up with a completely tested alternative. JohnBeckett 11:37, September 10, 2009 (UTC)

Hi. AFAIK, using source is really not issue if you do not work with explicit XML but (X)HTML in your MediaWiki pages. Also, there is a way to have the GeSHI plugin use a default language (txt is convenient so that, without the lang parameter, it behaves like a pre):

// in LocalSettings.php
require_once("extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php");
$wgSyntaxHighlightDefaultLang = "text";

But I don't know if Wikia lets you manage these kind of local settings. Chikamichi 12:26, September 13, 2009 (UTC) Also, I confirm the issue with single comment quotes in GeSHi/Vim. I guess this should be fixed in the mainstream lib, must check for a bug tracker or something… Chikamichi 12:41, September 13, 2009 (UTC)

Around Wikia's network

Random Wiki