Page 1 of 1

Code formatting error in mod discussions

Posted: Sat Mar 04, 2017 9:24 am
by JustTheBast
On the Factorio mods site, the "Discussion" tab associated with each mod has a bug when it comes to displaying code segments in posts.

Code snippets in posts are recognised and wrapped in <pre> and <code> elements, but then the <pre> element is escaped to HTML entities ("<pre>") and thus ends up being displayed as the literal text "<pre>" and "</pre>" before and after the code segment. As a result, the lines of the code segment run into each other as an undifferentiated blob, making them hard to decypher.

For example, the actual text that is written like this:

Code: Select all

    elseif vrn.results then
      if vrn.results[1].type == "item" or vrn.results[1].type == "fluid" then
        table.insert(newicons,{icon=data.raw[vrn.results[1].type][vrn.results[1].name].icon}) 
      end
ends up being displayed like this:
<pre>elseif vrn.results then if vrn.results[1].type == "item" or vrn.results[1].type == "fluid" then table.insert(newicons,{icon=data.raw[vrn.results[1].type][vrn.results[1].name].icon}) end</pre>
To fix this, either the <pre> element needs to be inserted unescaped, or it could be left out and instead the style of the <code> element could receive the property white-space: pre; or white-space: pre-wrap;.

Re: Code formatting error in mod discussions

Posted: Tue Oct 26, 2021 10:15 pm
by BloodyRain2k
There's the option to format a single line with ` at the beginning into "something", which in other mark-ups (gotta love the inconsistency of them) is meant for code or at least monospace.

There's also a block variant done with ```, but this one completely breaks new lines on the mod discussions.

Edit: ok nevermind, I just remembered that in other mark-ups the same issue happens when the ``` isn't left alone in it's own line, and guess what, the same bug happens here too...

It's not helpful though to use BBCode here and Mark-up for the mod discussions and don't link to any help for that.
If the text I pasted wouldn't have had randomly reacted to the single line ` code line mark-up, I'd still be guessing how that formatting works.