1*0244be5cSAndreas Gohr<?php 2*0244be5cSAndreas Gohr 3*0244be5cSAndreas Gohrnamespace dokuwiki\Parsing\ParserMode; 4*0244be5cSAndreas Gohr 5*0244be5cSAndreas Gohr/** 6*0244be5cSAndreas Gohr * GFM strikethrough via paired double tildes: `~~text~~`. 7*0244be5cSAndreas Gohr * 8*0244be5cSAndreas Gohr * Emits deleted_open / deleted_close — the same instructions as DokuWiki's 9*0244be5cSAndreas Gohr * Deleted (`<del>…</del>`), so both syntaxes render as <del>. 10*0244be5cSAndreas Gohr */ 11*0244be5cSAndreas Gohrclass GfmDeleted extends AbstractFormatting 12*0244be5cSAndreas Gohr{ 13*0244be5cSAndreas Gohr /** @inheritdoc */ 14*0244be5cSAndreas Gohr public function getSort() 15*0244be5cSAndreas Gohr { 16*0244be5cSAndreas Gohr return 130; 17*0244be5cSAndreas Gohr } 18*0244be5cSAndreas Gohr 19*0244be5cSAndreas Gohr /** @inheritdoc */ 20*0244be5cSAndreas Gohr protected function getModeName(): string 21*0244be5cSAndreas Gohr { 22*0244be5cSAndreas Gohr return 'gfm_deleted'; 23*0244be5cSAndreas Gohr } 24*0244be5cSAndreas Gohr 25*0244be5cSAndreas Gohr /** @inheritdoc */ 26*0244be5cSAndreas Gohr protected function getInstructionName(): string 27*0244be5cSAndreas Gohr { 28*0244be5cSAndreas Gohr return 'deleted'; 29*0244be5cSAndreas Gohr } 30*0244be5cSAndreas Gohr 31*0244be5cSAndreas Gohr /** @inheritdoc */ 32*0244be5cSAndreas Gohr protected function getEntryPattern(): string 33*0244be5cSAndreas Gohr { 34*0244be5cSAndreas Gohr // Broken down: 35*0244be5cSAndreas Gohr // (?<!~) — not preceded by `~` (runs of 3+ tildes 36*0244be5cSAndreas Gohr // are fenced-code markers, not strike) 37*0244be5cSAndreas Gohr // ~~ — two opening tildes 38*0244be5cSAndreas Gohr // (?=[^\s~]) — next body char: not whitespace, not `~` 39*0244be5cSAndreas Gohr // (?= — lookahead: a valid closer must exist 40*0244be5cSAndreas Gohr // CONTENT_UNTIL_PARA — body that doesn't cross a blank line 41*0244be5cSAndreas Gohr // [^\s]~~ — non-whitespace, then closing `~~` 42*0244be5cSAndreas Gohr // (?!~) — and not followed by another `~` 43*0244be5cSAndreas Gohr // ) 44*0244be5cSAndreas Gohr return '(?<!~)~~(?=[^\s~])' 45*0244be5cSAndreas Gohr . '(?=' . self::CONTENT_UNTIL_PARA . '[^\s]~~(?!~))'; 46*0244be5cSAndreas Gohr } 47*0244be5cSAndreas Gohr 48*0244be5cSAndreas Gohr /** @inheritdoc */ 49*0244be5cSAndreas Gohr protected function getExitPattern(): string 50*0244be5cSAndreas Gohr { 51*0244be5cSAndreas Gohr return '(?<=[^\s])~~(?!~)'; 52*0244be5cSAndreas Gohr } 53*0244be5cSAndreas Gohr} 54