Skip to content

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

Open
@dswitzer

Description

@dswitzer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions