Skip to content

Commit 6cd6068

Browse files
committed
Change overview generation script
1 parent df3bb09 commit 6cd6068

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

eng/pipelines/scripts/generate_overview_from_readme.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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 &amp; in the HTML content
65+
html_readme_content = html_readme_content.replace('&', '&amp;')
66+
# Replace &amp;amp; (double escaped) back to &amp;
67+
html_readme_content = html_readme_content.replace('&amp;amp;', '&amp;')
68+
# Restore entities that should remain as they are
69+
for entity in ['&amp;lt;', '&amp;gt;', '&amp;quot;', '&amp;apos;', '&amp;nbsp;']:
70+
html_readme_content = html_readme_content.replace(entity, entity.replace('&amp;', '&'))
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

Comments
 (0)