I was trying to figure out how to export rendered HTML from a TiddlyWiki tiddler so I could paste it into an MS Word document. Since there doesn't seem to be a supported way to do this in TiddlyWiki, I found two methods that seem to work:
- If you're using Firefox, just highlight the tiddler text, then right-click your selection and choose "View Selection Source." I dunno why this works, but it does.
- Otherwise, I threw together the Ugliest TiddlyWiki Hack Ever!
I may be reinventing the wheel here, but whatever.
Save a backup of your TiddlyWiki file, then open it in a text editor and search for the createTiddlerToolbar function. In that function, look for the section that adds buttons to the non-editor toolbar and add the following lines to that block:
insertSpacer(theToolbar);
createTiddlyButton(
theToolbar,
"html",
"show/hide HTML of this tiddler",
onClickToolbarShowHTML
);
Now add the following function somewhere in the page, preferably near where the other button handlers live:
function onClickToolbarShowHTML(e)
{
hideMessage();
if(this.parentNode.id) {
var viewer =
document.getElementById("viewer" + this.parentNode.id.substr(7));
if (!viewer.isHTMLView) {
viewer.innerHTML = viewer.innerHTML.replace(/\</g,"<");
viewer.isHTMLView = true;
} else {
viewer.isHTMLView = false;
displayTiddler(
null,this.parentNode.id.substr(7),1,null,null,false
);
}
}
}
This is admittedly a gross hack: we're just grabbing the HTML of the viewer tiddler and replacing all the left angle brackets with HTML entities, then stuffing the HTML back into the tiddler. Since calling displayTiddler refreshes the tiddler content, we can use that to undo the damage without manipulating the string again.
This has been pretty useful to me, since I love the simple TiddlyWiki table markup for doing spec work, but usually have to cut and paste it into a report written in HTML or Word. Now, I just hit that "html" tiddler button, copy/paste the HTML, then toggle it back.