From 61a0840bae9109eb55a2cde41214983b0b50b3e9 Mon Sep 17 00:00:00 2001 From: Gedulis12 <80179975+Gedulis12@users.noreply.github.com> Date: Mon, 7 Aug 2023 21:38:06 +0300 Subject: [PATCH] Revert "Ignore markdown codeblocks for tags (#66)" This reverts commit f7d206c0f3603bdf692f03cbd038a5666d9aa84b. --- flatnotes/flatnotes.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/flatnotes/flatnotes.py b/flatnotes/flatnotes.py index f6a827f..3c6c53e 100644 --- a/flatnotes/flatnotes.py +++ b/flatnotes/flatnotes.py @@ -20,7 +20,7 @@ from logger import logger MARKDOWN_EXT = ".md" -INDEX_SCHEMA_VERSION = "4" +INDEX_SCHEMA_VERSION = "3" StemmingFoldingAnalyzer = StemmingAnalyzer() | CharsetFilter(accent_map) @@ -170,7 +170,6 @@ def _get_matched_fields(matched_terms): class Flatnotes(object): TAGS_RE = re.compile(r"(?:(?<=^#)|(?<=\s#))\w+(?=\s|$)") - CODEBLOCK_RE = re.compile(r"`{1,3}.*?`{1,3}", re.DOTALL) TAGS_WITH_HASH_RE = re.compile(r"(?:(?<=^)|(?<=\s))#\w+(?=\s|$)") def __init__(self, dir: str) -> None: @@ -212,9 +211,7 @@ def extract_tags(cls, content) -> Tuple[str, Set[str]]: - The content without the tags. - A set of tags converted to lowercase.""" - content_ex_codeblock = re.sub(cls.CODEBLOCK_RE, '', content) - _, tags = re_extract(cls.TAGS_RE, content_ex_codeblock) - content_ex_tags, _ = re_extract(cls.TAGS_RE, content) + content_ex_tags, tags = re_extract(cls.TAGS_RE, content) try: tags = [tag.lower() for tag in tags] return (content_ex_tags, set(tags))