Skip to content

The Unified and Autonomous Development Platform

Fix the issue that some markdown header can not be rendered with anchor

robin shine6bf368a5b27d
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/component/markdownviewer/markdown-viewer.js b/commons.wicket/src/main/java/com/pmease/commons/wicket/component/markdownviewer/markdown-viewer.js
index 485b002c95..4f5d0c3bad 100644
--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/component/markdownviewer/markdown-viewer.js
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/component/markdownviewer/markdown-viewer.js
@@ -16,6 +16,10 @@ pmease.commons.initMarkdownViewer = function($preview, taskCallback) {
$this.addClass("anchored-h").append($anchor.html());
$anchor.empty();
$this.prepend("<a href='#" + $anchor.attr("name") + "' class='anchor'><i class='fa fa-link'></i></a>");
+ } else {
+ var anchorName = encodeURIComponent($this.text());
+ $this.addClass("anchored-h").prepend("<a name='" + anchorName + "'></a>");
+ $this.prepend("<a href='#" + anchorName + "' class='anchor'><i class='fa fa-link'></i></a>");
}
});
}
\ No newline at end of file