No commit activity in last 3 years
No release in over 3 years
A Jekyll plugin that cleans JSONs up. If you use Liquid templates to build JSONs for your site, then you probably really want it.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.9

Runtime

>= 3.8, < 5
 Project Readme

Jekyll-Tidy-JSON

Gem Version Build Status

A Jekyll plugin that cleans JSONs up.

It takes a JSON page and applies consistent formatting rules to it. If that input is malformed, then raises an exception preventing you from deploying a buggy site.

If you use Liquid templates to build JSONs for your site, then you probably really want it.

Installation

Include this gem in your site’s Gemfile under the jekyll_plugins group:

group :jekyll_plugins do
  gem "jekyll-tidy-json"
end

Visit Jekyll documentation for a detailed description or more installation options.

Configuration

This plugin’s behaviour is steered by "tidy_json" entry in site’s _config.yml. For example, following enables JSON prettifying:

tidy_json:
  pretty: true

Available configuration options:

Option name Description Default setting

continue_on_error

If set to false, any malformed JSON encounter will raise error, preventing site from being built. If set to true, all malformed files are exempted from being tidied up with a meaningful warning being printed, but site generation continues.

false

enabled

Can be used to disable the plugin entirely by setting it to false.

true

pretty

If set to true, then JSONs will be prettified for readability sake. If set to false, then all unnecessary spaces and new lines will be removed.

false

TODO

This plugin is fairly complete. However, some enhancements would be welcome:

  • more options for pretty formatting

  • options for including/excluding JSON files

  • JSON sanitizing features, perhaps by integrating json-sanitizer by OWASP

  • support for some improved JSON syntax like JSON5 or Relaxed JSON if any of them gets popular enough

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/geolexica/jekyll-tidy-json.

Credits

This gem is developed, maintained and funded by Ribose Inc.

License

This gem is licensed under MIT license.