File tree 4 files changed +23
-1
lines changed
4 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ New in master
3
3
4
4
Features
5
5
--------
6
+
7
+ * New normalize_html filter
6
8
* Support UTF-8 paths and encoded links when the ``USE_SLUGIFY`` option
7
9
is disabled. (Issue #2037)
8
10
* Per-document hyphenation using "hyphenate" metadata flag.
@@ -17,6 +19,7 @@ Features
17
19
Bugfixes
18
20
--------
19
21
22
+ * Make typogrify filter work when applied from metadata (Issue #2064)
20
23
* Handle metadata in post files that start with a BOM (Issue #2059)
21
24
* Handle error downloading bootswatches (Issue #2054)
22
25
* Monitor plugins/ in ``nikola auto`` (Issue #2044)
Original file line number Diff line number Diff line change @@ -1351,6 +1351,10 @@ typogrify_sans_widont
1351
1351
minify_lines
1352
1352
**THIS FILTER HAS BEEN TURNED INTO A NOOP** and currently does nothing.
1353
1353
1354
+ normalize_html
1355
+ Pass HTML through LXML to normalize it. For example, it will resolve ``"`` to actual
1356
+ quotes. Usually not needed.
1357
+
1354
1358
yui_compressor
1355
1359
Compress CSS/JavaScript using `YUI compressor <http://yui.github.io/yuicompressor/>`_
1356
1360
Original file line number Diff line number Diff line change 34
34
import tempfile
35
35
import shlex
36
36
37
+ import lxml
37
38
try :
38
39
import typogrify .filters as typo
39
40
except ImportError :
@@ -236,6 +237,7 @@ def typogrify(data):
236
237
if typo is None :
237
238
req_missing (['typogrify' ], 'use the typogrify filter' )
238
239
240
+ data = _normalize_html (data )
239
241
data = typo .amp (data )
240
242
data = typo .widont (data )
241
243
data = typo .smartypants (data )
@@ -253,6 +255,7 @@ def typogrify_sans_widont(data):
253
255
if typo is None :
254
256
req_missing (['typogrify' ], 'use the typogrify_sans_widont filter' )
255
257
258
+ data = _normalize_html (data )
256
259
data = typo .amp (data )
257
260
data = typo .smartypants (data )
258
261
# Disabled because of typogrify bug where it breaks <title>
@@ -302,3 +305,15 @@ def jsminify(data):
302
305
except Exception as exc :
303
306
LOGGER .error ("can't use javascript-minifier.com: {}" , exc )
304
307
return data
308
+
309
+
310
+ def _normalize_html (data ):
311
+ """Pass HTML through LXML to clean it up, if possible."""
312
+ try :
313
+ data = lxml .html .tostring (lxml .html .fragment_fromstring (data ), encoding = 'unicode' )
314
+ except :
315
+ pass
316
+ return data
317
+
318
+
319
+ normalize_html = apply_to_text_file (_normalize_html )
Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ def tl_ch():
116
116
pass
117
117
else :
118
118
flist .append (f )
119
- yield utils .apply_filters (task , {os .path .splitext (dest ): flist })
119
+ yield utils .apply_filters (task , {os .path .splitext (dest )[ - 1 ] : flist })
120
120
121
121
def dependence_on_timeline (self , post , lang ):
122
122
"""Check if a post depends on the timeline."""
You can’t perform that action at this time.
0 commit comments