-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
frontmatter is targeted #336
Comments
|
I'm not familiar with all those remark/eslint stuffs. But as far as I know, the frontmatter would be transformed into something like: export const frontmatter = {
title: '<link >'
} Does it really make sense to lint that part? JSX wouldn't consider that |
That would depend on @wooorm Will the following work as same as above? ---
title: Code Splitting
related:
- title: <link rel="prefetch/preload" /> in webpack
url: <https://medium.com/webpack/link-rel-prefetch-preload-in-webpack-51a52358f84c>
--- It's parsed as How can I know whether { "type": "root", "children": [ { "type": "thematicBreak", "position": { "start": { "line": 1, "column": 1, "offset": 0 }, "end": { "line": 1, "column": 4, "offset": 3 }, "indent": [] } }, { "type": "paragraph", "children": [ { "type": "text", "value": "title: Code Splitting\nrelated:", "position": { "start": { "line": 2, "column": 1, "offset": 4 }, "end": { "line": 3, "column": 9, "offset": 34 }, "indent": [ 1 ] } } ], "position": { "start": { "line": 2, "column": 1, "offset": 4 }, "end": { "line": 3, "column": 9, "offset": 34 }, "indent": [ 1 ] } }, { "type": "list", "ordered": false, "start": null, "spread": false, "children": [ { "type": "listItem", "spread": false, "checked": null, "children": [ { "type": "paragraph", "children": [ { "type": "text", "value": "title: ", "position": { "start": { "line": 4, "column": 5, "offset": 39 }, "end": { "line": 4, "column": 12, "offset": 46 }, "indent": [] } }, { "type": "jsx", "value": "", "position": { "start": { "line": 4, "column": 12, "offset": 46 }, "end": { "line": 4, "column": 42, "offset": 76 }, "indent": [] } }, { "type": "text", "value": " in webpack\nurl: ", "position": { "start": { "line": 4, "column": 42, "offset": 76 }, "end": { "line": 5, "column": 10, "offset": 97 }, "indent": [ 5 ] } }, { "type": "link", "title": null, "url": "https://medium.com/webpack/link-rel-prefetch-preload-in-webpack-51a52358f84c", "children": [ { "type": "text", "value": "https://medium.com/webpack/link-rel-prefetch-preload-in-webpack-51a52358f84c", "position": { "start": { "line": 5, "column": 10, "offset": 97 }, "end": { "line": 5, "column": 86, "offset": 173 }, "indent": [] } } ], "position": { "start": { "line": 5, "column": 10, "offset": 97 }, "end": { "line": 5, "column": 86, "offset": 173 }, "indent": [] } } ], "position": { "start": { "line": 4, "column": 5, "offset": 39 }, "end": { "line": 5, "column": 86, "offset": 173 }, "indent": [ 5 ] } } ], "position": { "start": { "line": 4, "column": 1, "offset": 35 }, "end": { "line": 5, "column": 86, "offset": 173 }, "indent": [ 1 ] } } ], "position": { "start": { "line": 4, "column": 1, "offset": 35 }, "end": { "line": 5, "column": 86, "offset": 173 }, "indent": [ 1 ] } }, { "type": "thematicBreak", "position": { "start": { "line": 6, "column": 1, "offset": 174 }, "end": { "line": 6, "column": 4, "offset": 177 }, "indent": [] } } ], "position": { "start": { "line": 1, "column": 1, "offset": 0 }, "end": { "line": 7, "column": 1, "offset": 178 } } } |
Shouldn't the frontmatter be preprocessed and put aside as metadata before the JSX parser is unleashed on the rest of the document? |
I'm not familiar with frontmatter, let's wait @wooorm to clarify first. Personally, I don't want to add specific logic for a specific plugin. If you have any good thought, welcome to PR to preview first. |
Frontmatter, often in YAML, is frequently used in combination with markdown/MDX: https://github.com/wooorm/xdm#frontmatter. While ESM import/exports are powerful, frontmatter is static: it can be access without compiling and evaluating the file.
Not necessarily, frontmatter has always worked with a plugin, but exposing it as an
If
It sounds like
Yes, I agree. frontmatter in YAML is really strict. It is highly unlikely that someone does not want frontmatter but still starts a document with those three dashes. |
It is using My test case is |
I believe |
@wooorm I mean will the parsed AST be same between |
Yes, the AST is the same with |
@wooorm Does the plugins order matter? In OK, I find the problem, the custom remark config is only used for |
@chenxsan Please try |
@chenxsan Did you add |
Oops, I just noticed that I have to set |
See #336 (comment), |
Subject of the issue
Say I have a MDX file with this frontmatter:
Note that the
<link >
was not closed.Now eslint would report
Parsing error: Expected corresponding JSX closing tag for <link>
. Which seems wrong to me. A related comment is here webpack/webpack.js.org#5312 (comment).Your environment
Steps to reproduce
src/content/guides/code-splitting.mdx
and replace the/>
with>
in the related part of frontmatter.FYI, I've tried the latest version #334 (comment) with no luck.
Expected behaviour
No error.
Actual behaviour
An error was shown because frontmatter is targetted.
The text was updated successfully, but these errors were encountered: