module

Shortcode::Engine

Master shortcode tokenizer and expansion engine.

Constants

CODE_MASK_REGEX = /(?:```|~~~)[^\n]*\r?\n[\s\S]*?\r?\n(?:```|~~~)|`[^`\n]+`/
PARAM_REGEX = /([a-zA-Z0-9_-]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/

Class methods

expand(html : String, shortcodes : Hash(String, Invocation), compiler : MarkdownCompiler, depth : Int32 = 0, custom_renderer : Proc(Invocation, String, String) | Nil = nil) : String

Expands all shortcode placeholders within compiled HTML using the provided MarkdownCompiler.

Source
find_matching_closing_tag(text : String, tag_name : String) : Tuple(Int32, Int32) | Nil

Finds the index and length of the corresponding closing tag for a block shortcode.

Source
parse_params(param_str : String) : Hash(String, String)

Parses key-value parameters from a shortcode invocation string.

Source
render_shortcode(invocation : Invocation, inner_html : String) : String

Renders an individual shortcode invocation to HTML.

Source
tokenize(raw_body : String, prefix : String = "SHORTCODE") : Tuple(String, Hash(String, Invocation))

Tokenizes raw content into AST-safe placeholder comments and extracts invocations.

Source