Menu

#63 Not recognizing double backlash inside regular expression in js code

None
pending
backslash (1)
2023-02-23
2022-07-27
No

When editing a JavaScript code, the editor is losing track of code after a funcion that includes double backslash inside a regular expression, as explained below:

function nltoparag(txt){
    txt = txt.replace(/\\/g, ""); <-- AFTER FIRST SLASH IS ALL YELLOW
    var html = txt;
        if(html.indexOf('<p>')==-1) { <-- AFTER < IS ALL BLACK AND AFTER QUOTE IS ALL GREEN
        html = '<p>'+html+'</p>';
        html = html.replace(/\n\r/g, '</p><p>'); <-- TEXT INSIDE QUOTES IS GREEN, SHOULD BE THE OPPOSITE
        html = html.replace(/\r\n/g, '</p><p>');
        html = html.replace(/\n/g, '</p><p>');
        html = html.replace(/\r/g, '</p><p>');
    }
    return html;
}

function recursoExterno(titulo, html){
    console.log("recursoExterno titulo: "+titulo);
    console.log("recursoExterno titulo decoded: "+titulo.decodeHEX());
    console.log("recursoExterno html: "+html);
    console.log("recursoExterno html decoded: "+html.decodeHEX());
    var Jan = new $Jan('geral?titulo="'+titulo.decodeHEX()+'"&x=10&y=10&l=640&a=480', html.decodeHEX());
}

Discussion

  • Dr. Martin Senftleben

    • status: open --> pending
     
  • Dr. Martin Senftleben

    I'll take a look, maybe I find the cause of this...

     
  • Dr. Martin Senftleben

    • assigned_to: Dr. Martin Senftleben
     
  • Andrius

    Andrius - 2023-01-12

    regex of javascript is most difficult pattern to do, because one need to look ahead for patterns, and bluefish scanning engine does not have this capability. I have spend significant amount of time on modifying javascript file patterns, and this is the best I could do.
    There is javascript_syntax_highlighting_testfile.js having all difficult paterns, please add your patterns here.
    The language files are located ⁨bluefish⁩ ▸ ⁨data⁩ ▸ ⁨bflang⁩ ▸ all-javascript.bfinc and javascript.bflang2

     
  • Andrius

    Andrius - 2023-01-12

    if you add space after \
    txt = txt.replace(/\\ /g, "");
    the highlighting works. So problems is that current language file does not handle \/ sequence correctly, assuming that \/ is escape sequence while it is regex close slash.

     
  • Dr. Martin Senftleben

    Thanks for your input, @Andrius! Where is this javascript_syntax_highlighting_testfile.js?

     

Log in to post a comment.