Action
Switch Syntax…
Shows a popup allowing you to choose a new syntax-highlighting scheme (grammar) for the current draft, i.e. choosing between Markdown, Taskpaper, etc.
Steps
-
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 = p.show(); var selectedGrammar = p.fieldValues["listSelect"]; if (p.buttonPressed == "Switch Syntax" && currentGrammar != selectedGrammar) { draft.languageGrammar = selectedGrammar; draft.update(); app.displaySuccessMessage("Switched to " + selectedGrammar); }
Options
-
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.