Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Indenting code in MediaWiki

Is it possible to indent a block of code in MediaWiki using SyntaxHighlight GeSHi?

For example, I would like the code container below to be aligned with the third-level list

* This is plain text of a first-level list to be rendered by MediaWiki
** This is plain text of a a second-level list to be rendered by MediaWiki
*** This is plain text of a third-level list to be rendered by MediaWiki

<source lang="Cpp">
int main(int argc, char** argv)
{
    my_function(4, 1, 2, 3);
    return 0;
}
</source>

I have tried wrapping the GeSHi code container with colons (using MediaWiki's standard indentation syntax), but that prevents SyntaxHighlight GeSHi from parsing the code correctly.

Just to clarify, I would like to avoid wrapping my code with <code></code> as I need proper syntax highlighting.

Any suggestions?

like image 386
Amelio Vazquez-Reina Avatar asked Feb 08 '11 01:02

Amelio Vazquez-Reina


People also ask

How do you underline in MediaWiki?

Other text formatting such as underline or blockquote needs to be done using HTML tags, including U for underline, TT for typewriter text, S for strikethrough, SUB for lower index and SUP for upper index.

How do you format a wiki page?

To make changes to a page or section of a Wiki tab, just click into it and start typing. You have all the usual formatting options, such as bold, italic, and underlined text, highlighting, headers, and lists.

How do I highlight in MediaWiki?

UsageEdit. {{highlight|text|red}} , or {{highlight|text}} to use the default highlight color, shown above. Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages.

How do I create a category in MediaWiki?

A category is created by creating a page in the Category: namespace. A category page can be created the same way as other wiki pages (see Help:Starting a new page ); just add " Category: " before the page title. To avoid extra work, try searching within your wiki before creating a new category.


2 Answers

You could always wrap it with normal HTML div tags as well:

<div style="margin-left: 2em;">
  <source ...>
    ...
  </source>
</div>
like image 166
Wes Hardaker Avatar answered Sep 24 '22 20:09

Wes Hardaker


You can put the source inside a table, and then indent the table:

:::{|
|
<source ...>
...
</source>
|}
like image 42
Ángel J. Vico Avatar answered Sep 22 '22 20:09

Ángel J. Vico