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