ShortcodeProcessor
in package
implements
MarkdownPreProcessorContract
Handle all shortcode processing for a Markdown conversion.
The shortcode system has a few limitations, as it is meant to be simple by design so that it is easy to understand how the code works, and what each shortcode does. Shortcodes are expanded on a per-line basis, and do not support multi-line input. Shortcodes are expected to be the very first thing on a line. The signature is a static string that is used to identify the shortcode. The built-in shortcodes do not use regex, as that would make them harder to read.
Tags
Table of Contents
Interfaces
- MarkdownPreProcessorContract
- Process Markdown before it is converted to HTML.
Properties
- $input : string
- The input Markdown document body.
- $output : string
- The processed Markdown document body.
- $shortcodes : array<string, MarkdownShortcodeContract>
- The activated shortcode instances.
Methods
- preprocess() : string
- discoverShortcodes() : void
- discoverSignature() : string
- expandShortcode() : string
- getOutput() : string
- processInput() : static
Properties
$input
The input Markdown document body.
protected
string
$input
$output
The processed Markdown document body.
protected
string
$output
$shortcodes
The activated shortcode instances.
protected
array<string, MarkdownShortcodeContract>
$shortcodes
Methods
preprocess()
public
static preprocess(string $markdown) : string
Parameters
- $markdown : string
-
Markdown to be processed
Return values
string —$markdown Processed Markdown output
discoverShortcodes()
protected
discoverShortcodes() : void
discoverSignature()
protected
discoverSignature(string $line) : string
Parameters
- $line : string
Return values
stringexpandShortcode()
protected
expandShortcode(string $line) : string
Parameters
- $line : string
Return values
stringgetOutput()
protected
getOutput() : string
Return values
stringprocessInput()
protected
processInput() : static