Closed kankaristo closed 2 years ago
I don't know Obsidian.md but I can tell you that you should not mix and match Markdown libraries for a single source file. This can and often will always end badly.
So if you are using Obsidian.md for your Markdown files, stay with them and use their tooling.
As for your question: The additional syntax introduced by Obsidian.md clashes with the kramdown syntax, as you have noticed. kramdown's syntax is based on what the original Markdown syntax was/is and this syntax has been in use since at least 2009. So changing it is out of the question. As is toggling with an option.
I understand that using #tag
is often used for tagging in various contexts. If you really need to start a line with such a construct when using kramdown, you could put another character in front of it, e.g. a zero-width space:
- #Test without zero-width space
- #Test with zero-width space
I was directed here from an issue I created in Markdownlint, which uses Kramdown as it's parser.
Kramdown doesn't work very well with "hashtags", or with tags in Obsidian.md, a fairly popular Markdown editor (which doesn't use Kramdown however, at least as far as I know).
The tags that I'm talking about are very similar to atx style Markdown headers, but without a space after the hash. So, something like
#tag
or#another-tag
. Apart from being very common in Obsidian.md, these could also appear in "regular" text, since they're also used for hashtags in social media, channels in IRC/Slack/Discord, etc.Example input:
The above parses
#tag
as a heading, which it isn't in normal Markdown (although without the dash for the list item, it would be).I found this closed issue, which explains that
#tag
is parsed as a heading, because Kramdown supports "nesting" a header inside a list item.Personally, I would not expect
#tag
to be a legal header anywhere; some parsers support it, some don't. I looked through Kramdown's syntax for atx style headers, and it isn't very clear (or explicit) whether it's meant to support an atx style header without at least one space after the hash character (#Header
vs# Header
).Is the current behavior of not requiring a space after the hash character(s) intended? If it is, can it be toggled off with an option?
I know I could escape the hash character (and write
\#tag
), but this would also escape the tag in Obsidian.md, so that's not really an option for me (I might as well not type the hash at all, since escaping would "break" the tag).