tartan 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README +130 -0
  3. data/TODO +17 -0
  4. data/lib/core_ext/array.rb +12 -0
  5. data/lib/core_ext/file.rb +15 -0
  6. data/lib/core_ext/hash.rb +16 -0
  7. data/lib/core_ext/match_data.rb +62 -0
  8. data/lib/core_ext/module.rb +17 -0
  9. data/lib/core_ext/regexp.rb +33 -0
  10. data/lib/markdown.yml +499 -0
  11. data/lib/symbolize.rb +78 -0
  12. data/lib/table.yml +63 -0
  13. data/lib/tartan.rb +359 -0
  14. data/lib/tartan_markdown.rb +8 -0
  15. data/lib/tartan_markdown_def.rb +7 -0
  16. data/lib/tartan_table_def.rb +7 -0
  17. data/lib/tartan_test_base_def.rb +5 -0
  18. data/lib/tartan_wikilink_def.rb +14 -0
  19. data/lib/test_base.yml +18 -0
  20. data/lib/wiki-test.rb +94 -0
  21. data/lib/wiki_rule.rb +240 -0
  22. data/lib/wikilink.yml +18 -0
  23. data/test/MarkdownTest_1.0/Amps and angle encoding.html +17 -0
  24. data/test/MarkdownTest_1.0/Amps and angle encoding.text +21 -0
  25. data/test/MarkdownTest_1.0/Auto links.html +18 -0
  26. data/test/MarkdownTest_1.0/Auto links.text +13 -0
  27. data/test/MarkdownTest_1.0/Backslash codeescapes.html +68 -0
  28. data/test/MarkdownTest_1.0/Backslash codeescapes.text +68 -0
  29. data/test/MarkdownTest_1.0/Backslash simpleescapes.html +33 -0
  30. data/test/MarkdownTest_1.0/Backslash simpleescapes.text +33 -0
  31. data/test/MarkdownTest_1.0/Blockquotes with code blocks.html +15 -0
  32. data/test/MarkdownTest_1.0/Blockquotes with code blocks.text +11 -0
  33. data/test/MarkdownTest_1.0/Hard-wrapped paragraphs with list-like lines.html +8 -0
  34. data/test/MarkdownTest_1.0/Hard-wrapped paragraphs with list-like lines.text +8 -0
  35. data/test/MarkdownTest_1.0/Horizontal rules.html +71 -0
  36. data/test/MarkdownTest_1.0/Horizontal rules.text +67 -0
  37. data/test/MarkdownTest_1.0/Inline HTML (Advanced).html +14 -0
  38. data/test/MarkdownTest_1.0/Inline HTML (Advanced).text +14 -0
  39. data/test/MarkdownTest_1.0/Inline HTML (Simple).html +72 -0
  40. data/test/MarkdownTest_1.0/Inline HTML (Simple).text +69 -0
  41. data/test/MarkdownTest_1.0/Inline HTML comments.html +13 -0
  42. data/test/MarkdownTest_1.0/Inline HTML comments.text +13 -0
  43. data/test/MarkdownTest_1.0/Links, inline style.html +9 -0
  44. data/test/MarkdownTest_1.0/Links, inline style.text +9 -0
  45. data/test/MarkdownTest_1.0/Links, reference style.html +18 -0
  46. data/test/MarkdownTest_1.0/Links, reference style.text +31 -0
  47. data/test/MarkdownTest_1.0/Literal quotes in titles.html +3 -0
  48. data/test/MarkdownTest_1.0/Literal quotes in titles.text +7 -0
  49. data/test/MarkdownTest_1.0/Markdown Documentation - Basics.html +314 -0
  50. data/test/MarkdownTest_1.0/Markdown Documentation - Basics.text +306 -0
  51. data/test/MarkdownTest_1.0/Markdown Documentation - Syntax.html +942 -0
  52. data/test/MarkdownTest_1.0/Markdown Documentation - Syntax.text +888 -0
  53. data/test/MarkdownTest_1.0/Nested blockquotes.html +9 -0
  54. data/test/MarkdownTest_1.0/Nested blockquotes.text +5 -0
  55. data/test/MarkdownTest_1.0/Ordered and unordered lists.html +137 -0
  56. data/test/MarkdownTest_1.0/Ordered and unordered lists.text +122 -0
  57. data/test/MarkdownTest_1.0/Strong and em together.html +7 -0
  58. data/test/MarkdownTest_1.0/Strong and em together.text +7 -0
  59. data/test/MarkdownTest_1.0/Tabs.html +25 -0
  60. data/test/MarkdownTest_1.0/Tabs.text +21 -0
  61. data/test/MarkdownTest_1.0/Tidyness.html +8 -0
  62. data/test/MarkdownTest_1.0/Tidyness.text +5 -0
  63. data/test/MarkdownTest_1.0/run-markdown.rb +56 -0
  64. data/test/MarkdownTest_1.0/test-fireball-markdown.rb +177 -0
  65. data/test/MarkdownTest_1.0/testdiff.rb +42 -0
  66. data/test/harder/test-markdown-harder.rb +11 -0
  67. data/test/harder/test-markdown-harder.yml +111 -0
  68. data/test/redcloth/redcloth-markdown-tests.rb +29 -0
  69. data/test/redcloth/redcloth-markdown-tests.yml +218 -0
  70. data/test/test-combo.rb +23 -0
  71. data/test/test-hash.rb +31 -0
  72. data/test/test-markdown.rb +11 -0
  73. data/test/test-markdown.yml +1144 -0
  74. data/test/test-match-data.rb +54 -0
  75. data/test/test-readme-example.rb +48 -0
  76. data/test/test-tables.rb +16 -0
  77. data/test/test-tables.yml +82 -0
  78. data/test/test-tartan-markdown.rb +11 -0
  79. data/test/test-tartan.rb +306 -0
  80. data/test/test-wikilink.rb +18 -0
  81. data/test/test-wikilink.yml +22 -0
  82. data/test/wikilink-test-helper.rb +14 -0
  83. metadata +139 -0
@@ -0,0 +1,9 @@
1
+ <blockquote>
2
+ <p>foo</p>
3
+
4
+ <blockquote>
5
+ <p>bar</p>
6
+ </blockquote>
7
+
8
+ <p>foo</p>
9
+ </blockquote>
@@ -0,0 +1,5 @@
1
+ > foo
2
+ >
3
+ > > bar
4
+ >
5
+ > foo
@@ -0,0 +1,137 @@
1
+ <h2>Unordered</h2>
2
+
3
+ <p>Asterisks tight:</p>
4
+
5
+ <ul>
6
+ <li>asterisk 1</li>
7
+ <li>asterisk 2</li>
8
+ <li>asterisk 3</li>
9
+ </ul>
10
+
11
+ <p>Asterisks loose:</p>
12
+
13
+ <ul>
14
+ <li><p>asterisk 1</p></li>
15
+ <li><p>asterisk 2</p></li>
16
+ <li><p>asterisk 3</p></li>
17
+ </ul>
18
+
19
+ <hr />
20
+
21
+ <p>Pluses tight:</p>
22
+
23
+ <ul>
24
+ <li>Plus 1</li>
25
+ <li>Plus 2</li>
26
+ <li>Plus 3</li>
27
+ </ul>
28
+
29
+ <p>Pluses loose:</p>
30
+
31
+ <ul>
32
+ <li><p>Plus 1</p></li>
33
+ <li><p>Plus 2</p></li>
34
+ <li><p>Plus 3</p></li>
35
+ </ul>
36
+
37
+ <hr />
38
+
39
+ <p>Minuses tight:</p>
40
+
41
+ <ul>
42
+ <li>Minus 1</li>
43
+ <li>Minus 2</li>
44
+ <li>Minus 3</li>
45
+ </ul>
46
+
47
+ <p>Minuses loose:</p>
48
+
49
+ <ul>
50
+ <li><p>Minus 1</p></li>
51
+ <li><p>Minus 2</p></li>
52
+ <li><p>Minus 3</p></li>
53
+ </ul>
54
+
55
+ <h2>Ordered</h2>
56
+
57
+ <p>Tight:</p>
58
+
59
+ <ol>
60
+ <li>First</li>
61
+ <li>Second</li>
62
+ <li>Third</li>
63
+ </ol>
64
+
65
+ <p>and:</p>
66
+
67
+ <ol>
68
+ <li>One</li>
69
+ <li>Two</li>
70
+ <li>Three</li>
71
+ </ol>
72
+
73
+ <p>Loose using tabs:</p>
74
+
75
+ <ol>
76
+ <li><p>First</p></li>
77
+ <li><p>Second</p></li>
78
+ <li><p>Third</p></li>
79
+ </ol>
80
+
81
+ <p>and using spaces:</p>
82
+
83
+ <ol>
84
+ <li><p>One</p></li>
85
+ <li><p>Two</p></li>
86
+ <li><p>Three</p></li>
87
+ </ol>
88
+
89
+ <p>Multiple paragraphs:</p>
90
+
91
+ <ol>
92
+ <li><p>Item 1, graf one.</p>
93
+
94
+ <p>Item 2. graf two. The quick brown fox jumped over the lazy dog's
95
+ back.</p></li>
96
+ <li><p>Item 2.</p></li>
97
+ <li><p>Item 3.</p></li>
98
+ </ol>
99
+
100
+ <h2>Nested</h2>
101
+
102
+ <ul>
103
+ <li>Tab
104
+ <ul>
105
+ <li>Tab
106
+ <ul>
107
+ <li>Tab</li>
108
+ </ul></li>
109
+ </ul></li>
110
+ </ul>
111
+
112
+ <p>Here's another:</p>
113
+
114
+ <ol>
115
+ <li>First</li>
116
+ <li>Second:
117
+ <ul>
118
+ <li>Fee</li>
119
+ <li>Fie</li>
120
+ <li>Foe</li>
121
+ </ul></li>
122
+ <li>Third</li>
123
+ </ol>
124
+
125
+ <p>Same thing but with paragraphs:</p>
126
+
127
+ <ol>
128
+ <li><p>First</p></li>
129
+ <li><p>Second:</p>
130
+
131
+ <ul>
132
+ <li>Fee</li>
133
+ <li>Fie</li>
134
+ <li>Foe</li>
135
+ </ul></li>
136
+ <li><p>Third</p></li>
137
+ </ol>
@@ -0,0 +1,122 @@
1
+ ## Unordered
2
+
3
+ Asterisks tight:
4
+
5
+ * asterisk 1
6
+ * asterisk 2
7
+ * asterisk 3
8
+
9
+
10
+ Asterisks loose:
11
+
12
+ * asterisk 1
13
+
14
+ * asterisk 2
15
+
16
+ * asterisk 3
17
+
18
+ * * *
19
+
20
+ Pluses tight:
21
+
22
+ + Plus 1
23
+ + Plus 2
24
+ + Plus 3
25
+
26
+
27
+ Pluses loose:
28
+
29
+ + Plus 1
30
+
31
+ + Plus 2
32
+
33
+ + Plus 3
34
+
35
+ * * *
36
+
37
+
38
+ Minuses tight:
39
+
40
+ - Minus 1
41
+ - Minus 2
42
+ - Minus 3
43
+
44
+
45
+ Minuses loose:
46
+
47
+ - Minus 1
48
+
49
+ - Minus 2
50
+
51
+ - Minus 3
52
+
53
+
54
+ ## Ordered
55
+
56
+ Tight:
57
+
58
+ 1. First
59
+ 2. Second
60
+ 3. Third
61
+
62
+ and:
63
+
64
+ 1. One
65
+ 2. Two
66
+ 3. Three
67
+
68
+
69
+ Loose using tabs:
70
+
71
+ 1. First
72
+
73
+ 2. Second
74
+
75
+ 3. Third
76
+
77
+ and using spaces:
78
+
79
+ 1. One
80
+
81
+ 2. Two
82
+
83
+ 3. Three
84
+
85
+ Multiple paragraphs:
86
+
87
+ 1. Item 1, graf one.
88
+
89
+ Item 2. graf two. The quick brown fox jumped over the lazy dog's
90
+ back.
91
+
92
+ 2. Item 2.
93
+
94
+ 3. Item 3.
95
+
96
+
97
+
98
+ ## Nested
99
+
100
+ * Tab
101
+ * Tab
102
+ * Tab
103
+
104
+ Here's another:
105
+
106
+ 1. First
107
+ 2. Second:
108
+ * Fee
109
+ * Fie
110
+ * Foe
111
+ 3. Third
112
+
113
+ Same thing but with paragraphs:
114
+
115
+ 1. First
116
+
117
+ 2. Second:
118
+ * Fee
119
+ * Fie
120
+ * Foe
121
+
122
+ 3. Third
@@ -0,0 +1,7 @@
1
+ <p><strong><em>This is strong and em.</em></strong></p>
2
+
3
+ <p>So is <strong><em>this</em></strong> word.</p>
4
+
5
+ <p><strong><em>This is strong and em.</em></strong></p>
6
+
7
+ <p>So is <strong><em>this</em></strong> word.</p>
@@ -0,0 +1,7 @@
1
+ ***This is strong and em.***
2
+
3
+ So is ***this*** word.
4
+
5
+ ___This is strong and em.___
6
+
7
+ So is ___this___ word.
@@ -0,0 +1,25 @@
1
+ <ul>
2
+ <li><p>this is a list item
3
+ indented with tabs</p></li>
4
+ <li><p>this is a list item
5
+ indented with spaces</p></li>
6
+ </ul>
7
+
8
+ <p>Code:</p>
9
+
10
+ <pre><code>this code block is indented by one tab
11
+ </code></pre>
12
+
13
+ <p>And:</p>
14
+
15
+ <pre><code> this code block is indented by two tabs
16
+ </code></pre>
17
+
18
+ <p>And:</p>
19
+
20
+ <pre><code>+ this is an example list item
21
+ indented with tabs
22
+
23
+ + this is an example list item
24
+ indented with spaces
25
+ </code></pre>
@@ -0,0 +1,21 @@
1
+ + this is a list item
2
+ indented with tabs
3
+
4
+ + this is a list item
5
+ indented with spaces
6
+
7
+ Code:
8
+
9
+ this code block is indented by one tab
10
+
11
+ And:
12
+
13
+ this code block is indented by two tabs
14
+
15
+ And:
16
+
17
+ + this is an example list item
18
+ indented with tabs
19
+
20
+ + this is an example list item
21
+ indented with spaces
@@ -0,0 +1,8 @@
1
+ <blockquote>
2
+ <p>A list within a blockquote:</p>
3
+ <ul>
4
+ <li>asterisk 1</li>
5
+ <li>asterisk 2</li>
6
+ <li>asterisk 3</li>
7
+ </ul>
8
+ </blockquote>
@@ -0,0 +1,5 @@
1
+ > A list within a blockquote:
2
+ >
3
+ > * asterisk 1
4
+ > * asterisk 2
5
+ > * asterisk 3
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env ruby
2
+ #$Id: run-markdown.rb 148 2006-07-22 14:04:20Z larry $
3
+ $:.unshift File.join(File.dirname(__FILE__), "../..", "lib")
4
+
5
+ require 'tartan'
6
+ require 'markdown'
7
+ # require 'profile'
8
+
9
+ class WikiparserRunner
10
+ def self.run(base, *other_args)
11
+ wikiFileName=base + ".text"
12
+ outFileName=base + ".out"
13
+
14
+ options = {}
15
+ args = []
16
+ other_args.each do |arg|
17
+ if arg =~ /([^=]+)=(.*)/
18
+
19
+ key = $1
20
+ value = $2
21
+
22
+ if key =~ /^:(.*)$/
23
+ key = $1.to_sym
24
+ end
25
+
26
+ value = case value
27
+ when /^:(.*)/
28
+ $1.to_sym
29
+ when /^[tT]rue$/
30
+ true
31
+ when /^[fF]alse$/
32
+ false
33
+ else
34
+ value
35
+ end
36
+
37
+ options[key] = value
38
+ else
39
+ args << arg
40
+ end
41
+ end
42
+
43
+ text = File.open(wikiFileName).read
44
+ require 'profile' if options['profile']
45
+ wp = Wikiparser.new(text, options)
46
+ html = wp.to_html
47
+ outFile = File.open(outFileName, "w+")
48
+ outFile.puts html
49
+ outFile.rewind
50
+ outFile
51
+ end
52
+ end
53
+
54
+ if __FILE__ == $0
55
+ WikiparserRunner.run(*ARGV).close
56
+ end
@@ -0,0 +1,177 @@
1
+ #!/usr/bin/env ruby
2
+ #$Id: test-fireball-markdown.rb 148 2006-07-22 14:04:20Z larry $
3
+ $:.unshift File.join(File.dirname(__FILE__), "../..", "lib")
4
+
5
+ require 'test/unit'
6
+ require 'tartan'
7
+ require 'markdown'
8
+ require 'profile'
9
+
10
+ class TestMarkdown < Test::Unit::TestCase
11
+ def setup
12
+ @basePara = "Now is the time for all good men..."
13
+ @nl = "\n"
14
+ end
15
+
16
+ def testAmps
17
+ text = File.open('Amps and angle encoding.text').read
18
+ truehtml = File.open('Amps and angle encoding.html').read
19
+ wp = Wikiparser.new(text)
20
+ html = wp.to_html
21
+ assert_equal truehtml, html
22
+ end
23
+
24
+ def testAutolinks
25
+ text = File.open('Auto links.text').read
26
+ truehtml = File.open('Auto links.html').read
27
+ wp = Wikiparser.new(text)
28
+ html = wp.to_html
29
+ assert_equal truehtml, html
30
+ end
31
+
32
+ def testBackslashsimpleescapes
33
+ text = File.open('Backslash simpleescapes.text').read
34
+ truehtml = File.open('Backslash simpleescapes.html').read
35
+ wp = Wikiparser.new(text)
36
+ html = wp.to_html
37
+ assert_equal truehtml, html
38
+ end
39
+
40
+ def testBackslashcodeescapes
41
+ text = File.open('Backslash codeescapes.text').read
42
+ truehtml = File.open('Backslash codeescapes.html').read
43
+ wp = Wikiparser.new(text)
44
+ html = wp.to_html
45
+ assert_equal truehtml, html
46
+ end
47
+
48
+ def testBlockquoteswithcodeblocks
49
+ text = File.open('Blockquotes with code blocks.text').read
50
+ truehtml = File.open('Blockquotes with code blocks.html').read
51
+ wp = Wikiparser.new(text)
52
+ html = wp.to_html
53
+ assert_equal truehtml, html
54
+ end
55
+
56
+ def testHardwrappedparagraphswithlistlikelines
57
+ text = File.open('Hard-wrapped paragraphs with list-like lines.text').read
58
+ truehtml = File.open('Hard-wrapped paragraphs with list-like lines.html').read
59
+ wp = Wikiparser.new(text)
60
+ html = wp.to_html
61
+ assert_equal truehtml, html
62
+ end
63
+
64
+ def testHorizontalrules
65
+ text = File.open('Horizontal rules.text').read
66
+ truehtml = File.open('Horizontal rules.html').read
67
+ wp = Wikiparser.new(text)
68
+ html = wp.to_html
69
+ assert_equal truehtml, html
70
+ end
71
+
72
+ def testInlineHTMLcomments
73
+ text = File.open('Inline HTML comments.text').read
74
+ truehtml = File.open('Inline HTML comments.html').read
75
+ wp = Wikiparser.new(text)
76
+ html = wp.to_html
77
+ assert_equal truehtml, html
78
+ end
79
+
80
+ def testInlineHTMLAdvanced
81
+ text = File.open('Inline HTML (Advanced).text').read
82
+ truehtml = File.open('Inline HTML (Advanced).html').read
83
+ wp = Wikiparser.new(text)
84
+ html = wp.to_html
85
+ assert_equal truehtml, html
86
+ end
87
+
88
+ def testInlineHTMLSimple
89
+ text = File.open('Inline HTML (Simple).text').read
90
+ truehtml = File.open('Inline HTML (Simple).html').read
91
+ wp = Wikiparser.new(text)
92
+ html = wp.to_html
93
+ assert_equal truehtml, html
94
+ end
95
+
96
+ def testLinksinlinestyle
97
+ text = File.open('Links, inline style.text').read
98
+ truehtml = File.open('Links, inline style.html').read
99
+ wp = Wikiparser.new(text)
100
+ html = wp.to_html
101
+ assert_equal truehtml, html
102
+ end
103
+
104
+ def testLinksreferencestyle
105
+ text = File.open('Links, reference style.text').read
106
+ truehtml = File.open('Links, reference style.html').read
107
+ wp = Wikiparser.new(text)
108
+ html = wp.to_html
109
+ assert_equal truehtml, html
110
+ end
111
+
112
+ def testLiteralquotesintitles
113
+ text = File.open('Literal quotes in titles.text').read
114
+ truehtml = File.open('Literal quotes in titles.html').read
115
+ wp = Wikiparser.new(text)
116
+ html = wp.to_html
117
+ assert_equal truehtml, html
118
+ end
119
+
120
+ def testMarkdownDocumentationBasics
121
+ text = File.open('Markdown Documentation - Basics.text').read
122
+ truehtml = File.open('Markdown Documentation - Basics.html').read
123
+ wp = Wikiparser.new(text)
124
+ html = wp.to_html
125
+ assert_equal truehtml, html
126
+ end
127
+
128
+ def testMarkdownDocumentationSyntax
129
+ text = File.open('Markdown Documentation - Syntax.text').read
130
+ truehtml = File.open('Markdown Documentation - Syntax.html').read
131
+ wp = Wikiparser.new(text)
132
+ html = wp.to_html
133
+ assert_equal truehtml, html
134
+ end
135
+
136
+ def testNestedblockquotes
137
+ text = File.open('Nested blockquotes.text').read
138
+ truehtml = File.open('Nested blockquotes.html').read
139
+ wp = Wikiparser.new(text)
140
+ html = wp.to_html
141
+ assert_equal truehtml, html
142
+ end
143
+
144
+ def testOrderedandunorderedlists
145
+ text = File.open('Ordered and unordered lists.text').read
146
+ truehtml = File.open('Ordered and unordered lists.html').read
147
+ wp = Wikiparser.new(text)
148
+ html = wp.to_html
149
+ assert_equal truehtml, html
150
+ end
151
+
152
+ def testStrongandemtogether
153
+ text = File.open('Strong and em together.text').read
154
+ truehtml = File.open('Strong and em together.html').read
155
+ wp = Wikiparser.new(text)
156
+ html = wp.to_html
157
+ assert_equal truehtml, html
158
+ end
159
+
160
+ def testTabs
161
+ text = File.open('Tabs.text').read
162
+ truehtml = File.open('Tabs.html').read
163
+ wp = Wikiparser.new(text)
164
+ html = wp.to_html
165
+ assert_equal truehtml, html
166
+ end
167
+
168
+ def testTidyness
169
+ text = File.open('Tidyness.text').read
170
+ truehtml = File.open('Tidyness.html').read
171
+ wp = Wikiparser.new(text)
172
+ html = wp.to_html
173
+ assert_equal truehtml, html
174
+ end
175
+
176
+
177
+ end