Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown Lists Reformat (*⇨-) Action #116

Open
extratone opened this issue Aug 5, 2024 · 0 comments
Open

Markdown Lists Reformat (*⇨-) Action #116

extratone opened this issue Aug 5, 2024 · 0 comments
Assignees
Labels
configuration documentation Improvements or additions to documentation

Comments

@extratone
Copy link
Owner

extratone commented Aug 5, 2024

Markdown Lists Reformat (*⇨-) Action

Updated 08042024-192559


Social

no idea why I hadn't before just made an Action for this but ... I have now. https://directory.getdrafts.com/a/2Tt

<script async="" src="https://telegram.org/js/telegram-widget.js?1" data-telegram-post="https://t.me/draftsapp/674" data-width="100%"></script> <iframe src="https://mastodon.social/@DavidBlue/112906648707796769/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="400" allowfullscreen="allowfullscreen"></iframe><script src="https://static-cdn.mastodon.social/embed.js" async="async"></script>

Meta

Description

Changes (replaces) any [* ]-formatted Markdown lists in the current Draft to hyphen format (- ).

Directory Description

Changes (replaces) any [* ]-formatted Markdown lists in the current Draft to hyphen format (- ) via regex (/^\*\s+/gm).

Source

  • SnippetsLab
drafts://action?data=%7B%22groupDisposition%22:0,%22backingAssignFlag%22:0,%22uuid%22:%224693AE3F-BB41-4FCA-B494-64D9D65AA93B%22,%22backingPlatforms%22:3,%22keyCommand%22:%7B%22discoverabilityTitle%22:%22Markdown%20Lists%20Reformat%20(*%E2%87%A8-)%22,%22controlKey%22:false,%22shiftKey%22:false,%22input%22:%22%22,%22optionKey%22:false,%22type%22:%22action%22,%22commandKey%22:false%7D,%22actionDescription%22:%22Changes%20(replaces)%20any%20%5B*%20%5D-formatted%20Markdown%20lists%20in%20the%20current%20Draft%20to%20hyphen%20format%20(-%20).%22,%22disposition%22:0,%22assignTags%22:%5B%5D,%22visibility%22:2016,%22shouldConfirm%22:false,%22keyUseIcon%22:false,%22groupUUID%22:%22896E9936-31AB-4722-A67D-AA578EABE763%22,%22tintColor%22:%22yellow%22,%22backingIsSeparator%22:false,%22steps%22:%5B%7B%22platforms%22:3,%22type%22:%22script%22,%22isEnabled%22:true,%22data%22:%7B%22allowAsync%22:%22false%22,%22script%22:%22%5C/%5C/%20Get%20the%20content%20of%20the%20current%20draft%5Cnlet%20content%20%3D%20draft.content;%5Cn%5Cn%5C/%5C/%20Define%20a%20regular%20expression%20to%20find%20all%20instances%20of%20lists%20formatted%20with%20%5B*%20%5D%5Cnlet%20regex%20%3D%20%5C/%5E%5C%5C*%5C%5Cs+%5C/gm;%5Cn%5Cn%5C/%5C/%20Replace%20the%20matches%20with%20%5B-%20%5D%5Cnlet%20updatedContent%20%3D%20content.replace(regex,%20'-%20');%5Cn%5Cn%5C/%5C/%20Update%20the%20draft%20content%20with%20the%20new%20format%5Cndraft.content%20%3D%20updatedContent;%5Cn%5Cn%5C/%5C/%20Save%20the%20draft%5Cndraft.update();%22%7D,%22uuid%22:%22FFE84C7E-4D9B-42F5-8CAE-01DD2211837A%22%7D%5D,%22notificationType%22:2,%22name%22:%22Markdown%20Lists%20Reformat%20(*%E2%87%A8-)%22,%22icon%22:%22400-list2%22,%22logLevel%22:1,%22shortName%22:%22%22%7D
// Get the content of the current draft
let content = draft.content;

// Define a regular expression to find all instances of lists formatted with [* ]
let regex = /^\*\s+/gm;

// Replace the matches with [- ]
let updatedContent = content.replace(regex, '- ');

// Update the draft content with the new format
draft.content = updatedContent;

// Save the draft
draft.update();
@extratone extratone added documentation Improvements or additions to documentation configuration labels Aug 5, 2024
@extratone extratone self-assigned this Aug 5, 2024
extratone added a commit that referenced this issue Aug 5, 2024
extratone added a commit that referenced this issue Aug 5, 2024
Wow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration documentation Improvements or additions to documentation
Projects
Status: Contemplating
Development

No branches or pull requests

1 participant