threedaymonk / htmlbeautifier

A normaliser/beautifier for HTML that also understands embedded Ruby. Ideal for tidying up Rails templates.
MIT License
325 stars 59 forks source link

case without matcher #33

Closed zerocool4u2 closed 8 years ago

zerocool4u2 commented 8 years ago

It's not a mayor issue, but the class: "something" notation it's not supported, it is perceived as a class definition instead of a symbol definition so mess the indentation

f.inputs Phone.model_name.human.pluralize do
            f.has_many :phones, allow_destroy: true, heading: nil do |phone|
                phone.input :area_code_id, as: :select, collection: AreaCode.all.order(:area_code).pluck(:area_code, :id), wrapper_html: { class: "phone_area_code_wrapper" }
                                                                                                                                             phone.input :phone_number, wrapper_html: { class: "phone_phone_number_wrapper" }
                                                                                                                                                                                        end
                                                                                                                                                                                        end
                                                                                                                                                                                        f.actions
                                                                                                                                                                                        end

like i say, it's not a mayor issue, the :class => "" notation works fine and is rare to have this kind of definitions in .rb files anyway(active_admin), regards!

zerocool4u2 commented 8 years ago

not the best solution, but works for me, not really sure if there are other cases to avoid look for a general solution and the most important, class: should be a valid scenario for definition of a class? really don't know if there are some cases with this particular expression

#(module|class[^:]|def)
  ruby.add_matcher(:standard,
                   /((#{start_statement_boundary}(module|class[^:]|def))|#{pre_keyword_boundary}do)\b/,
                   /(((^|;|\s)end)|#{continue_statement_boundary}(rescue|ensure))\b/,
                   :nest_except => [:double_quote, :regex, :backtick])
threedaymonk commented 8 years ago

I'm puzzled. What is this ruby.add_matcher syntax from? It's not part of this library!

zerocool4u2 commented 8 years ago

really sorry!!! i'm working on this and other library at the same time, wrong tab, regards!