|
@@ -141,6 +141,7 @@ Crowi.rendererType = {};
|
|
|
Crowi.rendererType.markdown = function(){};
|
|
Crowi.rendererType.markdown = function(){};
|
|
|
Crowi.rendererType.markdown.prototype = {
|
|
Crowi.rendererType.markdown.prototype = {
|
|
|
render: function(contentText) {
|
|
render: function(contentText) {
|
|
|
|
|
+
|
|
|
marked.setOptions({
|
|
marked.setOptions({
|
|
|
gfm: true,
|
|
gfm: true,
|
|
|
highlight: function (code, lang, callback) {
|
|
highlight: function (code, lang, callback) {
|
|
@@ -169,6 +170,8 @@ Crowi.rendererType.markdown.prototype = {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
var contentHtml = Crowi.unescape(contentText);
|
|
var contentHtml = Crowi.unescape(contentText);
|
|
|
|
|
+ // TODO 前処理系のプラグイン化
|
|
|
|
|
+ contentHtml = this.preFormatMarkdown(contentHtml);
|
|
|
contentHtml = this.expandImage(contentHtml);
|
|
contentHtml = this.expandImage(contentHtml);
|
|
|
contentHtml = this.link(contentHtml);
|
|
contentHtml = this.link(contentHtml);
|
|
|
|
|
|
|
@@ -181,6 +184,12 @@ Crowi.rendererType.markdown.prototype = {
|
|
|
$body.html(content);
|
|
$body.html(content);
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
|
|
+ preFormatMarkdown: function(content){
|
|
|
|
|
+ var x = content
|
|
|
|
|
+ .replace(/^(#{1,})([^\s]+)?(.*)$/gm, '$1 $2$3') // spacer for section
|
|
|
|
|
+ .replace(/>[\s]*\n>[\s]*\n/g, '> <br>\n> \n');
|
|
|
|
|
+ return x;
|
|
|
|
|
+ },
|
|
|
link: function (content) {
|
|
link: function (content) {
|
|
|
return content
|
|
return content
|
|
|
//.replace(/\s(https?:\/\/[\S]+)/g, ' <a href="$1">$1</a>') // リンク
|
|
//.replace(/\s(https?:\/\/[\S]+)/g, ' <a href="$1">$1</a>') // リンク
|