Skip to content

Commit

Permalink
Improved handling markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 committed Apr 12, 2024
1 parent a019adc commit 7a577df
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 7a577df

Please sign in to comment.