Add support for placeholder in code snippets
See original GitHub issueHave you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Motivation
Hey all, I’m trying to find a way to implement placeholders in a code snippet. I haven’t managed to find any trivial way to do so.
Specifically I’d like to be able to insert the following snippet
plugins("abc").version("[library_version]")
And the [library_version]
placeholder should be replaced by the actual version of the library I’m maintaining. The library version is available inside a custom field in the docusaurus config: https://github.com/detekt/detekt/blob/47428426d0760181a4acb395abad6c6aefed4968/website/docusaurus.config.js#L182-L184
The idea is to have code snippets which are easy to copy-n-paste for the library authors.
So far I’ve looked into creating a custom component, but that’s non trivial as JSX is not playing well with the white spaces and special chars we have in a snippet. I’m looking into doing some text pre-processing before I kick off the bundler, but I’m looking into understanding if there is an easier way to do so.
More context on this is here: https://github.com/detekt/detekt/issues/4915
Self-service
- I’d be willing to do some initial work on this proposal myself.
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top GitHub Comments
We implemented it using a custom remark plugin as you suggested @Josh-Cena. If someone else is interested in a similar implementation, you can find it here: https://github.com/detekt/detekt/pull/5001
Better ask on the Discord server or in GitHub discussions, in that case. The issue tracker doesn’t really take feature requests like this without a corresponding request gaining some traction on Canny first. I’m going to go ahead and close this for now. It’s not rejecting your feature, just that the team has little interest in making this the default for now, without understanding how many people are interested and what are some typical use-cases. If you want us to implement it, you can submit a feature request on our Canny board. If you have problems while making your Remark plugin, feel free to reach out on Discord.