|
|
|
@ -187,9 +187,9 @@ QString ChatMessage::detectMarkdown(const QString &str)
@@ -187,9 +187,9 @@ QString ChatMessage::detectMarkdown(const QString &str)
|
|
|
|
|
|
|
|
|
|
// Create regex for certain markdown syntax
|
|
|
|
|
QRegExp exp("(\\*\\*)([^\\*\\*]{2,})(\\*\\*)" // Bold **text** |
|
|
|
|
"|(\\*)([^\\*]{2,})(\\*)" // Bold *text*
|
|
|
|
|
"|(\\*)([^\\*]{2,})(\\*)" // Italics *text*
|
|
|
|
|
"|(\\_)([^\\_]{2,})(\\_)" // Italics _text_
|
|
|
|
|
"|(\\_\\_)([^\\_\\_]{2,})(\\_\\_)" // Italics __text__
|
|
|
|
|
"|(\\_\\_)([^\\_\\_]{2,})(\\_\\_)" // Bold __text__
|
|
|
|
|
"|(\\-)([^\\-]{2,})(\\-)" // Underline -text-
|
|
|
|
|
"|(\\~)([^\\~]{2,})(\\~)" // Strike ~text~
|
|
|
|
|
"|(\\~~)([^\\~\\~]{2,})(\\~~)" // Strike ~~text~~
|
|
|
|
@ -225,12 +225,12 @@ QString ChatMessage::detectMarkdown(const QString &str)
@@ -225,12 +225,12 @@ QString ChatMessage::detectMarkdown(const QString &str)
|
|
|
|
|
// Match captured string to corresponding md format
|
|
|
|
|
if (exp.cap(1) == "**") // Bold **text**
|
|
|
|
|
htmledSnippet = QString(" <b>%1</b> ").arg(snippet.mid(mul,snippet.length()-2*mul)); |
|
|
|
|
else if (exp.cap(4) == "*" && snippet.length() > 2) // Bold *text*
|
|
|
|
|
htmledSnippet = QString(" <b>%1</b> ").arg(snippet.mid(mul/2,snippet.length()-mul)); |
|
|
|
|
else if (exp.cap(4) == "*" && snippet.length() > 2) // Italics *text*
|
|
|
|
|
htmledSnippet = QString(" <i>%1</i> ").arg(snippet.mid(mul/2,snippet.length()-mul)); |
|
|
|
|
else if (exp.cap(7) == "_" && snippet.length() > 2) // Italics _text_
|
|
|
|
|
htmledSnippet = QString(" <i>%1</i> ").arg(snippet.mid(mul/2,snippet.length()-mul)); |
|
|
|
|
else if (exp.cap(10) == "__"&& snippet.length() > 4) // Italics __text__
|
|
|
|
|
htmledSnippet = QString(" <i>%1</i> ").arg(snippet.mid(mul,snippet.length()-2*mul)); |
|
|
|
|
else if (exp.cap(10) == "__"&& snippet.length() > 4) // Bold __text__
|
|
|
|
|
htmledSnippet = QString(" <b>%1</b> ").arg(snippet.mid(mul,snippet.length()-2*mul)); |
|
|
|
|
else if (exp.cap(13) == "-" && snippet.length() > 2) // Underline -text-
|
|
|
|
|
htmledSnippet = QString(" <u>%1</u> ").arg(snippet.mid(mul/2,snippet.length()-mul)); |
|
|
|
|
else if (exp.cap(16) == "~" && snippet.length() > 2) // Strikethrough ~text~
|
|
|
|
|