Last active
December 16, 2015 12:09
-
-
Save kevinoconnor7/5432376 to your computer and use it in GitHub Desktop.
Advanced usage of my Bootstrap Pagedown jQuery plugin
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
<!-- 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