File tree Expand file tree Collapse file tree
src/main/kotlin/com/wafflestudio/team8server/syncwithsite/service Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,17 +29,21 @@ class SyncWithSiteService(
2929 companion object {
3030 private const val SUGANG_URL = " https://sugang.snu.ac.kr/sugang/co/co010.action"
3131 private const val TIMEOUT_MS = 15_000
32- private const val NL_MARKER = " \u0000 NL\u0000 "
3332 }
3433
3534 private fun textWithBr (elements : Elements ): String {
3635 if (elements.isEmpty()) return " "
37- return elements
38- .joinToString(" " ) { elem ->
36+ val raw =
37+ elements .joinToString(" \n " ) { elem ->
3938 val clone = elem.clone()
40- clone.select(" br" ).forEach { it.replaceWith(TextNode (NL_MARKER )) }
41- clone.text()
42- }.replace(NL_MARKER , " \n " )
39+ clone.select(" br" ).forEach { it.replaceWith(TextNode (" \n " )) }
40+ clone.wholeText()
41+ }
42+ return raw
43+ .replace(" \r\n " , " \n " )
44+ .replace(Regex (" \\ n[ \\ t]+" ), " " )
45+ .replace(Regex (" [ \\ t]+\\ n" ), " \n " )
46+ .replace(Regex (" \\ n{2,}" ), " \n " )
4347 .trim()
4448 }
4549
You can’t perform that action at this time.
0 commit comments