Skip to content

Commit

Permalink
Merge pull request #120 from DEPthes/develop
Browse files Browse the repository at this point in the history
V.4.2.4 Deploy && [FIX]: 게시글 미리보기 개행 적용
  • Loading branch information
phonil authored Aug 21, 2024
2 parents f9b2ec9 + f884e3c commit 2d45dd0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/main/java/mvp/deplog/infrastructure/markdown/MarkdownUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ public static String extractPlainText(String markdown) {
return text.isEmpty() ? EMPTY_STRING : text;
}

// Markdown -> (Html) -> WholeText (개행 포함)
public static String extractPlainWholeText(String markdown) {
String html = markdownToHtml(markdown);
Document document = Jsoup.parse(html);
document.outputSettings(new Document.OutputSettings().prettyPrint(false)); // this will preserve whitespace and newlines
String text = document.body().wholeText();
return text.isEmpty() ? EMPTY_STRING : text;
}


// Markdown -> (Html) -> ImageUrl list
public static List<String> extractImageLinks(String markdown) {
String html = markdownToHtml(markdown);
Expand All @@ -37,11 +47,11 @@ public static List<String> extractImageLinks(String markdown) {
}

// Markdown -> (Html) -> Text -> Preview Content
public static String extractPreviewContent(String content) {
if (content == null || content.isEmpty())
public static String extractPreviewContent(String markdown) {
if (markdown == null || markdown.isEmpty())
return EMPTY_STRING;

String plainText = extractPlainText(content);
String plainText = extractPlainWholeText(markdown);
if (plainText.length() > 100)
return plainText.substring(0, 100);
else
Expand Down

0 comments on commit 2d45dd0

Please sign in to comment.