Skip to content

Commit

Permalink
regexp: uses extended mode (BC break)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 16, 2025
1 parent fa1406e commit d744b49
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion src/Texy/Modifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function setProperties(?string $s): void
$ch = $s[$p];

if ($ch === '(') { // title
preg_match('#(?:\\\\\)|[^)\n])++\)#', $s, $m, 0, $p);
preg_match('~(?:\\\\\)|[^)\n])++\)~', $s, $m, 0, $p);
$this->title = Helpers::unescapeHtml(str_replace('\)', ')', trim(substr($m[0], 1, -1))));
$p += strlen($m[0]);

Expand Down
2 changes: 1 addition & 1 deletion src/Texy/Modules/BlockModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(Texy\Texy $texy)

$texy->registerBlockPattern(
$this->pattern(...),
'~^/--++\ *+(.*)' . Texy\Patterns::MODIFIER_H . '?$((?:\n(?0)|\n.*+)*)(?:\n\\\--.*$|\z)~mUi',
'~^/--++\ *+(.*)' . Texy\Patterns::MODIFIER_H . '?$((?:\n(?0)|\n.*+)*)(?:\n\\\--.*$|\z)~mUix',
'blocks',
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Texy/Modules/BlockQuoteModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(Texy\Texy $texy)

$texy->registerBlockPattern(
$this->pattern(...),
'~^(?:' . Texy\Patterns::MODIFIER_H . '\n)?\>([\ \t]++|:)(\S.*+)$~mU', // original
'~^(?:' . Texy\Patterns::MODIFIER_H . '\n)?\>([\ \t]++|:)(\S.*+)$~mUx', // original
'blockquote',
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Texy/Modules/FigureModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(Texy\Texy $texy)
$texy->registerBlockPattern(
$this->pattern(...),
'~^\[\*\ *+([^\n' . Patterns::MARK . ']{1,1000})' . Patterns::MODIFIER . '?\ *+(\*|(?<!<)>|<)\]' // [* urls .(title)[class]{style} >]
. '(?::(' . Patterns::LINK_URL . '|:))??\ ++\*\*\*\ ++(.{0,2000})' . Patterns::MODIFIER_H . '?()$~mU',
. '(?::(' . Patterns::LINK_URL . '|:))??\ ++\*\*\*\ ++(.{0,2000})' . Patterns::MODIFIER_H . '?()$~mUx',
'figure',
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Texy/Modules/HeadingModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ public function __construct(Texy\Texy $texy)
$texy->registerBlockPattern(
$this->patternUnderline(...),
'~^(\S.{0,1000})' . Texy\Patterns::MODIFIER_H . '?\n'
. '(#{3,}+|\*{3,}+|={3,}+|-{3,}+)$~mU',
. '(\#{3,}+|\*{3,}+|={3,}+|-{3,}+)$~mUx',
'heading/underlined',
);

$texy->registerBlockPattern(
$this->patternSurround(...),
'~^(#{2,}+|={2,}+)(.+)' . Texy\Patterns::MODIFIER_H . '?()$~mU',
'~^(\#{2,}+|={2,}+)(.+)' . Texy\Patterns::MODIFIER_H . '?()$~mUx',
'heading/surrounded',
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Texy/Modules/HorizLineModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(Texy\Texy $texy)

$texy->registerBlockPattern(
$this->pattern(...),
'~^(\*{3,}+|-{3,}+)[\ \t]*' . Texy\Patterns::MODIFIER . '?()$~mU',
'~^(\*{3,}+|-{3,}+)[\ \t]*' . Texy\Patterns::MODIFIER . '?()$~mUx',
'horizline',
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Texy/Modules/HtmlModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public function __construct(Texy\Texy $texy)

$texy->registerLinePattern(
$this->patternTag(...),
'~<(/?)([a-z][a-z0-9_:-]{0,50})((?:\s++[a-z0-9\_:-]++|=\s*+"[^"' . Patterns::MARK . ']*+"|=\s*+\'[^\'' . Patterns::MARK . ']*+\'|=[^\s>' . Patterns::MARK . ']++)*)\s*+(/?)>~is',
'~<(/?)([a-z][a-z0-9_:-]{0,50})((?:\s++[a-z0-9\_:-]++|=\s*+"[^"' . Patterns::MARK . ']*+"|=\s*+\'[^\'' . Patterns::MARK . ']*+\'|=[^\s>' . Patterns::MARK . ']++)*)\s*+(/?)>~isx',
'html/tag',
);

$texy->registerLinePattern(
$this->patternComment(...),
'~<!--([^' . Patterns::MARK . ']*?)-->~is',
'~<!--([^' . Patterns::MARK . ']*?)-->~isx',
'html/comment',
);
}
Expand Down Expand Up @@ -288,7 +288,7 @@ private function parseAttributes(string $attrs): array
{
$matches = $res = [];
preg_match_all(
'~([a-z0-9\_:-]+)\s*(?:=\s*(\'[^\']*\'|"[^"]*"|[^\'"\s]+))?()~isu',
'~([a-z0-9\_:-]+)\s*(?:=\s*(\'[^\']*\'|"[^"]*"|[^\'"\s]+))?()~isux',
$attrs,
$matches,
PREG_SET_ORDER,
Expand Down
2 changes: 1 addition & 1 deletion src/Texy/Modules/HtmlOutputModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private function postProcess(Texy\Texy $texy, string &$s): void
}

// right trim
$s = Regexp::replace($s, "~[\t ]+(\n|\r|$)~", '$1'); // right trim
$s = Regexp::replace($s, '~[\t ]+(\n|\r|$)~', '$1'); // right trim

// join double \r to single \n
$s = str_replace("\r\r", "\n", $s);
Expand Down
4 changes: 2 additions & 2 deletions src/Texy/Modules/ImageModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct(Texy\Texy $texy)
$texy->registerLinePattern(
$this->patternImage(...),
'~\[\*\ *+([^\n' . Patterns::MARK . ']{1,1000})' . Patterns::MODIFIER . '?\ *+(\*|(?<!<)>|<)\]' // [* urls .(title)[class]{style} >]
. '(?::(' . Patterns::LINK_URL . '|:))??()~U',
. '(?::(' . Patterns::LINK_URL . '|:))??()~Ux',
'image',
);
}
Expand All @@ -69,7 +69,7 @@ private function beforeParse(Texy\Texy $texy, &$text): void
// [*image*]: urls .(title)[class]{style}
$text = Texy\Regexp::replace(
$text,
'~^\[\*([^\n]{1,100})\*\]:[\ \t]+(.{1,1000})[\ \t]*' . Patterns::MODIFIER . '?\s*()$~mU',
'~^\[\*([^\n]{1,100})\*\]:[\ \t]+(.{1,1000})[\ \t]*' . Patterns::MODIFIER . '?\s*()$~mUx',
$this->patternReferenceDef(...),
);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Texy/Modules/LinkModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ public function __construct(Texy\Texy $texy)
// [reference]
$texy->registerLinePattern(
$this->patternReference(...),
'~(\[[^\[\]\*\n' . Patterns::MARK . ']++\])~U',
'~(\[[^\[\]\*\n' . Patterns::MARK . ']++\])~Ux',
'link/reference',
);

// direct url; charaters not allowed in URL <>[\]^`{|}
$texy->registerLinePattern(
$this->patternUrlEmail(...),
'~(?<=^|[\s([<:\x17])(?:https?://|www\.|ftp://)[0-9.' . Patterns::CHAR . '-][/\d' . Patterns::CHAR . '+\.\~%&?@=_:;#$!,*()\x{ad}-]{1,1000}[/\d' . Patterns::CHAR . '+\~?@=_#$*]~',
'~(?<=^|[\s([<:\x17])(?:https?://|www\.|ftp://)[0-9.' . Patterns::CHAR . '-][/\d' . Patterns::CHAR . '+\.\~%&?@=_:;#$!,*()\x{ad}-]{1,1000}[/\d' . Patterns::CHAR . '+\~?@=_#$*]~x',
'link/url',
'~(?:https?://|www\.|ftp://)~',
);
Expand All @@ -72,7 +72,7 @@ public function __construct(Texy\Texy $texy)
self::$EMAIL = '[' . Patterns::CHAR . '][0-9.+_' . Patterns::CHAR . '-]{0,63}@[0-9.+_' . Patterns::CHAR . '\x{ad}-]{1,252}\.[' . Patterns::CHAR . '\x{ad}]{2,19}';
$texy->registerLinePattern(
$this->patternUrlEmail(...),
'~(?<=^|[\s([<\x17])' . self::$EMAIL . '~',
'~(?<=^|[\s([<\x17])' . self::$EMAIL . '~x',
'link/email',
'~' . self::$EMAIL . '~',
);
Expand All @@ -90,7 +90,7 @@ private function beforeParse(Texy\Texy $texy, &$text): void
if (!empty($texy->allowed['link/definition'])) {
$text = Texy\Regexp::replace(
$text,
'~^\[([^\[\]#\?\*\n]{1,100})\]:\ ++(\S{1,1000})([\ \t].{1,1000})?' . Patterns::MODIFIER . '?\s*()$~mU',
'~^\[([^\[\]#\?\*\n]{1,100})\]:\ ++(\S{1,1000})([\ \t].{1,1000})?' . Patterns::MODIFIER . '?\s*()$~mUx',
$this->patternReferenceDef(...),
);
}
Expand Down Expand Up @@ -362,7 +362,7 @@ private function textualUrl(Link $link): string
: $link->raw;

// parse_url() in PHP damages UTF-8 - use regular expression
if (!preg_match('~^(?:(?P<scheme>[a-z]+):)?(?://(?P<host>[^/?#]+))?(?P<path>(?:/|^)(?!/)[^?#]*)?(?:\?(?P<query>[^#]*))?(?:#(?P<fragment>.*))?()$~u', $raw, $parts)) {
if (!preg_match('~^(?:(?P<scheme>[a-z]+):)?(?://(?P<host>[^/?#]+))?(?P<path>(?:/|^)(?!/)[^?#]*)?(?:\?(?P<query>[^#]*))?(?:\#(?P<fragment>.*))?()$~ux', $raw, $parts)) {
return $link->raw;
}

Expand Down
8 changes: 4 additions & 4 deletions src/Texy/Modules/ListModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ private function beforeParse(): void
$this->texy->registerBlockPattern(
$this->patternList(...),
'~^(?:' . Patterns::MODIFIER_H . '\n)?' // .{color: red}
. '(' . implode('|', $RE) . ')[\ \t]*+\S.*$~mU', // item (unmatched)
. '(' . implode('|', $RE) . ')[\ \t]*+\S.*$~mUx', // item (unmatched)
'list',
);

$this->texy->registerBlockPattern(
$this->patternDefList(...),
'~^(?:' . Patterns::MODIFIER_H . '\n)?' // .{color:red}
. '(\S.{0,2000})\:[\ \t]*' . Patterns::MODIFIER_H . '?\n' // Term:
. '([\ \t]++)(' . implode('|', $REul) . ')[\ \t]*+\S.*$~mU', // - description
. '([\ \t]++)(' . implode('|', $REul) . ')[\ \t]*+\S.*$~mUx', // - description
'list/definition',
);
}
Expand Down Expand Up @@ -162,7 +162,7 @@ public function patternDefList(BlockParser $parser, array $matches): HtmlElement
$mod->decorate($texy, $el);
$parser->moveBackward(2);

$patternTerm = '~^\n?(\S.*)\:[\ \t]*' . Patterns::MODIFIER_H . '?()$~mUA';
$patternTerm = '~^\n?(\S.*)\:[\ \t]*' . Patterns::MODIFIER_H . '?()$~mUAx';

while (true) {
if ($elItem = $this->patternItem($parser, $bullet, true, 'dd')) {
Expand Down Expand Up @@ -200,7 +200,7 @@ public function patternDefList(BlockParser $parser, array $matches): HtmlElement
private function patternItem(BlockParser $parser, string $bullet, bool $indented, string $tag): ?HtmlElement
{
$spacesBase = $indented ? ('[\ \t]{1,}') : '';
$patternItem = "~^\n?($spacesBase){$bullet}[ \\t]*(\\S.*)?" . Patterns::MODIFIER_H . '?()$~mAU';
$patternItem = "~^\\n?($spacesBase){$bullet}[ \\t]*(\\S.*)?" . Patterns::MODIFIER_H . '?()$~mAUx';

// first line with bullet
$matches = null;
Expand Down
2 changes: 1 addition & 1 deletion src/Texy/Modules/ParagraphModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function process(Texy\BlockParser $parser, string $content, Texy\HtmlElem

// try to find modifier
$mod = null;
if ($mx = Regexp::match($s, '~' . Texy\Patterns::MODIFIER_H . '(?=\n|\z)~sUm', Regexp::OFFSET_CAPTURE)) {
if ($mx = Regexp::match($s, '~' . Texy\Patterns::MODIFIER_H . '(?=\n|\z)~sUmx', Regexp::OFFSET_CAPTURE)) {
[$mMod] = $mx[1];
$s = trim(substr_replace($s, '', $mx[0][1], strlen($mx[0][0])));
if ($s === '') {
Expand Down
40 changes: 20 additions & 20 deletions src/Texy/Modules/PhraseModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,64 +53,64 @@ public function __construct(Texy\Texy $texy)
// UNIVERSAL
$texy->registerLinePattern(
array($this, 'patternPhrase'),
'~((?>([*+/^_"\~`-])+?))(?!\s)(.*(?!\2).)'.Texy\Patterns::MODIFIER.'?(?<!\s)\1(?!\2)(?::('.Texy\Patterns::LINK_URL.'))??()~Us',
'~((?>([*+/^_"\~`-])+?))(?!\s)(.*(?!\2).)'.Texy\Patterns::MODIFIER.'?(?<!\s)\1(?!\2)(?::('.Texy\Patterns::LINK_URL.'))??()~Usx',
'phrase/strong'
);
*/

// ***strong+emphasis***
$texy->registerLinePattern(
$this->patternPhrase(...),
'~(?<![*\\\])\*\*\*(?![\s*])((?:[^ *]++|[ *])+)' . Patterns::MODIFIER . '?(?<![\s*\\\])\*\*\*(?!\*)(?::(' . Patterns::LINK_URL . '))??()~Us',
'~(?<![*\\\])\*\*\*(?![\s*])((?:[^ *]++|[ *])+)' . Patterns::MODIFIER . '?(?<![\s*\\\])\*\*\*(?!\*)(?::(' . Patterns::LINK_URL . '))??()~Usx',
'phrase/strong+em',
);

// **strong**
$texy->registerLinePattern(
$this->patternPhrase(...),
'~(?<![*\\\])\*\*(?![\s*])((?:[^ *]++|[ *])+)' . Patterns::MODIFIER . '?(?<![\s*\\\])\*\*(?!\*)(?::(' . Patterns::LINK_URL . '))??()~Us',
'~(?<![*\\\])\*\*(?![\s*])((?:[^ *]++|[ *])+)' . Patterns::MODIFIER . '?(?<![\s*\\\])\*\*(?!\*)(?::(' . Patterns::LINK_URL . '))??()~Usx',
'phrase/strong',
);

// //emphasis//
$texy->registerLinePattern(
$this->patternPhrase(...),
'~(?<![/:])\/\/(?![\s/])((?:[^ /]++|[ /])+)' . Patterns::MODIFIER . '?(?<![\s/:])\/\/(?!\/)(?::(' . Patterns::LINK_URL . '))??()~Us',
'~(?<![/:])\/\/(?![\s/])((?:[^ /]++|[ /])+)' . Patterns::MODIFIER . '?(?<![\s/:])\/\/(?!\/)(?::(' . Patterns::LINK_URL . '))??()~Usx',
'phrase/em',
);

// *emphasisAlt*
$texy->registerLinePattern(
$this->patternPhrase(...),
'~(?<![*\\\])\*(?![\s*])((?:[^\s*]++|[*])+)' . Patterns::MODIFIER . '?(?<![\s*\\\])\*(?!\*)(?::(' . Patterns::LINK_URL . '))??()~Us',
'~(?<![*\\\])\*(?![\s*])((?:[^\s*]++|[*])+)' . Patterns::MODIFIER . '?(?<![\s*\\\])\*(?!\*)(?::(' . Patterns::LINK_URL . '))??()~Usx',
'phrase/em-alt',
);

// *emphasisAlt2*
$texy->registerLinePattern(
$this->patternPhrase(...),
'~(?<![^\s.,;:<>()"\'' . Patterns::MARK . '-])\*(?![\s*])((?:[^ *]++|[ *])+)' . Patterns::MODIFIER . '?(?<![\s*\\\])\*(?![^\s.,;:<>()"?!\'-])(?::(' . Patterns::LINK_URL . '))??()~Us',
'~(?<![^\s.,;:<>()"\'' . Patterns::MARK . '-])\*(?![\s*])((?:[^ *]++|[ *])+)' . Patterns::MODIFIER . '?(?<![\s*\\\])\*(?![^\s.,;:<>()"?!\'-])(?::(' . Patterns::LINK_URL . '))??()~Usx',
'phrase/em-alt2',
);

// ++inserted++
$texy->registerLinePattern(
$this->patternPhrase(...),
'~(?<!\+)\+\+(?![\s+])((?:[^\r\n +]++|[ +])+)' . Patterns::MODIFIER . '?(?<![\s+])\+\+(?!\+)()~U',
'~(?<!\+)\+\+(?![\s+])((?:[^\r\n +]++|[ +])+)' . Patterns::MODIFIER . '?(?<![\s+])\+\+(?!\+)()~Ux',
'phrase/ins',
);

// --deleted--
$texy->registerLinePattern(
$this->patternPhrase(...),
'~(?<![<-])\-\-(?![\s>-])((?:[^\r\n -]++|[ -])+)' . Patterns::MODIFIER . '?(?<![\s<-])\-\-(?![>-])()~U',
'~(?<![<-])\-\-(?![\s>-])((?:[^\r\n -]++|[ -])+)' . Patterns::MODIFIER . '?(?<![\s<-])\-\-(?![>-])()~Ux',
'phrase/del',
);

// ^^superscript^^
$texy->registerLinePattern(
$this->patternPhrase(...),
'~(?<!\^)\^\^(?![\s^])((?:[^\r\n ^]++|[ ^])+)' . Patterns::MODIFIER . '?(?<![\s^])\^\^(?!\^)()~U',
'~(?<!\^)\^\^(?![\s^])((?:[^\r\n ^]++|[ ^])+)' . Patterns::MODIFIER . '?(?<![\s^])\^\^(?!\^)()~Ux',
'phrase/sup',
);

Expand All @@ -124,7 +124,7 @@ public function __construct(Texy\Texy $texy)
// __subscript__
$texy->registerLinePattern(
$this->patternPhrase(...),
'~(?<!\_)\_\_(?![\s_])((?:[^\r\n _]++|[ _])+)' . Patterns::MODIFIER . '?(?<![\s_])\_\_(?!\_)()~U',
'~(?<!\_)\_\_(?![\s_])((?:[^\r\n _]++|[ _])+)' . Patterns::MODIFIER . '?(?<![\s_])\_\_(?!\_)()~Ux',
'phrase/sub',
);

Expand All @@ -138,70 +138,70 @@ public function __construct(Texy\Texy $texy)
// "span"
$texy->registerLinePattern(
$this->patternPhrase(...),
'~(?<!\")\"(?!\s)((?:[^\r "]++|[ ])+)' . Patterns::MODIFIER . '?(?<!\s)\"(?!\")(?::(' . Patterns::LINK_URL . '))??()~U',
'~(?<!\")\"(?!\s)((?:[^\r "]++|[ ])+)' . Patterns::MODIFIER . '?(?<!\s)\"(?!\")(?::(' . Patterns::LINK_URL . '))??()~Ux',
'phrase/span',
);

// ~alternative span~
$texy->registerLinePattern(
$this->patternPhrase(...),
'~(?<!\~)\~(?!\s)((?:[^\r \~]++|[ ])+)' . Patterns::MODIFIER . '?(?<!\s)\~(?!\~)(?::(' . Patterns::LINK_URL . '))??()~U',
'~(?<!\~)\~(?!\s)((?:[^\r \~]++|[ ])+)' . Patterns::MODIFIER . '?(?<!\s)\~(?!\~)(?::(' . Patterns::LINK_URL . '))??()~Ux',
'phrase/span-alt',
);

// >>quote<<
$texy->registerLinePattern(
$this->patternPhrase(...),
'~(?<!\>)\>\>(?![\s>])((?:[^\r\n <]++|[ <])+)' . Patterns::MODIFIER . '?(?<![\s<])\<\<(?!\<)(?::(' . Patterns::LINK_URL . '))??()~U',
'~(?<!\>)\>\>(?![\s>])((?:[^\r\n <]++|[ <])+)' . Patterns::MODIFIER . '?(?<![\s<])\<\<(?!\<)(?::(' . Patterns::LINK_URL . '))??()~Ux',
'phrase/quote',
);

// acronym/abbr "et al."((and others))
$texy->registerLinePattern(
$this->patternPhrase(...),
'~(?<!\")\"(?!\s)((?:[^\r\n "]++|[ ])+)' . Patterns::MODIFIER . '?(?<!\s)\"(?!\")\(\((.+)\)\)()~U',
'~(?<!\")\"(?!\s)((?:[^\r\n "]++|[ ])+)' . Patterns::MODIFIER . '?(?<!\s)\"(?!\")\(\((.+)\)\)()~Ux',
'phrase/acronym',
);

// acronym/abbr NATO((North Atlantic Treaty Organisation))
$texy->registerLinePattern(
$this->patternPhrase(...),
'~(?<![' . Patterns::CHAR . '])([' . Patterns::CHAR . ']{2,})()\(\(((?:[^\n )]++|[ )])+)\)\)~U',
'~(?<![' . Patterns::CHAR . '])([' . Patterns::CHAR . ']{2,})()\(\(((?:[^\n )]++|[ )])+)\)\)~Ux',
'phrase/acronym-alt',
);

// ''notexy''
$texy->registerLinePattern(
$this->patternNoTexy(...),
'~(?<!\')\'\'(?![\s\'])((?:[^' . Patterns::MARK . '\r\n\']++|[\'])+)(?<![\s\'])\'\'(?!\')()~U',
'~(?<!\')\'\'(?![\s\'])((?:[^' . Patterns::MARK . '\r\n\']++|[\'])+)(?<![\s\'])\'\'(?!\')()~Ux',
'phrase/notexy',
);

// `code`
$texy->registerLinePattern(
$this->patternPhrase(...),
'~\`(\S(?:[^' . Patterns::MARK . '\r\n `]++|[ `])*)' . Patterns::MODIFIER . '?(?<!\s)\`(?::(' . Patterns::LINK_URL . '))??()~U',
'~\`(\S(?:[^' . Patterns::MARK . '\r\n `]++|[ `])*)' . Patterns::MODIFIER . '?(?<!\s)\`(?::(' . Patterns::LINK_URL . '))??()~Ux',
'phrase/code',
);

// ....:LINK
$texy->registerLinePattern(
$this->patternPhrase(...),
'~([' . Patterns::CHAR . '0-9@#$%&.,_-]++)()(?=:\[)(?::(' . Patterns::LINK_URL . '))()~U',
'~([' . Patterns::CHAR . '0-9@#$%&.,_-]++)()(?=:\[)(?::(' . Patterns::LINK_URL . '))()~Ux',
'phrase/quicklink',
);

// [text |link]
$texy->registerLinePattern(
$this->patternPhrase(...),
'~(?<!\[)\[(?![\s*])([^|\r\n\]]++)\|((?:[^' . Patterns::MARK . '|\r\n \]]++|[ ])+)' . Patterns::MODIFIER . '?(?<!\s)\](?!\])()~U',
'~(?<!\[)\[(?![\s*])([^|\r\n\]]++)\|((?:[^' . Patterns::MARK . '|\r\n \]]++|[ ])+)' . Patterns::MODIFIER . '?(?<!\s)\](?!\])()~Ux',
'phrase/wikilink',
);

// [text](link)
$texy->registerLinePattern(
$this->patternPhrase(...),
'~(?<![[.])\[(?![\s*])((?:[^|\r\n \]]++|[ ])+)' . Patterns::MODIFIER . '?(?<!\s)\]\(((?:[^' . Patterns::MARK . '\r )]++|[ ])+)\)()~U',
'~(?<![[.])\[(?![\s*])((?:[^|\r\n \]]++|[ ])+)' . Patterns::MODIFIER . '?(?<!\s)\]\(((?:[^' . Patterns::MARK . '\r )]++|[ ])+)\)()~Ux',
'phrase/markdown',
);

Expand Down
Loading

0 comments on commit d744b49

Please sign in to comment.