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
This happens as the Remark plugin is getting already "preprocessed" nodes by the built-in highlighter (Shiki in my case). In other words, toString(tree) already includes some HTML which therefore adds a lot more plain text to the reading-time function call.
While digging into MDX, I realized that the merging of Markdown plugins got changed by #5684 (especially here). Before, Markdown plugins were added before any MDX or built-in syntax highlighters and extensions.
Since it seems pretty common to add plugins and their order is quite relevant, we should most likely only inject highlighters as the last plugins. Unless this is due to another reason?
Besides, in the PR mentions that we could eject from the highlighters and define the order on the consumer side. However, since remark-shiki is not directly exposed and cannot be directly imported, the code would need to be copy-pasted. Therefore, we could also export these "internal" plugins.
You can observe the change in behavior through the following reproducible setup and change back to the following package.json dependencies:
What version of
astro
are you using?2.0.4
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
npm
What operating system are you using?
Linux
Describe the Bug
While migrating to Astro 2.0 the "reading time" feature for my articles based on the Astro documentation (https://docs.astro.build/en/guides/markdown-content/#example-calculate-reading-time), I'm getting different reading times.
This happens as the Remark plugin is getting already "preprocessed" nodes by the built-in highlighter (Shiki in my case). In other words,
toString(tree)
already includes some HTML which therefore adds a lot more plain text to thereading-time
function call.While digging into MDX, I realized that the merging of Markdown plugins got changed by #5684 (especially here). Before, Markdown plugins were added before any MDX or built-in syntax highlighters and extensions.
Since it seems pretty common to add plugins and their order is quite relevant, we should most likely only inject highlighters as the last plugins. Unless this is due to another reason?
Besides, in the PR mentions that we could eject from the highlighters and define the order on the consumer side. However, since
remark-shiki
is not directly exposed and cannot be directly imported, the code would need to be copy-pasted. Therefore, we could also export these "internal" plugins.You can observe the change in behavior through the following reproducible setup and change back to the following
package.json
dependencies:Happy to hear your thoughts here!
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-vcjigg?file=astro.config.mjs
Participation
The text was updated successfully, but these errors were encountered: