Some Nastiness that had taken place, with my Blocks Of Code

When we write Web-content in HTML, then one default behavior of the internet is, that it wraps the text around, so that every paragraph is really being submitted to the browser as if it just consisted of one line. After that, the browser breaks the lines in such a way as to fit the browser-window.

But, there do exist formatting tags built-in to HTML, which override that behavior, but which still keep HTML interpreted as HTML.

What this means, is that if we want to post a piece of actual code, we need a special HTML tag, which turns this behavior off. That set of tags is provided by <code></code>, wrapped up inside <pre></pre> if the code is to be several lines long. Hence, just to illustrate, when we want to put code into a Web-site, for readability, we do this:



Some formatted code here...
Line 1
Line 2
Line 3



Now, in some cases I even used this format to express equations of some sort, which were quasi-mathematical in nature, but which I had written in some plain text, the general meaning of which might still have been understood, if the line-formatting had been preserved.

But unfortunately, I had also been using a WordPress plugin called ‘Transposh’, which was translating my whole blog into several other languages – successfully. A nasty side-effect of ‘Transposh’ was, that it turned every <code></code> tag-pair into a single line of code. The translation system had lulled me into a false sense of security, with the promise from its author that it would not translate such blocks of code. Well the translation system also did not preserve any of the newline-characters that existed, anywhere in such a pair of tags.

Now, one reason I had not noticed this until now, was the fact that it was not visible in the windows I use to edit my postings. I just submitted my postings, and assumed they would appear the same way to the public as they did to me. But the reason those code-blocks seemed okay in my editing view was the fact that I was composing my writings in the default language, which was not to be translated until a later context, that being any context in which the public could view them.

As it happens, I was never really 100% satisfied with those automated translations anyway. And further, by simply switching that plugin off, I think I may have been able to restore the code-blocks in all my earlier postings.

Good Riddance.



Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>