-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Horizontal bar being incorrectly detected as YAML frontmatter #314
Comments
This happens because of 3afab84. I didn't quite realize pulldown-cmark's implementation of metadata blocks supports blocks within a document body, which is somewhat different from the typical frontmatter seen in Obsidian and SSGs like Hugo, Jekyll, Zola, etc. Dumping the events generated by pulldown-cmark shows clearly what's happening here:
This is clearly working as intended for their implementation of metadata blocks, though it clashes with the rules for thematic breaks specified by CommonMark, which states Thematic breaks do not need blank lines before or after. I suppose reverting 3afab84 is an option, but I never liked that dependency and the way it extracted the frontmatter block, so I'm loathe to go that route. I'm tempted towards keeping the current implementation/behavior, considering the following simple workarounds are available, and neither feels like a tall ask of users:
How problematic would it be for you if this stayed as-is? That being said, we can programmatically detect when we hit a metadata block that's not at the start of the document, and I do feel it's worth triggering a better warning or error when that happens. That way we can give the user some suggestions on what to do, instead of getting a YAML decode error (or worse, some text going missing from the document when it actually decodes as valid YAML). |
For now, I wrote a script that replaces all But also yeah, it needs a better warning. I was dumbfounded when it said I had a frontmatter error when that was not the case at all. |
Hello, I'd like to vote for fixing this issue somehow and not just leaving it as-is. I came here today to report it but found it's already reported. IMO YAML should not be expected in the middle of the file. However I understand now that this might be a pulldown-cmark's issue, not obsidian-export's. Theoretically, I could write a sed script or something like this to change all the files in the vault. But I know that I still will be writing the separator as |
This example
gives the following error:
However this works just fine?
It loads just fine in Obsidian of course. YAML frontmatter can only ever be at the top so there shouldn't be any checks in the body of the file. I should mention that this was an old file, so it had to have been something from a new update. I still have a commit from Dec 9, 2023, 5:31AM UTC where this exported properly and it had the exact same contents
EDIT: markdownguide.org does say to add blank lines before horizontal rules, so that might be partly my fault. I've found that using
- - -
also works in Obsidian and also gets interpreted properly by the exporter. So my guess is it has something to do with the Heading 2 logic where a text gets set as Heading 2 whenever there is a number of-
character on the line after it.EDIT 2: There's another strange behavior where
asd aand here's more something asdasda sdasd ---
turns into
## asd aand here's more something asdasda sdasd
The text was updated successfully, but these errors were encountered: