clean done items in simple list

Posted by @FlohGro, Last update 7 months ago

Removes done items in simple list

Steps

  • script

    // clean done items in simple list
    // break draft into lines
    
    var lines = draft.content.split("\n");
    var begin = '';
    var end = '';
    var c = "- [x]";
    
    // sort lines based on their leading characters
    
    for(var line of lines){
    	var check = line.includes(c);
    	// if line contains c:
    	if (check) {
    		//ignore line
    //		end += line + "\n";
    	} else if ( line.includes("## done")){
    		//ignore line!
    	} 
    	else{
    		begin += line + "\n";
    	}
    }
    
    // recompile / reorder draft
    begin = begin.slice(0,-1);
    end = end.slice(0,-1);
    editor.setText(begin + "\n");
    draft.update();
    editor.focus(draft); 

Options

  • After Success Default
    Notification Info
    Log Level Info
Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.