I've been reading through the docs and codebase and I'm stilling having trouble understanding how the flexmark-ext-xwiki-macros extension can be used to render custom output.
What I'm looking to do is create some special macros for rendering pre-made HTML snippets, but I do not want to allow raw HTML in the input.
For example:
{{alert}}
Hello **world**
{{/alert}}
I'd want that to generate something like:
<div class="alert alert-primary" role="alert">
Hello <strong>world</strong>
</div>
When I enable the plugin and set the MacroExtension.ENABLE_RENDERING to true, my input renders as:
{{alert}}
Hello <strong>world</strong>
{{/alert}}
When I set MacroExtension.ENABLE_RENDERING to false, the content is left out of the rendered output.
What I'd like to be able to do is a few things:
- Decide on a case-by-case bases whether output should be rendered. There may be some cases where I do not want the child content rendered from Commonmark.
- Replace the
{{alert}} and {{/alert}} placeholders with the correct text.
In looking at the MacroNodeRenderer I see why it's rendering that way, but I'm not seeing how to overwrite the behavior.
I could call setOpeningMarker() and setClosingMarker() to change the markers and then setName() to change the contents to the HTML I want, but that doesn't seem right.
And how I would I choose to skip outputting and just capture the data if I needed to?
I'm obviously missing something basic.
Can anyone help me?
Thanks!
-Dan
I've been reading through the docs and codebase and I'm stilling having trouble understanding how the flexmark-ext-xwiki-macros extension can be used to render custom output.
What I'm looking to do is create some special macros for rendering pre-made HTML snippets, but I do not want to allow raw HTML in the input.
For example:
I'd want that to generate something like:
When I enable the plugin and set the
MacroExtension.ENABLE_RENDERINGtotrue, my input renders as:When I set
MacroExtension.ENABLE_RENDERINGtofalse, the content is left out of the rendered output.What I'd like to be able to do is a few things:
{{alert}}and{{/alert}}placeholders with the correct text.In looking at the
MacroNodeRendererI see why it's rendering that way, but I'm not seeing how to overwrite the behavior.I could call
setOpeningMarker()andsetClosingMarker()to change the markers and thensetName()to change the contents to the HTML I want, but that doesn't seem right.And how I would I choose to skip outputting and just capture the data if I needed to?
I'm obviously missing something basic.
Can anyone help me?
Thanks!
-Dan