Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

'Button Bar' Plugin parsing 'script' and 'style' tags inside 'pre' tags (even on these forums!)

edited March 2012 in Vanilla 2.0 - 2.8

This is the actual code I put:

code block example

I don't know if the problem is with the forum core or Button Bar plugin or Google-Code-Prettify, but the

<script type="text/javascript"> and <style> tags are being removed/parsed.

// Say hello world until the user starts questioning
// the meaningfulness of their existence.
function helloWorld(world) {
  for (var i = 42; --i >= 0;) {
    alert('Hello ' + String(world));
  }
}


p { color: pink }
b { color: blue }
u { color: "umber" }

Is this a bug? Can someone help me resolve this?

Thanks.

Answers

  • UPDATE: It appears to be a bug in 'Button Bar' plugin as the exact same code shown up fine here (a simple HTML page using Google-code-prettify): http://google-code-prettify.googlecode.com/svn/trunk/styles/index.html

    Hope, someone can help.

  • jspautschjspautsch Themester ✭✭✭

    It isn't a problem with those plugins, it's been that way forever, pre tags don't seem to like any xml tags at all, which is why on my forums I just stick to code. It seems to be the only thing that properly preformats code snippets.

  • edited March 2012

    @jspautsch : I don't understand. Does the dev team know about this? If they do, why wouldn't they fixed it? What's the problem?

    Anyone ( @x00 ?) with knowledge of this, please clarify.

    My forum is entirely based around codes (I am learning to code), so I direly need this to function properly. Any help is very much appreciated.

  • edited March 2012

    Here's a pointer to anyone who can try to help. If I encode the code I want to put between the <pre> tags, it's working fine.

    That is, if I use this code:

    code

    Instead of this one (like we normall do):

    code 2

    The pre tags are working as they should. The code is presented fine. Check this:

    <script type="text/javascript">
    // Say hello world until the user starts questioning
    // the meaningfulness of their existence.
    function helloWorld(world) {
      for (var i = 42; --i >= 0;) {
        alert('Hello ' + String(world));
      }
    }
    </script>
    <style>
    p { color: pink }
    b { color: blue }
    u { color: "umber" }
    </style>

    Does that make any sense? Can anyone help me fix this based on the pointer? (I cant't expect forum users to encode their code prior to sharing it on the forum.)

  • You can expect anything, just don't expect an answer within a couple of hours. Just let your thread sit for a while

    There was an error rendering this rich post.

  • edited March 2012

    That seems to be BUG - 1. And this one is probably BUG - 2 (and hopefully the only one):

    <script type="text/javascript">
    
    // Say hello world until the user starts questioning
    
    // the meaningfulness of their existence.
    function helloWorld(world) {
      for (var i = 42; --i >= 0;) {
        alert('Hello ' + String(world));
      }
    }
    </script>

    The thing is, a SPACE is being added on empty lines. Why?

    If you don't understand what I am saying, please see this screenshot (the thing in blue is a single SPACE automatically added on all empty lines).

    Imgur

  • PS: I just learnt that BUG - 2 is (probably) caused by Google-Code-Prettify. I only see spaces on empty lines when I use:

    <pre class="prettyprint linenums">

    and not when I use:

    <pre class="prettyprint">

    So, spaces are added when you enable line numbers for the code block that is syntax highlighted by Google-Code-Prettify.

  • edited March 2012

    Okay, here's the thing. You are not supposed to use HTML tags like <pre> and <code> in Markdown, and that's obvious, isn't it?

    So, in order to preserve a code block, you need to add 4 SPACES or 1 TAB at the beginning of each line of the code block. That's it!

    And that means, you need to add class="prettyprint linenums" to your 'pre' tags dynamically using Javascript, and here's the code for that (pulled from the source code of VanillaForums.org):

    <script type="text/javascript">jQuery(document).ready(function($) {
       $('.Message pre').addClass('prettyprint linenums');
       prettyPrint();
    });</script>
    
  • LincLinc Detroit Admin

    dasdasd

Sign In or Register to comment.