refactor: Swap out remarkable for habitica flavored markdown-it

This commit is contained in:
Blade Barringer
2016-04-22 17:27:27 -05:00
parent 2cdb30bd5b
commit ad57dedecb
6 changed files with 8 additions and 66 deletions

View File

@@ -6,11 +6,7 @@
*/
(function(){
var md = function () {
var remarkable = new Remarkable({
// TODO: Add in code highlighting?
// highlight: function (#<{(|str, lang|)}>#) { return ''; }
linkify: true
});
var mdown = window.habiticaMarkdown;
emoji.img_path = 'common/img/emoji/unicode/';
@@ -18,63 +14,13 @@
if (markdown == undefined)
return '';
markdown = remarkable.render(markdown);
markdown = mdown.render(markdown);
markdown = emoji.replace_colons(markdown);
markdown = emoji.replace_unified(markdown);
return markdown;
};
// This was applie to marked, the old markdown library which has an xss exploit.
// If we want this behavior again, we'll need to rewrite it.
// ---
// [nickgordon20131123] this hacky override wraps images with a link to the image in a new window, and also adds some classes in case we want to style
// marked.InlineLexer.prototype.outputLink = function(cap, link) {
// var escape = function(html, encode) {
// return html
// .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&amp;')
// .replace(/</g, '&lt;')
// .replace(/>/g, '&gt;')
// .replace(/"/g, '&quot;')
// .replace(/'/g, '&#39;');
// };
// if (cap[0].charAt(0) !== '!') {
// return '<a class="markdown-link" target="_blank" href="'
// + escape(link.href)
// + '"'
// + (link.title
// ? ' title="'
// + escape(link.title)
// + '"'
// : '')
// + '>'
// + this.output(cap[1])
// + '</a>';
// } else {
// return '<a class="markdown-img-link" target="_blank" href="'
// + escape(link.href)
// + '"'
// + (link.title
// ? ' title="'
// + escape(link.title)
// + '"'
// : '')
// + '><img class="markdown-img" src="'
// + escape(link.href)
// + '" alt="'
// + escape(cap[1])
// + '"'
// + (link.title
// ? ' title="'
// + escape(link.title)
// + '"'
// : '')
// + '></a>';
// }
// }
//hljs.tabReplace = ' ';
return {
toHtml:toHtml
};
@@ -99,7 +45,6 @@
html = html.replace(userHighlight, "<u>@"+userName+"</u>");
html = html.replace(' href',' target="'+linktarget+'" href');
element.html(html);
if(MOBILE_APP) {
@@ -140,8 +85,6 @@
return function(input){
var html = md.toHtml(input);
html = html.replace(' href',' target="_blank" href');
return html;
};
});