You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support remark-code-import by passing file metadata during parser creation
Description
When attempting to use the remark-code-import plugin with code snippet imports using the file syntax:
```js file=./myFile.js```
The plugin fails to resolve files because the primary file object passed to the parser lacks the necessary pathing information required by the remark vfile object.
Current Behavior
The plugin throws an error when attempting to resolve imported code files
Error message indicates missing VFile context:
if(!file.dirname){thrownewError('"file" should be an instance of VFile');}
Expected Behavior
The parser should properly resolve and import code files when using the remark-code-import syntax
File paths should be correctly resolved relative to the source markdown file
Fix
Pretty sure the issue is in createMarkdownParser - we just need to pass more context to the unified processor so it can create a proper VFile with the dirname (and other important bits) set.
This is probably breaking other remark plugins too since quite a few of them need proper VFile metadata to resolve paths and do filesystem operations. remark-code-import is just where I happened to notice it.
Steps to Reproduce
Install and configure Nuxt MDC with remark-code-import
Create a markdown file with a code import directive
Attempt to build/process the markdown file
Observe the VFile error
The text was updated successfully, but these errors were encountered:
Support
remark-code-import
by passing file metadata during parser creationDescription
When attempting to use the
remark-code-import
plugin with code snippet imports using the file syntax:The plugin fails to resolve files because the primary file object passed to the parser lacks the necessary pathing information required by the remark
vfile
object.Current Behavior
Expected Behavior
remark-code-import
syntaxFix
Pretty sure the issue is in
createMarkdownParser
- we just need to pass more context to the unified processor so it can create a proper VFile with the dirname (and other important bits) set.This is probably breaking other remark plugins too since quite a few of them need proper
VFile
metadata to resolve paths and do filesystem operations.remark-code-import
is just where I happened to notice it.Steps to Reproduce
remark-code-import
The text was updated successfully, but these errors were encountered: