Skip to content

Commit 79e7f9f

Browse files
committed
fix(guide): improve anchor result matching
1 parent d6a0cb1 commit 79e7f9f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/util/discordDocs.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,15 @@ export function parseSections(content: string): ParsedSection[] {
127127
return res;
128128
}
129129

130+
function formatAnchor(text: string) {
131+
return `#${text.toLowerCase().replaceAll(' ', '-').replaceAll(/[:'.]/gi, '')}`;
132+
}
133+
130134
export function findRelevantDocsSection(query: string, docsMd: string, defaultFirst = false) {
131135
const sections = parseSections(docsMd);
132136

133137
for (const section of sections) {
134-
const anchor = `#${section.headline.toLowerCase().replaceAll(' ', '-').replaceAll(':', '')}`;
138+
const anchor = formatAnchor(section.headline);
135139

136140
if (anchor === query) {
137141
return section;

0 commit comments

Comments
 (0)