API Documentation

CodeblockFilepathProcessor
in package
implements MarkdownPreProcessorContract, MarkdownPostProcessorContract

Resolves file path comments found in Markdown code blocks into a neat badge shown in the top right corner.

Table of Contents

Interfaces

MarkdownPreProcessorContract
Process Markdown before it is converted to HTML.
MarkdownPostProcessorContract
Process Markdown after it is converted to HTML.

Properties

$patterns  : array<string|int, string>
$torchlightKey  : string

Methods

postprocess()  : string
Process the meta-blocks added by the preprocessor, injecting the filepath badge template into the code block.
preprocess()  : string
Extract lines matching the shortcode pattern and replace them with meta-blocks that will be processed later.
injectLabelToCodeLine()  : string
injectLabelToTorchlightCodeLine()  : string
lineMatchesPattern()  : bool
resolveTemplate()  : string
trimHydeDirective()  : string

Properties

$patterns

protected static array<string|int, string> $patterns = ['// filepath: ', '// filepath ', '/* filepath: ', '/* filepath ', '# filepath: ', '# filepath ', '<!-- filepath: ', '<!-- filepath ']

Methods

postprocess()

Process the meta-blocks added by the preprocessor, injecting the filepath badge template into the code block.

public static postprocess(string $html) : string
Parameters
$html : string

HTML to be processed

Return values
string

$html Processed HTML output

preprocess()

Extract lines matching the shortcode pattern and replace them with meta-blocks that will be processed later.

public static preprocess(string $markdown) : string
Parameters
$markdown : string

Markdown to be processed

Return values
string

$markdown Processed Markdown output

injectLabelToCodeLine()

protected static injectLabelToCodeLine(string $label, string $lines) : string
Parameters
$label : string
$lines : string
Return values
string

injectLabelToTorchlightCodeLine()

protected static injectLabelToTorchlightCodeLine(string $label, string $lines) : string
Parameters
$label : string
$lines : string
Return values
string

lineMatchesPattern()

protected static lineMatchesPattern(string $line) : bool
Parameters
$line : string
Return values
bool

resolveTemplate()

protected static resolveTemplate(string $path) : string
Parameters
$path : string
Return values
string

trimHydeDirective()

protected static trimHydeDirective(string $line) : string
Parameters
$line : string
Return values
string

        
On this page

Search results