Action
Markdown Code
This is a modified version of someone else’s code syntax. This Action creates the Markdown code ticks around selected text, or, if there is no selected text, it creates two tick marks with the cursor in between them.
Steps
-
script
// Apply Markdown code to selection, or insert ` if no selection var sel = editor.getSelectedText(); var selRange = editor.getSelectedRange(); if (!sel || sel.length == 0) { // editor.setSelectedText("`"); // Let's try putting two ticks editor.setSelectedText("``"); // editor.setSelectedRange(selRange[0]+1,0); // Let's try making the cursor be in the middle of the two tick marks editor.setSelectedRange(selRange[0]+1,0) } else { editor.setSelectedText("`"+sel+"`"); editor.setSelectedRange(selRange[0]+selRange[1]+2,0); }
Options
-
After Success Default Notification Error Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.