rehype-pretty / rehype-pretty-code

Beautiful code blocks for Markdown or MDX.
https://rehype-pretty.pages.dev
MIT License
998 stars 63 forks source link

[docs] add example of converting code block meta strings to required matches #221

Open tlawrie opened 3 months ago

tlawrie commented 3 months ago

Description

For those of us transitioning from a previous module to rehype-pretty-code we may already have code meta which would break prior versions of documentation.

For example

tlawrie commented 3 months ago

Similar to: https://github.com/rehype-pretty/rehype-pretty-code/issues/52

Albeit we want to change the line number encapturing as well

tlawrie commented 3 months ago

Turns out this can be done by

      filterMetaString: (str) => str.replace(/lines=\[([^]*)\]/g, '{$1}').replace(/filename=([^ ]*)/g, 'title="$1"'),

This should be added to the documentation as an example.