Source code for wikitextparser._wikilink

from __future__ import annotations

from regex import DOTALL, Match

from ._wikitext import SubWikiText, rc

FULLMATCH = rc(
    rb'[\[\2]\0*+[\[\2]'
    rb'('  # 1: target
    rb'([^|#\]\3]*+)'  # 2: title
    rb'(?>#([^|\]\3]*+))?'  # 3: fragment
    rb')'
    rb'(?:\|(.*))?'  # 4: text
    rb'[\]\3]\0*+[\]\3]',
    DOTALL,
).fullmatch