Drafts Action Directory

Change markup language

Posted by @ComplexPoint, Last updated: 2018-06-22 21:09:18 UTC

Change the draft.languageGrammar syntax setting,

choosing from a menu of the alternatives, drawn from:

  • TaskPaper
  • Markdown
  • Javascript
  • Plain text
  • Simple list
Install

Steps

  • script

    (() => {
        'use strict';
    
        const
            lg = draft.languageGrammar,
            p = [
                'Taskpaper',
                'Markdown',
                'JavaScript',
                'Plain Text',
                'Simple List',
            ]
            .reduce(
                (a, k) => lg !== k ? (
                    a.addButton(k),
                    a
                ) : a, // No button needed to keep current setting.
                Object.assign(
                    Prompt.create(), {
                        title: 'Change grammar or Cancel',
                        message: lg + ' ->'
                    }
                )
            );
        return p.show() ? (
            app.displaySuccessMessage(`${lg} -> ${
                    (() => {
                        const g = p.buttonPressed;
                        return (
                          draft.languageGrammar = g,
                          draft.update(),
                          g
                        );
                    })()
                }`)
        ) : (
            app.displayInfoMessage(lg),
            lg
        );
    })();
    

Comments

Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.