Commit 8e5d13e4 authored by Liang Ding's avatar Liang Ding

🎨 更新目录生成以适配 Lute 引擎

parent 6b541d26
...@@ -77,7 +77,7 @@ public class ToCPlugin extends NotInteractivePlugin { ...@@ -77,7 +77,7 @@ public class ToCPlugin extends NotInteractivePlugin {
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://www.annpeter.cn">Ann Peter</a> * @author <a href="http://www.annpeter.cn">Ann Peter</a>
* @author <a href="http://vanessa.b3log.org">Vanessa</a> * @author <a href="http://vanessa.b3log.org">Vanessa</a>
* @version 2.0.0.1, Jan 24, 2020 * @version 2.0.0.2, Mar 4, 2020
* @since 0.6.7 * @since 0.6.7
*/ */
class ToCEventHandler extends AbstractEventListener<JSONObject> { class ToCEventHandler extends AbstractEventListener<JSONObject> {
...@@ -101,7 +101,12 @@ class ToCEventHandler extends AbstractEventListener<JSONObject> { ...@@ -101,7 +101,12 @@ class ToCEventHandler extends AbstractEventListener<JSONObject> {
final Element element = hs.get(i); final Element element = hs.get(i);
final String tagName = element.tagName().toLowerCase(); final String tagName = element.tagName().toLowerCase();
final String text = element.text(); final String text = element.text();
final String id = "toc_" + tagName + "_" + i; String id = element.attr("id");
if (StringUtils.isBlank(id)) {
id = "toc_" + tagName + "_" + i;
} else if (StringUtils.startsWith(id, "#")) {
id = StringUtils.substringAfter(id, "#");
}
element.attr("id", id); element.attr("id", id);
final JSONObject li = new JSONObject(). final JSONObject li = new JSONObject().
put("className", "toc__" + tagName). put("className", "toc__" + tagName).
......
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