Action

Move Completed Tasks

Posted by nahumck, Last update over 5 years ago

Move lines containing a completed markdown task (“- [x]”) to the bottom of the current draft.

Steps

  • script

    // Move lines containing a completed markdown task (“- [x]”) to the bottom of the current draft.
    
    var text = editor.getText();
    var lines = text.split("\n");
    var begin = '';
    var end = '';
    var c ="- [x]";
    
    for (var line of lines) {
      //if line contains "- [x]"… 
      if (line.includes(c)) {
      //add it to var end
        end += line + "\n";
      }
      else {
        begin += line + "\n";
      }
    }
    begin = begin.slice(0,-1);
    end = end.slice(0,-1);
    editor.setText(begin + "\n" + end);

Options

  • After Success Default
    Notification Error
    Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.