Skip to content

Commit f4f3e07

Browse files
authored
Remove .md before adding .html to links (#13)
1 parent 04f0d74 commit f4f3e07

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

mk_docs.py

Lines changed: 7 additions & 3 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,8 +28,12 @@ def md2html(md_file, html_file, file_name):
2828

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

3438
if (len(parts) > 1):
3539
a['href'] = a['href'] + '#' + parts[1]

0 commit comments

Comments
 (0)