Commit 0b33fb3c authored by alex yao's avatar alex yao

feat:内容导出-优化换行问题

parent e8ea5053
......@@ -22,6 +22,8 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author alex.yao
......@@ -59,9 +61,13 @@ public class ContentReportRestImpl implements ContentReportRest {
}
private String convertMarkdownToHtml(String markdown) {
Pattern p = Pattern.compile("(\r?\n(\\s*\r?\n)+)");
Matcher m = p.matcher(markdown);
String result = m.replaceAll("\r\n");
Parser parser = Parser.builder().build();
HtmlRenderer renderer = HtmlRenderer.builder().build();
Document document = parser.parse(markdown);
Document document = parser.parse(result);
return renderer.render(document);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment