13e6baeffSAndreas Gohr<?php 23e6baeffSAndreas Gohr 33e6baeffSAndreas Gohrnamespace dokuwiki\Parsing\ParserMode; 43e6baeffSAndreas Gohr 53e6baeffSAndreas Gohruse dokuwiki\Parsing\Handler; 63e6baeffSAndreas Gohr 73e6baeffSAndreas Gohr/** 83e6baeffSAndreas Gohr * Horizontal rule — single mode covering both DokuWiki and GFM dialects. 93e6baeffSAndreas Gohr * 103e6baeffSAndreas Gohr * Replaces the legacy DW Hr mode and is always loaded across all four 113e6baeffSAndreas Gohr * `$conf['syntax']` settings; the opener pattern self-narrows based on 123e6baeffSAndreas Gohr * syntax preference. Pure `dokuwiki` keeps its historical 4-or-more 133e6baeffSAndreas Gohr * dashes rule. The other three settings accept 3-or-more of any one 143e6baeffSAndreas Gohr * GFM thematic-break character (`-`, `*`, `_`). 153e6baeffSAndreas Gohr * 163e6baeffSAndreas Gohr * No leading, trailing, or internal whitespace in either flavor: the 173e6baeffSAndreas Gohr * delimiter run must be a bare line. The DW pattern's old `[ \t]*` 183e6baeffSAndreas Gohr * leading-whitespace tolerance was inert in practice for everything 193e6baeffSAndreas Gohr * but 0-1 spaces (Preformatted at sort 20 intercepts ≥ 2 spaces or any 203e6baeffSAndreas Gohr * tab); dropping it costs nothing real and keeps both flavors strict. 213e6baeffSAndreas Gohr * 223e6baeffSAndreas Gohr * Emits the existing `hr` handler call so renderers, downloads and 233e6baeffSAndreas Gohr * call shape are unchanged. 243e6baeffSAndreas Gohr */ 253e6baeffSAndreas Gohrclass GfmHr extends AbstractMode 263e6baeffSAndreas Gohr{ 273e6baeffSAndreas Gohr /** @inheritdoc */ 283e6baeffSAndreas Gohr public function getSort() 293e6baeffSAndreas Gohr { 303e6baeffSAndreas Gohr return 160; 313e6baeffSAndreas Gohr } 323e6baeffSAndreas Gohr 333e6baeffSAndreas Gohr /** @inheritdoc */ 343e6baeffSAndreas Gohr public function connectTo($mode) 353e6baeffSAndreas Gohr { 36*47a02a10SAndreas Gohr $pattern = $this->registry->getSyntax() === 'dw' 373e6baeffSAndreas Gohr ? '\n-{4,}(?=\n)' 383e6baeffSAndreas Gohr : '\n(?:-{3,}|\*{3,}|_{3,})(?=\n)'; 393e6baeffSAndreas Gohr 403e6baeffSAndreas Gohr $this->Lexer->addSpecialPattern($pattern, $mode, 'gfm_hr'); 413e6baeffSAndreas Gohr } 423e6baeffSAndreas Gohr 433e6baeffSAndreas Gohr /** @inheritdoc */ 443e6baeffSAndreas Gohr public function handle($match, $state, $pos, Handler $handler) 453e6baeffSAndreas Gohr { 463e6baeffSAndreas Gohr $handler->addCall('hr', [], $pos); 473e6baeffSAndreas Gohr return true; 483e6baeffSAndreas Gohr } 493e6baeffSAndreas Gohr} 50