1212 "Web application deployment" : "web_app_deploy.md" ,
1313 "Citation" : "citation.md" ,
1414 "Credits and acknowledgements" : "credits.md" ,
15+ "Contact and feedback" : "contact.md" ,
1516}
1617
1718
@@ -66,6 +67,22 @@ def decrease_header_levels(content):
6667 return "\n " .join (new_lines )
6768
6869
70+ def clean_trailing_links (content ):
71+ """Remove trailing links and clean up extra empty lines."""
72+ # Remove [label]: link style
73+ content = re .sub (r"^\[.+?\]:\s+\S+$" , "" , content , flags = re .MULTILINE )
74+ # Remove (url): url style
75+ content = re .sub (
76+ r"^\(https?://[^\s)]+\):\s*https?://[^\s)]+$" , "" , content , flags = re .MULTILINE
77+ )
78+ content = re .sub (
79+ r"^\(mailto:[^\s)]+\):\s*mailto:[^\s)]+$" , "" , content , flags = re .MULTILINE
80+ )
81+ # Remove empty lines
82+ content = re .sub (r"\n{2,}" , "\n \n " , content ).strip ()
83+ return content
84+
85+
6986def process_readme (readme_path , output_dir ):
7087 readme = Path (readme_path ).read_text ()
7188
@@ -81,12 +98,32 @@ def process_readme(readme_path, output_dir):
8198 myst_content = (
8299 f"## { section_title } \n \n { convert_gfm_to_sphinx (content , links )} "
83100 )
101+ if filename .lower () == "contact.md" :
102+ myst_content = clean_trailing_links (myst_content )
84103 myst_content = decrease_header_levels (myst_content )
85104 (output_dir / filename ).write_text (myst_content )
86105 print (f"Generated { filename } " )
87106 else :
88107 print (f"Warning: Section '{ section_title } ' not found in README" )
89108
109+ # Include CONTRIBUTING.md with its own link references
110+ contrib_path = readme_path .parent / "CONTRIBUTING.md"
111+ if contrib_path .exists ():
112+ raw_contrib = contrib_path .read_text ()
113+ contrib_links = extract_links_from_readme (raw_contrib )
114+
115+ # Convert content
116+ contrib_converted = convert_gfm_to_sphinx (raw_contrib , contrib_links )
117+
118+ # Remove trailing link definitions
119+ contrib_converted = clean_trailing_links (contrib_converted )
120+
121+ # Write output
122+ (output_dir / "contributing.md" ).write_text (contrib_converted )
123+ print ("Generated contributing.md" )
124+ else :
125+ print ("Warning: CONTRIBUTING.md not found" )
126+
90127
91128if __name__ == "__main__" :
92129 default_readme = Path (__file__ ).resolve ().parent .parent / "README.md"
0 commit comments