commonmarker-0.20.2/ 0000755 0000041 0000041 00000000000 13600617370 014320 5 ustar www-data www-data commonmarker-0.20.2/test/ 0000755 0000041 0000041 00000000000 13600617370 015277 5 ustar www-data www-data commonmarker-0.20.2/test/test_maliciousness.rb 0000644 0000041 0000041 00000012654 13600617370 021551 0 ustar www-data www-data # frozen_string_literal: true require 'test_helper' class CommonMarker::TestMaliciousness < Minitest::Test def setup @doc = CommonMarker.render_doc('Hi *there*') end def test_init_with_bad_type assert_raises TypeError do Node.new(123) end assert_raises NodeError do Node.new(:totes_fake) end assert_raises TypeError do Node.new([]) end assert_raises TypeError do Node.new([23]) end assert_raises TypeError do Node.new(nil) end end def test_rendering_with_bad_type assert_raises TypeError do CommonMarker.render_html("foo \n baz", 123) end assert_raises TypeError do CommonMarker.render_html("foo \n baz", :totes_fake) end assert_raises TypeError do CommonMarker.render_html("foo \n baz", []) end assert_raises TypeError do CommonMarker.render_html("foo \n baz", [23]) end assert_raises TypeError do CommonMarker.render_html("foo \n baz", nil) end assert_raises TypeError do CommonMarker.render_html("foo \n baz", [:SMART, 'totes_fake']) end assert_raises TypeError do CommonMarker.render_html(123) end assert_raises TypeError do CommonMarker.render_html([123]) end assert_raises TypeError do CommonMarker.render_html(nil) end err = assert_raises TypeError do CommonMarker.render_html("foo \n baz", [:SMART]) end assert_equal err.message, 'option \':SMART\' does not exist for CommonMarker::Config::Render' assert_raises TypeError do CommonMarker.render_doc("foo \n baz", 123) end err = assert_raises TypeError do CommonMarker.render_doc("foo \n baz", :safe) end assert_equal err.message, 'option \':safe\' does not exist for CommonMarker::Config::Parse' assert_raises TypeError do CommonMarker.render_doc("foo \n baz", :totes_fake) end assert_raises TypeError do CommonMarker.render_doc("foo \n baz", []) end assert_raises TypeError do CommonMarker.render_doc("foo \n baz", [23]) end assert_raises TypeError do CommonMarker.render_doc("foo \n baz", nil) end assert_raises TypeError do CommonMarker.render_doc("foo \n baz", [:SMART, 'totes_fake']) end assert_raises TypeError do CommonMarker.render_doc(123) end assert_raises TypeError do CommonMarker.render_doc([123]) end assert_raises TypeError do CommonMarker.render_doc(nil) end end def test_bad_set_string_content assert_raises TypeError do @doc.string_content = 123 end end def test_bad_walking assert_nil @doc.parent assert_nil @doc.previous end def test_bad_insertion code = Node.new(:code) assert_raises NodeError do @doc.insert_before(code) end paragraph = Node.new(:paragraph) assert_raises NodeError do @doc.insert_after(paragraph) end document = Node.new(:document) assert_raises NodeError do @doc.prepend_child(document) end assert_raises NodeError do @doc.append_child(document) end end def test_bad_url_get assert_raises NodeError do @doc.url end end def test_bad_url_set assert_raises NodeError do @doc.url = '123' end link = CommonMarker.render_doc('[GitHub](https://www.github.com)').first_child.first_child assert_raises TypeError do link.url = 123 end end def test_bad_title_get assert_raises NodeError do @doc.title end end def test_bad_title_set assert_raises NodeError do @doc.title = '123' end image = CommonMarker.render_doc('') image = image.first_child.first_child assert_raises TypeError do image.title = 123 end end def test_bad_header_level_get assert_raises NodeError do @doc.header_level end end def test_bad_header_level_set assert_raises NodeError do @doc.header_level = 1 end header = CommonMarker.render_doc('### Header Three').first_child assert_raises TypeError do header.header_level = '123' end end def test_bad_list_type_get assert_raises NodeError do @doc.list_type end end def test_bad_list_type_set assert_raises NodeError do @doc.list_type = :bullet_list end ul_list = CommonMarker.render_doc("* Bullet\n*Bullet").first_child assert_raises NodeError do ul_list.list_type = :fake end assert_raises TypeError do ul_list.list_type = 1234 end end def test_bad_list_start_get assert_raises NodeError do @doc.list_start end end def test_bad_list_start_set assert_raises NodeError do @doc.list_start = 12 end ol_list = CommonMarker.render_doc("1. One\n2. Two").first_child assert_raises TypeError do ol_list.list_start = :fake end end def test_bad_list_tight_get assert_raises NodeError do @doc.list_tight end end def test_bad_list_tight_set assert_raises NodeError do @doc.list_tight = false end end def test_bad_fence_info_get assert_raises NodeError do @doc.fence_info end end def test_bad_fence_info_set assert_raises NodeError do @doc.fence_info = 'ruby' end fence = CommonMarker.render_doc("``` ruby\nputs 'wow'\n```").first_child assert_raises TypeError do fence.fence_info = 123 end end end commonmarker-0.20.2/test/test_basics.rb 0000644 0000041 0000041 00000000576 13600617370 020137 0 ustar www-data www-data # frozen_string_literal: true require 'test_helper' class TestBasics < Minitest::Test def setup @doc = CommonMarker.render_doc('Hi *there*') end def test_to_html assert_equal "
Hi there
\n", @doc.to_html end def test_markdown_to_html html = CommonMarker.render_html('Hi *there*') assert_equal "Hi there
\n", html end end commonmarker-0.20.2/test/test_renderer.rb 0000644 0000041 0000041 00000001432 13600617370 020471 0 ustar www-data www-data # frozen_string_literal: true require 'test_helper' class TestRenderer < Minitest::Test def setup @doc = CommonMarker.render_doc('Hi *there*') end def test_html_renderer renderer = HtmlRenderer.new result = renderer.render(@doc) assert_equal "Hi there
\n", result end def test_multiple_tables content = ''' | Input | Expected | Actual | | ----------- | ---------------- | --------- | | One | Two | Three | | Header | Row | Example | | :------: | ---: | :------ | | Foo | Bar | Baz | ''' doc = CommonMarker.render_doc(content, :DEFAULT, [:autolink, :table, :tagfilter]) results = CommonMarker::HtmlRenderer.new.render(doc) assert_equal 2, results.scan(//).size end end commonmarker-0.20.2/test/fixtures/ 0000755 0000041 0000041 00000000000 13600617370 017150 5 ustar www-data www-data commonmarker-0.20.2/test/fixtures/table.md 0000644 0000041 0000041 00000000142 13600617370 020556 0 ustar www-data www-data One extension: | a | b | | --- | --- | | c | d | | **x** | | Another extension: ~~hi~~ commonmarker-0.20.2/test/fixtures/dingus.md 0000644 0000041 0000041 00000000336 13600617370 020765 0 ustar www-data www-data ## Try CommonMark You can try CommonMark here. This dingus is powered by [commonmark.js](https://github.com/jgm/commonmark.js), the JavaScript reference implementation. 1. item one 2. item two - sublist - sublist commonmarker-0.20.2/test/fixtures/strong.md 0000644 0000041 0000041 00000000020 13600617370 020776 0 ustar www-data www-data I am **strong** commonmarker-0.20.2/test/fixtures/curly.md 0000644 0000041 0000041 00000000076 13600617370 020633 0 ustar www-data www-data This curly quote “makes commonmarker throw an exception”. commonmarker-0.20.2/test/test_smartpunct.rb 0000644 0000041 0000041 00000001225 13600617370 021063 0 ustar www-data www-data # 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) define_method("test_smart_punct_example_#{testcase[:example]}") do actual = doc.to_html.strip assert_equal testcase[:html], actual, testcase[:markdown] end end def test_smart_hardbreak_no_spaces_render_doc markdown = "\"foo\"\nbaz" result = "“foo”
\nbaz
This curly quote “makes commonmarker throw an exception”.
' end def test_string_content_is_utf8 doc = CommonMarker.render_doc('Hi *there*') text = doc.first_child.last_child.first_child assert_equal text.string_content, 'there' assert_equal text.string_content.encoding.name, 'UTF-8' end end commonmarker-0.20.2/test/test_footnotes.rb 0000644 0000041 0000041 00000001137 13600617370 020705 0 ustar www-data www-data # frozen_string_literal: true require 'test_helper' class TestFootnotes < Minitest::Test def setup @doc = CommonMarker.render_doc("Hello[^hi].\n\n[^hi]: Hey!\n", :FOOTNOTES) @expected = <<-HTMLHello1.
Hey! ↩
Hi there, I am mostly text!
\n", @doc.to_html end def test_html_renderer renderer = HtmlRenderer.new result = renderer.render(@doc) assert_equal "Hi there, I am mostly text!
\n", result end def test_walk_and_set_string_content @doc.walk do |node| if node.type == :text && node.string_content == 'there' node.string_content = 'world' end end result = HtmlRenderer.new.render(@doc) assert_equal "Hi world, I am mostly text!
\n", result end def test_walk_and_delete_node @doc.walk do |node| if node.type == :emph node.insert_before(node.first_child) node.delete end end assert_equal "Hi there, I am mostly text!
\n", @doc.to_html end def test_inspect assert_match /#