Add rubocop to our build. (#5004)

This commit is contained in:
Guo Xiang Tan
2017-07-28 10:20:09 +09:00
committed by GitHub
parent ff4e295c4f
commit 5012d46cbd
871 changed files with 5480 additions and 6056 deletions

View File

@ -3,24 +3,23 @@ require "nokogiri"
class HtmlToMarkdown
class Block < Struct.new(:name, :head, :body, :opened, :markdown)
def initialize(name, head="", body="", opened=false, markdown=""); super; end
def initialize(name, head = "", body = "", opened = false, markdown = ""); super; end
end
def initialize(html, opts={})
def initialize(html, opts = {})
@opts = opts || {}
@doc = fix_span_elements(Nokogiri::HTML(html))
remove_whitespaces!
end
# If a `<div>` is within a `<span>` that's invalid, so let's hoist the `<div>` up
def fix_span_elements(node)
if node.name == 'span' && node.at('div')
node.swap(node.children)
end
node.children.each {|c| fix_span_elements(c)}
node.children.each { |c| fix_span_elements(c) }
node
end