Switch Syntax…

Posted by @mattgemmell, Last update almost 6 years ago

Shows a popup allowing you to choose a new syntax-highlighting scheme (grammar) for the current draft, i.e. choosing between Markdown, Taskpaper, etc.


  • script

    var syntaxList = ["Plain Text", "Markdown", "Simple List", "Taskpaper", "JavaScript"];
    var currentGrammar = draft.languageGrammar;
    var p = Prompt.create();
    p.title = "Switch Syntax";
    p.message = "Currently: " + currentGrammar;
    p.addSelect("listSelect", "Syntax", syntaxList, [currentGrammar], false);
    p.addButton("Switch Syntax");
    var didSelect =;
    var selectedGrammar = p.fieldValues["listSelect"];
    if (p.buttonPressed == "Switch Syntax" && currentGrammar != selectedGrammar) {
    	draft.languageGrammar = selectedGrammar;
    	app.displaySuccessMessage("Switched to " + selectedGrammar);


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