Content processing with shortcodes

Shortcodes are probably the most powerful tool to process Markdown content inline.

A corner stone

They are simple to create and use, almost anything can be done with them, and they represent an important opportunity that should not be missed. Eleventy has two kinds of shortcode:

{% _shortcode_id "argument" %}

{% _shortcode_id %}... Content to be processed ...{% end_shortcode_id %}

11tyTips doesn’t use a lot of shortcodes, but they are essential to its content. Let’s dissect the most omnipresent of it: the _code_block paired shortcode. It is passed to Eleventy configuration method addPairedShortcode this way:

make_o.addPairedShortcode('_code_block', content_s => CODES_o.code_block__s( content_s ) )

Here, _code_block is the shortcode identifier 11tyTips uses a leading underscore character because the shortcode closing tag adds the word end before the shortcode identifier: end_shortcode is more readable than endshortcode, isn’t it?

Shortcode anatomy (to be continued...)