Forum BBCode and Formatting Help

I have occasionally been asked about formatting stuff here on the forum. AFAIK, there is no official document describing the site’s markup. This thread is designed to help.

    Mind you, this is different than the markup employed by the Articles section,
    which has its own set of tricks and hidden features. That said, many of the
    suggestions here can be applied there as well.


──────────────────────────────────────────────────
Contents
──────────────────────────────────────────────────
  • Rationale: Visual Organization Sells Your Content
  • Supported BBCode
  • Special Characters For Formatting
  • Headers
  • Lists
  • URLs
  • Images
  • Tables
  • Quirks
  • Final Notes


───────────────────────────────────────
Rationale: Visual Organization Sells Your Content
───────────────────────────────────────
Especially for long posts, like this one, you should break it up into byte-sized pieces using headers, lists, and short, to-the-point paragraphs.

  Non-essential, but interesting additional content is tucked into smaller asides.

Breaking up the flow into discrete pieces makes reading and comprehension easier, and will help you to craft better posts.

I will skip all the High-School lecturing about how to organize an essay. Just... use those skills in your posts:

  • Introduce your main point
  • Provide exposition, with lesser supporting points
  • Conclusion — tl;dr


──────────────────────────────────────────────────
Supported BBCode
──────────────────────────────────────────────────
Cplusplus.com uses a custom subset of BBCode (https://en.wikipedia.org/wiki/BBCode), supporting:

  Standard text formatting

    [b]bold[/b]                    
bold 
    [i]italic[/i]                  
italic 
    [u]underline[/u]               
underline 
    [s]strikethrough[/s]           
strikethrough 

    [tt]fixed width[/tt]           fixed width 
    [small]small text[/small]      
small text 
    super[sup]script[/sup]         
superscript 
    sub[sub]script[/sup]           
subscript 

  Centered text
    
[center]centered text[/center]
 
  Inline code

    Using [code]std::vector<int>[/code] is better than using an array.

    
Using std::vector<int> is better than using an array.

  Indented, line-numbered code blocks with “pre”-formatting (and optional first line number)

    [code]
      int main( int argc, char** argv )
      {
    [/code]

    [code firstline=7]
      constexpr double pi = 3.14159;
      constexpr char   s  = "Hello world!";
    [/code]
 
1
2
  int main( int argc, char** argv )
  {

7
8
  constexpr double pi = 3.14159;
  constexpr char   s  = "Hello world!";

A single line will still be indented, but will not have line numbers.

    [code]
      int x = -7;
    [/code]
 
 
  int x = -7;
 
  Indented terminal “output” blocks with “pre”-formatting:

    [output]first line goes here!
    second line    spaces preserved![/output]
 
first line goes here!
second line    spaces preserved!

  Code and Output blocks can be combined into a left-right layout:

    [code]
      Code on the left

    -----
      Output on the right
    [/code]
 
1
2
  Code on the left
  Output on the right
 
  Block quotes (and optional  Zhu Li wrote:  header):

    [quote]Guards! Do the thing![/quote]

    [quote=Zhu Li]You’re an upstanding citizen again, sir.[/quote]
 
Guards! Do the thing!
 
Zhu Li wrote:
You’re an upstanding citizen again, sir.


Combinations of stuff is totally possible. Tag case does not matter, but case needs to match in begin and end tags. So [I]italic[/i] does not work.

    This fixes what would otherwise be a bug using code like array[i],
    and still allow code blocks to have italicized text in them. Whether
    or not it actually works seems to be a varying feature... Maybe
    choice of browser makes a difference?


Unfortunately, that’s about it. Cplusplus.com is a very old website, with code that dates back to around 2000. You read that right. It’s “classic”.

    While some effort was made to update it several times, the owner/developer,
    Juan Soulié, is long out of college and has other things pressing on his time.
    It is the fact that the site uses entirely custom-crafted code gives it some quirks.
    (For example, the new post, no preview bug was introduced during one of
     those updates.)

So, to use additional fancy features, you need to be crafty.
Last edited on
──────────────────────────────────────────────────
Special Characters For Formatting
──────────────────────────────────────────────────
Non-breaking space.

If there is any one essential character you should become familiar with, it is the non-breaking space.
It may be painful to use, though. Your browser and/or OS may or may not let you simply copy and paste it. Chrome browsers on Windows don’t, for example.

W I N D O W S
On Windows keyboards, you can hold down the Alt key and type 2 5 5 on the Numeric Keypad.

L I N U X
On modern Linuxes, you can try Alt+Shift+U followed by 0 0 A 0.
Or if your keyboard layout supports it, AltGr+Space or Ctrl+Shift+Space

O S  X
Mac users will be pleased to know that Option+Space typically works.

Other Special Characters
For the rule of pretty, there are also:

  — em dash (use between words)
  – en dash (use between numbers)
  ‘single quotes’
  “double quotes”
  TradeMark™
  ↑ ↓ → ← arrows (which only only look good in the normal font)
  ┌────┬────────┐
  │line│graphics│
  └────┴────────┘
  etc

A good combination when formatting stuff to line up is non-breaking spaces and [tt] blocks. For example, the following construct was used to align all the supported BBCode examples above:
[tt]
  hello
[/tt]
 

  There’s more to it though. See the “Quirks” section below.


──────────────────────────────────────────────────
Headers
──────────────────────────────────────────────────
It does not matter what you do for headers, as long as you are consistent.

I tend to use boxed / line graphics stuff for H1 type headers, bold for H2, and a combination of small, teletype, spaced uppercase for H3.


──────────────────────────────────────────────────
Lists
──────────────────────────────────────────────────
Lists are an essential ordering technique. Of course, there are two kinds of lists:

  • Unordered
  • Ordered

Unfortunately, cplusplus.com does not support either in BBCode. So we have to fake it.

For a simple unordered list, I typically apply two or four non-breaking spaces, followed by a bullet character (Alt+0149 or Alt+7 on Windows), followed by another space and then the list item.

For ordered lists, or any list with elements spanning more than one line of text, additional formatting care must be taken.

[tt]  • [/tt]No, Squidward, I meant...[i]good for your soul[/i].
[tt]    [/tt][small]Oh, please! I have no soul.[/small]
 
  • No, Squidward, I meant...good for your soul.
    Oh, please! I have no soul.


──────────────────────────────────────────────────
URLs
──────────────────────────────────────────────────
Cplusplus.com’s markup parser handles inline links starting with http:// and https://, but it doesn’t really know when to stop. (Leading to a common bug: https://www.google.com). ← clicking goes nowhere

The way to avoid this is to introduce an empty markup sequence:

  (https://www.google.com[b][/b])

  
(https://www.google.com) ← clicking works as intended

This technique is also useful when showing someone how to use [[b][/b]code] → [code] tags.

Opaque Links are not supported. (They were trialed for a short while, but quickly removed.) This is expressly because opaque links are too easy to abuse. Juan Soulié would prefer all links to be explicit. Don’t complain; that’s the way it is.

To make a hard link more palatable, I will often add something that looks much like the markup for an opaque link:

  Click for Microsoft’s documentation on (GetConsoleMode|https://www.google.com/search?btnI=1&q=msdn+GetConsoleMode)
──────────────────────────────────────────────────
Images
──────────────────────────────────────────────────
It is for a similar reason that inline images are not supported on the forum. Other forums that do support them often have to combat malicious/NSFW/vapor/not-allowed hotlinks, cluttering an otherwise clean interface. It is a problem cplusplus.com does not have.

Cplusplus.com’s preference is to post the content of an assignment/whatever. When an image is required, use a normal link to a media site so that users can choose whether or not they want Imgur (for example) dumping malware/popups/whatever into their browsing session.

The best way to deal with images, however, is straight up Ascii Art!

~~~~~~~~~?~~~~~=+~~~~~MMMM7.
~~~~~~~M7~~~DI~~~~~~~~Z~~N
~~~~~~~~M~~~~D~~~~~~~~N.
~~~~~~~~7~~~?7~~~~~~~M.    
~~~~~~~8~~~~~~~N~$~I       █ █▄ █  █▄ ▄█ ▄  █  █▀▀▄ █▀▀ █▀▀ █▀▀ ▄▄ █ █▀▀  █▀▀   ▀▄   █ ▄▄  █  ▄ █▀▀▄
~~~~~MM~~~~~~~O~~~M        █ █ ██  █ ▀ █ ▀█▀   █  █ █▀  █▄  █▀  █ ██  ▀▀▄ █▀      ▀▄▀ █  █ █  █ █▄▄▀
~~~~Z~~~~~~~~~==~~D        █ █  █  █   █  █    █▄▀  █▄▄ █   █▄▄ █  █ ▄▄▄▀ █▄▄ ▄    █  ▀▄▄▀ ▀▄▄▀ █ ▀▄
~?7+~~~~~~~D~~~~~M                                                            ▀
+O~~~~~~~~~O~~~~8         ▄▀▀▄  ▄  █▀▀▄  █  █  ▄▄ █▀▀   █▀▄ █▀▀ █▀▀ ▄▄ █  ▄▀▀▄ ▄ ▄ █ █▀▀▄ █ ▀▀█ █ ▄  █ ▄▀▀▀    
~~~~~~~~~~+N~~~~~M        █    █▄█ █▄▄▀  █▀▀█ █▄█  ▀▀▄  █▀▄ █▀  █▀  █ ██  █  █  █  █ █  █ █ ▄▀  █ █▀▄█ █ ▄▄
~~~~~~~~~O~~~~~~~M        ▀▄▄▄█  █ █ ▀▄  █  █ █ █ ▄▄▄▀  █▄▀ █▄▄ █▄▄ █  █  ▀▄▄▀ ▀ ▀ ▀ █▄▄▀ █ ▀▀▀ ▀ █ ▀█ ▀▄▄▀
~~~~~NOM8~~~~~~~~M         
ZD=~~N~~~~~~~8~?M          █▀▀▀ █ ▄▄ █ ▄▀▀▄ █▀▀  ▀▄  █  ▄▄  █  █  ▄▀▀▀  ▄▀▀▄ ▀█▀▀   ▄ ▀█▀▀
~~~~~~~~~~+7~~~+            ▀▀▄ █ █ ██ █    █▀    ▀█▀  █  █ █  █  █  ▄▄ █  █  █     █  █
~~~~~~=~~~N~~~~?           ▄▄▄▀ █ █  █ ▀▄▄▄ █▄▄    █   ▀▄▄▀ ▀▄▄▀  ▀▄▄▄▀ ▀▄▄▀  █     █  █ ▄
~~~~~~~~~~~~~~~M           
O~~~MDD~~~~M~~   . $NM:    
~?~~~~~~~~?O~=  .~~~~~Z
==~~~~~?=DN+D,   +~~~IM                             M
~~~~~~~M~~7        =,                              =$
~~~~~~~M                                           N.
~~~~~8M$                    
~=~8~~O    M~~M8~~          ▄ ▀█▀ █ ▄▀    ▄▀█▀   █ ▄▀▀ ▀█▀▀  █  █  ▄▄ █▀▄ ▄▄  █▀▀ ▄▄ █ █ ▄  █ ▄▀▀▀
~M~~M    M~?~~~~~~+         █  █   ▀▄▄      █ █  █  ▀▀▄ █    █▀▀█ █▄█ █▄█ █▄█ █▀  █ ██ █ █▀▄█ █ ▄▄
Z~~~8    Z~7~~~+~~7         █  █   ▄▄▄▀  ▀▄▄▀ ▀▄▄▀ ▄▄▄▀ █    █  █ █ █ █   █   █▄▄ █  █ ▀ █ ▀█ ▀▄▄▀
M~~M.    M~~$7~?I?8
~ZN       ,~DZO             ▄▀▄   █    ▄▄ ▀█▀▀  █▀▀ ▄▄  ▄▀▀ ▀█▀▀▄▄▄ █▀▀▄   █▄  █ ▄▀▀▄ █   █
~~~8                        █▄█   █   █  █ █    █▄ █▄▄█  ▀▀▄ █  █▄  █▄▄▀   █ █ █ █  █ █   █
~~~M                        █  █  █▄▄ ▀▄▄▀ █    █  █  █ ▄▄▄▀ █  █▄▄ █ ▀▄   █  ▀█ ▀▄▄▀ ▀▄▀▄▀ ▄
~~$.         M$MO7M         
~I~      O+D8~7=7~~
~=Z    M?~I~~~~~~+~I:                          =
M.     I~~~~~~ZZ7~~=~                          M
       N~~~~M$~~$N8=                          N.
         ..                                  ,.
                                            +O
                                           =.
      ~OM~ZO                .8D+  ~DM     M
  +~~Z~~~==I               N          8                      =MMMMDOMO
 ,N+?~~~8++:              M            O                    MM$M8ZM8,NMN
 M~~~~~~NM:           $  .           ,MM                   MIZMI8MM=8M$MM
  :$=:$:              M  $  ~=.    IM  I?                 8,  M: :OMMZMMM
                      M  = M           I+                 M      .=?$MMMM
                      ..  ZN           M                  M.          ,8M
                       M.Z8M           =                  ,D           MM
  .                     MM ?.        +N                    D         =MM
 8   ?I                 +D  .M$.  .DM                       M?     7MMI~I
    .                   .     7M      M                        =+, MMM
  I                           MMM     M                           IM
   O=                        . M 8   $+                           MIN
     :                       M M .M  N                            M$$
   +?                       I? M   77                             7$ :
                            M  O   +M                            : $ M
         ~                  =  I                                 M 7 D.
   :7: $=                  O   +                                :8 + .N
                          .N   I                                M  +  M
                               M7                               ~ NM  +
     .                        ?IM                                 M8:  :
       O,                     M Z                                 ,.N
   $O                         7  :                               8  M
                             +   M                               M  I
                             M   M                              8~   =
                            Z=   =7                             M    N
                            M     M                             I    M
                           ,      Z                            =     I+
                           M       ,                           M      M
                          Z=       8                          ~O      N
                          M        M                          M       ,
                         ?         $?                         O        D






Of course, simple line art or boxes and arrows for linked lists is what is mostly expected.

Remember now, “With great power comes great responsibility.”
──────────────────────────────────────────────────
Tables
──────────────────────────────────────────────────
When dealing with tables, it is simplest to use an [output] block. Format your information in your favorite fixed-width text editor, then copy and past into an [output] block, making sure to snug the BB tags up to the first and last lines.

The other option is to make extensive use of the non-breaking space character. You can even get fancy with [tt] and line characters and fancy formatting.

ANIMAL    SPEAK
Dog       Woof
Cat       Meow
 

    ANIMAL  SPEAK
    Dog     Woof
    Cat     Meow
 

  The fox, by the way, barks. https://www.youtube.com/watch?v=XKiI8TahmDU


──────────────────────────────────────────────────
Quirks
──────────────────────────────────────────────────
There exist a few other quirks in the forum software. The two most obnoxious are:


S U B M I T   I S   D A N G E R O U S 

This is the one most indispensible thing to know when editing posts:

  Always, always Ctrl+A, Ctrl+C before clicking Submit.

The forum software is known to lose long, carefully crafted posts. Don’t become a victim!


( S O M E )   T A G S   E A T   N E W L I N E S

When there is an ending tag (like “[/tt]”) followed immediately by a newline, the newline tends to get eaten. Usually.

I have not spent any time trying to figure out when or why. But when it matters, the way to combat it is to put a non-breaking space, followed by a normal space, immediately after the ending tag.

That, and use the Preview function to see what actually happens.


──────────────────────────────────────────────────
Final Notes
──────────────────────────────────────────────────
Well, there you go. Hopefully this will give you some useful tricks to play with. The next best thing is to practice.

When crafting a longer post, I personally find it useful to use a text editor for all the actual editing, then copy and paste to preview.

Hope this helps!
Last edited on
For me it is simply use code/output tags as needed, and break up looooooooong and wordy text into shorter bite-sized paragraphs.

I'm a minimalist kinda guy.

Not that I am complaining about what you wrote, it can be helpful. :)
Heh, your quote with Spongebob and Squidward......I watched that episode earlier today.

3rd season is probably some of the best stories and animation of the entire series.
Kind of like making a field goal and being told my cleats were untied.
Yes I think that's extremely helpful. I didn't even know you could start code at a particular line, and will certainly use the URL trick you mentioned from now on.

Some ASCII generator links:
ASCII flowchart: http://asciiflow.com/
ASCII table: https://ozh.github.io/ascii-tables/
I wrote this years ago: http://www.cplusplus.com/articles/z13hAqkS/

Yours is probably better though!
I like the show and tell visual method of your article. Updated to do the same kind of thing here.

[edit]
If it is still possible to edit your article, you have my permission to cut-n-paste (and modify) any of the stuff here to update it if you want.
Last edited on
Forever bump #1
Topic archived. No new replies allowed.