Skip to content

Commit

Permalink
添加截取文章摘要(返回HTML)方法
Browse files Browse the repository at this point in the history
  • Loading branch information
zaoangod committed Oct 8, 2018
1 parent c596f35 commit 9151b8c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/main/java/com/tale/extension/Theme.java
Original file line number Diff line number Diff line change
Expand Up @@ -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("<!--more-->");
if (pos != -1) {
String html = value.substring(0, pos);
return TaleUtils.mdToHtml(html);
} else {
return TaleUtils.mdToHtml(value);
}
}

/**
* 截取文章摘要
*
Expand Down

0 comments on commit 9151b8c

Please sign in to comment.