Shop OBEX P1 Docs P2 Docs Learn Events
Formatting code in the forum — Parallax Forums

Formatting code in the forum

PJMontyPJMonty Posts: 983
edited 2007-03-12 07:33 in General Discussion
Hi,

Phil Pilgrim has created a cool web applet that he is hosting on his site that allows you to paste SX assembly code into it and it will create text with all the formatting necessary to display properly. However, when I tried using it, the tabbed text didn't line up. Fill explained that the problem is part of the style sheet used in the forum software. See this post:

http://forums.parallax.com/showthread.php?p=636532

I have two questions:

1 - Can someone at Parallax modify the style sheet to follow Phil's suggestion? It will make formatted code line up correctly on pretty much everyone's system. He also has set it up so that the custom Parallax font is first, which means that Propeller code would format right if the user had that font installed.

2 - Can Phil's applet be integrated into the forum software so that we have a means of formatting code for the best possible display?

Thanks,
PeterM

Comments

  • Robert KubichekRobert Kubichek Posts: 343
    edited 2007-03-08 01:09
    Why don't they add a customizable "CODE" HTML header with rules that would auto format any text according to the set rules like;

    1) keep the hard spaces in the enclosed text.
    2) convert tabbed text to hard spaces.
    2) set a font style that formats, and looks good for all users.


    Bob scool.gif
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-03-12 07:33
    Most browsers will allow you to view pages in "user mode" rather than "author mode". In user mode, you provide your own style sheet (.css file) that specifies how you want things to look. Opera will even do this on a site-by-site basis. So I experimented by copying the dotNetBB style sheet onto my own PC and replacing Lucinda Console with the Parallax typeface. The Parallax typeface doesn't scale well to sizes less than 11 points, though. And, although it looks great at 11 points, displayed programs take up more room at that point size. Another thing I discovered is that browsers will add leading between lines by default. If you want those schematics in the Parallax typeface to display without gaps between lines, you have to add a line-height property to the .msgCode style that's equal to the specified point size. So here are the three lines that are different, the first two being modified and the last being added:

        font-family : Parallax, ProggyCleanTT, Lucinda Console, Courier, Monospace;
        font-size : 11pt;
        line-height : 11pt;
    
    
    


    I tested these settings with the following Propeller Spin code snippet, as pasted from my Spin formatter at www.phipi.com/format:

    [noparse][[/noparse]code]
    [noparse][[/noparse]b]CON[noparse][[/noparse]/b]
            [noparse][[/noparse]b]_clkmode[noparse][[/noparse]/b]        = [noparse][[/noparse]b]xtal[noparse][[/noparse]/b]1 + [noparse][[/noparse]b]pll[noparse][[/noparse]/b]16x
            [noparse][[/noparse]b]_xinfreq[noparse][[/noparse]/b]        = 5_000_000
            
    [noparse][[/noparse]b]PUB[noparse][[/noparse]/b] Start
    
    'Here's a demo for the forum to display the Parallax font's special characters.
    
    '            ┬
    '            ┣──
    ' ──┳──
    '         │
    '           
    
    [noparse][[/noparse]/code]
    
    
    


    The numbers after the pound signs are translations from the original Unicode graphic characters performed by the formatter. Here is a screenshot of how it reconstructed in the forum in user mode while I was editing this post:

    attachment.php?attachmentid=45861

    So what conclusions can be drawn from this? Here's what I think:

    1. 11 points may be too big a font for general use in the forum's code blocks, because the text takes up so much screen real estate.

    2. Even though the Propeller font looks good, it's hard to recommend it for general forum use, since it doesn't scale well below 11 points.

    3. Nonetheless, people can still set up their own user mode .css file, if they're dead set on seeing a special font in the forum.

    4. But the simplest solution to most people's code display issues is just to install Lucinda Console on their systems.

    -Phil

    Post Edited (Phil Pilgrim (PhiPi)) : 3/12/2007 7:41:32 AM GMT
    755 x 536 - 17K
Sign In or Register to comment.