` and * `...`. * * This renderer is used only by {@see GfmSpecTest} so the spec roundtrip * can compare against byte-level spec HTML. Production rendering is * unchanged. Methods not overridden here fall through to the XHTML * renderer (paragraphs, emphasis, code spans, lists, etc.) — those render * the same shape the spec expects. * * Note: title attributes on links/images are discarded at handle time * (no DW instruction slot), so spec examples that expect `title="..."` * still don't pass and stay in `skip.php`. */ class SpecCompatRenderer extends Doku_Renderer_xhtml { public function table_open($maxcols = null, $numrows = null, $pos = null, $classes = null) { // Production DW wraps `
...`. $this->doc .= "
\n"; } public function quote_close() { $this->doc .= "\n"; } public function listu_open($classes = null) { $this->doc .= "
. The handler emits/strips // p_open / p_close to drive that distinction; the wrapper itself // produces no output here. } public function listcontent_close() { } public function file($text, $language = null, $filename = null, $options = null) { $this->doc .= $this->specCode($text, $language); } public function preformatted($text) { // The Preformatted CallWriter rewriter collapses start/content/ // newline/end into one `preformatted` call. GFM expects the body // to end with a newline (spec example 104); DW's internal text // loses it to `trim()`, so we re-append here. $this->doc .= $this->specCode($text . "\n", null); } /** * GFM shape:
.... The
* production DW renderer emits with no inner
* , which diverges byte-for-byte.
*/
private function specCode($text, $language): string
{
$classAttr = '';
if ($language !== null && $language !== '') {
$classAttr = ' class="language-' . hsc((string) $language) . '"';
}
return '' . hsc((string) $text) . '
';
}
private function specImg($src, $alt, $width, $height): string
{
$out = '
label. If the label is a media
* descriptor array (the shape Media::parseMedia() returns, passed by
* Internallink / GfmLink when the label is `{{img}}` / ``),
* render the
inside the .
*/
private function specLink($href, $label): string
{
if (is_array($label) && isset($label['type'])) {
$img = $this->specImg(
$label['src'],
$label['title'],
$label['width'] ?? null,
$label['height'] ?? null
);
return '' . $img . '';
}
$text = ($label === null || $label === '') ? $href : $label;
return '' . hsc((string) $text) . '';
}
}