Skip to content
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

Pass filename to highlighter #592

Merged
merged 3 commits into from
Jun 4, 2024

Conversation

vnphanquang
Copy link
Contributor

@vnphanquang vnphanquang commented Feb 29, 2024

Context

Today, as of [email protected], a custom highlighter function is not aware of the filename of the file being processed by MDsveX, and there is no way (that i am aware of) to get around this using the public API.

This issue adds such support by passing additional filename positional param for highlighter.

Rationale

Having filename in highlighter will allow more complex customization. Specifically, I'm trying to have the syntax highlighter read the source code from file system provided in a meta line, something like this:

```svelte
/// source=./examples/an-example.svelte
```

This allows keeping certain example source code in a separate file, making better use of editor support, enabling reusability of said source code, and keeping the MDsveX file succinct.

Copy link

changeset-bot bot commented Feb 29, 2024

🦋 Changeset detected

Latest commit: 939981d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
mdsvex Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vnphanquang vnphanquang force-pushed the pass-filename-to-highlighter branch from ae4db41 to 9d36729 Compare March 1, 2024 02:48
@vnphanquang
Copy link
Contributor Author

Ran prettier just now, amended to existing commit. Sorry for not doing that earlier.

@pngwn pngwn merged commit bfc720b into pngwn:master Jun 4, 2024
7 checks passed
@github-actions github-actions bot mentioned this pull request Jun 4, 2024
@pngwn
Copy link
Owner

pngwn commented Jun 4, 2024

Sorry for the delay! Released now https://github.com/pngwn/MDsveX/releases/tag/mdsvex%400.11.1

@vnphanquang
Copy link
Contributor Author

Sorry for the delay! Released now https://github.com/pngwn/MDsveX/releases/tag/mdsvex%400.11.1

Thanks 🎉. No worries at all

@vnphanquang vnphanquang deleted the pass-filename-to-highlighter branch August 15, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants