Action

Line Quotes

Posted by TheChels.uk, Last update about 12 hours ago

UPDATES

about 12 hours ago

Updated description

About

Prepend quote (> in md) to each non-title line. Often when capturing from the web in safari some text is not quoted correctly so this helps fix this for quote posts

Tip

If you find this useful and want to support me, you can tip at ko-fi.com/thechelsuk

Steps

  • script

    /*
     * @title: Quote it all
     * @author: TheChelsUk
     * @notes: Makes each non-title line in a Draft a quote
     */
    
    if (draft) {
        console.log("Draft found...");
    
        let lines = draft.content.split('\n');
    
        if (lines.length > 0) {
            console.log(`Draft has ${lines.length} lines. Processing content...`);
    
            let title = lines[0];
            let quotedLines = lines.slice(1).map(line => 
                line.trim() ? `> ${line}` : line // Add prefix only if the line is non-empty
            );
            let updatedContent = [title, ...quotedLines].join('\n');
    
            // Update the draft content
            draft.content = updatedContent;
            draft.update();
    
            console.log("Draft updated successfully!");
        } else {
            console.log("Draft is empty..");
        }
    } else {
        console.log("No active draft found...");
    }

Options

  • After Success Nothing
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.