1<?php 2 3namespace dokuwiki\Parsing\ParserMode; 4 5/** 6 * GFM strikethrough via paired double tildes: `~~text~~`. 7 * 8 * Emits deleted_open / deleted_close — the same instructions as DokuWiki's 9 * Deleted (`<del>…</del>`), so both syntaxes render as <del>. 10 */ 11class GfmDeleted extends AbstractFormatting 12{ 13 /** @inheritdoc */ 14 public function getSort() 15 { 16 // Deliberately sorted last: many plugins claim `~~KEYWORD~~` macros 17 // (e.g. ~~TOC~~, ~~NOFOOTER~~) whose opener the strikethrough entry 18 // pattern also matches. A high sort lets those plugins parse first 19 // and keep their syntax; plain ~~text~~ still falls through to here. 20 return 1000; 21 } 22 23 /** @inheritdoc */ 24 protected function getModeName(): string 25 { 26 return 'gfm_deleted'; 27 } 28 29 /** @inheritdoc */ 30 protected function getInstructionName(): string 31 { 32 return 'deleted'; 33 } 34 35 /** @inheritdoc */ 36 protected function getEntryPattern(): string 37 { 38 // Broken down: 39 // (?<!~) — not preceded by `~` (runs of 3+ tildes 40 // are fenced-code markers, not strike) 41 // ~~ — two opening tildes 42 // (?=[^\s~]) — next body char: not whitespace, not `~` 43 return '(?<!~)~~(?=[^\s~])'; 44 } 45 46 /** @inheritdoc */ 47 protected function getExitPattern(): string 48 { 49 return '(?<=[^\s])~~(?!~)'; 50 } 51} 52