Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #459 from zaoangod/develop
Browse files Browse the repository at this point in the history
✨ add intro method
  • Loading branch information
hellokaton authored Oct 8, 2018
2 parents f1bf247 + 9151b8c commit ce00746
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 ce00746

Please sign in to comment.