diff --git a/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt b/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt index fddf3582a..0922e7e79 100644 --- a/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt +++ b/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt @@ -4,6 +4,7 @@ import org.commonmark.parser.Parser import org.commonmark.renderer.html.HtmlRenderer import org.jsoup.Jsoup import org.springframework.stereotype.Service +import java.io.File @Service class ConvertDocumentService { @@ -17,7 +18,27 @@ class ConvertDocumentService { fun mdToHtml(md: String): String { val html = Jsoup.parse(ARTICLE) val article = htmlRenderer.render(parser.parse(md)) - html.body().append(article) - return html.toString() + html.getElementsByTag("article").append(article) + html.getElementsByTag("h1").forEach { + it.addClass("sub1-semibold") + } + html.getElementsByTag("h2").forEach { + it.addClass("sub1-semibold top bottom 5px") + } + html.getElementsByTag("h3").forEach { + it.addClass("sub1-semibold") + } + html.getElementsByTag("img").forEach { + it.addClass("!max-h-[260px] object-contain") + } + return html.body().html() } +} + +fun main() { + val convertDocumentService = ConvertDocumentService() + val file = + File("/Users/jongjun/Documents/Code/Spring/24th-Web-Team-1-BE/storage/src/main/resources/test.md") + val md = file.readText() + println(convertDocumentService.mdToHtml(md)) } \ No newline at end of file