I use mediawiki-1.30.0 and want to bold a part of code snippet in MediaWiki. Unfortunately as it is described here, it seems <b></b> does not work in pre tag. Also I did not find any way to bold a part of code in SyntaxHighlight_GeSHi extension which comes with MediaWiki 1.21 and above.
How I can bold part of code snippet without adding a space in front of each row?
Edit
I tested all these three:
<pre>
a <strong>text</strong> inside another ...
</pre>
<pre>
a <strong>text</strong> inside another ...
</pre>
<code>
a <strong>text</strong> inside another ...
</code>
The result was the same:
a <strong>text</strong> inside another ...
Only <code></code> bolds text, for example for both below codes
<code>
a <strong>text</strong> inside another ...
and another line
</code>
<code>
a <b>text</b> inside another ...
and another line
</code>
the result is:
a text inside another ... and another line
As you can see it processes <b></b>; but does not preserve new line characters.
If you absolutely cannot add a space in front of each line, you could try using this: (somewhat inspired by @StanislavKralin's comment)
The
.mw-codeclass mirrors the styles for<pre>for any element that has it. However, it also needs adisplay: blockto be formatted correctly. If you didn't want to put thedisplay: blockon every instance, you could add the following code to theMediaWiki:Common.csspage:Then, you would only have to add the
.mw-codeclass to the<code>element.However, this only works if no lines are skipped and the code isn't ever indented, this longer test case:
makes this:
Since this is not a
<pre>, the wikitext is still parsed inside, such as a space making a code block, which is why we have all the nested codeblocks.Alternatively, you could add a space in front of each row, like so:
yields:
and always works: