Skip to content

Markdown

The small amount of Markdown and YAML escaping the emitters share.

Docblock prose was written for a PHP comment, not for a table cell or a YAML scalar, so anything crossing into one has to be made safe first: an unescaped pipe silently splits a row, and a colon or a quote can make a frontmatter block unparsable and fail the site build.

final class Markdown

SourceEmitter/Markdown.php
MethodDescription
cell(string $text): stringProse made safe for a table cell.
oneLine(string $text): stringCollapses prose onto one line, for a description or a table cell.
table(list<string> $headers, list<list<string>> $rows, bool $headerless = false): stringA Markdown table in the site’s own style: terse separators, no padding, no alignment colons.
yamlScalar(string $value): stringA YAML scalar that survives whatever the prose contains.

public function cell(string $text): string

Prose made safe for a table cell.

A pipe would end the cell, and a line break would end the row.

ParameterTypeDescription
$textstring

Returns string

public function oneLine(string $text): string

Collapses prose onto one line, for a description or a table cell.

ParameterTypeDescription
$textstring

Returns string

public function table(list<string> $headers, list<list<string>> $rows, bool $headerless = false): string

A Markdown table in the site’s own style: terse separators, no padding, no alignment colons.

Renders an empty header row, for a two-column fact list where column titles would say nothing.

ParameterTypeDescription
$headerslist``<``string``>
$rowslist``<``list``<``string``>``>
$headerlessboolRenders an empty header row, for a two-column fact list where column titles would say nothing.

Returns string

public function yamlScalar(string $value): string

A YAML scalar that survives whatever the prose contains.

Always quoted rather than quoted-when-necessary: the rules for when a plain scalar is safe are subtle enough that guessing wrong shows up as a broken build in another repository.

ParameterTypeDescription
$valuestring

Returns string