This discussion is archived
1 2 Previous Next 21 Replies Latest reply: Jul 31, 2013 2:18 PM by Dude! RSS

preserving code formatting

Barbara Boehmer Oracle ACE
Currently Being Moderated

How do I preserve code formatting?  I found the following in the FAQ:

 

"How do I format code?

Switch to the advanced editor, paste your code, mark it, click the >> (insert) button, select Syntax Highlighting, choose the style."

 

I did that and tried SQL and various other options under syntax highlighting, all of which add line numbers, but destroy column alignment.  Which one should I be picking?  Or which font should I be using with it?  Or is there a way to use code tags or pre tags?  If this has already been discussed and resolved, then a simple link will suffice, but I suggest that the FAQ be updated to reflect it.  I have waited to ask until now as I have been waiting for the dust to settle regarding all of the forum upgrade stuff and figured it might still be a work in progress.

  • 1. Re: preserving code formatting
    Dude! Guru
    Currently Being Moderated

    Fixing the Syntax Highlighting options are still in progress: Performance improvements, points, and a few other things 

     

    From my experience, you cannot paste a table into the editor without having the forum editor convert the data into separate tables and screw up the content. Apparently the forum editor is automatically intercepting the clipboard and you cannot win the game, regardless of post Syntax Highlighting.

  • 2. Re: preserving code formatting
    Barbara Boehmer Oracle ACE
    Currently Being Moderated

    Thanks for the link Dude; I missed that part of that thread.  So, I guess we'll all just wait and see. 

  • 3. Re: preserving code formatting
    SomeoneElse Guru
    Currently Being Moderated

    For now, I go into the Advanced Editor, paste the code, then highlight it and change the font to Courier New.

     

    That at least changes it to a fixed width font and looks kinda code-ish.

  • 4. Re: preserving code formatting
    BluShadow Guru Moderator
    Currently Being Moderated

    SomeoneElse wrote:

     

    For now, I go into the Advanced Editor, paste the code, then highlight it and change the font to Courier New.

     

    That at least changes it to a fixed width font and looks kinda code-ish.

     

    that's what I do too, and then use the ">>" and "Quote" option to quote it. (or you can actually highlight the text and click the "Quote Previous Message" button which will also quote it (so the button is somewhat mis-labelled).  That way it kind of indents the code from the main text and I think it's easier to read like that.

  • 5. Re: preserving code formatting
    Dude! Guru
    Currently Being Moderated

    Courier is a non-proportional font, but not necessarily the best font for code. Check the following:

     

    Courier:

     

    whatever -lO

    whatever -10

    whatever -l0

    whatever -IO

     

    Terminal:

     

    whatever -lO

    whatever -10

    whatever -l0

    whatever -I0

     

    So the font Terminal or Monaco is far better for reading and less confusing regarding l's, I's, 1's and O's or 0's compared to Courier.

  • 6. Re: preserving code formatting
    BluShadow Guru Moderator
    Currently Being Moderated

    Not sure what browser you're using, but they seem fairly obvious to me in the Courier font, and ther Terminal is not really any clearer.

  • 7. Re: preserving code formatting
    SomeoneElse Guru
    Currently Being Moderated

    One thing I've never liked about Terminal is that it's difficult to tell parenthesis from angle brackets:

     

    Courier New:

    < >

    ( )

     

    Terminal:

     

    < >

    ( )

  • 8. Re: preserving code formatting
    Dude! Guru
    Currently Being Moderated

    How is your result possible?

     

    Can you create a simple Word document, copy and paste the text I used as an example, then change the font to Courier and Terminal? The difference should be obvious.

     

    What are your browser settings? Do you allow pages to choose their own fonts?

    The setting, in Firefox should be under Content: Fonts & Color: Advanced.

     

    I'm using Firefox 21 on Mac OS X, but that should only make a difference whether the system would use Monaco (Mac) or Terminal (PC).

     

    You might want to check the following: http://www.lowing.org/fonts/images/showPreview.php

    Does it all look the same on your display?

  • 9. Re: preserving code formatting
    Dude! Guru
    Currently Being Moderated

    The difference between parenthesis and angle brackets is very clear on my display, using either fonts.

     

    To increase visibility there used to be Bitmap fonts to address the low resolution of the screen. However it should not apply anymore with any modern equipment which are fine to use TrueType or OpenType fonts for the printer and display at any size. I suggest you also check the behavior in Word and perhaps check your browser settings to make sure you are not overwriting any font styles.

     

    Btw, you can use Ctrl+ (PC) or CMD+ (Mac) to zoom the text and graphics in Firefox.

  • 10. Re: preserving code formatting
    SomeoneElse Guru
    Currently Being Moderated

    On my laptop (Windows 7, IE 8), I can easily see the difference between the "ells" and "zeros" in your earlier post but the angle brackets and parentheses are almost the same.

     

    On my iPhone (Safari) it's the reverse, the parentheses and angle brackets are very clearly discernable.  But in your earlier post, the lines under Courier look nearly identical to those under Terminal except that Terminal is slightly more bold.  The zeros don't have slashes through them in either font.

  • 11. Re: preserving code formatting
    BluShadow Guru Moderator
    Currently Being Moderated

    Dude wrote:

     

    How is your result possible?

     

    Probably as I don't appear to have Terminal font installed on this works machine (which is odd!)

    The browser is IE9 (not my choice).

    Perhaps it's the good quality and size of monitor and my good eyes that don't have a problem differentiating between things in Courier.  I guess I'm used to it.

  • 12. Re: preserving code formatting
    Dude! Guru
    Currently Being Moderated

    Below are a couple of screenshots to see what I see:

     

    http://i.imgur.com/rc4OUcv.jpg

    http://i.imgur.com/KN9CJtO.jpg

  • 13. Re: preserving code formatting
    Dude! Guru
    Currently Being Moderated

    Sometimes I don't know who is worse, Microsoft or corporations who think they have to cripple systems down until they are useless or make ridiculous policies!? Anyway, the difference between the number 1 and lowercase letter L should generally be difficult to see in Courier. Arial, for instance, does not make any noticeable difference between lowercase L and uppercase I. Some things are simply stupid.

  • 14. Re: preserving code formatting
    Dude! Guru
    Currently Being Moderated

    This tells me you are not seeing the page's font. Perhaps your browser is substituting fonts due to your settings or you are missing classic fonts. The Terminal Font is standard for Microsoft command line. Monaco was an old standard system font for Apple, now it's Menlo. Btw: https://github.com/andreberg/Meslo-Font

     

    I find Courier is a poor choice for a programmers or code font. I think Terminal or Monaco are a better choice than Courier. However, if you do not have any other mono-spaced font beside Courier or Andale Mono installed in your system than that's all you will ever see. I guess there is no solution, unless you embed fonts in web pages.

1 2 Previous Next