-
Notifications
You must be signed in to change notification settings - Fork 129
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
validate front matter #1054
validate front matter #1054
Conversation
9638cb9
to
abbe0a4
Compare
I've rebased this PR and added some sort of validation for all the expected fields. The story for toc is a bit complicated, since it gets merged with config.toc later on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a commit which takes this in a slightly different direction:
- Changes the
MarkdownPage["data"]
to the strongly-typedFrontMatter
interface - Adds missing fields to the
FrontMatter
interface (e.g.,sidebar
,style
) - Adds front matter normalization tests
- Removes obsolete downstream coercion e.g. in
mergeToc
andmergeStyle
- Removes warning logs/erroring in favor of deterministic normalization
The last part is in the spirit of HTML5, which is to say that the normalization is well-defined, regardless of whatever input types the user gives us, so we don’t really need to consider these as errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving but disabled auto merge so you have a chance to review. 🙏
We still need to catch any |
7aa61cc
to
1b67f88
Compare
I don’t think we should error. We should just ignore the front matter. (Markdown and HTML in general don’t error for bad syntax — it just gets ignored.) |
OK, this simplifies things a lot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it so that if the front matter is invalid, it just gets treated as content so you can immediately see on the page that the front matter is broken. Also, this means we don’t need to log the buffer to the console, which I didn’t find useful anyway (since the buffer could be arbitrarily long — even the entire document — which meant that you can’t even see the error message in the console).
thanks! |
we could validate more stuff in the futurecloses #1005
(although I could not reproduce the same crashes)
I had fun making sql tables named '123' and 'a"b': it worked. I would definitely not recommend, though.