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

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

Open
tlawrie opened this issue May 29, 2024 · 2 comments

Comments

@tlawrie
Copy link

tlawrie commented May 29, 2024

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

  • title= may be filename= or heading=
  • highlighting lines may be lines[x,z] or #x,z instead of {x,z}
@tlawrie
Copy link
Author

tlawrie commented May 29, 2024

Similar to: #52

Albeit we want to change the line number encapturing as well

@tlawrie
Copy link
Author

tlawrie commented May 29, 2024

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.

@tlawrie tlawrie changed the title [feature] allow custom meta prefixes for line highlighting and titles [docs] add example of converting code block meta strings to required matches May 29, 2024
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

No branches or pull requests

1 participant