diff --git a/imports/Spectral/Panel/RoomPanel.qml b/imports/Spectral/Panel/RoomPanel.qml index d7f7a26..32bcaf3 100644 --- a/imports/Spectral/Panel/RoomPanel.qml +++ b/imports/Spectral/Panel/RoomPanel.qml @@ -13,8 +13,6 @@ import Spectral 0.1 import Spectral.Setting 0.1 import SortFilterProxyModel 0.2 -import "qrc:/js/md.js" as Markdown - Item { property var currentRoom: null diff --git a/imports/Spectral/Panel/RoomPanelInput.qml b/imports/Spectral/Panel/RoomPanelInput.qml index a172e7a..90a0b28 100644 --- a/imports/Spectral/Panel/RoomPanelInput.qml +++ b/imports/Spectral/Panel/RoomPanelInput.qml @@ -10,8 +10,6 @@ import Spectral.Setting 0.1 import Spectral 0.1 -import "qrc:/js/md.js" as Markdown - Control { property alias isReply: replyItem.visible property var replyUser @@ -349,8 +347,7 @@ Control { } if (text.indexOf(PREFIX_MARKDOWN) === 0) { text = text.substr(PREFIX_MARKDOWN.length) - var parsedText = Markdown.markdown_parser(text) - currentRoom.postHtmlMessage(text, parsedText, RoomMessageEvent.Text) + currentRoom.postMarkdownText(text) return } diff --git a/js/md.js b/js/md.js deleted file mode 100644 index ceae2ef..0000000 --- a/js/md.js +++ /dev/null @@ -1,90 +0,0 @@ -.pragma library - -var preg_replace=function(a,b,c,d){void 0===d&&(d=-1);var e=a.substr(a.lastIndexOf(a[0])+1),f=a.substr(1,a.lastIndexOf(a[0])-1),g=RegExp(f,e),i=[],j=0,k=0,l=c,m=[];if(-1===d){do m=g.exec(c),null!==m&&i.push(m);while(null!==m&&-1!==e.indexOf("g"))}else i.push(g.exec(c));for(j=i.length-1;j>-1;j--){for(m=b,k=i[j].length;k>-1;k--)m=m.replace("${"+k+"}",i[j][k]).replace("$"+k,i[j][k]).replace("\\"+k,i[j][k]);l=l.replace(i[j][0],m)}return l}; - -var markdown_parser = function(str){ - - var rules = [ - // headers - ['/(#+)(.*)/g', function(chars, header){ - var level = chars.length; - return ''+header.trim()+''; - }], - // images -// ['/\\!\\[([^\\[]+)\\]\\(([^\\(]+)\\)/g', '\"\\1\"'], - // link - ['/\\[([^\\[]+)\\]\\(([^\\(]+)\\)/g', '\\1'], - // bold - ['/(\\*\\*|__)(.*?)\\1/g', '\\2'], - // emphasis - ['/(\\*|_)(.*?)\\1/g', '\\2'], - // strike - ['/(\\~\\~)(.*?)\\1/g', '\\2'], - // quote - ['/\\:\\"(.*?)\\"\\:/g', '\\1'], - // unordered list -// ['/\\n\\*(.*)/g', function(item){ -// return ''; -// }], - // ordered list -// ['/\\n[0-9]+\\.(.*)/g', function(item){ -// return '
    \n
  1. '+item.trim()+'
  2. \n
'; -// }], - // blockquote - ['/\\n\\>(.*)/g', function(str){ - return '
'+str.trim()+'
'; - }] - // paragraphs -// ['/\\n[^\\n]+\\n/g', function(line){ -// line = line.trim(); -// if(line[0] === '<'){ -// return line; -// } -// return '\n

'+line+'

\n'; -// }] - ], fixes = [ - ['/<\\/ul>\n