Skip to content

Commit

Permalink
fix: do not add target blank to urls that start with # in markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
ResuBaka committed Aug 11, 2022
1 parent e6b60fe commit 2ad0d63
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/histoire/src/node/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function createMarkdownRenderer () {
const hrefIndex = tokens[idx].attrIndex('href')
const classIndex = tokens[idx].attrIndex('class')

if (hrefIndex >= 0 && !tokens[idx].attrs[hrefIndex][1].startsWith('/') && (classIndex < 0 || !tokens[idx].attrs[classIndex][1].includes('header-anchor'))) {
if (hrefIndex >= 0 && !tokens[idx].attrs[hrefIndex][1].startsWith('/') && !tokens[idx].attrs[hrefIndex][1].startsWith('#') && (classIndex < 0 || !tokens[idx].attrs[classIndex][1].includes('header-anchor'))) {
// If you are sure other plugins can't add `target` - drop check below
const aIndex = tokens[idx].attrIndex('target')

Expand Down

0 comments on commit 2ad0d63

Please sign in to comment.