@@ -52,7 +52,7 @@ def generate_overview(readme_file, version, overview_file_path):
5252 cleaned_readme_content_lines .append (re .sub (pattern = "``` *java +[a-zA-Z0-9.#\-_]*" , repl = "```java" , string = line , flags = re .UNICODE ))
5353
5454 readme_content = '' .join (cleaned_readme_content_lines )
55- readme_content = re .sub (pattern = '\\ B&\\ B' , repl = '&' , string = readme_content , flags = re .UNICODE )
55+ # readme_content = re.sub(pattern='\\B&\\B', repl='&', string=readme_content, flags=re.UNICODE)
5656
5757 # markdown2.markdown will create html from the readme.md file. The fenced-code-blocks
5858 # extras being passed into the markdown call is necessary to deal with the embedded
@@ -61,6 +61,14 @@ def generate_overview(readme_file, version, overview_file_path):
6161 # The toc helps the anchor link to jump to the right place.
6262 html_readme_content = markdown2 .markdown (re .sub (pattern = '(?<!opencode)@' , repl = '{@literal @}' , string = readme_content , flags = re .MULTILINE | re .UNICODE ), extras = ["fenced-code-blocks" , "target-blank-links" , "toc" ])
6363
64+ # Replace all instances of & with & in the HTML content
65+ html_readme_content = html_readme_content .replace ('&' , '&' )
66+ # Replace &amp; (double escaped) back to &
67+ html_readme_content = html_readme_content .replace ('&amp;' , '&' )
68+ # Restore entities that should remain as they are
69+ for entity in ['&lt;' , '&gt;' , '&quot;' , '&apos;' , '&nbsp;' ]:
70+ html_readme_content = html_readme_content .replace (entity , entity .replace ('&' , '&' ))
71+
6472 # Now use BeautifulSoup to cleanup the generated HTML so that it conforms to Javadoc compliance.
6573 soup = BeautifulSoup (html_readme_content , features = "html.parser" )
6674
0 commit comments