Permalink
Browse files

Initial commit

This is the first commit from the extraction from Haml. There are still
lots of issues to sort out; namespacing needs to be completely cleaned
up, and the dependency on Haml itself needs to be removed.
  • Loading branch information...
0 parents commit 6efa5541da4c75c456f48e63d0b82b63d4adb6f7 @norman norman committed Jun 6, 2012
Showing with 1,769 additions and 0 deletions.
  1. +10 −0 .gitignore
  2. +14 −0 .travis.yml
  3. +6 −0 Gemfile
  4. +18 −0 MIT-LICENSE
  5. +40 −0 README.md
  6. +25 −0 Rakefile
  7. +7 −0 bin/html2haml
  8. +24 −0 html2haml.gemspec
  9. +8 −0 lib/html2haml.rb
  10. +260 −0 lib/html2haml/exec.rb
  11. +423 −0 lib/html2haml/html.rb
  12. +141 −0 lib/html2haml/html/erb.rb
  13. +3 −0 lib/html2haml/version.rb
  14. +440 −0 test/erb_tests.rb
  15. +342 −0 test/html2haml_test.rb
  16. +8 −0 test/test_helper.rb
@@ -0,0 +1,10 @@
+/.yardoc
+/coverage
+/doc
+/pkg
+*.rbc
+.rbenv-version
+Gemfile.lock
+.rvmrc
+.rbx
+tmp
@@ -0,0 +1,14 @@
+rvm:
+ - 1.8.7
+ - 1.9.3
+ - jruby-18mode
+ - rbx-18mode
+
+gemfile:
+ - Gemfile
+
+branches:
+ only:
+ - master
+
+script: "bundle exec rake test"
@@ -0,0 +1,6 @@
+source 'https://rubygems.org'
+
+gem "haml", :git => "git://github.com/haml/haml.git"
+
+gemspec
+
@@ -0,0 +1,18 @@
+Copyright (c) 2006-2012 Hampton Catlin, Nathan 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.
@@ -0,0 +1,40 @@
+# Html2haml
+
+Converts HTML to Haml. This is in the process of being extracted from the Haml
+gem.
+
+## Installation
+
+Add this line to your application's Gemfile:
+
+ gem 'html2haml'
+
+And then execute:
+
+ $ bundle
+
+Or install it yourself as:
+
+ $ gem install html2haml
+
+## Usage
+
+See `html2haml --help`:
+
+ Usage: html2haml [options] [INPUT] [OUTPUT]
+
+ Description: Transforms an HTML file into corresponding Haml code.
+
+ Options:
+ -e, --erb Parse ERb tags.
+ --no-erb Don't parse ERb tags.
+ -r, --rhtml Deprecated; same as --erb.
+ --no-rhtml Deprecated; same as --no-erb.
+ -x, --xhtml Parse the input using the more strict XHTML parser.
+ --html-attributes Use HTML style attributes instead of Ruby hash style.
+ -E ex[:in] Specify the default external and internal character encodings.
+ -s, --stdin Read input from standard input instead of an input file
+ --trace Show a full traceback on error
+ --unix-newlines Use Unix-style newlines in written files.
+ -?, -h, --help Show this message
+ -v, --version Print version
@@ -0,0 +1,25 @@
+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'
+ t.test_files = Dir["test/**/*_test.rb"]
+ t.verbose = true
+end
+
+task :set_coverage_env do
+ ENV["COVERAGE"] = "true"
+end
+
+desc "Run Simplecov (only works on 1.9)"
+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
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../lib/html2haml'
+require 'html2haml/exec'
+
+opts = Html2haml::Exec::HTML2Haml.new(ARGV)
+opts.parse!
@@ -0,0 +1,24 @@
+# -*- encoding: utf-8 -*-
+require File.expand_path('../lib/html2haml/version', __FILE__)
+
+Gem::Specification.new do |gem|
+ gem.authors = ["Norman Clarke"]
+ gem.email = ["norman@njclarke.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.add_dependency 'hpricot'
+ gem.add_dependency 'haml'
+ gem.add_development_dependency 'erubis'
+ gem.add_development_dependency 'ruby_parser'
+ gem.add_development_dependency 'simple_cov'
+ gem.add_development_dependency 'rake'
+end
@@ -0,0 +1,8 @@
+require "html2haml/version"
+require "haml/util"
+require "haml/parser"
+require "haml/error"
+require "html2haml/html"
+
+module Html2haml
+end
Oops, something went wrong.

0 comments on commit 6efa554

Please sign in to comment.