Custom tokens for placeholders/variables
fviolette opened this issue · comments
Hello,
Is it possible to insert a placeholder within a code block processed by EC?
Following these guidelines, I'm thinking of something like:
- repo: https://github.com/{{{YOUR_ORGANIZATION}}}/docs
where {{{ }}} signifies this has to be processed in a non-literal way, inserting a <var>
element with possibly a @title picked up from the block options (```yaml var="YOUR_ORGANIZATION:Replace YOUR_ORGANIZATION
with the name of your organization").
Thanks.
Hello François!
This sounds like a great use case for a custom plugin. There are examples on https://expressive-code.com/guides/developing-plugins/#adding-custom-annotations-to-code that show how you can create a plugin that accepts some special syntax inside the code and uses it to add an annotation that can render HTML elements and style them.
It should be possible to adapt this example code to create the functionality you described. Getting parsed information from the meta line is possible using the codeBlock.metaOptions
API that is available through the context argument passed to each hook.
Hope that helps to point you into the right direction! Let me know if you encounter issues while developing the plugin!