A tutorial on Lambdium-light's BBcode markup
I'll be releasing Lambdium-light 0.80 very soon; this is the version that accepts a variant of BBcode for markup. For reference purposes, here follows a tutorial detailing the use of this markup for stories/comments.
-
Paragraphs:
An empty line is used to separate paragraphs. The reason this was chosen instead of an XHTMLy syntax (using <p> and such) is because it is so much more convenient. Example:
This is all part of the same paragraph. But this is a new one.
Will produce:
This is all part of the same paragraph.
But this is a new one.
-
Inline formatting:
You can apply various formatting tags to text inside a paragraph (dubbed "inline text"). Example:
This is normal text, but [b]this one[/b] is in bold, while [i]this one[/i] is italic. You can also do [sup]superscripts[/sup] and [sub]subscripts[/sub].
Will produce:
This is normal text, but this one is in bold, while this one is italic. You can also do superscripts and subscripts.
-
Escaping characters:
Use '\' to escape other characters. This is the only way to tell the parser that the character '[' should not be interpreted as the beginning of a tag. Example:
Here is the character \\. Opening tags take the form \[tagname\], while their closing counterparts are \[/tagname\].
Will produce:
Here is the character \. Opening tags take the form [tagname], while their closing counterparts are [/tagname].
-
Links:
You can produce links in either of two ways: if the text to be displayed is the same as the URL, you can just use the [url] tag. If, on the other hand, you wish to show a different text, then pass the URL as a parameter to the [url] tag.
Here is a link to [url]http://nleyten.com/[/url]. And this is a link to [url=http://nleyten.com/]this blog[/url].
Will produce:
Here is a link to http://nleyten.com/. And this is a link to this blog.
-
Section headings:
Use the [section] tag. Example:
This is a paragraph. [section]This is a new section[/section] This is another paragraph.
Will produce:
This is a paragraph.
This is a new section
This is another paragraph.
-
Quotations:
Use the [quote] tag. Example:
This is a normal paragraph. [quote] This is a quote. You can use [b]whatever[/b] formatting you want inside quotes. You can even begin new paragraphs and nest quotes ad infinitum! [/quote] This is again a normal paragraph.
Will produce:
This is a normal paragraph.
This is a quote. You can use whatever formatting you want inside quotes.
You can even begin new paragraphs and nest quotes ad infinitum!
This is again a normal paragraph.
-
Code blocks:
You can use the [code] tag to delimit blocks that should be displayed verbatim. This is particularly useful for displaying source code. Example:
This is a normal paragraph. [code] type block = Paragraph | Section | Quote | Code let block_of_string = function | "paragraph" -> Paragraph | "section" -> Section | "quote" -> Quote | "code" -> Code | _ -> raise Invalid_argument [/code] This is again a normal paragraph.
Will produce:
This is a normal paragraph.
type block = Paragraph | Section | Quote | Code let block_of_string = function | "paragraph" -> Paragraph | "section" -> Section | "quote" -> Quote | "code" -> Code | _ -> raise Invalid_argument
This is again a normal paragraph.
-
Unordered lists:
Use the [list] tag to mark the beginning of an unordered list. The tag [*] is used to mark each item, and [/list] ends the list. Example:
This is a normal paragraph. [list] [*] This is an item; [*] This is also an item; [*] And this too is an item. [/list] This is again a normal paragraph.
Will produce:
This is a normal paragraph.
- This is an item;
- This is also an item;
- And this too is an item.
This is again a normal paragraph.
-
Ordered lists:
Ordered lists (or enumerations) are in all similar to unordered lists. The only difference is that [enum] is used as the tag. Example:
This is a normal paragraph. [enum] [*] This is an item; [*] This is also an item; [*] And this too is an item. [list] [*] This belongs in a sublist; [*] This too. [/list] [/enum] This is again a normal paragraph.
Will produce:
This is a normal paragraph.
- This is an item;
- This is also an item;
- And this too is an item.
- This belongs in a sublist;
- This too.
This is again a normal paragraph.
-
Formal grammar:
Below you will find the Ocaml type definitions that describes a document (either a story or a comment). As you can see, a document is composed of a series of blocks, where each block is either a text paragraph, or one of the special blocks (such as section headings, quotations, code, etc). Particularly of relevance is the fact that quotations and lists (both ordered and unordered) accept entire documents as children. You can therefore recurse all you want.
type text_t = string type link_t = string type inline_t = node_t list and node_t = Text of text_t | Bold of inline_t | Emph of inline_t | Sup of inline_t | Sub of inline_t | Link of link_t * text_t type fragment_t = block_t list and block_t = Paragraph of inline_t | Section of inline_t | Quote of fragment_t | Code of text_t | Listing of fragment_t list | Enum of fragment_t list type t = fragment_t

Comments