Skip to content

Commit

Permalink
πŸ› #1347 handle .md#anchor type links
Browse files Browse the repository at this point in the history
  • Loading branch information
yzhang-gh committed Nov 8, 2023
1 parent 666e2b1 commit 04ca329
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/print.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ async function print(type: string, uri?: Uri, outFolder?: string) {
});
}

//// Convert `.md` links to `.html` by default (#667)
//// Convert `.md` links to `.html` by default (#667, #1324, #1347)
const hrefRegex = /(<a[^>]+href=")([^"]+)("[^>]*>)/g; // Match '<a...href="..."...>'
body = body.replace(hrefRegex, function (_, g1, g2, g3) {
if (g2.endsWith('.md') && !(g2.includes('github.com') && g2.includes('blob'))) {
if ((g2.endsWith('.md') || g2.includes('.md#')) && !(g2.includes('github.com') && g2.includes('blob'))) {
return `${g1}${g2.replace(/\.md$/, '.html')}${g3}`;
} else {
return _;
Expand Down

0 comments on commit 04ca329

Please sign in to comment.