@@ -13,6 +13,8 @@ val span = Regex("<span (.*?)>(.*?)</span>")
1313val color = Regex (" [\" ;]color:#(.*?)[\" ;]" )
1414val styleItalic = Regex (" (font-style:italic)" )
1515val styleBold = Regex (" (font-weight:bold)" )
16+ val emptyFont = Regex (" <font[^>]*?></font>" )
17+ val uselessFont = Regex (" <font[^>]*?>(( )+)</font>" )
1618
1719val clipboard = Toolkit .getDefaultToolkit().systemClipboard!!
1820val clipboardHtml
@@ -50,6 +52,7 @@ private fun convertClipboard() {
5052private fun String.convertCode () =
5153 substring(pre)
5254 ?.replace(span) { span -> span.groups[2 ]!! .value.styledWith(span.groups[1 ]!! .value) }
55+ ?.popupBr()
5356 ?.replaceTags()
5457 ?.wrapWithCode()
5558
@@ -60,8 +63,19 @@ private fun String.putIntoClipboard() =
6063private fun String.wrapWithCode () =
6164 " <code>$this </code>"
6265
66+ private fun String.popupBr () =
67+ // popup <br> from any style tags
68+ replace(" <br></b>" , " </b><br>" )
69+ .replace(" <br></i>" , " </i><br>" )
70+ .replace(" <br></font>" , " </font><br>" )
71+ // useless style removing (minification)
72+ .replace(" <b></b>" , " " )
73+ .replace(" <i></i>" , " " )
74+ .replace(emptyFont, " " )
75+ .replace(uselessFont, " $1" )
76+
6377private fun String.replaceTags () =
64- replace(" <br>" , " \n " )
78+ replace(" <br>" , " \n " )
6579 .replace("  " , " " )
6680
6781private fun String.styledWith (style : String ) =
0 commit comments