Skip to content

Commit 78e82aa

Browse files
authored
Merge pull request #431 from bysiber/fix-footnote-spaces
2 parents 198b03e + 87c091f commit 78e82aa

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/mistune/plugins/footnotes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from typing import TYPE_CHECKING, Any, Dict, List, Match, Union
33

44
from ..core import BlockState
5-
from ..helpers import LINK_LABEL
65
from ..util import unikey
76

87
if TYPE_CHECKING:
@@ -14,16 +13,18 @@
1413
__all__ = ["footnotes"]
1514

1615
_PARAGRAPH_SPLIT = re.compile(r"\n{2,}")
16+
# Like LINK_LABEL but disallows whitespace in footnote identifiers
1717
# https://michelf.ca/projects/php-markdown/extra/#footnotes
18+
_FOOTNOTE_LABEL = r"(?:[^\\\[\]\s]|\\.){1,500}"
1819
REF_FOOTNOTE = (
1920
r"^(?P<footnote_lead> {0,4})"
20-
r"\[\^(?P<footnote_key>" + LINK_LABEL + r")]:[ \t\n]"
21+
r"\[\^(?P<footnote_key>" + _FOOTNOTE_LABEL + r")]:[ \t\n]"
2122
r"(?P<footnote_text>[^\n]*(?:\n+|$)"
2223
r"(?:(?P=footnote_lead) {1,4}(?! )[^\n]*\n+)*"
2324
r")"
2425
)
2526

26-
INLINE_FOOTNOTE = r"\[\^(?P<footnote_key>" + LINK_LABEL + r")\]"
27+
INLINE_FOOTNOTE = r"\[\^(?P<footnote_key>" + _FOOTNOTE_LABEL + r")\]"
2728

2829

2930
def parse_inline_footnote(inline: "InlineParser", m: Match[str], state: "InlineState") -> int:

0 commit comments

Comments
 (0)