Skip to content

Commit

Permalink
Merge pull request #6095 from grzesiek2010/COLLECT-5685_q
Browse files Browse the repository at this point in the history
Improved interpreting text as markdown
  • Loading branch information
seadowg authored Apr 23, 2024
2 parents 4f7db74 + 7a577df commit 73b812b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ static String markdownToHtml(String text) {
text = text.replaceAll("(?s)\\*\\*(.*?)\\*\\*", "<strong>$1</strong>");

// emphasis using underscore
text = text.replaceAll("\\s_([^\\s][^_\n]*)_\\s", " <em>$1</em> ");
text = text.replaceAll("^_([^\\s][^_\n]*)_$", "<em>$1</em>");
text = text.replaceAll("^_([^\\s][^_\n]*)_\\s", "<em>$1</em> ");
text = text.replaceAll("\\s_([^\\s][^_\n]*)_$", " <em>$1</em>");
text = text.replaceAll("(^|[\\s]|[^\\w])_([^\\s][^_\n]*)_($|[\\s]|[^\\w])", "$1<em>$2</em>$3");

// emphasis using asterisk
text = text.replaceAll("\\*([^\\s][^\\*\n]*)\\*", "<em>$1</em>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ public void markDownToHtmlEscapesBackslash() {
{"A _B_ C", "A <em>B</em> C"},
{"A_B_ C", "A_B_ C"},
{"A _B_C", "A _B_C"},
{"_A_5", "_A_5"},
{"_A_", "<em>A</em>"},
{"(_A_)", "(<em>A</em>)"},
{"_A_?", "<em>A</em>?"},
{"*_A_", "*<em>A</em>"},
{"blah _A_!", "blah <em>A</em>!"},
{" _A_! blah", " <em>A</em>! blah"},
{"\\_ _AB\\__", "_ <em>AB_</em>"},
{"\\\\ _AB\\_\\\\_", "\\ <em>AB_\\</em>"},
{"A\\*B\\*C", "A*B*C"},
Expand Down

0 comments on commit 73b812b

Please sign in to comment.