xref: /dokuwiki/inc/Parsing/ParserMode/GfmStrongUnderscore.php (revision 1c00c02121477c81b95fe750b94acdf109cba20a)
1<?php
2
3namespace dokuwiki\Parsing\ParserMode;
4
5/**
6 * GFM / CommonMark strong emphasis via double underscores: `__text__`.
7 *
8 * Only loaded when Markdown is the only or preferred syntax
9 *
10 * Emits strong_open / strong_close — the same instructions as DokuWiki's
11 * Strong (`**`), so both delimiters render as <strong>.
12 */
13class GfmStrongUnderscore extends AbstractFormatting
14{
15    /** @inheritdoc */
16    public function getSort()
17    {
18        return 70;
19    }
20
21    /** @inheritdoc */
22    protected function getModeName(): string
23    {
24        return 'gfm_strong_underscore';
25    }
26
27    /** @inheritdoc */
28    protected function getInstructionName(): string
29    {
30        return 'strong';
31    }
32
33    /** @inheritdoc */
34    protected function getEntryPattern(): string
35    {
36        return self::NO_WORD_BEFORE
37            . '__(?=[^\s_])';
38    }
39
40    /** @inheritdoc */
41    protected function getExitPattern(): string
42    {
43        return '(?<=[^\s])__' . self::NO_WORD_AFTER;
44    }
45}
46