1515# will be written to overview file. If there is a readme, its contents will be added after that.
1616
1717import argparse
18+ import html
1819from bs4 import BeautifulSoup
1920import pdb
2021import markdown2
@@ -43,12 +44,17 @@ def generate_overview(readme_file, version, overview_file_path):
4344 if (readme_exists ):
4445 with open (readme_file , 'r' , encoding = 'utf-8' ) as f :
4546 raw_readme_content_lines = f .readlines ()
46-
47+
48+ # Replace all instances of & with & in the raw readme content
49+ escaped_readme_content_lines = []
50+ for line in raw_readme_content_lines :
51+ escaped_readme_content_lines .append (html .escape (line , quote = True ))
52+
4753 # Before passing the README contents to markdown2 clean out the codesnippet tags on the java code fences.
4854 # Clean ```java com.azure.core.aCodeSnippetTag to ```java, without doing this markdown2 won't properly process
49- # the contents of the code fence.
55+ # the contents of the code fence.
5056 cleaned_readme_content_lines = []
51- for line in raw_readme_content_lines :
57+ for line in escaped_readme_content_lines :
5258 cleaned_readme_content_lines .append (re .sub (pattern = "``` *java +[a-zA-Z0-9.#\-_]*" , repl = "```java" , string = line , flags = re .UNICODE ))
5359
5460 readme_content = '' .join (cleaned_readme_content_lines )
@@ -107,4 +113,4 @@ def main():
107113 raise ValueError ('{} is not a readmefile. The --readme-file argument must be a readme.md file.' .format (args .readme_file ))
108114
109115if __name__ == '__main__' :
110- main ()
116+ main ()
0 commit comments