Pre Tags In Forum Posts

ChainsawXIV
ChainsawXIV
edited December 2009 in Bug Reports

Comments

  • ChainsawXIV
    ChainsawXIV
    Posts: 530
    *Edit Note:* Further investigation while editing the examples in this post has revealed that in some cases, this is actually being handled correctly. It would appear that the text within a _pre_ tag is only parsed as code when a blank line is left between the opening _pre_ tag and preceding elements. This is clearly not correct. The original post has been preserved below the examples, but is substantially incorrect in light of this information.

    *Example 1:* In the following _pre_ tag, the _div_ tags around "Hello World" should be visible, but they aren't, because they're served back as written.
    Hello World

    *Example 2:* This code for the _pre_ seen here is exactly the same as the code for the one above, except that here a blank line has been left before the opening _pre_ tag.

    Hello World

    *Example 3:* The brackets in the code below have been manually converted, but as you can see from the page source, the ampersands were auto-converted, so it didn't work.

    Hello World

    *Example 4:* The _pre_ below has the exact same code as the one above. The only difference is that there's *no* blank line in the post before the opening _pre_ tag.
    Hello World


    *Original Post:*

    Attempting to display HTML code examples in forum posts is currently all but impossible. After some investigation, this is caused by the way that user submitted text found within HTML _pre_ tags is converted for display.

    The issue stems from the fact that the left and right bracket characters used in all HTML tags are not converted to their XML token equivalents. This would normally be only a nuisance, except that the ampersand character, which users would need in order to manualy convert the characters, _is_ converted automaticaly, preventing them from doing so. Note that it appears that ampersands are only parsed this way when they appear inside of _pre_ tags, and work fine elsewhere in posts.

    By comparison, the wiki system handles this in the ideal fashion. For text within _pre_ tags, the left and right bracket characters are converted to their XML token equivalents (< and >), so that HTML code within the tags will never be interpreted by the browser. This is the approach that I would recommend for the forums, both for consistency, and ease of use.

    As an addendum, I've noticed that the forum also performs some additional parsing within the _pre_ tags that it probably should not. Specifically, it converts line breaks to HTML _br_ tags. While this is currently not an issue, because those tags remain intact and are interpreted, they are not necessary (since _pre_ text observes natural line breaks), and may become broken when the other issue is addressed, depending on parse order.

    I've only examined this on Firefox 3.11, but very much doubt this is a browser specific issue.
Sign In or Register to comment.

April 2024
Season of Strife

Read the feature post on the blog
Return to Obsidian Portal

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Discussions