Work in progress, CommonMark spec
This commit is contained in:
parent
657e592a39
commit
fc90dd3592
|
@ -966,4 +966,69 @@ HTML
|
|||
end
|
||||
end
|
||||
|
||||
# work in progress
|
||||
skip 'passes commonmark spec' do
|
||||
|
||||
SiteSetting.traditional_markdown_linebreaks = true
|
||||
|
||||
html,state,md = nil
|
||||
failed = 0
|
||||
|
||||
File.readlines(Rails.root + 'spec/fixtures/md/spec.txt').each do |line|
|
||||
if line == "```````````````````````````````` example\n"
|
||||
state = :example
|
||||
next
|
||||
end
|
||||
|
||||
if line == "````````````````````````````````\n"
|
||||
md.gsub!('→', "\t")
|
||||
html ||= ''
|
||||
html.gsub!('→', "\t")
|
||||
html.strip!
|
||||
|
||||
# normalize brs
|
||||
html.gsub!('<br />', '<br>')
|
||||
html.gsub!('<hr />', '<hr>')
|
||||
html.gsub!(/<img([^>]+) \/>/, "<img\\1>")
|
||||
|
||||
cooked = PrettyText.markdown(md, sanitize: false)
|
||||
cooked.strip!
|
||||
cooked.gsub!(" class='lang-auto'", '')
|
||||
cooked.gsub!(/<span class="hashtag">(.*)<\/span>/, "\\1")
|
||||
# we don't care about this
|
||||
cooked.gsub!("<blockquote>\n</blockquote>", "<blockquote></blockquote>")
|
||||
|
||||
unless cooked == html
|
||||
failed += 1
|
||||
puts "FAILED SPEC"
|
||||
puts "Expected: "
|
||||
puts html
|
||||
puts "Got: "
|
||||
puts cooked
|
||||
puts "Markdown: "
|
||||
puts md
|
||||
puts
|
||||
end
|
||||
html,state,md = nil
|
||||
next
|
||||
end
|
||||
|
||||
if state == :example && line == ".\n"
|
||||
state = :html
|
||||
next
|
||||
end
|
||||
|
||||
if state == :example
|
||||
md = (md || "") << line
|
||||
end
|
||||
|
||||
if state == :html
|
||||
html = (html || "") << line
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
expect(failed).to eq(0)
|
||||
end
|
||||
end
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue