Skip to content
Permalink
Browse files
minifyjson filter
  • Loading branch information
da2x committed Sep 21, 2015
1 parent 47de6c4 commit 402a62eee125bf545413b43c95b4110322d74e8b
Showing 3 changed files with 11 additions and 0 deletions.
@@ -4,6 +4,7 @@ New in master
Features
--------

* New ```jsonmnify``` filter for minifying JSON files.
* New option ``FEED_PREVIEWIMAGE`` includes the ``post.meta.previewimage``
image in Atom and RSS feeds. (Issue #2095)

@@ -1381,6 +1381,9 @@ cssminify
jsminify
Minify JS using http://javascript-minifier.com/ (requires internet access)

jsonminify
Minify JSON files (strips whitespace and use minimal separators).

You can apply filters to specific posts or pages by using the ``filters`` metadata field:

.. code:: restructuredtext
@@ -29,6 +29,7 @@
from functools import wraps
import os
import io
import json
import shutil
import subprocess
import tempfile
@@ -307,6 +308,12 @@ def jsminify(data):
return data


@apply_to_text_file
def jsonminify(data):
data = json.dumps(json.loads(data), indent=None, separators=(',', ':'))
return data


def _normalize_html(data):
"""Pass HTML through LXML to clean it up, if possible."""
try:

0 comments on commit 402a62e

Please sign in to comment.