Skip to content

Commit 9b3971a

Browse files
committed
Remove .md before adding .html to links
1 parent 66b5d5d commit 9b3971a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mk_docs.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /bin/python3
1+
#!/bin/python3
22

33
import markdown
44
import glob
@@ -28,7 +28,11 @@ def md2html(md_file, html_file, file_name):
2828

2929
if not a['href'].startswith(('http://', 'https://', '#')):
3030
if not a['href'].endswith(('html')):
31-
a['href'] = a['href']+".html"
31+
href = a['href']
32+
# Handle case when href is a link to another markdown file (commonly used in repositories).
33+
if href.endswith('.md'):
34+
href = href[:-3]
35+
a['href'] = href + '.html'
3236

3337
if (str(a['href']).find(":") > 0):
3438
a['href'] = a['href'].replace(":", "/")

0 commit comments

Comments
 (0)