xref: /dokuwiki/inc/Parsing/ParserMode/GfmEmphasisUnderscore.php (revision fe58309edafb067d90f3f40ef3d416100d558a04)
1<?php
2
3namespace dokuwiki\Parsing\ParserMode;
4
5/**
6 * GFM / CommonMark emphasis via single underscores: `_text_`.
7 *
8 * Only loaded when Markdown is the only or preferred syntax
9 *
10 * Emits emphasis_open / emphasis_close — the same instructions as DokuWiki's
11 * Emphasis (`//`) and GfmEmphasis (`*`), so all three render as <em>.
12 */
13class GfmEmphasisUnderscore extends AbstractFormatting
14{
15    /** @inheritdoc */
16    public function getSort()
17    {
18        return 80;
19    }
20
21    /** @inheritdoc */
22    protected function getModeName(): string
23    {
24        return 'gfm_emphasis_underscore';
25    }
26
27    /** @inheritdoc */
28    protected function getInstructionName(): string
29    {
30        return 'emphasis';
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