Created
February 17, 2016 12:01
-
-
Save cumet04/35097bff9840455f24fd to your computer and use it in GitHub Desktop.
pukiwikiでmarkdownを使うプラグイン(marked.js利用)
This file contains hidden or 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
<?php | |
/** | |
* Markdon Syntax with marked.js | |
*/ | |
function plugin_markedjs_convert() | |
{ | |
$args = func_get_args(); | |
$body = array_pop($args); | |
$noskin = in_array("noskin", $args); | |
$body = htmlspecialchars($body); | |
static $num = 0; | |
$num++; | |
$divid = 'markedjs_content' . $num; | |
$output = " | |
<script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.5/marked.js'></script> | |
<script src='//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/highlight.min.js'></script> | |
<div id='$divid'>$body</div> | |
<script> | |
hljs.initHighlightingOnLoad(); | |
setTimeout(function() { | |
marked.setOptions({ | |
renderer: new marked.Renderer(), | |
gfm: true, | |
tables: true, | |
breaks: true, | |
pedantic: false, | |
sanitize: true, | |
smartLists: true, | |
smartypants: false, | |
langPrefix: '' | |
}); | |
var e = document.getElementById('$divid'); | |
e.innerHTML=marked(e.textContent); | |
}, 0); | |
</script>"; | |
return $output; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment