Skip to content

Commit

Permalink
Revert "Ignore markdown codeblocks for tags (dullage#66)"
Browse files Browse the repository at this point in the history
This reverts commit f7d206c.
  • Loading branch information
Gedulis12 committed Aug 7, 2023
1 parent 3c6f776 commit 61a0840
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions flatnotes/flatnotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from logger import logger

MARKDOWN_EXT = ".md"
INDEX_SCHEMA_VERSION = "4"
INDEX_SCHEMA_VERSION = "3"

StemmingFoldingAnalyzer = StemmingAnalyzer() | CharsetFilter(accent_map)

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 61a0840

Please sign in to comment.