Last active
December 27, 2015 02:09
-
-
Save jkishner/7250532 to your computer and use it in GitHub Desktop.
This script will create an HTML file in dropbox in which the cursor text is the title and all its children are rendered as unordered lists. A new window opens with the shareable Dropbox URL. Adapted from a op.visitSubs script written by Dave Winer.
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
export as html | |
var title = op.getLineText(); | |
var s = ""; | |
var head = "<html><body><h1>" + title + "</h1>"; | |
var foot = "</body></html>"; | |
op.visitSubs ( | |
function (headline, level) { | |
s += string.filledString ("\t", level) + "<li>" + headline.getLineText () + "</li>\r\n"; | |
}, | |
function () {s += "<ul>";}, | |
function () {s += "</ul>";} | |
); | |
html = head + s + foot; | |
path = title + '.html'; | |
file.writeWholeFile (path, html, function (data) { | |
file.getPublicUrl (path, function (url) { | |
window.open (url); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment