make standard conform [fix]
Signed-off-by: hoijui <hoijui.quaero@gmail.com>
This commit is contained in:
		
							parent
							
								
									3233a448c6
								
							
						
					
					
						commit
						ad1a2fb19c
					
				@ -826,7 +826,6 @@ const anchorForId = id => {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const createHeaderId = (headerContent, headerIds = null) => {
 | 
					const createHeaderId = (headerContent, headerIds = null) => {
 | 
				
			||||||
 | 
					 | 
				
			||||||
  // to escape characters not allow in css and humanize
 | 
					  // to escape characters not allow in css and humanize
 | 
				
			||||||
  const slug = slugifyWithUTF8(headerContent)
 | 
					  const slug = slugifyWithUTF8(headerContent)
 | 
				
			||||||
  let id
 | 
					  let id
 | 
				
			||||||
@ -839,13 +838,13 @@ const createHeaderId = (headerContent, headerIds = null) => {
 | 
				
			|||||||
    // see GitHub implementation reference:
 | 
					    // see GitHub implementation reference:
 | 
				
			||||||
    // https://gist.github.com/asabaylus/3071099#gistcomment-1593627
 | 
					    // https://gist.github.com/asabaylus/3071099#gistcomment-1593627
 | 
				
			||||||
    // it works like 'lower-case', but ...
 | 
					    // it works like 'lower-case', but ...
 | 
				
			||||||
    const id_base = slug.toLowerCase()
 | 
					    const idBase = slug.toLowerCase()
 | 
				
			||||||
    id = id_base
 | 
					    id = idBase
 | 
				
			||||||
    if (headerIds !== null) {
 | 
					    if (headerIds !== null) {
 | 
				
			||||||
      // ... making sure the id is unique
 | 
					      // ... making sure the id is unique
 | 
				
			||||||
      let i = 1
 | 
					      let i = 1
 | 
				
			||||||
      while (headerIds.has(id)) {
 | 
					      while (headerIds.has(id)) {
 | 
				
			||||||
        id = id_base + '-' + i
 | 
					        id = idBase + '-' + i
 | 
				
			||||||
        i++
 | 
					        i++
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      headerIds.add(id)
 | 
					      headerIds.add(id)
 | 
				
			||||||
@ -890,7 +889,6 @@ function getHeaderContent (header) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function changeHeaderId ($header, id, newId) {
 | 
					function changeHeaderId ($header, id, newId) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
  $header.attr('id', newId)
 | 
					  $header.attr('id', newId)
 | 
				
			||||||
  const $headerLink = $header.find(`> a.anchor[href="#${id}"]`)
 | 
					  const $headerLink = $header.find(`> a.anchor[href="#${id}"]`)
 | 
				
			||||||
  $headerLink.attr('href', `#${newId}`)
 | 
					  $headerLink.attr('href', `#${newId}`)
 | 
				
			||||||
@ -898,11 +896,10 @@ function changeHeaderId ($header, id, newId) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function deduplicatedHeaderId (view) {
 | 
					export function deduplicatedHeaderId (view) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
  // headers contained in the last change
 | 
					  // headers contained in the last change
 | 
				
			||||||
  const headers = view.find(':header.raw').removeClass('raw').toArray()
 | 
					  const headers = view.find(':header.raw').removeClass('raw').toArray()
 | 
				
			||||||
  if (headers.length == 0) {
 | 
					  if (headers.length === 0) {
 | 
				
			||||||
    return;
 | 
					    return
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if (window.linkifyHeaderStyle === 'gfm') {
 | 
					  if (window.linkifyHeaderStyle === 'gfm') {
 | 
				
			||||||
    // consistent with GitHub, GitLab, Pandoc & co.
 | 
					    // consistent with GitHub, GitLab, Pandoc & co.
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user