xref: /dokuwiki/inc/Parsing/ParserMode/Emphasis.php (revision 13a62f810fbd091d15ab734b467eaec0a6bf829a)
1<?php
2
3namespace dokuwiki\Parsing\ParserMode;
4
5class Emphasis extends AbstractFormatting
6{
7    /** @inheritdoc */
8    public function getSort()
9    {
10        return 80;
11    }
12
13    /** @inheritdoc */
14    protected function getModeName(): string
15    {
16        return 'emphasis';
17    }
18
19    /**
20     * @inheritdoc
21     * @see https://github.com/dokuwiki/dokuwiki/issues/384
22     * @see https://github.com/dokuwiki/dokuwiki/issues/763
23     * @see https://github.com/dokuwiki/dokuwiki/issues/1468
24     *
25     * Flanking rules (simplified): opener must be followed by non-whitespace
26     * non-`/`; closer must be preceded by non-whitespace non-colon (the colon
27     * exclusion protects `http://`-style URLs).
28     */
29    protected function getEntryPattern(): string
30    {
31        return '//(?=[^\s/])(?=' . self::CONTENT_UNTIL_PARA . '[^\s:]//)';
32    }
33
34    /** @inheritdoc */
35    protected function getExitPattern(): string
36    {
37        return '(?<=[^\s])//';
38    }
39}
40