jekyll-prettier 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/Gemfile +4 -0
- data/README.md +44 -0
- data/jekyll-prettier.gemspec +22 -0
- data/lib/jekyll-prettier.rb +37 -0
- metadata +62 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 5579df6f0b3f7fb46ced8cc90aaa16d78851cf3b5acb2c99a83635be2b863210
|
|
4
|
+
data.tar.gz: c86a8bf667bba3820919785485b137a6ad04df6a048724e06b24b380cf2919cb
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 2eac717fa6aa018a3bd8c866bdf00d8ca9d181f2c9b74c96cdd8cfc61ddbebad7bc3e590507cd46d34d9591ecde7977ffd00b9d91448cdcba628dc19801e7195
|
|
7
|
+
data.tar.gz: bebf0c5b90540144ecba1b64bacbaa8eba95ee203d57c2d0d91377851d3b1e61af0186fdd3090be21f8897a4b65b458884fa9510b0e46469ff44c2560ec14464
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# jekyll-prettier
|
|
2
|
+
|
|
3
|
+
Post-render hooks for cleaning up Jekyll outputs with `prettier`. Really basic
|
|
4
|
+
— this README is longer than the plugin itself.
|
|
5
|
+
|
|
6
|
+
Written as an alternative to
|
|
7
|
+
[jekyll-tidy](https://github.com/apsislabs/jekyll-tidy), which uses
|
|
8
|
+
`htmlbeautifier` under-the-hood. Key distinctions:
|
|
9
|
+
|
|
10
|
+
- `prettier` is more robust to various input HTML styles
|
|
11
|
+
([for example, multi-line self-closing blocks](https://github.com/threedaymonk/htmlbeautifier/issues/53))
|
|
12
|
+
- `prettier` supports more languages
|
|
13
|
+
- `prettier` isn't a Ruby gem, so it needs to be installed manually
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
### Installation
|
|
18
|
+
|
|
19
|
+
In your site `Gemfile`, add:
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
group :jekyll_plugins do
|
|
23
|
+
gem "jekyll-prettier"
|
|
24
|
+
end
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
### Dependencies
|
|
30
|
+
|
|
31
|
+
Requires that [prettier](https://prettier.io/docs/en/install.html) is installed and
|
|
32
|
+
in the PATH.
|
|
33
|
+
|
|
34
|
+
Can be installed with npm:
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
npm install --global prettier
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
or with Yarn:
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
yarn global add prettier
|
|
44
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = 'jekyll-prettier'
|
|
8
|
+
spec.version = '0.0.0'
|
|
9
|
+
spec.summary = 'Jekyll formatting plugin'
|
|
10
|
+
spec.description = 'Jekyll (Ruby static website generator) plugin that runs prettier on generated outputs.'
|
|
11
|
+
spec.authors = %w(brentyi)
|
|
12
|
+
spec.email = 'brentyi@berkeley.edu'
|
|
13
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
14
|
+
spec.homepage = 'https://github.com/brentyi/jekyll-prettier'
|
|
15
|
+
spec.license = 'MIT'
|
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
17
|
+
spec.require_paths = ['lib']
|
|
18
|
+
|
|
19
|
+
spec.required_ruby_version = '>= 2.4'
|
|
20
|
+
|
|
21
|
+
spec.add_dependency 'jekyll', '>= 3.8'
|
|
22
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'open3'
|
|
2
|
+
|
|
3
|
+
def command?(command)
|
|
4
|
+
system("which #{ command} > /dev/null 2>&1")
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
if !command?("prettier")
|
|
8
|
+
puts "!!!"
|
|
9
|
+
puts "`prettier` not found; jekyll-prettier will be disabled\e[0m"
|
|
10
|
+
puts "!!!"
|
|
11
|
+
else
|
|
12
|
+
# Handle docs
|
|
13
|
+
Jekyll::Hooks.register :documents, :post_render do |doc|
|
|
14
|
+
puts "Running prettier on doc: " + doc.url
|
|
15
|
+
args = ["prettier", "--parser", "html"]
|
|
16
|
+
Open3.popen2(*args) do |stdin, stdout, wait_thru|
|
|
17
|
+
stdin.print doc.output
|
|
18
|
+
stdin.close
|
|
19
|
+
doc.output = stdout.read
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Handle pages
|
|
24
|
+
Jekyll::Hooks.register :pages, :post_render do |page|
|
|
25
|
+
puts "Running prettier on page: " + page.url
|
|
26
|
+
if page.html?
|
|
27
|
+
args = ["prettier", "--parser", "html"]
|
|
28
|
+
else
|
|
29
|
+
args = ["prettier", "--stdin-filepath", page.relative_path]
|
|
30
|
+
end
|
|
31
|
+
Open3.popen2(*args) do |stdin, stdout, wait_thru|
|
|
32
|
+
stdin.print page.output
|
|
33
|
+
stdin.close
|
|
34
|
+
page.output = stdout.read
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: jekyll-prettier
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- brentyi
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-09-16 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: jekyll
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '3.8'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '3.8'
|
|
27
|
+
description: Jekyll (Ruby static website generator) plugin that runs prettier on generated
|
|
28
|
+
outputs.
|
|
29
|
+
email: brentyi@berkeley.edu
|
|
30
|
+
executables: []
|
|
31
|
+
extensions: []
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
files:
|
|
34
|
+
- ".gitignore"
|
|
35
|
+
- Gemfile
|
|
36
|
+
- README.md
|
|
37
|
+
- jekyll-prettier.gemspec
|
|
38
|
+
- lib/jekyll-prettier.rb
|
|
39
|
+
homepage: https://github.com/brentyi/jekyll-prettier
|
|
40
|
+
licenses:
|
|
41
|
+
- MIT
|
|
42
|
+
metadata: {}
|
|
43
|
+
post_install_message:
|
|
44
|
+
rdoc_options: []
|
|
45
|
+
require_paths:
|
|
46
|
+
- lib
|
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
48
|
+
requirements:
|
|
49
|
+
- - ">="
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: '2.4'
|
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
|
+
requirements:
|
|
54
|
+
- - ">="
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: '0'
|
|
57
|
+
requirements: []
|
|
58
|
+
rubygems_version: 3.1.2
|
|
59
|
+
signing_key:
|
|
60
|
+
specification_version: 4
|
|
61
|
+
summary: Jekyll formatting plugin
|
|
62
|
+
test_files: []
|