Module: HTML5
- Defined in:
- lib/h5-min.rb,
lib/h5-min/optional.rb
Defined Under Namespace
Modules: OptionalTags
Constant Summary collapse
- PRE_TAGS =
Elements in which whitespace is significant, so can’t be normalised
[:pre, :style, :script, :textarea]
- FLOW_ELEMENTS =
Elements representing flow content
%w{a abbr address area article aside audio b bdo blockquote br button canvas cite code command datalist del details dfn div dl em embed fieldset figure footer form h1 h2 h3 h4 h5 h6 header hgroup hr i iframe img input ins kbd keygen label link map mark math menu meta meter nav noscript object ol output p pre progress q ruby samp script section select small span strong style sub sup svg table textarea time ul var video wbr }.map(&:to_sym)
Class Method Summary collapse
Class Method Details
.minify(html) ⇒ Object
139 140 141 142 143 |
# File 'lib/h5-min.rb', line 139 def self.minify html minifier = @minifier.new Nokogiri::HTML::SAX::Parser.new(minifier).parse(html) OptionalTags.remove minifier.buf.strip end |
.minify_css(text) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/h5-min.rb', line 126 def self.minify_css text Tempfile.open('css') do |input| input << text input.close return begin `yuicompressor --type css --charset utf-8 #{input.to_path}` rescue Errno::ENOENT warn "yuicompressor not found; won't minify CSS" text end end end |