Compare commits

...

3 Commits

Author SHA1 Message Date
Sergio Martínez Portela
5552b3324b Handle ] which not close link descriptions or references.
Some checks failed
Testing / stability-extra-test (push) Waiting to run
Testing / pytest (push) Successful in 38s
Testing / style-sorted-imports (push) Waiting to run
Testing / mypy (push) Successful in 46s
Testing / style-formatting (push) Has been cancelled
2024-08-22 00:21:02 +02:00
Sergio Martínez Portela
f31c64c242 Properly track which tokens are used for closing formats. 2024-08-22 00:20:54 +02:00
Sergio Martínez Portela
490b36887a Require space before list item tag separator. 2024-08-22 00:20:15 +02:00

View File

@ -103,7 +103,7 @@ PLANNING_RE = re.compile(
r")+\s*" r")+\s*"
) )
LIST_ITEM_RE = re.compile( LIST_ITEM_RE = re.compile(
r"(?P<indentation>\s*)((?P<bullet>[*\-+])|((?P<counter>\d|[a-zA-Z])(?P<counter_sep>[.)]))) ((?P<checkbox_indentation>\s*)\[(?P<checkbox_value>[ Xx])\])?((?P<tag_indentation>\s*)(?P<tag>.*?)::)?(?P<content>.*)" r"(?P<indentation>\s*)((?P<bullet>[*\-+])|((?P<counter>\d|[a-zA-Z])(?P<counter_sep>[.)]))) ((?P<checkbox_indentation>\s*)\[(?P<checkbox_value>[ Xx])\])?((?P<tag_indentation>\s*)((?P<tag>.*?)\s::))?(?P<content>.*)"
) )
IMPLICIT_LINK_RE = re.compile(r"(https?:[^<> ]*[a-zA-Z0-9])") IMPLICIT_LINK_RE = re.compile(r"(https?:[^<> ]*[a-zA-Z0-9])")
@ -1911,7 +1911,7 @@ def tokenize_contents(contents: str) -> List[TokenItems]:
continue continue
# Possible link close or open of description # Possible link close or open of description
if char == "]" and len(contents) > i + 1 and in_link: if char == "]" and len(contents) > i + 1 and in_link and contents[i + 1] in "][":
if contents[i + 1] == "]": if contents[i + 1] == "]":
cut_string() cut_string()
@ -1962,6 +1962,7 @@ def tokenize_contents(contents: str) -> List[TokenItems]:
cut_string() cut_string()
tokens.append((TOKEN_TYPE_CLOSE_MARKER, char)) tokens.append((TOKEN_TYPE_CLOSE_MARKER, char))
has_changed = True has_changed = True
closes.remove(i)
if not has_changed: if not has_changed:
text.append(char) text.append(char)
@ -2052,7 +2053,7 @@ def dump_contents(raw):
content = "\n".join(content_lines) content = "\n".join(content_lines)
checkbox = f"[{raw.checkbox_value}]" if raw.checkbox_value else "" checkbox = f"[{raw.checkbox_value}]" if raw.checkbox_value else ""
tag = ( tag = (
f"{raw.tag_indentation}{token_list_to_raw(raw.tag or '')}::" f"{raw.tag_indentation}{token_list_to_raw(raw.tag or '')} ::"
if raw.tag or raw.tag_indentation if raw.tag or raw.tag_indentation
else "" else ""
) )