Hello if anyone knows of a way to get python-markdown to behave in the way I’d like, or of an alternative way to do it, I’d love some help! My use case is I’m converting .md files made with Obsidian into html files. Obsidian has tags that are a pound sign followed by the tag (so like “#TagName”). When the tag is the first item on a line the pound sign is confused for a heading, even though there is no space after it.
Is there a way that I can avoid this so it only reads it as a heading if there is a space between the pound and the next word? I’m even considering some kind of find/replace logic so I can swap it out with like a link to a page that lists all the pages with that tag or something that gets run before the markdown to html conversion.
Edit:
The solution I’m going for is a regex find/replace. Currently the string pattern looks like "#[^\s#][^\s" + string.punctuation + "#]*"
which can find tags but ignores headers. Since the ultimate goal is to have the tags link to a tag page anyway I can solve it all in one step by doing a replace with a relevant link.
#\s+
is:#
: a literal#
\s
: any whitespace character (space, tab etc)+
: the previous thing (here the whitespace), one or more timesIn words: “a hash followed by at least one whitespace character”
#[^\s].
is:#
: a literal#
[^\s]
: a negated character class. This matches anything other than the set of characters after the^
.\s
has the same meaning as before, any whitespace character.
: matches any single characterIn words: “a hash followed by any character other than a whitespace character, then any character”.
https://regex101.com/ is really good for explaining regex