15
15
# will be written to overview file. If there is a readme, its contents will be added after that.
16
16
17
17
import argparse
18
+ import html
18
19
from bs4 import BeautifulSoup
19
20
import pdb
20
21
import markdown2
@@ -43,12 +44,17 @@ def generate_overview(readme_file, version, overview_file_path):
43
44
if (readme_exists ):
44
45
with open (readme_file , 'r' , encoding = 'utf-8' ) as f :
45
46
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
+
47
53
# Before passing the README contents to markdown2 clean out the codesnippet tags on the java code fences.
48
54
# 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.
50
56
cleaned_readme_content_lines = []
51
- for line in raw_readme_content_lines :
57
+ for line in escaped_readme_content_lines :
52
58
cleaned_readme_content_lines .append (re .sub (pattern = "``` *java +[a-zA-Z0-9.#\-_]*" , repl = "```java" , string = line , flags = re .UNICODE ))
53
59
54
60
readme_content = '' .join (cleaned_readme_content_lines )
@@ -107,4 +113,4 @@ def main():
107
113
raise ValueError ('{} is not a readmefile. The --readme-file argument must be a readme.md file.' .format (args .readme_file ))
108
114
109
115
if __name__ == '__main__' :
110
- main ()
116
+ main ()
0 commit comments