Wiki - syntax highlighting

Discussion of all aspects of the website, wiki, and forums, including support requests and new ideas.

Moderators: Forum Moderators, Developers

Post Reply
User avatar
Celtic_Minstrel
Developer
Posts: 1569
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Wiki - syntax highlighting

Post by Celtic_Minstrel » March 13th, 2016, 1:56 am

You can now apply syntax highlighting to code snippets on the wiki! This works for almost any language you can think of, including WML.

The syntax for this is:

Code: Select all

<syntaxhighlight lang="wml">
[some_tag]
    some_key=some_value
[/some_tag]
# etc etc
</syntaxhighlight>
Other likely values for lang='""
  • wfl - Formula language, for example for formula= in Standard Unit Filters.
  • fai - Also formula language, but for AI (the only difference from wfl is that it highlights additional built-in functions)
  • lua - Self-explanatory - doesn't highlight Wesnoth API functions though
  • cpp - C++ code
This is just the ones expected to be most commonly used on the wiki; there are many other supported languages.

Other options that can be added to the opening tag:
  • line - Enable line numbering. This is a little buggy, though, as the line numbers are muddled up with the code.
  • start="10" - Line numbering starts at the specified line (requires the above to be present too).
  • highlight="1,2,5-9" - Highlight some lines to draw attention to them.
  • inline - Use this to include a small snippet of code in the middle of running text.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

User avatar
ancestral
Developer
Posts: 1108
Joined: August 1st, 2006, 5:29 am
Location: Motion City

Re: Wiki - syntax highlighting

Post by ancestral » March 16th, 2016, 2:32 am

How about WML syntax highlighting for code in the forums?
Wesnoth BestiaryPREVIEW IT HERE )
Unit tree and stat browser
CanvasPREVIEW IT HERE )
Exp. map viewer

User avatar
Celtic_Minstrel
Developer
Posts: 1569
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Wiki - syntax highlighting

Post by Celtic_Minstrel » March 17th, 2016, 5:04 am

Shadowm (who's the one who set this up) said he wanted to upgrade the forum software before considering forum syntax highlighting. I'm also not sure if there's a Pygments-based syntax highlighting extension for phpBB — MediaWiki uses Pygments in its official syntax highlighting extension, and because of that, I chose it to write my WML syntax highlighter with.

So, basically... it's a thing that might happen, eventually, but there are things to be worked out first. :)
Last edited by Celtic_Minstrel on March 18th, 2016, 5:01 am, edited 1 time in total.
Reason: Shadowm demanded name change
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

Post Reply