Index: src/caterpillar.py |
diff --git a/src/caterpillar.py b/src/caterpillar.py |
index 603a52f4d68b77576c2cc00d89020cf5e87066a8..540557ffda774639b5d03259c979efaaac800719 100755 |
--- a/src/caterpillar.py |
+++ b/src/caterpillar.py |
@@ -280,22 +280,24 @@ def inject_misc_tags(soup, ca_manifest, root_path, html_path): |
This can be either absolute or relative. |
html_path: Path to the HTML document being modified. |
""" |
+ target_tag = soup.head if soup.head else soup |
Matt Giuca
2016/01/28 06:56:25
Maybe this should create a head tag, instead of ju
Matthew Alger
2016/01/28 23:08:43
Good idea - done.
|
+ |
# Add manifest link tag. |
manifest_path = os.path.join(root_path, PWA_MANIFEST_FILENAME) |
manifest_link = soup.new_tag('link', rel='manifest', href=manifest_path) |
- soup.head.append(manifest_link) |
+ target_tag.append(manifest_link) |
# Add meta tags (if they don't already exist). |
for tag in ('description', 'author', 'name'): |
if tag in ca_manifest and not soup('meta', {'name': tag}): |
meta = soup.new_tag('meta', content=ca_manifest[tag]) |
meta['name'] = tag |
- soup.head.append(meta) |
+ target_tag.append(meta) |
logging.debug('Injected `%s` tag into `%s` with content `%s`.', tag, |
html_path, ca_manifest[tag]) |
if not soup('meta', {'charset': True}): |
meta_charset = soup.new_tag('meta', charset='utf-8') |
- soup.head.insert(0, meta_charset) |
+ target_tag.insert(0, meta_charset) |
def insert_todos_into_file(js_path): |