diff --git a/src/main/java/com/tale/extension/Theme.java b/src/main/java/com/tale/extension/Theme.java index 0e3568b6..426ab6c7 100644 --- a/src/main/java/com/tale/extension/Theme.java +++ b/src/main/java/com/tale/extension/Theme.java @@ -283,6 +283,25 @@ public static String intro(int len) { return ""; } + /** + * 截取文章摘要(返回HTML) + * + * @param value 文章内容 + * @return 转换 markdown 为 html + */ + public static String intro(String value) { + if (StringKit.isBlank(value)) { + return null; + } + int pos = value.indexOf(""); + if (pos != -1) { + String html = value.substring(0, pos); + return TaleUtils.mdToHtml(html); + } else { + return TaleUtils.mdToHtml(value); + } + } + /** * 截取文章摘要 *