Mecha CMS


Escaping Blocks

Author: Taufik Nurrohman · 252 Views


How to write literal block syntax in the page content?

Table of Content

Unlike Markdown, blocks are still accessible within the <code> tags. So, it is not possible to write literal block syntax within the <code> tags. To write literal block syntax in the page content, you will need to wrap the syntax with some backtick characters like so:


This will make the block parser ignore them, and instead, it will unwrap the blocks from backtick characters and keep the syntax visible as how it was written without the surrounding ` characters.

That’s the first option. The second option is by using an invisible characters that have no dimension at all, but still considered exists in the string. For this reason, Mecha decided to take &zwnj; as the best candidate for this task.

The zero-width non-joiner (ZWNJ) is a non-printing character used in the computerization of writing systems that make use of ligatures. When placed between two characters that would otherwise be connected into a ligature, a ZWNJ causes them to be printed in their final and initial forms, respectively. This is also an effect of a space character, but a ZWNJ is used when it is desirable to keep the words closer together or to connect a word with its morpheme. — Wikipedia

It is clear that the block parser essentially requires the [‌[ and ]‌] characters to be present lined up exactly without any additional characters in between. By adding these characters between them, the probability of them to be parsed is very small. &zwnj; character is invisible, but it is still considered exists. As an example, put your cursor in the text input below and then press +A to select all characters in it, then press to show the placeholder text:

You can copy that invisible character from the text input and then paste it between [‌, ‌], / and the block ID so that it becomes like this:


Why Invisible Characters? 

It’s just for the sake of aesthetics. By using invisible characters, your page’s source will be kept clean and readable by others as it is. Using ` as the escaping characters is conform with the procedure, but some Markdown users may assume that, a ‌`[‌[‌block‌]‌]`‌ syntax will turn into HTML <code>[‌[‌block‌]‌]</code>. In fact, it will only turn into [‌[‌block‌]‌] because they need at least two ` characters to make it becomes wrapped by the HTML <code>.

Some good source code editor like CodeMirror can visualize them as red dots:




No comments yet.