Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
TaEduard authored Aug 10, 2023
1 parent 82ffa36 commit 9d8e0cb
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@

load_dotenv()

def escape_markdown_content(md_content: str) -> str:
escape_mappings = {
"&": "&",
"<": "&lt;",
">": "&gt;",
}
for char, escape_sequence in escape_mappings.items():
md_content = md_content.replace(char, escape_sequence)
return md_content


workspace = environ.get('GITHUB_WORKSPACE')
if not workspace:
print('No workspace is set')
Expand All @@ -29,7 +40,11 @@

current = requests.get(url, auth=(envs['user'], envs['token'])).json()

html = markdown(md, extensions=[GithubFlavoredMarkdownExtension()])
# Escape the markdown content before converting it
escaped_md = escape_markdown_content(md)

html = markdown(escaped_md, extensions=[GithubFlavoredMarkdownExtension()])

content = {
'id': current['id'],
'type': current['type'],
Expand Down

0 comments on commit 9d8e0cb

Please sign in to comment.