Skip to content

Instantly share code, notes, and snippets.

@FND
Created June 3, 2010 07:39
Show Gist options
  • Select an option

  • Save FND/423607 to your computer and use it in GitHub Desktop.

Select an option

Save FND/423607 to your computer and use it in GitHub Desktop.
/***
|''Requires''|MarkdownFormatterPlugin|
!Usage
<<md2html [[source]]>>
{{{
<<md2html tiddler>>
}}}
!Code
***/
//{{{
(function($) {
if(!config.parsers.markdownFormatter) {
throw "Missing dependency: MarkdownFormatterPlugin";
}
config.macros.md2html = {
btnLabel: "convert markup",
btnTooltip: "generate HTML from tiddler %0",
handler: function(place, macroName, params, wikifier, paramString, tiddler) {
var title = params[0];
var tooltip = this.btnTooltip.format([title]);
var btn = createTiddlyButton(place, this.btnLabel, tooltip, this.onClick);
$(btn).data("tiddler", title);
},
onClick: function(ev) {
var title = $(this).data("tiddler");
var tiddler = store.getTiddler(title);
var html = wikifyStatic(tiddler.text, null, null, "markdown");
$("<textarea />").val(html).hide().
prependTo(document.body).slideDown().select();
}
};
})(jQuery);
//}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment