Skip to content

Instantly share code, notes, and snippets.

@kevinoconnor7
Last active December 16, 2015 12:09
Show Gist options
  • Save kevinoconnor7/5432376 to your computer and use it in GitHub Desktop.
Save kevinoconnor7/5432376 to your computer and use it in GitHub Desktop.
Advanced usage of my Bootstrap Pagedown jQuery plugin
<!-- Le script -->
<script type="text/javascript" src="js/jquery.pagedown-bootstrap.combined.min.js"></script>
<!-- Le CSS -->
<link href="css/jquery.pagedown-bootstrap.css" rel="stylesheet">
<!-- Le lift -->
<script type="text/javascript">
$("textarea#pagedownMeDangerously").pagedownBootstrap({
'sanatize': false,
'help': function () { alert("Do you need help?"); },
'hooks': [
{
'event': 'preConversion',
'callback': function (text) {
return text.replace(/\b(a\w*)/gi, "*$1*");
}
},
{
'event': 'plainLinkText',
'callback': function (url) {
return "This is a link to " + url.replace(/^https?:\/\//, "");
}
}
]
});
</script>
<!-- Le input -->
<textarea id="pagedownMeDangerously" class="form-control" rows="10">
This is the *second* editor.
------------------------------
It has a plugin hook registered that surrounds all words starting with the
letter A with asterisks before doing the Markdown conversion. Another one gives bare links
a nicer link text. User input isn't sanitized here:
<marquee>I'm the ghost from the past!</marquee>
http://google.com
http://stackoverflow.com
It also includes a help button.
</textarea>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment