Menu

#310 XML: treat - (minus) as a special char

None
wont-fix
Skeeve
XML (7)
5
2017-10-30
2012-09-03
No

"--" string is not permitted inside a comment. So I suggest to treat "-" as a special character. That would make it possible to use "Characters to Entities" to escape such strings. That's the goal of using "Characters to Entites", to convert characters that make problems in parsing into correct xml code.

I have 3 ideas, but don't know which would be best for the plugin:

1. treat "-" always as a special char and replace it with -
2. treat "-" as special only after another "-"
3. treat "-" as special if configured so

In any case Entites to Characters should replace the entity with original character.

Without this functionality a common problem I meet is ant scripts with exec call, with arguments like --output. These commands are impossible to comment out.

Discussion

  • Skeeve

    Skeeve - 2017-10-29

    I think this is a very special case.

    I propse you use a macro to set a comment and remove it.

    Set the macro:

    SearchAndReplace.setSearchString("--");
    SearchAndReplace.setReplaceString("--");
    SearchAndReplace.setBeanShellReplace(false);
    SearchAndReplace.setWholeWord(false);
    SearchAndReplace.setIgnoreCase(true);
    SearchAndReplace.setRegexp(false);
    SearchAndReplace.replace(view);
    Registers.cut(textArea,'$');
    textArea.setSelectedText("<!--  -->");
    textArea.goToPrevCharacter(false);
    textArea.goToPrevCharacter(false);
    textArea.goToPrevCharacter(false);
    textArea.goToPrevCharacter(false);
    EditBus.send(new PositionChanging(editPane));
    Registers.paste(textArea,'$',false);
    

    It will put the current selection (just one) into a comment and replace every "--" with "--"

    The next one reverts that change by removing the enclosing comment (or the comment to the left of the cursor) and replace "-%45;" with "--"

    SearchAndReplace.setSearchString("<!-- ");
    SearchAndReplace.setAutoWrapAround(false);
    SearchAndReplace.setReverseSearch(true);
    SearchAndReplace.setWholeWord(false);
    SearchAndReplace.setIgnoreCase(true);
    SearchAndReplace.setRegexp(false);
    SearchAndReplace.setSearchFileSet(new CurrentBufferSet());
    SearchAndReplace.find(view);
    textArea.backspace();
    a=textArea.getCaretPosition();
    SearchAndReplace.setSearchString(" -->");
    SearchAndReplace.setAutoWrapAround(false);
    SearchAndReplace.setReverseSearch(false);
    SearchAndReplace.setWholeWord(false);
    SearchAndReplace.setIgnoreCase(true);
    SearchAndReplace.setRegexp(false);
    SearchAndReplace.setSearchFileSet(new CurrentBufferSet());
    SearchAndReplace.find(view);
    textArea.backspace();
    z=textArea.getCaretPosition();
    textArea.setSelection(new Selection.Range(a,z));
    SearchAndReplace.setSearchString("-&#45;");
    SearchAndReplace.setReplaceString("--");
    SearchAndReplace.setBeanShellReplace(false);
    SearchAndReplace.setWholeWord(false);
    SearchAndReplace.setIgnoreCase(true);
    SearchAndReplace.setRegexp(false);
    SearchAndReplace.replace(view);
    

    I hope this helps.

    Proposal for this featuer request: Close -> won't fix.

     

    Last edit: Skeeve 2017-10-30
    • Alan Ezust

      Alan Ezust - 2017-10-29

      Hi Skeeve, I just added you as a developer so you can close tickets, and
      assign things to yourself.

      ​Thanks for helping out!

      --Alan

       
  • Skeeve

    Skeeve - 2017-10-30
    • status: open --> wont-fix
    • assigned_to: Eric Le Lay --> Skeeve
    • Group: -->
     

Log in to post a comment.