You said you wanted to display the markdown as-is, that’s why I provided you with instructions to display the markdown as-is and not rendered. If you want to display it rendered as HTML, you could try replacing
@Inject
@Named("plain/1.0")
private Parser plainTextParser;
by
@Inject
@Named("markdown+github/1.0")
private Parser plainTextParser;
Of course you could/should also rename the variable to something like markdownParser
to make the code clearer. If you’re using a recent-enough XWiki version (14.10.5/15.1), you could also use a MacroContentParser
which provides some more convenience features. Further, if you’re on 14.2 or more recent, you could also pass an id generator to the parse method to ensure that ids, e.g., of headings, are unique across the whole document. You can get the id generator using macroContext.getXDOM().getIdGenerator()
where macroContext
is the context parameter of type MacroTransformationContext
that is passed to the execute
-method of the macro.
The MacroBlock
for the content macro might work, too, though you should definitely set the inline
parameter to false
if this should be a whole document.