summaryrefslogtreecommitdiff
path: root/public/js
diff options
context:
space:
mode:
authorhoijui2019-10-21 22:10:06 +0200
committerhoijui2019-10-22 09:05:37 +0200
commite654ca8a3130108a6616131e35524d8f50d80ed0 (patch)
treee3e54724c3c55a5ce79e33482f09201e62b31a73 /public/js
parent20adab2f32a785c2dedcd42ee8e0750039fd9dd9 (diff)
Allow to generate lower case header references through the config
This makes the references consistent/compatible with GitHub, GitLab, Pandoc and many other tools. This behavior can be enabled in config.json with: ``` "linkifyHeaderStyle": "gfm" ``` Signed-off-by: hoijui <hoijui.quaero@gmail.com>
Diffstat (limited to 'public/js')
-rw-r--r--public/js/extra.js6
-rw-r--r--public/js/lib/common/constant.ejs2
2 files changed, 7 insertions, 1 deletions
diff --git a/public/js/extra.js b/public/js/extra.js
index 91984c2c..d381576f 100644
--- a/public/js/extra.js
+++ b/public/js/extra.js
@@ -833,7 +833,11 @@ const linkifyAnchors = (level, containingElement) => {
if (header.getElementsByClassName('anchor').length === 0) {
if (typeof header.id === 'undefined' || header.id === '') {
// to escape characters not allow in css and humanize
- const id = slugifyWithUTF8(getHeaderContent(header))
+ let id = slugifyWithUTF8(getHeaderContent(header))
+ // to make compatible with GitHub, GitLab, Pandoc and many more
+ if (window.linkifyHeaderStyle !== 'keep-case') {
+ id = id.toLowerCase()
+ }
header.id = id
}
if (!(typeof header.id === 'undefined' || header.id === '')) {
diff --git a/public/js/lib/common/constant.ejs b/public/js/lib/common/constant.ejs
index a94b815e..bbcb8c7a 100644
--- a/public/js/lib/common/constant.ejs
+++ b/public/js/lib/common/constant.ejs
@@ -5,4 +5,6 @@ window.version = '<%- version %>'
window.allowedUploadMimeTypes = <%- JSON.stringify(allowedUploadMimeTypes) %>
+window.linkifyHeaderStyle = <%- JSON.stringify(linkifyHeaderStyle) %>
+
window.DROPBOX_APP_KEY = '<%- DROPBOX_APP_KEY %>'