Obsidian-Markdown-Parser icon indicating copy to clipboard operation
Obsidian-Markdown-Parser copied to clipboard

'#' symbol in MarkdownFile tags property

Open danymat opened this issue 5 years ago • 1 comments

If a file has a tag, it will cause issues in retrieving the tags from the MarkdownFile object. Certain tags will be retrieved, and others Objects will have the tag property like : {'#'}

[(file.fileName, file.tags) for file in parser.mdFiles if len(file.tags) != 0]
[('La pratique sans but.md', {'#'}), ('Lignes directives de la méditation.md', {'develop'}), ("L'indépendance de chaque phénomène.md", {'#'}), ('Privilégier la feature au design.md', {'design'}), ("De l'être et du devenir.md", {'essais'}), ('About Art.md', {'essais'}), ('Gamification.md', {'gamification'}), ('Cygne Noir.md', {'cygneNoir'}), ('Non-être.md', {'#'}), ('Du brouillard magique.md', {'essais'}), ('Du voyage.md', {'essais'}), ('La voie de chemin de fer.md', {'#'}), ('Activité.md', {'develop'}), ("Du processus de création d'une note.md", {'personalManagement'}), ('La vraie nature.md', {'méditation', '#'}), ('Méditation.md', {'develop', '#'})]

danymat avatar Feb 20 '21 18:02 danymat

This is due to the regex used in MardownFile.py simpleTags = re.compile(r"((?<=#)\S+)") Which results in ### Heading 3 is being read as tag: ##

my solution would be

for find in re.compile(r"^#([^\s#]+)|\s#([^\s^#]+)").findall(content):
    [tags.append(tag) for tag in find if tag != ""]

robinFdr avatar Aug 17 '23 08:08 robinFdr