Code snippets with <script>

I’m struggling with making code-snippets nice for our developers.
Both the code and highlight macros, and github flavoured markdown seem to balk at script tags in jsx/tsx as used in react, and can’t save code with those tags in them.

e.g. this fails:

import React from 'react';

type RootLayoutProps = {
    children: React.ReactNode;
};

export default async function RootLayout({
    children,
}: Readonly<RootLayoutProps>) {
    
    return (
        <html lang="en">
            <head>
                <Script
                    strategy="beforeInteractive"
                    id="sss"
                    type="text/javascript"
                ></Script>
           </head>
        </html>
    );
}

Hello. What is failing and wdym by “balk”? Could you show exactly the markup you have for your wiki page?

The following is working fine for me:

{{code langage="react"}}
import React from 'react';

type RootLayoutProps = {
    children: React.ReactNode;
};

export default async function RootLayout({
    children,
}: Readonly<RootLayoutProps>) {
    
    return (
        <html lang="en" className={customFont.className}>
            <head>
                <Script
                    strategy="beforeInteractive"
                    id="sss"
                    type="text/javascript"
                ></Script>
                      </head>
        </html>
    );
}
{{/code}}

Sorry for the lack of info- obviously remiss of me! I was just about to paste an error

Basically things fail to save.

Server side I don’t see any java errors though.
Could it be something in tomcat that is trying to prevent injection attacks?
I’m using the 16.4 container image.

Got it - we have a cloudflare proxy in front, and that’s doing the “protection”.

So no a problem in xwiki (thanks for the quick reply though)

1 Like