public
Rubygem
Description: BlueCloth's evil twin - convert HTML into Markdown
Homepage: http://www.craigjolicoeur.com/clothblue
Clone URL: git://github.com/cpjolicoeur/clothblue.git
Search Repo:
Click here to lend your support to: clothblue and make a donation at www.pledgie.com !
add initial test files
cpjolicoeur (author)
Wed May 14 09:29:20 -0700 2008
commit  daee589339cca71d6a3473c1f8c96d12801b84d7
tree    b2d0cd028121d1401cefbd4faae52ba406979ca2
parent  b71a64b7ef2cd9fbe8b901564b4951cc2b797d98
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
29
30
31
0
@@ -1 +1,32 @@
0
+# test_entities.rb
0
+# May 14, 2008
0
+#
0
+
0
+$:.unshift File.join(File.dirname(__FILE__),'..','lib')
0
+
0
+begin
0
+ require "rubygems"
0
+ require "clothblue"
0
+rescue LoadError
0
+ require "clothblue"
0
+end
0
+
0
+require 'test/unit'
0
+
0
+class TestClothBlueEntities < Test::Unit::TestCase
0
+
0
+ ENTITIES_TEST = [
0
+ ["&#8220;", '"'], ["&#8221;", '"'], ["&#8212;", "--"], ["&#8212;", "--"],
0
+ ["&#8211;","-"], ["&#8230;", "..."], ["&#215;", " x "], ["&#8482;","(TM)"],
0
+ ["&#174;","(R)"], ["&#169;","(C)"], ["&#8217;", "'"]
0
+ ]
0
+
0
+ def test_entities
0
+ ENTITIES_TEST.each do |html, markdown|
0
+ test_html = ClothBlue.new(html)
0
+ result = test_html.to_markdown
0
+ assert_equal(markdown,result)
0
+ end
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
29
30
31
32
33
0
@@ -1 +1,34 @@
0
+# test_formatting.rb
0
+# May 15, 2008
0
+#
0
+
0
+#circumventing a require Problem:
0
+$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
0
+
0
+begin
0
+ require "rubygems"
0
+ require "clothblue"
0
+rescue LoadError
0
+ require "clothblue"
0
+end
0
+
0
+require "test/unit"
0
+
0
+class TestClothBlueFormatting < Test::Unit::TestCase
0
+
0
+ FORMATTING_STRINGS = [
0
+ ["<b>bold</b>","**bold**"], ["<strong>strong</strong>", "**strong**"],
0
+ ["<em>emphasized</em>", "_emphasized_"],["<i>italics</i>", "_italics_"],
0
+ ["<code>ClothBlue#to_markdown</code>", "`ClothBlue#to_markdown`"]
0
+ ]
0
+
0
+ def test_textformatting
0
+ FORMATTING_STRINGS.each do |html, markdown|
0
+ test_html = ClothBlue.new(html)
0
+ result = test_html.to_markdown
0
+ assert_equal(markdown,result)
0
+ end
0
+ end
0
+
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
0
@@ -1 +1,47 @@
0
+# test_headings.rb
0
+# May 15, 2008
0
+#
0
+
0
+$:.unshift File.join(File.dirname(__FILE__),'..','lib')
0
+
0
+begin
0
+ require "rubygems"
0
+ require "clothblue"
0
+rescue LoadError
0
+ require "clothblue"
0
+end
0
+
0
+require 'test/unit'
0
+
0
+class TestClothBlueHeadings < Test::Unit::TestCase
0
+
0
+ HEADING_TEST = [
0
+ ["<h1>Heading 1</h1>","# Heading 1 #\n\n"], ["<h2>Heading 2</h2>", "## Heading 2 ##\n\n"],
0
+ ["<h3>Heading 3</h3>", "### Heading 3 ###\n\n"], ["<h4>Heading 4</h4>", "#### Heading 4 ####\n\n"],
0
+ ["<h5>Heading 5</h5>", "##### Heading 5 #####\n\n"], ["<h6>Heading 6</h6>", "###### Heading 6 ######\n\n"]
0
+ ]
0
+
0
+
0
+ def test_headings
0
+ HEADING_TEST.each do |html, markdown|
0
+ test_html = ClothBlue.new(html)
0
+ result = test_html.to_markdown
0
+ assert_equal(markdown,result)
0
+ end
0
+ end
0
+
0
+ MIST_TEST = [
0
+ ["<h1>Heading 1</h1><h2>Heading 2</h2>","# Heading 1 #\n\n## Heading 2 ##\n\n"],
0
+ ]
0
+
0
+
0
+ def test_mist_headings
0
+ MIST_TEST.each do |html, markdown|
0
+ test_html = ClothBlue.new(html)
0
+ result = test_html.to_markdown
0
+ assert_equal(markdown,result)
0
+ end
0
+ end
0
+
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
29
0
@@ -1 +1,30 @@
0
+# test_lists.rb
0
+# May 15, 2008
0
+#
0
+
0
+$:.unshift File.join(File.dirname(__FILE__),'..','lib')
0
+
0
+begin
0
+ require "rubygems"
0
+ require "clothblue"
0
+rescue LoadError
0
+ require "clothblue"
0
+end
0
+
0
+require 'test/unit'
0
+
0
+class TestClothBlueLists < Test::Unit::TestCase
0
+
0
+LISTS_TEST = [
0
+ ["<ol>",""], ["</ol>","\n\n"], ["<li>","+ "], ["</li>","\n"], ["<ul>", ""], ["</ul>", "\n\n"]
0
+ ]
0
+
0
+ def test_lists
0
+ LISTS_TEST.each do |html, markdown|
0
+ test_html = ClothBlue.new(html)
0
+ result = test_html.to_markdown
0
+ assert_equal(markdown,result)
0
+ end
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
29
30
31
32
0
@@ -1 +1,33 @@
0
+# test_structure.rb
0
+# May 15, 2008
0
+#
0
+
0
+$:.unshift File.join(File.dirname(__FILE__),'..','lib')
0
+
0
+begin
0
+ require "rubygems"
0
+ require "clothblue"
0
+rescue LoadError
0
+ require "clothblue"
0
+end
0
+
0
+require 'test/unit'
0
+
0
+class TestClothBlueStructures < Test::Unit::TestCase
0
+
0
+ STRUCTURE_TEST = [
0
+ ["<blockquote>blockquote</blockquote>","> blockquote\n"],
0
+ ["<p>paragraph</p><p>another paragraph</p>", "\n\nparagraph\n\n\n\nanother paragraph\n\n"],
0
+ ["HTML page break<br>", "HTML page break\n"], ["XHTML page break<br />", "XHTML page break\n"]
0
+ ]
0
+
0
+
0
+ def test_structures
0
+ STRUCTURE_TEST.each do |html, markdown|
0
+ test_html = ClothBlue.new(html)
0
+ result = test_html.to_markdown
0
+ assert_equal(markdown,result)
0
+ end
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
29
30
0
@@ -1 +1,31 @@
0
+# test_tables.rb
0
+# May 15, 2008
0
+#
0
+
0
+$:.unshift File.join(File.dirname(__FILE__),'..','lib')
0
+
0
+begin
0
+ require "rubygems"
0
+ require "clothblue"
0
+rescue LoadError
0
+ require "clothblue"
0
+end
0
+
0
+require 'test/unit'
0
+
0
+class TestClothBlueTables < Test::Unit::TestCase
0
+
0
+ TABLES_TEST = [
0
+ ["<table><tr><td>name</td><td>age</td><td>sex</td></tr><tr><td>joan</td><td>24</td><td>f</td></tr></table>",
0
+ "\n\n<table><tr><td>name</td><td>age</td><td>sex</td></tr><tr><td>joan</td><td>24</td><td>f</td></tr></table>\n\n"]
0
+ ]
0
+
0
+ def test_entities
0
+ TABLES_TEST.each do |html, markdown|
0
+ test_html = ClothBlue.new(html)
0
+ result = test_html.to_markdown
0
+ assert_equal(markdown,result)
0
+ end
0
+ end
0
+end

Comments

    No one has commented yet.