Class: Nanoc::Tidy::Filter
- Inherits:
-
Filter
- Object
- Filter
- Nanoc::Tidy::Filter
- Includes:
- FileUtils, Spawn
- Defined in:
- lib/nanoc/tidy/filter.rb
Class Method Summary collapse
-
.default_argv ⇒ Array<String>
The default argv for tidy-html5.
Instance Method Summary collapse
-
#run(content, options = {}) ⇒ String
Runs the filter.
Methods included from Spawn
Class Method Details
.default_argv ⇒ Array<String>
The default argv for tidy-html5
21 22 23 |
# File 'lib/nanoc/tidy/filter.rb', line 21 def self.default_argv @default_argv ||= ["-wrap", "120", "-indent"] end |
Instance Method Details
#run(content, options = {}) ⇒ String
Runs the filter
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/nanoc/tidy/filter.rb', line 36 def run(content, = {}) = Ryo() file = temporary_file( File.basename(item.identifier.to_s), content ) spawn .exe || "tidy5", [*default_argv, *(.argv || []), "-modify", file.path] File.read(file.path) ensure file ? file.tap(&:unlink).close : nil end |