Giter Site home page Giter Site logo

html2haml's Introduction

html2haml.heroku.com

html2haml is a sinatra web application that allows you to convert html 2 haml.

It is currently using haml 4.0.0! and html2haml 2.0.0.beta

Features

  • html text to haml text

    Copy your html in the html text area and click on convert and html2haml will convert it to haml in the text box below.

  • url to haml

    Enter a url to a web site and click submit html2haml will download the page and convert it to haml in the haml text area below

  • Now you can use json to do your conversions

    Post:

      {'page': { 'html': '<h1>Hello World</h1>' }}
    

    and receive:

      {'page': { 'html': '<h1>Hello World</h1>', 'haml': '%h1 Hello World' }}
    

Requirements for Development

  • Ruby 1.9.3
  • Bundler

Development

git clone git://github.com/twilson63/html2haml.git

bundle install

# run tests
rake

# run application
rackup

# open browser to http://localhost:9292

Having problems

Please post an issue in the issues

How to contribute

Interested in adding a new feature to the application? Awesome!

  • First clone the repository
  • Write a test for your feature in the spec folder using rspec
  • Write your new feature
  • Once your code is passing and re-factored send a pull request

LICENSE

The MIT License

Copyright (c) 2008 Jack Russell Software Company

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's People

Contributors

dalton avatar itsthatguy avatar nfedyashev avatar rdniller avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

html2haml's Issues

Quotes are not properly escaped

This code:

<div class="hello <%= "bye" if @welcome.nil? %>">
</div>

Generates:

%div{:class => "hello #{"bye" if @welcome.nil?}"}

Which will break because the quote is improperly closed.

HTML5 void elements not parsed correctly

This input:

<hr>
<h2>
  First line of my header<br>
  <%= some_helper %> and second header line
</h2>

Results in this output:

%hr
  %h2
    First line of my header
    %br
      = some_helper
      and second header line

However, <hr> and <br> can never have any contents. Maybe upstream bug? I note html2haml has released two new beta versions beyond your current one, though I can't seem to get it working at the moment to check (complains about missing hpricot even though it's installed).

twitter html widget code bug

after pasting code for twitter widget and push button "convert" application is redirect me to data; path.

here is the code of twitter widget

<a class="twitter-timeline" href="https://twitter.com/search?q=deadlinecamp" data-widget id="352915126443200512">Твиты о "deadlinecamp"</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s [0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

empty tags

empty tags are not converted properly

...
<script …>
</script>
</head>
<body>

->

%script
  %body

Wrong code indent

http://imm.io/vTox

<%if @user.phone.present?%>
    <%= render :partial => "users/settings/phone_observer"%>
<%end%>
<%#if @user.qiwi_phone.present?%>
    <%# render :partial => "users/settings/phone_observer"%>
<%#end%>
<script>
  inputPlaceholder( document.getElementById('user_blacklist_by_words') );  
</script>
- if @user.phone.present?
  = render :partial => "users/settings/phone_observer"
  :javascript
    inputPlaceholder( document.getElementById('user_blacklist_by_words') );

Instead of

- if @user.phone.present?
  = render :partial => "users/settings/phone_observer"
:javascript
  inputPlaceholder( document.getElementById('user_blacklist_by_words') );

no such file to load -- spec (LoadError)

hello,

installing html2haml and got this on first try

$ ruby html2haml_spec.rb
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require': no such file to load -- spec (LoadError) from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from html2haml_spec.rb:4

the gem env and installed gems follow.

what have i missed or do i need ruby 1.9?

regards

john

the gem env is

$ gem env
RubyGems Environment:

  • RUBYGEMS VERSION: 1.3.7
  • RUBY VERSION: 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
  • INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
  • RUBY EXECUTABLE: /usr/bin/ruby1.8
  • EXECUTABLE DIRECTORY: /usr/bin
  • RUBYGEMS PLATFORMS:
    • ruby
    • x86-linux
  • GEM PATHS:
    • /usr/lib/ruby/gems/1.8
    • /home/lawsonst/.gem/ruby/1.8
  • GEM CONFIGURATION:
    • :update_sources => true
    • :verbose => true
    • :benchmark => false
    • :backtrace => false
    • :bulk_threshold => 1000
  • REMOTE SOURCES:

the installed gems are

$ gem list

*** LOCAL GEMS ***

abstract (1.0.0)
action_mailer_tls (1.1.3)
actionmailer (3.0.1, 3.0.0, 2.3.8, 2.3.5, 2.1.1, 2.0.2, 1.3.0)
actionpack (3.0.1, 3.0.0, 2.3.8, 2.3.5, 2.1.1, 2.0.2, 1.13.6, 1.13.0)
actionwebservice (1.2.6, 1.2.0)
activemodel (3.0.1, 3.0.0)
activerecord (3.0.1, 3.0.0, 2.3.8, 2.3.5, 2.1.1, 2.0.2, 1.15.6, 1.15.0)
activeresource (3.0.1, 3.0.0, 2.3.8, 2.3.5, 2.1.1, 2.0.2)
activesupport (3.0.1, 3.0.0, 2.3.8, 2.3.5, 2.1.1, 2.0.2, 1.4.4, 1.4.0)
acts_as_list (0.1.2)
addressable (2.2.2, 2.2.1, 2.2.0, 2.1.1)
arel (2.0.1, 1.0.1)
at-the-movies (0.1.0)
authlogic (2.1.6, 2.1.3)
babosa (0.2.0)
builder (2.1.2)
bundler (1.0.3, 1.0.2, 1.0.0, 0.9.19)
capistrano (2.5.19)
cgi_multipart_eof_fix (2.5.0)
cmdparse (2.0.2)
creole (0.3.7)
daemon_controller (0.2.5)
daemons (1.1.0)
data_objects (0.10.2, 0.10.1)
datamapper (1.0.2)
desert (0.5.4, 0.5.3)
diff-lcs (1.1.2)
dm-aggregates (1.0.2)
dm-constraints (1.0.2)
dm-core (1.0.2)
dm-do-adapter (1.0.2)
dm-migrations (1.0.2)
dm-serializer (1.0.2)
dm-sqlite-adapter (1.0.2)
dm-timestamps (1.0.2)
dm-transactions (1.0.2)
dm-types (1.0.2)
dm-validations (1.0.2)
do_mysql (0.10.2, 0.10.1)
do_sqlite3 (0.10.2, 0.10.1.1)
echoe (4.3.1, 4.3, 4.1)
erubis (2.6.6)
escape_utils (0.1.9)
evaluator (0.1.5)
eventmachine (0.12.10)
exifr (1.0.3, 0.10.9)
extlib (0.9.15)
fastercsv (1.5.3)
fastthread (1.0.7)
ffi (0.6.3, 0.5.4)
file-tail (1.0.5)
friendly_id (3.1.7, 2.3.0)
gem_plugin (0.2.3)
gemcutter (0.6.1, 0.5.0)
gitrb (0.2.7)
grit (2.3.0)
haml (3.0.22, 3.0.21, 2.2.19)
has_scope (0.5.0)
highline (1.6.1)
hoe (2.6.2)
hpricot (0.8.2)
i18n (0.4.1)
inherited_resources (1.1.2, 0.9.5)
json_pure (1.4.6, 1.2.4, 1.2.0)
juicer (1.0.8, 1.0.7, 1.0.3)
kgio (1.3.1)
less (1.2.21)
macaddr (1.0.0)
mail (2.2.7, 2.2.6.1)
maruku (0.6.0)
mechanize (1.0.0)
memcache-client (1.8.5, 1.8.2)
mime-types (1.16)
mimemagic (0.1.7)
mongrel (1.1.5)
mutter (0.5.3)
mysql (2.8.1)
net-scp (1.0.4)
net-sftp (2.0.5)
net-ssh (2.0.23)
net-ssh-gateway (1.0.1)
nokogiri (1.4.3.1, 1.4.1)
org-ruby (0.5.3)
paperclip (2.3.4, 2.3.1.1)
passenger (3.0.0)
Piggy (0.5.0.0)
polyglot (0.3.1)
pony (1.0.1)
rack (1.2.1, 1.1.0, 1.0.1)
rack-mount (0.6.13)
rack-test (0.5.6, 0.5.5)
radiant (0.9.1, 0.8.1)
rails (3.0.1, 3.0.0, 2.3.8, 2.3.5, 2.1.1, 2.0.2, 1.2.0)
railties (3.0.1, 3.0.0)
rake (0.8.7)
rdiscount (1.6.5, 1.5.8)
RedCloth (4.2.3, 4.2.2)
responders (0.6.2)
rspec (2.0.1)
rspec-core (2.0.1)
rspec-expectations (2.0.1)
rspec-mocks (2.0.1)
rubyforge (2.0.4, 2.0.3)
rubygems-update (1.3.7, 1.3.6)
rubypants (0.2.0)
rubyzip (0.9.4)
sequel (3.16.0)
sinatra (1.1.0, 1.0)
slim (0.7.0)
spruz (0.1.5)
sqlite3-ruby (1.3.2, 1.3.1, 1.2.5)
stringex (1.2.0, 1.1.0)
syntax (1.0.0)
temple (0.1.3)
test-spec (0.10.0)
thin (1.2.7)
thor (0.14.3, 0.14.1)
tilt (1.1)
treetop (1.4.8)
tzinfo (0.3.23)
unicode (0.4.0)
unicorn (2.0.0)
utf8proc (1.1.5)
uuid (2.3.1)
uuidtools (2.1.1)
will_paginate (2.3.15, 2.3.12)
yajl-ruby (0.7.8)

Wierd '?' parsing

Tested on http://html2haml.heroku.com/

INPUT :

<h3>What People <span>Say</span>?</h3>

OUTPUT:

   %h3
        What People
            = succeed "?" do
                %span Say

But the following is correct (and is generated if the additional space is inserted before '?') :

INPUT :

<h3>What People <span>Say</span> ?</h3>

OUTPUT:

%h3
  What People
  %span Say
  ?

cycles

try to convert erb:
< tr class=<%= cycle("odd", "even") %> >

and get:
%tr{:class => "< haml_loud "}
cycle("odd", "even") >

JavaScript bug

<!doctype html>
<html>
  <head>
    <script>window.jQuery || document.write('<script src="./js/jquery.js">\x3C/script>');</script>
    <script src="./js/custom.js"></script>
  </head>
</html>

This code compiles to:

<!doctype html>
%html
  %head
    :javascript
      window.jQuery || document.write('<script src="./js/jquery.js">\x3C/script>');    %script{:src => "./js/custom.js"}

It can't be properly compiled again to HTML:

<!doctype html>
<html>
  <head>
    <script>
      window.jQuery || document.write('<script src="./js/jquery.js">\x3C/script>');    %script{:src => "./js/custom.js"}
    </script>
  </head>
</html>

Expected html2haml compilation result:

<!doctype html>
%html
  %head
    :javascript
      window.jQuery || document.write('<script src="./js/jquery.js">\x3C/script>');  
    %script{:src => "./js/custom.js"}

Create JSON Api

When a page object is posted to /json
it should return a json page object with the haml filled in.

Wrong conversion

<p><h4>h4</h4><b>b</b> text</p>

converts to

%p
%h4 h4
%b b
text

but should be

%p
  %h4 h4
  %b b
  text

Feature: Choose tab-spacing rather than single-spacing

As a disclaimer, I am a newbie. This tool/your work has been a huge help to me, so many thanks! And apologies if this is not the right place to put something like this.

When converting various html.erb snippets in to html.haml I have run into rendering issues when there is inconsistent use of single-spaces and tabs. If there was a way to choose which we prefer on the html2haml website that would be amazing. Perhaps similar to the way I can select how spaces a "tab" equates to in TextMate.

Problem with application.html.erb and <nav> tags

Hi...

I recently switched to Haml and used html2haml to convert my existing views. I also converted my existing application.html.erb file, but ran into a problem. The %ul entries under the %nav entry were not properly indented, so the

element was empty and the
    entries were just hanging out on the left of the screen with no special formatting. I'm on haml 3.1.1 and did the conversion a couple of times before I found out what was happening.

    I can send samples of the input/output if you want, but it was a very simple erb file; what I got was this:
    %nav.round
    %ul
    %li= link_to "Home", :welcome_index
    %li= link_to "Incident Report", :incident_reports
    %li= link_to "Check Request", '#'
    %li= link_to "Purchase Requisition", '#'
    %li= link_to "Quote Request", '#'
    %section.round
    Notice that the %nav and the %ul are at the same indentation level...

Copyright Symbol Crashes App

Use of the copyright symbol (©) anywhere in a page's code causes the application to crash and display an Internal Server Error. Possibly a Heroku issue, non-specific to this app.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.