HTML content not being rendered in Scripts

HI all,

I am trying to add HTML content inside of my groovy/velocity scripts but it seems that the HTML content is working as intended. Is there a way to see what is causing it to not render the HTML? Are there any specific settings that I need to check in xwiki.cfg/properties to allow this behavior? I am using our global administrator account and have checked to make sure that programming and scripting rights are set correctly. I am using XWiki version 15.10.13

Example script:

{{groovy}}
out.print("<h1>Groovy HTML Testing</h1>")
out.print("<p>This is a paragraph of text, rendered directly from the Groovy script.</p>")
out.print("<p>The current time is: <strong>${new Date()}</strong></p>")
{{/groovy}}


{{velocity}}
 ## Simple Velocity Script
<h1>Velocity HTML Testing</h1>
<p>This is a paragraph of text, rendered directly from the Velocity script.</p>
<p>The current time is: <strong>$!xwiki.dateFormatter.get("HH:mm:ss dd-MM-yyyy")</strong></p>
{{/velocity}}

On page save it shows as:

Looking at the the editing section in Wiki Administrator, I do have HTML 5.0, Plain 1.0, XHTML 1.0 and XHTML 5 checked under the disabled syntax section, would this affect HTML in scripts? What is also interesting is that the HTML macro is not affected and I am able to do HTML with that but not in groovy/velocity scripts where it is needed.

Any ideas?

The output of a Groovy script macro is treated as wiki syntax. You could add out.print("{{html clean=\"false\"}}") as first and out.print("{{/html}}") as last command in your example script. In Velocity, you can directly add {{html clean="false"}} and {{/html}} at the start/end of the script. Please make sure you escape your output accordingly as explained in the developer guide.

1 Like