rainlab/blog-plugin

Wrong code format displayed in website

calebeso opened this issue · 2 comments

When I'm making a blog post in my backend application, I got the correctly preview of what should be the code format:

correto

But when I go to the website, this is what is being displayed in the front. Already check possible css alters but no one's found..

errado

Any ideia of what could be?

Hi @calebeso

This is because the frontend and backend are using a different theme. If you are using the demo theme, take a look at the javascript/app.js file and see where it activates code formatting:

    /*
     * Init code blocks
     */

    $('pre').each(function () {
        var $this = $(this),
            $code = $this.html(),
            originalValue = $this.html(),
            unescaped = originalValue.replace(/&lt;/g, "<").replace(/&gt;/g, ">")
    
        $this.empty()
        var cm = new CodeMirror(this, {
            value: $code,
            mode: 'twig',
            htmlMode: true,
            lineNumbers: true,
            readOnly: true
        })

        cm.setValue(unescaped)
    })

You can apply a different theme here. These themes are supported: https://codemirror.net/demo/theme.html

I hope this helps!

Thanks for replying!

Problem solved!