mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 19:06:18 +01:00 
			
		
		
		
	Prefix all user-generated IDs in markup (#9477)
* Prefix all user-generated IDs in markup * Add user-content- to IDs in unit-tests * fixup markdown_test.go * update the hrefs for the wiki test * Add blackfriday extension regex Signed-off-by: jolheiser <john.olheiser@gmail.com>
This commit is contained in:
		| @@ -2472,21 +2472,10 @@ $(document).ready(() => { | ||||
|  | ||||
|   // Set anchor. | ||||
|   $('.markdown').each(function () { | ||||
|     const headers = {}; | ||||
|     $(this).find('h1, h2, h3, h4, h5, h6').each(function () { | ||||
|       let node = $(this); | ||||
|       const val = encodeURIComponent(node.text().toLowerCase().replace(/[^\u00C0-\u1FFF\u2C00-\uD7FF\w\- ]/g, '').replace(/[ ]/g, '-')); | ||||
|       let name = val; | ||||
|       if (headers[val] > 0) { | ||||
|         name = `${val}-${headers[val]}`; | ||||
|       } | ||||
|       if (headers[val] === undefined) { | ||||
|         headers[val] = 1; | ||||
|       } else { | ||||
|         headers[val] += 1; | ||||
|       } | ||||
|       node = node.wrap(`<div id="${name}" class="anchor-wrap" ></div>`); | ||||
|       node.append(`<a class="anchor" href="#${name}"><span class="octicon octicon-link"></span></a>`); | ||||
|       node = node.wrap('<div class="anchor-wrap"></div>'); | ||||
|       node.append(`<a class="anchor" href="#${encodeURIComponent(node.attr('id'))}"><span class="octicon octicon-link"></span></a>`); | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user