mirror of https://github.com/status-im/codimd.git
Allow to generate lower case header references through the config (#1305)
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>
This commit is contained in:
parent
9e4d07926a
commit
34c2bfcfc5
|
@ -127,6 +127,7 @@
|
|||
"plantuml":
|
||||
{
|
||||
"server": "https://www.plantuml.com/plantuml"
|
||||
}
|
||||
},
|
||||
"linkifyHeaderStyle": "gfm"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,5 +162,6 @@ module.exports = {
|
|||
allowEmailRegister: true,
|
||||
allowGravatar: true,
|
||||
allowPDFExport: true,
|
||||
openID: false
|
||||
openID: false,
|
||||
linkifyHeaderStyle: 'keep-case'
|
||||
}
|
||||
|
|
|
@ -99,7 +99,8 @@ statusRouter.get('/config', function (req, res) {
|
|||
version: config.fullversion,
|
||||
plantumlServer: config.plantuml.server,
|
||||
DROPBOX_APP_KEY: config.dropbox.appKey,
|
||||
allowedUploadMimeTypes: config.allowedUploadMimeTypes
|
||||
allowedUploadMimeTypes: config.allowedUploadMimeTypes,
|
||||
linkifyHeaderStyle: config.linkifyHeaderStyle
|
||||
}
|
||||
res.set({
|
||||
'Cache-Control': 'private', // only cache by client
|
||||
|
|
|
@ -867,7 +867,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))
|
||||
var 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 === '')) {
|
||||
|
|
|
@ -6,4 +6,6 @@ window.plantumlServer = '<%- plantumlServer %>'
|
|||
|
||||
window.allowedUploadMimeTypes = <%- JSON.stringify(allowedUploadMimeTypes) %>
|
||||
|
||||
window.linkifyHeaderStyle = <%- JSON.stringify(linkifyHeaderStyle) %>
|
||||
|
||||
window.DROPBOX_APP_KEY = '<%- DROPBOX_APP_KEY %>'
|
||||
|
|
Loading…
Reference in New Issue