Skip to content

Instantly share code, notes, and snippets.

@jkishner
Last active December 27, 2015 02:09
Show Gist options
  • Save jkishner/7250532 to your computer and use it in GitHub Desktop.
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.
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