BML deals mostly with plain text, so it doesn’t have much special syntax for formatting documents. Besides a few automatic cleanup processes, BML generally outputs your text plain and without formatting.

Automatic formatting cleanup

Because BML’s chance operations can introduce a lot of noisy whitespace in counterintuitive ways, BML by default performs a series of post-processing tasks to correct common errors. Each can be disabled using document settings.

Whitespace Cleanup

Controlled by settings.whitespaceCleanup

  • Removes all trailing whitespace in every line
  • Collapses all runs of over one blank line into just one
  • Similarly collapses all runs of spaces in the middle of lines
  • Removes all whitespace from the start and end of the document
  • Ensures the text ends with a single line break.

Whitespace at doc start is removed
Whitespace    in lines is collapsed
    But indentation is preserved

> 1 blank line is collapsed
and whitespace at doc end is removed


Punctuation Cleanup

Controlled by settings.punctuationCleanup

  • Performs simple English-like correction of whitespace around punctuation marks by snapping , . : ; ! ? to the end of preceding words when separated by whitespace (including line breaks)
Conveniently , BML corrects placement of punctuation {(.), (!)}
This lets you write chancy punctuation more legibly.

Capitalization Cleanup

Controlled by settings.punctuationCleanup

  • Tries to correct capitalization of the first words of sentences.
BML can correct capitalization {(;), (.)}
this is useful when sentence divisions are chancy.

Visual Line Breaks

In complex documents with lots of choices, especially nested ones, it’s very helpful to use indentation to visually organize logical levels. These line breaks and indentation will not be included in the output as long as they are placed in the braces context, not within the parentheses which enclose literal text.

test: {

But for complex documents and those with lengthy choice bodies, visual line breaks allow you to use line breaks and indentation without including them in the output. Simply end a line with a single backslash \; the backslash, line break, and any following indentation will collapse into a single whitespace character.

one \

another {
    (single \
        (nested \
        (nested \
         line 2)

ℹ️ Note

If you’re targetting a format-aware language like markdown or HTML, visual newlines may not be needed since such languages often treat all line breaks as visual line breaks.

Example: Using BML to write Markdown

While BML itself doesn’t include any formatting capability, you can use BML to write documents in other languages which do. A common BML target is Markdown, a ubiquitous and simple markup language for converting legible plaintext into website-ready HTML.

Markdown is a good deal easier to learn than BML, and there are loads of resources out there for it, for example this cheatsheet and this interactive tutorial.

To write BML code targeting Markdown, simply write Markdown and insert BML directives as needed.

# Hello {(blurry), (chancy)} world!
1. {(An ordered), (A)} list
2. Second entry

This output can then be sent to a Markdown processor and converted to formatted and CSS-styleable HTML.