I've gotten frustrated with the "Code Wrapping Off" checkbox in my user settings (too many people posting REALLY long lines) so I decided to start using the "Code Prefix" option to make it obvious when lines wrap.

The basic usage is straight forward, the example of "&001;:&nbsp;" works fine, but I wanted it to stand out a little more, so I tried changing it to "<font color="red">&001;:</font>&nbsp"

Unfortunately, that doesn't seem to work ... when I view source on a page with code, the first line renders as "<font&nbsp;color="red">001:</font>&nbsp;" (ie: something is converting the " " i put inside the font tag into "&nbsp;")

Is this is bug (or possibly a feature gone bad) in the user settings code? Is there a way arround it?

Replies are listed 'Best First'.
Re: Spaces in " Code Prefix" ?
by hossman (Prior) on May 25, 2003 at 05:55 UTC

    On a related note, it occurs to me that a really great additional user setting would be a "Wrap Prefix", which would be prepended to the wrapped portions of long lines (or just after the soft hyphen for users of "Auto-Wrap"

    For example, if I have my Code Prefix set to "#&001;:&nbsp;" and my Code Wrap Length set to "10" then 2 long lines consisting of a-z and A-Z looks like this (at least it does on a scratch pad)...

    #001: abcdefghij
    +klmnopqrs
    +tuvwxyz
    #002: ABCDEFGHIJ
    +KLMNOPQRS
    +TUVWXYZ
    

    But if there was a "Wrap Prefix" option, i could set it to something like "&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;" and it would render as...

    #001: abcdefghij
        : klmnopqrst
        : uvwxyz
    #002: ABCDEFGHIJ
        : KLMNOPQRST
        : UVWXYZ
    
Re: Spaces in " Code Prefix" ?
by theorbtwo (Prior) on May 25, 2003 at 17:18 UTC

    The only thing I can see in the code that would be causing the behavior you're noting is s/  / &nbsp;/g, which I added so that if you had a prefix of (say) "Foo:", and the line starts with a space, you don't get a double-space at the beginning of the line, which would be quashed down to a single space.

    However, I don't see where that'd be causing the problem you're seeing -- it should only hit on double-space, whereas you've got a single space.


    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

      No, the code you added was this:

      # Prevent trailing spaces from quashing initial spaces in code: $prefix =~ s/ /&nbsp;/g;
      Update:: Thanks for the new patch. It has been applied. The problem should be fixed now.

                      - tye
Re: Spaces in " Code Prefix" ?
by hossman (Prior) on May 25, 2003 at 05:44 UTC
    Addendum:

    The problem appears to only occur when rendering CODE on some pages (ie: SOPW) but not others (ie: Scratch pads)