Skip to content

Commit

Permalink
Fix unescaped "<" and ">" in code examples
Browse files Browse the repository at this point in the history
  • Loading branch information
reima committed Oct 4, 2015
1 parent a48d3d8 commit 0720d63
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,12 @@ def replace_alias(matchobj):

return "<a href='../" + version_dir + r"/" + command + "'>" + alias + "</a>"

code = re.sub(r"\{%([a-zA-Z_][a-zA-Z_0-9]*?)\}", replace_alias, code).replace("\t", " ").replace("&", "&amp;")
code = code.replace("\t", " ")
code = code.replace("&", "&amp;")
code = code.replace("<", "&lt;")
code = code.replace(">", "&gt;")

code = re.sub(r"\{%([a-zA-Z_][a-zA-Z_0-9]*?)\}", replace_alias, code)

code = re.sub(r"(?<![a-zA-Z0-9_])(auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while|size_t|NULL|GLbyte|GLshort|GLint|GLsizei|GLfloat|GLclampf|GLdouble|GLclampd|GLubyte|GLboolean|GLushort|GLuint|GLenum|GLbitfield|GLchar)(?![a-zA-Z0-9_])", r"<span class='ckeyword'>\1</span>", code)
code = re.sub(r"(GL_[A-Z_0-9]*)", r"<span class='constant'>\1</span>", code)
Expand Down

0 comments on commit 0720d63

Please sign in to comment.