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

How should rendering macros via the flexmark-ext-xwiki-macros extension work? #651

Open
dswitzer opened this issue Mar 13, 2025 · 1 comment

Comments

@dswitzer
Copy link

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:

  1. 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.
  2. 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

@dswitzer
Copy link
Author

dswitzer commented Apr 1, 2025

Just following up on this issue.

After spending more time looking through the Flexmark code, I'm guessing the flexmark-ext-xwiki-macros extension isn't designed to do anything other than either strip the instructions out or to leave them as-is.

I'm thinking I'll need to fork the extension to do what I was hoping to do.

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