Created
October 27, 2014 00:35
-
-
Save mattcassinelli/8c88561e7b7ab46d14cf to your computer and use it in GitHub Desktop.
Re-number a list in Drafts 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function renumber(s) { | |
var rgx=/^\d+\. /m, | |
list=s.split(rgx), | |
count; | |
list.shift(); | |
count = list.length; | |
for(var i=0; i<count; i++) { | |
list[i] = (i+1).toString() + '. ' + list[i]; | |
} | |
return list.join(''); | |
} | |
var rngLines = getSelectedLineRange(), | |
iFrom=rngLines[0], | |
iTo=rngLines[1]; | |
setTextInRange(iFrom, iTo, renumber(getTextInRange(iFrom, iTo))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Taken from Dr. Drang: http://www.leancrew.com/all-this/2014/10/three-things-for-drafts-4/