Skip to content

Commit

Permalink
feat(dgeni): render headings with slugified IDs (#2927)
Browse files Browse the repository at this point in the history
  • Loading branch information
griest024 authored Jul 22, 2024
1 parent 000bae0 commit e6d1b35
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/dgeni/src/processors/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import graphql from 'highlight.js/lib/languages/graphql';
import scss from 'highlight.js/lib/languages/scss';
import typescript from 'highlight.js/lib/languages/typescript';
import xml from 'highlight.js/lib/languages/xml';
import { slugify } from 'markdown-toc/lib/utils';
import { marked } from 'marked';
import { markedHighlight } from 'marked-highlight';

Expand Down Expand Up @@ -74,6 +75,10 @@ marked.use({
token.href = getLinkUrl(token.href);
}
},
renderer: {
heading: (text: string, level: number, raw: string) =>
`<h${level} id="${slugify(text)}">${text}</h${level}>`,
},
});

export class MarkdownCodeProcessor implements Processor {
Expand Down

0 comments on commit e6d1b35

Please sign in to comment.