mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-17 06:47:09 +01:00
Manually create anchors for headings
This commit is contained in:
parent
3e8db1a67b
commit
95d3d1fb85
8 changed files with 82 additions and 156 deletions
14
src/utils/slugger.ts
Normal file
14
src/utils/slugger.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Returns HTML element id and href link usable as manual anchor links
|
||||
// This is needed because Github in check run summary doesn't automatically
|
||||
// create links out of headings as it normally does for other markdown content
|
||||
export function slug(name: string): {id: string; link: string} {
|
||||
const slugId = name
|
||||
.trim()
|
||||
.replace(/_/g, '')
|
||||
.replace(/[./\\]/g, '-')
|
||||
.replace(/[^\w-]/g, '')
|
||||
|
||||
const id = `user-content-${slugId}`
|
||||
const link = `#${slugId}`
|
||||
return {id, link}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue