Action

Change markup language

Posted by @ComplexPoint, Last update over 6 years ago

Change the draft.languageGrammar syntax setting,

choosing from a menu of the alternatives, drawn from:

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

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
        );
    })();
    

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.