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

[Feature request] Removing fence related plugin in @vuepress/markdown #1550

Closed
Mister-Hope opened this issue May 1, 2024 · 5 comments · Fixed by #1556
Closed

[Feature request] Removing fence related plugin in @vuepress/markdown #1550

Mister-Hope opened this issue May 1, 2024 · 5 comments · Fixed by #1556

Comments

@Mister-Hope
Copy link
Member

Clear and concise description of the problem

Our built-in plugins about code fence are breaking shiki highlighter, e.g., shiki has an own implementation about higlight lines, and shiki's twoslash is powerful

See https://plume.pengzhanbo.cn/guide/markdown/experiment/#%E5%BC%80%E5%90%AF%E5%8A%9F%E8%83%BD as an example, the community is patching our official pacakge to bypass this.

Suggested solution

Move the highlight lines and line number part into @vuepress/plugin-prismjs and @vuepress/plugin-shiki so that users can do more things with shiki and do not break current prismjs behvaior.

Alternative

No response

Additional context

I am planning to migrate the default highlighter to shiki for theme default.

@pengzhanbo
Copy link
Member

A crucial missing parameter is at codePlugin/codePlugin.ts#L76 where the third argument of options.highlight(code, lang, meta) should be passed as token.info instead of an empty string. Some transformers when using shiki can be controlled based on token.info.

@pengzhanbo
Copy link
Member

When using twoslash with VuePress, the line numbers are not functioning properly. This is because twoslash inserts additional <span>xx</span>\n into <code>, causing miscalculation of extra lines due to line numbers being counted based on \n. In plugin-shiki, there is no control over line-numbers.

@Mister-Hope
Copy link
Member Author

Can you open a pr for this? And maybe removing the line number plugin and implement it in plugin-prismjs?

@pengzhanbo
Copy link
Member

Can you open a pr for this? And maybe removing the line number plugin and implement it in plugin-prismjs?

Currently, the adjustment plan involves removing the codePlugin from @vuepress/markdown and transferring its functionality to be independently implemented in @vuepress/plugin-prismjs and @vuepress/plugin-shiki.

@Mister-Hope
Copy link
Member Author

You can open a pr to remove it, and use a patch to have plugin-prismjs and plugin-shiki implement the original feature, and we can then moving on upstream here.

meteorlxy added a commit that referenced this issue May 27, 2024
…to vuepress/ecosystem, close #1550 (#1556)

Co-authored-by: 张怀文 <[email protected]>
Co-authored-by: meteorlxy <[email protected]>
meteorlxy added a commit that referenced this issue May 27, 2024
#1556)

BREAKING CHANGE: `markdown.code` option is remove. Please use `@vuepress/plugin-shiki` and `@vuepress/plugin-prismjs` instead.

--------------

Co-authored-by: 张怀文 <[email protected]>
Co-authored-by: meteorlxy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants