• Hi there,
    I just install the enlighter for my internal blog (wordpress) for highlighting C++ code, here is my block

    <pre class="EnlighterJSRAW" data-enlighter-language="cpp">
    vector<int> A, B;
    int C = 13; // constant 
    
    for (int i=1; i<=10; i++) {
      A.push_back(i);
    }
    B.resize(A.size());
    std::transform(A.begin(), A.end(),B.begin(),std::bind(std::plus<int>(), std::placeholders::_1, C));
    
    for (int i=0; i<A.size(); i++) {
      std::cout << A[i] << " ";
    }
    </pre>

    I find that the C++ syntax with

    <int> and [i] and <A.

    mess up with the html tags so the page formatted all wrong.

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Andi Dittrich

    (@andi-dittrich)

    which editing mode (Gutenberg, TinyMCE, Gutenberg-Plain/HTML, TinyMCE-Plain-HTML) did you use ?

    Thread Starter evlee

    (@evlee)

    I use TinyMCE-Plain-HTML. I find that it is the “<>” in C++ syntax cause the issue. If I put spaces between “<” and “>”, e.g. vector< int >, it fix the issue. However, it is quite troublesome to modify the code by adding space everywhere before parsing them into my page.

    Plugin Author Andi Dittrich

    (@andi-dittrich)

    the problem is that you’re using html brackets within the code which are interpreted as regular html code by WordPress/your webbrowser.

    in case you want to write html code you have to escape the code on your own!

    The Enlighter plugin includes editing plugins for TinyMCE and Gutenberg (visual mode) which also take care of the html characters and escapes them automatically.

    maybe you want to use shortcodes

    Thread Starter evlee

    (@evlee)

    Thanks for your reply. I try to use TinyMCE (visual mode) but it still doesn’t work. I still have to add space in between <> to make it work. Any idea?

    Thread Starter evlee

    (@evlee)

    By the way, I try Gutenberg (visual mode) as well, it doesn’t work either.

    Plugin Author Andi Dittrich

    (@andi-dittrich)

    did you use the “code insert” button / gutenberg blocks ?

    i assume that this is a third party issue – the editing plugins are working fine

    Thread Starter evlee

    (@evlee)

    Yes, I do see the code insert button. I don’t know how to debug it if it is third party issue ??

    Plugin Author Andi Dittrich

    (@andi-dittrich)

    disable all other plugins and test if it’s working. then re-enable the plugins step-by-step

    Thread Starter evlee

    (@evlee)

    Thanks. I found it. This plugin conflicts with WPGlobus.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Syntax error for C++ coding’ is closed to new replies.