Dup Ver Goto 📝

ExtendingPTMD

pt2/pt2/hacking 10-16 13:59:03
To
38 lines, 200 words, 1465 chars Monday 2023-10-16 13:59:03

The renderer code is here.

Specials

There are two types of specials: block and inline. Inline extends the [[inline link]] notation, noting that an href containing a colon is invalid, and so if : occurs in it, it is a special.

Inline Specials

For example [[youtube:N7GoTb5L5gM]] embeds this video thus:

It removes leading and trailing spaces, so [[youtube: 7QVWjNAPxbQ ]] works. But it rejects invalid id's such as Invalid Youtube Id: 7QVWjNAPxbxQ.

We add inline specials to PTMD by adding methods named

  function special_inline_flibble($what,$args) {...

The $what in [[flibble:hexvision]] is theflibblebit, essentially whatever is before the first:, and the$args` is everything afterwards. Simples.

Block Specials

Here we reuse fenced code blocks. Ordinarily, a block fenced by backquotes

```python
like this
```

will be formatted as a code block with in this case the language set to Python. By adding methods

  function special_block_duolingo($what,$options,$content) {...

for example, we can then have blocks like

```duolingo
...
```

have some custom code turning them into HTML. The $what is the duolingobit, the $options are whatever follows it on the duolingo line. Then the $content is everything else within the code block.