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>
This commit is contained in:
		
							parent
							
								
									20adab2f32
								
							
						
					
					
						commit
						e654ca8a31
					
				@ -123,6 +123,7 @@
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
          "connectionString": "change this",
 | 
					          "connectionString": "change this",
 | 
				
			||||||
          "container": "change this"
 | 
					          "container": "change this"
 | 
				
			||||||
        }
 | 
					        },
 | 
				
			||||||
 | 
					        "linkifyHeaderStyle": "gfm"
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -157,5 +157,6 @@ module.exports = {
 | 
				
			|||||||
  allowEmailRegister: true,
 | 
					  allowEmailRegister: true,
 | 
				
			||||||
  allowGravatar: true,
 | 
					  allowGravatar: true,
 | 
				
			||||||
  allowPDFExport: true,
 | 
					  allowPDFExport: true,
 | 
				
			||||||
  openID: false
 | 
					  openID: false,
 | 
				
			||||||
 | 
					  linkifyHeaderStyle: 'keep-case'
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -96,7 +96,8 @@ statusRouter.get('/config', function (req, res) {
 | 
				
			|||||||
    debug: config.debug,
 | 
					    debug: config.debug,
 | 
				
			||||||
    version: config.fullversion,
 | 
					    version: config.fullversion,
 | 
				
			||||||
    DROPBOX_APP_KEY: config.dropbox.appKey,
 | 
					    DROPBOX_APP_KEY: config.dropbox.appKey,
 | 
				
			||||||
    allowedUploadMimeTypes: config.allowedUploadMimeTypes
 | 
					    allowedUploadMimeTypes: config.allowedUploadMimeTypes,
 | 
				
			||||||
 | 
					    linkifyHeaderStyle: config.linkifyHeaderStyle
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  res.set({
 | 
					  res.set({
 | 
				
			||||||
    'Cache-Control': 'private', // only cache by client
 | 
					    'Cache-Control': 'private', // only cache by client
 | 
				
			||||||
 | 
				
			|||||||
@ -833,7 +833,11 @@ const linkifyAnchors = (level, containingElement) => {
 | 
				
			|||||||
    if (header.getElementsByClassName('anchor').length === 0) {
 | 
					    if (header.getElementsByClassName('anchor').length === 0) {
 | 
				
			||||||
      if (typeof header.id === 'undefined' || header.id === '') {
 | 
					      if (typeof header.id === 'undefined' || header.id === '') {
 | 
				
			||||||
        // to escape characters not allow in css and humanize
 | 
					        // 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
 | 
					        header.id = id
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      if (!(typeof header.id === 'undefined' || header.id === '')) {
 | 
					      if (!(typeof header.id === 'undefined' || header.id === '')) {
 | 
				
			||||||
 | 
				
			|||||||
@ -5,4 +5,6 @@ window.version = '<%- version %>'
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
window.allowedUploadMimeTypes = <%- JSON.stringify(allowedUploadMimeTypes) %>
 | 
					window.allowedUploadMimeTypes = <%- JSON.stringify(allowedUploadMimeTypes) %>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					window.linkifyHeaderStyle = <%- JSON.stringify(linkifyHeaderStyle) %>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
window.DROPBOX_APP_KEY = '<%- DROPBOX_APP_KEY %>'
 | 
					window.DROPBOX_APP_KEY = '<%- DROPBOX_APP_KEY %>'
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user