mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
Add rubocop to our build. (#5004)
This commit is contained in:
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user