Jump to content

Topic on Project:Support desk/Flow

Format text in <pre> tag

4
Lucamauri (talkcontribs)

Even if <pre> tag encloses a preformatted text, HTML supports formatting of the block as explained here https://www.sitepoint.com/everything-need-know-html-pre-element/#using-nested-html-elements .

For instance, the following code:

<pre>
    This is preformatted text.
  It should be <span style="color:red;">further formattable</span>
</pre>

should produce a block of text with the last part in color red.
This works if you try it on CodePen or similar website, but produces this output in MediaWiki:

    This is preformatted text.
  It should be <span style="color:red;">further formattable</span>

So the color is ignored.
Why this happens? And anyone knows how to workaround it?

Thanks

星耀晨曦 (talkcontribs)

See m:Help:HTML in wikitext#Pre. You can use following way:

 It should be <span style="color:red;">further formattable</span>

Effect:

It should be further formattable
Lucamauri (talkcontribs)

Thanks for your effort, but unfortunately I can't use this method instead. I am importing into my Wiki several already-existing PRE blocks containing spaces, so I cannot simply add a space in front of each row.

Xin344 (talkcontribs)

I have the same issue and not solve.

Reply to "Format text in <pre> tag"