Action

Show invisibles in draft

Posted by @ComplexPoint, Last update over 6 years ago

Display contents of draft,
with non-printing characters (tabs, spaces, newlines etc), made visible.

Useful, for example, for spotting unexpected mixtures of tabs and spaces.

Displays a view like:

Project:\n
\t-.with.a.mixture.of.tabs\n
....-.and.multiple.spaces\n
\t-.etc

Steps

  • script

    (() => {
        'use strict';
    
        const
            strText = draft.content || '',
            strVisible = (strText.length > 0 ? (
                JSON.stringify(strText) // Visible escapes,
                .slice(1, -1)           // without flanking quotes,
                .replace(/ /g, '.')     // using . to show spaces,
                .split('\\n')           // and breaking the string
            ) : []).join('\\n\n'),      // into lines with visible \n
            p = Object.assign(
                Prompt.create(), {
                    title: 'Invisibles in draft',
                    message: 'Non-printing chars shown as:\n\n' +
                        'tab: \\t\nlinefeed: \\n\nspace: .'
                }
            );
        return (
            p.addTextView(
                'txt',
                'in draft:',
                strVisible, {
                    height: 240
                }
            ),
            p.show(),
            strVisible
        );
    })()
    

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.