Switch Syntax…

Posted by @nahumck, Last update about 3 years ago

Shows a popup allowing you to see the current syntax and choose a new syntax from a list of your installed syntaxes for the current draft, i.e. choosing between Markdown, Taskpaper, etc.

Code mostly by Greg.


  • script

    // Get currently installed syntax
    const syntaxes = Syntax.getAll();
    const syntaxNames = =>;
    // Get the current draft syntax
    const currentSyntax = draft.syntax;
    // Create a prompt to select a new syntax from a list or cancel
    let p = Prompt.create();
      p.title = "Switch Syntax";
      p.message = "Currently: " +;
      p.addSelect("listSelect", "Syntax", syntaxNames, [], false);
      p.addButton("Switch Syntax");
    let didSelect =;
    // Set the selected syntax in order to switch
    let selected = p.fieldValues["listSelect"];
    let selectedIndex = syntaxes.findIndex(s => == selected);
    let selectedSyntax = syntaxes[selectedIndex];
    // if Switch Syntax is selected, change the syntax to the selected syntax in the prompt
    if (p.buttonPressed == "Switch Syntax" && != {
    	draft.syntax = selectedSyntax;
    	app.displaySuccessMessage("Switched to " +;


  • 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.