Skip to content

Commit

Permalink
Issue 2075 - Close head tag after meta tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
kzar committed Mar 8, 2015
1 parent 8a5167b commit 1d82f9b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions convert.py
Expand Up @@ -232,6 +232,14 @@ def translate_tag(match):
text = re.sub(r"\$([\w\-]+)\((.*?)\)\$", lambda match: translate_tag(match), text)
return text

def move_meta_tags(head, body):
if not head:
return head, body
else:
meta_tag_regexp = r"\s{0,1}<meta\b[^>]*>\s"
head += "".join(re.findall(meta_tag_regexp, body, re.I + re.S))
return head, re.sub(meta_tag_regexp, "", body)

def process_page(path, menu):
pagename = os.path.join(os.path.dirname(path), os.path.basename(path).replace("page!", ""))
if "/" not in pagename:
Expand Down Expand Up @@ -275,6 +283,7 @@ def process_page(path, menu):

body = xml_to_text(bodies["en"])
head = xml_to_text(get_element(data["en"].documentElement, "head", "anwv"))
head, body = move_meta_tags(head, body)
if head:
pagedata = "<head>%s</head>%s" % (h.unescape(head), body)
else:
Expand Down

0 comments on commit 1d82f9b

Please sign in to comment.