File: test_smartpunct.rb

package info (click to toggle)
ruby-commonmarker 0.23.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,456 kB
  • sloc: ansic: 10,575; ruby: 1,741; sh: 36; makefile: 22
file content (28 lines) | stat: -rw-r--r-- 844 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

require "test_helper"

class SmartPunctTest < Minitest::Test
  smart_punct = open_spec_file("smart_punct.txt")

  smart_punct.each do |testcase|
    doc = CommonMarker.render_doc(testcase[:markdown], :SMART)
    html = CommonMarker.render_html(testcase[:markdown], :SMART)

    define_method("test_smart_punct_example_#{testcase[:example]}") do
      doc_rendered = doc.to_html.strip
      html_rendered = html.strip

      assert_equal testcase[:html], doc_rendered, testcase[:markdown]
      assert_equal testcase[:html], html_rendered, testcase[:markdown]
    end
  end

  def test_smart_hardbreak_no_spaces_render_doc
    markdown = "\"foo\"\nbaz"
    result = "<p>“foo”<br />\nbaz</p>\n"
    doc = CommonMarker.render_doc(markdown, :SMART)

    assert_equal(result, doc.to_html([:HARDBREAKS]))
  end
end