Enable auto-wrap for Inform 7 code blocks?

So once in a while someone posting on the Inform 7 sub-forum posts a code block that turns out to be pretty difficult to read because the code-block styling disables auto-wrapping. This makes sense for traditional programming languages and a lot of IF-targeted DSLs, because they naturally break into short-ish lines. But Inform 7 uses English-type paragraphs, and what winds up happening is that each paragraph is put onto a single “physically typeset” line, without wrapping it at all. This means that reading Inform 7 code posted to the forum is an exercise in frustration: on a desktop or laptop, you need to keep scrolling back and forth on the embedded frame with the mouse; this is much more difficult on mobile devices.

Is there some way that …

  • wrapping could be re-enabled for code blocks on the Inform 7 forum?, and/or
  • code blocks could detect Inform 7 code (or even just “detect that it’s in English and not, say, Javascript or C++”) and wrap?, and/or
  • there could be an option for the post author to re-enable wrapping of code blocks, either for a whole post or on a block-by-block basis?
2 Likes

I’m poking at the settings gently, but just need to figure out where it might be. Code-wrapping one line by back-ticking before and after does word-wrap, but wrapping multiple paragraphs with three back-ticks does not.

It almost seems there should be a place in the CSS somewhere to add
word-wrap: normal;

1 Like

We could make all code wrap but I don’t know if we can make just inform 7 code wrap.

However, you can format it as a quote rather than code.

2 Likes

The problem with this is whitespace, mainly tabs. Only code blocks properly render tab-indented lines. This makes code harder to read, and also would hopelessly complicate situations where someone is asking for help with their code and the problem is actually that the tabs are wrong.

Given the choice, I would tend to think wrapping all code is preferable to wrapping none. Would this cause major problems for the I6 or TADS people?

2 Likes

I don’t know a lot of CSS, but isn’t it possible to display something like a character (that won’t be part of the text, and not copied if all the text is selected, obviously) on the broken lines?

Like in this Vim screenshot:

image

Or even better, do what many other online code editors do: Wrap everything, but display line numbers on each actual line, like this CodePen example (the line numbers are very dark here though, might be hard to see). Line numbers would be neat anyway!

Note: I have no idea if this is easy, hard or impossible to do.

2 Likes

I don’t think CSS can do this. However, I don’t think it’s a sticking point either.