Sha256: fabd8ac9a5ed25456d7241c1df504bf2256b483ec6525e42540c0bdbb8aff628

Contents?: true

Size: 1.16 KB

Versions: 36

Compression:

Stored size: 1.16 KB

Contents

# ------------------------------------------------------------------------------
# ~/_plugins/prettify.rb
# Liquid filter for J1 Template to beautify HTML code
#
# Product/Info:
# http://jekyll.one
#
# Copyright (C) 2022 Juergen Adams
#
# J1 Template is licensed under the MIT License.
# See: https://github.com/jekyll-one-org/J1 Template/blob/master/LICENSE
# ------------------------------------------------------------------------------
#  NOTE:
#  CustomFilters cannot be used in SAFE mode (e.g not usable for
#  rendering pages with Jekyll on GitHub
#
#  USAGE:
#    {% capture cache_name %}
#
#      liquid code to generate HTML output goes here
#
#    {% endcapture %}
#    {{ cache_name | pretty_print }}
# ------------------------------------------------------------------------------
require 'nokogiri'
require 'nokogiri-pretty'
require 'htmlbeautifier'

module Jekyll
  module PrettyPrint
    def pretty_print(input)
      # 1st_stage cleanup
      content = Nokogiri::HTML input
      parsed_content = content.to_html
      # 2nd_stage cleanup
      pretty = HtmlBeautifier.beautify(parsed_content)
    end
  end
end

Liquid::Template.register_filter(Jekyll::PrettyPrint)

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
j1-template-2022.6.3 lib/starter_web/_plugins/filter/prettify.rb
j1-template-2022.6.2 lib/starter_web/_plugins/filter/prettify.rb
j1-template-2022.6.1 lib/starter_web/_plugins/filter/prettify.rb
j1-template-2022.6.0 lib/starter_web/_plugins/filter/prettify.rb
j1-template-2022.5.3 lib/starter_web/_plugins/prettify.rb
j1-template-2022.5.2 lib/starter_web/_plugins/prettify.rb
j1-template-2022.5.1 lib/starter_web/_plugins/prettify.rb
j1-template-2022.5.1.rc1 lib/starter_web/_plugins/prettify.rb
j1-template-2022.5.1.rc0 lib/starter_web/_plugins/prettify.rb
j1-template-2022.5.0 lib/starter_web/_plugins/prettify.rb
j1-template-2022.5.0.rc4 lib/starter_web/_plugins/prettify.rb
j1-template-2022.5.0.rc3 lib/starter_web/_plugins/prettify.rb
j1-template-2022.5.0.rc2 lib/starter_web/_plugins/prettify.rb
j1-template-2022.5.0.rc1 lib/starter_web/_plugins/prettify.rb
j1-template-2022.5.0.rc0 lib/starter_web/_plugins/prettify.rb
j1-template-2022.3.0.rc1 lib/starter_web/_plugins/prettify.rb
j1-template-2022.3.0.rc0 lib/starter_web/_plugins/prettify.rb
j1-template-2022.4.10 lib/starter_web/_plugins/prettify.rb
j1-template-2022.4.9 lib/starter_web/_plugins/prettify.rb
j1-template-2022.4.8 lib/starter_web/_plugins/prettify.rb