html2haml-2.0.0/ 0000755 0000041 0000041 00000000000 12471446672 013446 5 ustar www-data www-data html2haml-2.0.0/Rakefile 0000644 0000041 0000041 00000001215 12471446672 015112 0 ustar www-data www-data require "rake/clean"
require "rake/testtask"
require "rubygems/package_task"
task :default => :test
CLEAN.replace %w(pkg doc coverage .yardoc)
Rake::TestTask.new do |t|
t.libs << 'lib' << 'test'
if RUBY_PLATFORM == 'java'
t.test_files = FileList["test/**/*_test.rb"]
else
t.test_files = FileList["test/**/*_test.rb"].exclude(/jruby/)
end
t.verbose = true
end
task :set_coverage_env do
ENV["COVERAGE"] = "true"
end
desc "Run Simplecov"
task :coverage => [:set_coverage_env, :test]
gemspec = File.expand_path("../html2haml.gemspec", __FILE__)
if File.exist? gemspec
Gem::PackageTask.new(eval(File.read(gemspec))) { |pkg| }
end
html2haml-2.0.0/bin/ 0000755 0000041 0000041 00000000000 12471446672 014216 5 ustar www-data www-data html2haml-2.0.0/bin/html2haml 0000755 0000041 0000041 00000000234 12471446672 016033 0 ustar www-data www-data #!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../lib/html2haml'
require 'html2haml/exec'
opts = Html2haml::Exec::HTML2Haml.new(ARGV)
opts.parse!
html2haml-2.0.0/Gemfile 0000644 0000041 0000041 00000000050 12471446672 014734 0 ustar www-data www-data source 'https://rubygems.org'
gemspec
html2haml-2.0.0/MIT-LICENSE 0000644 0000041 0000041 00000002114 12471446672 015100 0 ustar www-data www-data Copyright (c) 2006-2014 Hampton Catlin, Natalie Weizenbaum and Norman Clarke
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. html2haml-2.0.0/html2haml.gemspec 0000644 0000041 0000041 00000002044 12471446672 016703 0 ustar www-data www-data # -*- encoding: utf-8 -*-
require File.expand_path('../lib/html2haml/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Norman Clarke", "Stefan Natchev"]
gem.email = ["norman@njclarke.com", "stefan.natchev@gmail.com"]
gem.description = %q{Converts HTML into Haml}
gem.summary = %q{Converts HTML into Haml}
gem.homepage = "http://haml.info"
gem.files = `git ls-files`.split($\)
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.name = "html2haml"
gem.require_paths = ["lib"]
gem.version = Html2haml::VERSION
gem.required_ruby_version = '>= 1.9.2'
gem.add_dependency 'nokogiri', '~> 1.6.0'
gem.add_dependency 'erubis', '~> 2.7.0'
gem.add_dependency 'ruby_parser', '~> 3.5'
gem.add_dependency 'haml', '~> 4.0.0'
gem.add_development_dependency 'simplecov', '~> 0.7.1'
gem.add_development_dependency 'minitest', '~> 4.4.0'
gem.add_development_dependency 'rake'
end
html2haml-2.0.0/.travis.yml 0000644 0000041 0000041 00000000244 12471446672 015557 0 ustar www-data www-data language: ruby
rvm:
- 2.1.0
- 2.0.0
- 1.9.3
- rbx-2
- jruby-19mode
gemfile:
- Gemfile
branches:
only:
- master
script: "bundle exec rake test"
html2haml-2.0.0/lib/ 0000755 0000041 0000041 00000000000 12471446672 014214 5 ustar www-data www-data html2haml-2.0.0/lib/html2haml.rb 0000644 0000041 0000041 00000000321 12471446672 016425 0 ustar www-data www-data require "rubygems"
gem "haml", ">= 3.2"
require File.expand_path("../html2haml/version", __FILE__)
require "haml/util"
require "haml/parser"
require "haml/error"
require "html2haml/html"
module Html2haml
end
html2haml-2.0.0/lib/html2haml/ 0000755 0000041 0000041 00000000000 12471446672 016104 5 ustar www-data www-data html2haml-2.0.0/lib/html2haml/html/ 0000755 0000041 0000041 00000000000 12471446672 017050 5 ustar www-data www-data html2haml-2.0.0/lib/html2haml/html/erb.rb 0000644 0000041 0000041 00000013134 12471446672 020147 0 ustar www-data www-data require 'cgi'
require 'erubis'
require 'ruby_parser'
module Html2haml
class HTML
# A class for converting ERB code into a format that's easier
# for the {Html2haml::HTML} Nokogiri-based parser to understand.
#
# Uses [Erubis](http://www.kuwata-lab.com/erubis)'s extensible parsing powers
# to parse the ERB in a reliable way,
# and [ruby_parser](http://parsetree.rubyforge.org/)'s Ruby knowledge
# to figure out whether a given chunk of Ruby code starts a block or not.
#
# The ERB tags are converted to HTML tags in the following way.
# `<% ... %>` is converted into ` ... `.
# `<%= ... %>` is converted into ` ... `.
# `<%== ... %>` is converted into ` ... `.
# Finally, if either of these opens a Ruby block,
# ` ... ` will wrap the entire contents of the block -
# that is, everything that should be indented beneath the previous silent or loud tag.
class ERB < Erubis::Basic::Engine
# Compiles an ERB template into a HTML document containing `haml_*` tags.
#
# @param template [String] The ERB template
# @return [String] The output document
# @see Html2haml::HTML::ERB
def self.compile(template)
new(template).src
end
# The ERB-to-Hamlized-HTML conversion has no preamble.
def add_preamble(src); end
# The ERB-to-Hamlized-HTML conversion has no postamble.
def add_postamble(src); end
# Concatenates the text onto the source buffer.
#
# @param src [String] The source buffer
# @param text [String] The raw text to add to the buffer
def add_text(src, text)
src << text
end
# Concatenates a silent Ruby statement onto the source buffer.
# This uses the `` tag,
# and may close and/or open a Ruby block with the `` tag.
#
# In particular, a block is closed if this statement is some form of `end`,
# opened if it's a block opener like `do`, `if`, or `begin`,
# and both closed and opened if it's a mid-block keyword
# like `else` or `when`.
#
# @param src [String] The source buffer
# @param code [String] The Ruby statement to add to the buffer
def add_stmt(src, code)
src << '' if block_closer?(code) || mid_block?(code)
src << '' << h(code) << '' unless code.strip == "end"
src << '' if block_opener?(code) || mid_block?(code)
end
# Concatenates a Ruby expression that's printed to the document
# onto the source buffer.
# This uses the `` tag,
# and may open a Ruby block with the `` tag.
# An expression never closes a block.
#
# @param src [String] The source buffer
# @param code [String] The Ruby expression to add to the buffer
def add_expr_literal(src, code)
src << '' << h(code) << ''
src << '' if block_opener?(code)
end
def add_expr_escaped(src, code)
src << "" << h(code) << ""
end
# `html2haml` doesn't support debugging expressions.
def add_expr_debug(src, code)
raise Haml::Error.new("html2haml doesn't support debugging expressions.")
end
private
# HTML-escaped some text (in practice, always Ruby code).
# A utility method.
#
# @param text [String] The text to escape
# @return [String] The escaped text
def h(text)
CGI.escapeHTML(text)
end
# Returns whether the code is valid Ruby code on its own.
#
# @param code [String] Ruby code to check
# @return [Boolean]
def valid_ruby?(code)
RubyParser.new.parse(code)
rescue Racc::ParseError, RubyParser::SyntaxError
false
end
# Returns whether the code has any content
# This is used to test whether lines have been removed by erubis, such as comments
#
# @param code [String] Ruby code to check
# @return [Boolean]
def has_code?(code)
return false if code == "\n"
return false if valid_ruby?(code) == nil
true
end
# Checks if a string of Ruby code opens a block.
# This could either be something like `foo do |a|`
# or a keyword that requires a matching `end`
# like `if`, `begin`, or `case`.
#
# @param code [String] Ruby code to check
# @return [Boolean]
def block_opener?(code)
return unless has_code?(code)
valid_ruby?(code + "\nend") ||
valid_ruby?(code + "\nwhen foo\nend")
end
# Checks if a string of Ruby code closes a block.
# This is always `end` followed optionally by some method calls.
#
# @param code [String] Ruby code to check
# @return [Boolean]
def block_closer?(code)
return unless has_code?(code)
valid_ruby?("begin\n" + code)
end
# Checks if a string of Ruby code comes in the middle of a block.
# This could be a keyword like `else`, `rescue`, or `when`,
# or even `end` with a method call that takes a block.
#
# @param code [String] Ruby code to check
# @return [Boolean]
def mid_block?(code)
return unless has_code?(code)
return if valid_ruby?(code)
valid_ruby?("if foo\n#{code}\nend") || # else, elsif
valid_ruby?("begin\n#{code}\nend") || # rescue, ensure
valid_ruby?("case foo\n#{code}\nend") # when
end
end
end
end
html2haml-2.0.0/lib/html2haml/exec.rb 0000644 0000041 0000041 00000020067 12471446672 017362 0 ustar www-data www-data require 'optparse'
require 'fileutils'
require 'rbconfig'
module Html2haml
# This module handles the Html2haml executable.
module Exec
# An abstract class that encapsulates the executable code for the Html2haml executable.
# It's split into a base class and a subclass for historic reasons: this previously
# was used by all the executables in the Haml project, before Html2haml was moved
# into its own gem.
class Generic
# @param args [Array] The command-line arguments
def initialize(args)
@args = args
@options = {:for_engine => {}}
end
# Parses the command-line arguments and runs the executable.
# Calls `Kernel#exit` at the end, so it never returns.
#
# @see #parse
def parse!
begin
parse
rescue Exception => e
raise e if @options[:trace] || e.is_a?(SystemExit)
$stderr.print "#{e.class}: " unless e.class == RuntimeError
$stderr.puts "#{e.message}"
$stderr.puts " Use --trace for backtrace."
exit 1
end
exit 0
end
# Parses the command-line arguments and runs the executable.
# This does not handle exceptions or exit the program.
#
# @see #parse!
def parse
@opts = OptionParser.new(&method(:set_opts))
@opts.parse!(@args)
process_result
@options
end
# @return [String] A description of the executable
def to_s
@opts.to_s
end
protected
# Finds the line of the source template
# on which an exception was raised.
#
# @param exception [Exception] The exception
# @return [String] The line number
def get_line(exception)
# SyntaxErrors have weird line reporting
# when there's trailing whitespace,
# which there is for Haml documents.
return (exception.message.scan(/:(\d+)/).first || ["??"]).first if exception.is_a?(::SyntaxError)
(exception.backtrace[0].scan(/:(\d+)/).first || ["??"]).first
end
# Tells optparse how to parse the arguments
# available for all executables.
#
# This is meant to be overridden by subclasses
# so they can add their own options.
#
# @param opts [OptionParser]
def set_opts(opts)
opts.on('-s', '--stdin', :NONE, 'Read input from standard input instead of an input file') do
@options[:input] = $stdin
end
opts.on('--trace', :NONE, 'Show a full traceback on error') do
@options[:trace] = true
end
opts.on('--unix-newlines', 'Use Unix-style newlines in written files.') do
# Note that this is the preferred way to check for Windows, since
# JRuby and Rubinius also run there.
if RbConfig::CONFIG['host_os'] =~ /mswin|windows|mingw/i
@options[:unix_newlines] = true
end
end
opts.on_tail("-?", "-h", "--help", "Show this message") do
puts opts
exit
end
opts.on_tail("-v", "--version", "Print version") do
puts("html2haml #{::Html2haml::VERSION}")
exit
end
end
# Processes the options set by the command-line arguments.
# In particular, sets `@options[:input]` and `@options[:output]`
# to appropriate IO streams.
#
# This is meant to be overridden by subclasses
# so they can run their respective programs.
def process_result
input, output = @options[:input], @options[:output]
args = @args.dup
input ||=
begin
filename = args.shift
@options[:filename] = filename
open_file(filename) || $stdin
end
output ||= open_file(args.shift, 'w') || $stdout
@options[:input], @options[:output] = input, output
end
COLORS = { :red => 31, :green => 32, :yellow => 33 }
# Prints a status message about performing the given action,
# colored using the given color (via terminal escapes) if possible.
#
# @param name [#to_s] A short name for the action being performed.
# Shouldn't be longer than 11 characters.
# @param color [Symbol] The name of the color to use for this action.
# Can be `:red`, `:green`, or `:yellow`.
def puts_action(name, color, arg)
return if @options[:for_engine][:quiet]
printf color(color, "%11s %s\n"), name, arg
end
# Same as `Kernel.puts`, but doesn't print anything if the `--quiet` option is set.
#
# @param args [Array] Passed on to `Kernel.puts`
def puts(*args)
return if @options[:for_engine][:quiet]
Kernel.puts(*args)
end
# Wraps the given string in terminal escapes
# causing it to have the given color.
# If terminal esapes aren't supported on this platform,
# just returns the string instead.
#
# @param color [Symbol] The name of the color to use.
# Can be `:red`, `:green`, or `:yellow`.
# @param str [String] The string to wrap in the given color.
# @return [String] The wrapped string.
def color(color, str)
raise "[BUG] Unrecognized color #{color}" unless COLORS[color]
# Almost any real Unix terminal will support color,
# so we just filter for Windows terms (which don't set TERM)
# and not-real terminals, which aren't ttys.
return str if ENV["TERM"].nil? || ENV["TERM"].empty? || !STDOUT.tty?
return "\e[#{COLORS[color]}m#{str}\e[0m"
end
private
def open_file(filename, flag = 'r')
return if filename.nil?
flag = 'wb' if @options[:unix_newlines] && flag == 'w'
File.open(filename, flag)
end
def handle_load_error(err)
dep = err.message[/^no such file to load -- (.*)/, 1]
raise err if @options[:trace] || dep.nil? || dep.empty?
$stderr.puts <] The command-line arguments
def initialize(args)
super
@module_opts = {}
end
# Tells optparse how to parse the arguments.
#
# @param opts [OptionParser]
def set_opts(opts)
opts.banner = < e
raise "#{e.is_a?(::Haml::SyntaxError) ? "Syntax error" : "Error"} on line " +
"#{get_line e}: #{e.message}"
rescue LoadError => err
handle_load_error(err)
end
end
end
end
html2haml-2.0.0/lib/html2haml/version.rb 0000644 0000041 0000041 00000000051 12471446672 020112 0 ustar www-data www-data module Html2haml
VERSION = "2.0.0"
end
html2haml-2.0.0/lib/html2haml/html.rb 0000644 0000041 0000041 00000042037 12471446672 017403 0 ustar www-data www-data require 'cgi'
require 'nokogiri'
require 'html2haml/html/erb'
# Haml monkeypatches various Nokogiri classes
# to add methods for conversion to Haml.
# @private
module Nokogiri
module XML
# @see Nokogiri
class Node
# Whether this node has already been converted to Haml.
# Only used for text nodes and elements.
#
# @return [Boolean]
attr_accessor :converted_to_haml
# Returns the Haml representation of the given node.
#
# @param tabs [Fixnum] The indentation level of the resulting Haml.
# @option options (see Html2haml::HTML#initialize)
def to_haml(tabs, options)
return "" if converted_to_haml || to_s.strip.empty?
text = uninterp(self.to_s)
#ending in a newline stops the inline nodes
if text.end_with?("\n")
parse_text_with_interpolation(text, tabs)
else
text << process_inline_nodes(next_sibling)
parse_text_with_interpolation(text, tabs)
end
end
private
def erb_to_interpolation(text, options)
return text unless options[:erb]
text = CGI.escapeHTML(uninterp(text))
%w[ ].each {|str| text.gsub!(CGI.escapeHTML(str), str)}
::Nokogiri::XML.fragment(text).children.inject("") do |str, elem|
if elem.is_a?(::Nokogiri::XML::Text)
str + CGI.unescapeHTML(elem.to_s)
else # element
str + '#{' + CGI.unescapeHTML(elem.inner_text.strip) + '}'
end
end
end
def tabulate(tabs)
' ' * tabs
end
def uninterp(text)
text.gsub('#{', '\#{') #'
end
def attr_hash
Hash[attributes.map {|k, v| [k.to_s, v.to_s]}]
end
def parse_text(text, tabs)
parse_text_with_interpolation(uninterp(text), tabs)
end
def parse_text_with_interpolation(text, tabs)
text.strip!
return "" if text.empty?
text.split("\n").map do |line|
line.strip!
"#{tabulate(tabs)}#{'\\' if Haml::Parser::SPECIAL_CHARACTERS.include?(line[0])}#{line}\n"
end.join
end
def process_inline_nodes(node)
text = ""
while node.is_a?(::Nokogiri::XML::Element) && node.name == "haml_loud"
node.converted_to_haml = true
text << '#{' <<
CGI.unescapeHTML(node.inner_text).gsub(/\n\s*/, ' ').strip << '}'
if node.next_sibling.is_a?(::Nokogiri::XML::Text)
node = node.next_sibling
text << uninterp(node.to_s)
node.converted_to_haml = true
end
node = node.next_sibling
end
text
end
end
end
end
# @private
HAML_TAGS = %w[haml_block haml_loud haml_silent]
#
# HAML_TAGS.each do |t|
# Nokogiri::XML::ElementContent[t] = {}
# Nokogiri::XML::ElementContent.keys.each do |key|
# Nokogiri::XML::ElementContent[t][key.hash] = true
# end
# end
#
# Nokogiri::XML::ElementContent.keys.each do |k|
# HAML_TAGS.each do |el|
# val = Nokogiri::XML::ElementContent[k]
# val[el.hash] = true if val.is_a?(Hash)
# end
# end
module Html2haml
# Converts HTML documents into Haml templates.
# Depends on [Nokogiri](http://nokogiri.org/) for HTML parsing.
# If ERB conversion is being used, also depends on
# [Erubis](http://www.kuwata-lab.com/erubis) to parse the ERB
# and [ruby_parser](http://parsetree.rubyforge.org/) to parse the Ruby code.
#
# Example usage:
#
# HTML.new("Blat").render
# #=> "%a{:href => 'http://google.com'} Blat"
class HTML
# @param template [String, Nokogiri::Node] The HTML template to convert
# @option options :erb [Boolean] (false) Whether or not to parse
# ERB's `<%= %>` and `<% %>` into Haml's `=` and `-`
# @option options :xhtml [Boolean] (false) Whether or not to parse
# the HTML strictly as XHTML
def initialize(template, options = {})
@options = options
if template.is_a? Nokogiri::XML::Node
@template = template
else
if template.is_a? IO
template = template.read
end
template = Haml::Util.check_encoding(template) {|msg, line| raise Haml::Error.new(msg, line)}
if @options[:erb]
require 'html2haml/html/erb'
template = ERB.compile(template)
end
@template = detect_proper_parser(template)
end
end
def detect_proper_parser(template)
if template =~ /^\s*\n/, "")
end
end
# @see Nokogiri
# @private
class ::Nokogiri::XML::DTD
# @see Html2haml::HTML::Node#to_haml
def to_haml(tabs, options)
attrs = external_id.nil? ? ["", "", ""] :
external_id.scan(/DTD\s+([^\s]+)\s*([^\s]*)\s*([^\s]*)\s*\/\//)[0]
raise Haml::SyntaxError.new("Invalid doctype") if attrs == nil
type, version, strictness = attrs.map { |a| a.downcase }
if type == "html"
version = ""
strictness = "strict" if strictness == ""
end
if version == "1.0" || version.empty?
version = nil
end
if strictness == 'transitional' || strictness.empty?
strictness = nil
end
version = " #{version.capitalize}" if version
strictness = " #{strictness.capitalize}" if strictness
"#{tabulate(tabs)}!!!#{version}#{strictness}\n"
end
end
# @see Nokogiri
# @private
class ::Nokogiri::XML::Comment
# @see Html2haml::HTML::Node#to_haml
def to_haml(tabs, options)
content = self.content
if content =~ /\A(\[[^\]]+\])>(.*) 1 # Multiline script block
# Normalize the indentation so that the last line is the base
indent_str = lines.last[/^[ \t]*/]
indent_re = /^[ \t]{0,#{indent_str.count(" ") + 8 * indent_str.count("\t")}}/
lines.map! {|s| s.gsub!(indent_re, '')}
# Add an extra " " to make it indented relative to "= "
lines[1..-1].each {|s| s.gsub!(/^/, " ")}
# Add | at the end, properly aligned
length = lines.map {|s| s.size}.max + 1
lines.map! {|s| "%#{-length}s|" % s}
if next_sibling && next_sibling.is_a?(Nokogiri::XML::Element) && next_sibling.name == "haml_loud" &&
next_sibling.inner_text.split("\n").reject {|s| s.strip.empty?}.size > 1
lines << "-#"
end
end
return lines.map {|s| output + s + "\n"}.join
when "haml_silent"
return CGI.unescapeHTML(inner_text).split("\n").map do |line|
next "" if line.strip.empty?
"#{output}- #{line.strip}\n"
end.join
when "haml_block"
return render_children("", tabs, options)
end
end
if self.next && self.next.text? && self.next.content =~ /\A[^\s]/
if self.previous.nil? || self.previous.text? &&
(self.previous.content =~ /[^\s]\Z/ ||
self.previous.content =~ /\A\s*\Z/ && self.previous.previous.nil?)
nuke_outer_whitespace = true
else
output << "= succeed #{self.next.content.slice!(/\A[^\s]+/).dump} do\n"
tabs += 1
output << tabulate(tabs)
#empty the text node since it was inserted into the block
self.next.content = ""
end
end
output << "%#{name}" unless name.to_s == 'div' &&
(static_id?(options) ||
static_classname?(options) &&
attr_hash['class'].to_s.split(' ').any?(&method(:haml_css_attr?)))
if attr_hash
if static_id?(options)
output << "##{attr_hash['id'].to_s}"
remove_attribute('id')
end
if static_classname?(options)
leftover = attr_hash['class'].to_s.split(' ').reject do |c|
next unless haml_css_attr?(c)
output << ".#{c}"
end
remove_attribute('class')
set_attribute('class', leftover.join(' ')) unless leftover.empty?
end
output << haml_attributes(options) if attr_hash.length > 0
end
output << ">" if nuke_outer_whitespace
output << "/" if to_xhtml.end_with?("/>")
if children && children.size == 1
child = children.first
if child.is_a?(::Nokogiri::XML::Text)
if !child.to_s.include?("\n")
text = child.to_haml(tabs + 1, options)
return output + " " + text.lstrip.gsub(/^\\/, '') unless text.chomp.include?("\n") || text.empty?
return output + "\n" + text
elsif ["pre", "textarea"].include?(name) ||
(name == "code" && parent.is_a?(::Nokogiri::XML::Element) && parent.name == "pre")
return output + "\n#{tabulate(tabs + 1)}:preserve\n" +
inner_text.gsub(/^/, tabulate(tabs + 2))
end
elsif child.is_a?(::Nokogiri::XML::Element) && child.name == "haml_loud"
return output + child.to_haml(tabs + 1, options).lstrip
end
end
render_children(output + "\n", tabs, options)
end
private
def render_children(so_far, tabs, options)
(self.children || []).inject(so_far) do |output, child|
output + child.to_haml(tabs + 1, options)
end
end
def dynamic_attributes
#reject any attrs without
@dynamic_attributes = attr_hash.select {|name, value| value =~ %r{ #{value}"
end
if options[:ruby19_style_attributes]
return "#{name}: #{value}"
end
":#{name} => #{value}"
end
end
end
end
html2haml-2.0.0/metadata.yml 0000644 0000041 0000041 00000007613 12471446672 015760 0 ustar www-data www-data --- !ruby/object:Gem::Specification
name: html2haml
version: !ruby/object:Gem::Version
version: 2.0.0
platform: ruby
authors:
- Norman Clarke
- Stefan Natchev
autorequire:
bindir: bin
cert_chain: []
date: 2015-01-19 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: nokogiri
requirement: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: 1.6.0
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: 1.6.0
- !ruby/object:Gem::Dependency
name: erubis
requirement: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: 2.7.0
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: 2.7.0
- !ruby/object:Gem::Dependency
name: ruby_parser
requirement: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: '3.5'
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: '3.5'
- !ruby/object:Gem::Dependency
name: haml
requirement: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: 4.0.0
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: 4.0.0
- !ruby/object:Gem::Dependency
name: simplecov
requirement: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: 0.7.1
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: 0.7.1
- !ruby/object:Gem::Dependency
name: minitest
requirement: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: 4.4.0
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: 4.4.0
- !ruby/object:Gem::Dependency
name: rake
requirement: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: '0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: '0'
description: Converts HTML into Haml
email:
- norman@njclarke.com
- stefan.natchev@gmail.com
executables:
- html2haml
extensions: []
extra_rdoc_files: []
files:
- ".gitignore"
- ".travis.yml"
- ".yardopts"
- Changelog.markdown
- Gemfile
- MIT-LICENSE
- README.md
- Rakefile
- bin/html2haml
- html2haml.gemspec
- lib/html2haml.rb
- lib/html2haml/exec.rb
- lib/html2haml/html.rb
- lib/html2haml/html/erb.rb
- lib/html2haml/version.rb
- test/erb_test.rb
- test/html2haml_test.rb
- test/jruby/erb_test.rb
- test/jruby/html2haml_test.rb
- test/test_helper.rb
homepage: http://haml.info
licenses: []
metadata: {}
post_install_message:
rdoc_options: []
require_paths:
- lib
required_ruby_version: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: 1.9.2
required_rubygems_version: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: '0'
requirements: []
rubyforge_project:
rubygems_version: 2.4.5
signing_key:
specification_version: 4
summary: Converts HTML into Haml
test_files:
- test/erb_test.rb
- test/html2haml_test.rb
- test/jruby/erb_test.rb
- test/jruby/html2haml_test.rb
- test/test_helper.rb
html2haml-2.0.0/test/ 0000755 0000041 0000041 00000000000 12471446672 014425 5 ustar www-data www-data html2haml-2.0.0/test/jruby/ 0000755 0000041 0000041 00000000000 12471446672 015560 5 ustar www-data www-data html2haml-2.0.0/test/jruby/html2haml_test.rb 0000644 0000041 0000041 00000004726 12471446672 021045 0 ustar www-data www-data class Html2HamlTest
def test_doctype
empty_body = "\n%html\n %head\n %body"
assert_equal '!!!' + empty_body, render("")
assert_equal '!!! 1.1' + empty_body, render('')
assert_equal '!!! Strict' + empty_body, render('')
assert_equal '!!! Frameset' + empty_body, render('')
assert_equal '!!! Mobile 1.2' + empty_body, render('')
assert_equal '!!! Basic 1.1' + empty_body, render('')
assert_equal '!!!' + empty_body, render('')
assert_equal '!!! Strict' + empty_body, render('')
assert_equal '!!! Frameset' + empty_body, render('')
assert_equal '!!!' + empty_body, render('')
end
def test_xhtml_strict_doctype
assert_equal(<
HTML
end
def test_html_document_without_doctype
assert_equal(<
Hello
Hello