Skip to content
Permalink
Browse files

Restore doctype in header permalinks/deduplicate IDs filters

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information...
Kwpolska committed Aug 9, 2017
1 parent 84b0c62 commit c5d3e3fac5806668d26c3e0626ec8bda5dd16639
Showing with 6 additions and 4 deletions.
  1. +2 −0 CHANGES.txt
  2. +4 −4 nikola/filters.py
@@ -24,6 +24,8 @@ Features
Bugfixes
--------

* Do not remove doctype if ``add_header_permalinks`` or
``deduplicate_ids`` are used
* Handle empty slug metadata (Issue #2887)
* Fix crash when compiling empty ``.html`` posts (Issue #2851)
* Make failures to get source commit hash non-fatal in
@@ -156,7 +156,7 @@ def yui_compressor(infile, executable=None):
try:
subprocess.call('yuicompressor', stdout=open(os.devnull, 'w'), stderr=open(os.devnull, 'w'))
yuicompressor = 'yuicompressor'
except:
except Exception:
raise Exception("yui-compressor is not installed.")
return False

@@ -394,7 +394,7 @@ def _normalize_html(data):
"""Pass HTML through LXML to clean it up, if possible."""
try:
data = lxml.html.tostring(lxml.html.fromstring(data), encoding='unicode')
except:
except Exception:
pass
return '<!DOCTYPE html>\n' + data

@@ -446,7 +446,7 @@ def add_header_permalinks(fname, xpath_list=None, file_blacklist=None):
node.append(new_node)

with io.open(fname, 'w', encoding='utf-8') as outf:
outf.write(lxml.html.tostring(doc, encoding="unicode"))
outf.write('<!DOCTYPE html>\n' + lxml.html.tostring(doc, encoding="unicode"))


@_ConfigurableFilter(top_classes='DEDUPLICATE_IDS_TOP_CLASSES')
@@ -496,6 +496,6 @@ def deduplicate_ids(data, top_classes=None):
if hl.attrib['href'] == '#' + i:
hl.attrib['href'] = '#' + new_id
break
return lxml.html.tostring(doc, encoding='unicode')
return '<!DOCTYPE html>\n' + lxml.html.tostring(doc, encoding='unicode')
else:
return data

0 comments on commit c5d3e3f

Please sign in to comment.
You can’t perform that action at this time.