tartan 0.1.0 → 0.1.1

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.
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
- #$Id: run-markdown.rb 148 2006-07-22 14:04:20Z larry $
2
+ #$Id: run-markdown.rb 174 2006-08-21 14:51:12Z bitherder $
3
3
  $:.unshift File.join(File.dirname(__FILE__), "../..", "lib")
4
4
 
5
5
  require 'tartan'
6
- require 'markdown'
6
+ require 'tartan_markdown'
7
7
  # require 'profile'
8
8
 
9
9
  class WikiparserRunner
@@ -42,7 +42,7 @@ class WikiparserRunner
42
42
 
43
43
  text = File.open(wikiFileName).read
44
44
  require 'profile' if options['profile']
45
- wp = Wikiparser.new(text, options)
45
+ wp = TartanMarkdown.new(text, options)
46
46
  html = wp.to_html
47
47
  outFile = File.open(outFileName, "w+")
48
48
  outFile.puts html
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  #$Id: test-markdown.rb 75 2006-02-07 00:09:26Z larry $
3
3
 
4
- $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
4
+ $:.unshift File.join(File.dirname(__FILE__), "../..", "lib")
5
5
 
6
6
  require 'tartan_markdown'
7
7
  require 'wiki-test'
@@ -1,4 +1,4 @@
1
- #$Id: test-markdown.yml 167 2006-08-15 06:15:47Z david $
1
+ #$Id: test-markdown.yml 175 2006-08-21 14:52:09Z bitherder $
2
2
  ---
3
3
  title: OneParagraph
4
4
  in: "abc\ndef\nxyz"
@@ -52,6 +52,7 @@ in: |-
52
52
  * item2
53
53
  html: |-
54
54
  <h1>A Header 1</h1>
55
+
55
56
  <ul>
56
57
  <li>item1</li>
57
58
  <li>item2</li>
@@ -395,6 +396,22 @@ html: |+
395
396
  Plus: <code>\+</code><br />
396
397
  Minus: <code>\-</code><br /></p>
397
398
  ---
399
+ title: ParagraphWithList
400
+ in: |-
401
+ A list within a blockquote:
402
+
403
+ * asterisk 1
404
+ * asterisk 2
405
+ * asterisk 3
406
+ html: |-
407
+ <p>A list within a blockquote:</p>
408
+
409
+ <ul>
410
+ <li>asterisk 1</li>
411
+ <li>asterisk 2</li>
412
+ <li>asterisk 3</li>
413
+ </ul>
414
+ ---
398
415
  title: ListInBlockquote
399
416
  in: |
400
417
  > A list within a blockquote:
@@ -1067,6 +1084,21 @@ html: |-
1067
1084
  <p>Happy days</p>
1068
1085
 
1069
1086
 
1087
+ ---
1088
+ title: TwoLineCodeBlock
1089
+ in: |2-
1090
+ Paragraph 1
1091
+
1092
+ http://example.com/
1093
+
1094
+ Paragraph 2
1095
+ html: |-
1096
+ <p>Paragraph 1</p>
1097
+
1098
+ <pre><code>http://example.com/
1099
+ </code></pre>
1100
+
1101
+ <p>Paragraph 2</p>
1070
1102
  ---
1071
1103
  # Transfered from test-markdown-harder.yml
1072
1104
  title: LTGTinCode
@@ -1142,3 +1174,18 @@ html: |-
1142
1174
  <p>bob</p>
1143
1175
 
1144
1176
  <hr />
1177
+ ---
1178
+ title: CodeAfterHeader
1179
+ in: |-
1180
+ ##Header
1181
+
1182
+ code
1183
+ html: |-
1184
+ <h2>Header</h2>
1185
+
1186
+ <pre><code>code
1187
+ </code></pre>
1188
+ ---
1189
+ title: DoubleCevrons
1190
+ in: Start with <<some text>> and some other text.
1191
+ html: <p>Start with &lt;&lt;some text&gt;&gt; and some other text.</p>
@@ -1,4 +1,4 @@
1
- #$Id: test-readme-example.rb 164 2006-08-13 18:17:48Z larry $
1
+ #$Id: test-readme-example.rb 173 2006-08-21 09:19:04Z bitherder $
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
4
4
 
@@ -8,16 +8,98 @@ require 'tartan'
8
8
  ParagraphAndCodeDef = %q~
9
9
  block:
10
10
  - title: code
11
- match: "/(^[ ]{2,}\S.+?$\n)+^[ ]{2,}\S.+?$/m"
11
+ match: /(^[ ]{2,}\S.+?$\n)+^[ ]{2,}\S.+?$/m
12
12
  html:
13
13
  start_mark: <pre><code>
14
14
  end_mark: </code></pre>
15
15
  - title: paragraph
16
- match: "/(^[^\n]+$\n)+^[^\n]+$/m"
16
+ match: /(^[^\n]+$\n)*^[^\n]+$/m
17
17
  html:
18
18
  start_mark: <p>
19
19
  end_mark: </p>
20
20
  ~
21
+ WithEmphasisDef = %q~
22
+ block:
23
+ - title: code
24
+ match: /(^[ ]{2,}\S.+?$\n)+^[ ]{2,}\S.+?$/m
25
+ html:
26
+ start_mark: <pre><code>
27
+ end_mark: </code></pre>
28
+ - title: paragraph
29
+ match: /(^[^\n]+$\n)*^[^\n]+$/m
30
+ subparse: paragraph
31
+ html:
32
+ start_mark: <p>
33
+ end_mark: </p>
34
+ paragraph:
35
+ - title: strong
36
+ match: /\*\*(.*?)\*\*/m
37
+ html:
38
+ replace: <strong>\1</strong>
39
+
40
+ - rescan
41
+
42
+ - title: emphasis
43
+ match: /\*(.*?)\*/m
44
+ html:
45
+ replace: <em>\1</em>
46
+ ~
47
+
48
+ WithoutStrongDef = %q~
49
+ block:
50
+ - title: code
51
+ match: /(^[ ]{2,}\S.+?$\n)+^[ ]{2,}\S.+?$/m
52
+ html:
53
+ start_mark: <pre><code>
54
+ end_mark: </code></pre>
55
+ - title: paragraph
56
+ match: /(^[^\n]+$\n)*^[^\n]+$/m
57
+ subparse: paragraph
58
+ html:
59
+ start_mark: <p>
60
+ end_mark: </p>
61
+ paragraph:
62
+ - title: emphasis
63
+ match: /\*(.*?)\*/
64
+ html:
65
+ replace: <em>\1</em>
66
+ ~
67
+ EntityDef = %q~
68
+ paragraph:
69
+ - rescan
70
+ - title: amp
71
+ match: /&/
72
+ html:
73
+ replace: '&amp;'
74
+ rescan: true
75
+ - title: rightArrow
76
+ match: /->/
77
+ html:
78
+ replace: '&rarr;'
79
+ rescan: true
80
+ - title: lessThan
81
+ match: /</
82
+ html:
83
+ replace: '&lt;'
84
+ rescan: true
85
+ - title: greaterThan
86
+ match: />/
87
+ html:
88
+ replace: '&gt;'
89
+ ~
90
+
91
+ EmphasisText = <<TEXT
92
+ Now is the time for all *good*
93
+ **men** to come to the aid of
94
+ their party.
95
+
96
+ p "Hello"
97
+ p "World"
98
+ TEXT
99
+
100
+ EmbeddedEmphasisText =
101
+ "Now listen to this **I want *you* to really hear me**."
102
+
21
103
  class ReadmeTestCase < Test::Unit::TestCase
22
104
  class ParagraphAndCode < Tartan
23
105
  set_defs(ParagraphAndCodeDef)
@@ -25,7 +107,7 @@ class ReadmeTestCase < Test::Unit::TestCase
25
107
 
26
108
  def testParagraphAndCode
27
109
  text = <<TEXT
28
- Now is the time for all good
110
+ Now is the time for all good
29
111
  men to come to the aid of
30
112
  their party.
31
113
 
@@ -34,7 +116,7 @@ their party.
34
116
  TEXT
35
117
 
36
118
  html = \
37
- %q~<p>Now is the time for all good
119
+ %q~<p>Now is the time for all good
38
120
  men to come to the aid of
39
121
  their party.</p>
40
122
 
@@ -45,4 +127,61 @@ their party.</p>
45
127
  parser = ParagraphAndCode.new(text)
46
128
  assert_equal(html, parser.to_html)
47
129
  end
130
+
131
+ class WithEmphasis < Tartan
132
+ set_defs(WithEmphasisDef)
133
+ end
134
+
135
+ def testWithEmphasis
136
+ html = \
137
+ %q~<p>Now is the time for all <em>good</em>
138
+ <strong>men</strong> to come to the aid of
139
+ their party.</p>
140
+
141
+ <pre><code> p "Hello"
142
+ p "World"</code></pre>
143
+ ~
144
+
145
+ parser = WithEmphasis.new(EmphasisText)
146
+ assert_equal(html, parser.to_html)
147
+ end
148
+
149
+ def testWithEmbeddedEmpahsis
150
+ html = "<p>Now listen to this <strong>I want <em>you</em> to really hear me</strong>.</p>"
151
+
152
+ parser = WithEmphasis.new(EmbeddedEmphasisText)
153
+ assert_equal(html, parser.to_html)
154
+ end
155
+
156
+ class WithoutStrong < Tartan
157
+ set_defs(WithoutStrongDef)
158
+ end
159
+
160
+ def testWithoutStrong
161
+ html = "<p>Now listen to this <em></em>I want <em>you</em> to really hear me<em></em>.</p>"
162
+
163
+ parser = WithoutStrong.new(EmbeddedEmphasisText)
164
+ assert_equal(html, parser.to_html)
165
+ end
166
+
167
+ class EntityMixin < Tartan
168
+ set_defs(WithEmphasisDef)
169
+ add_defs(EntityDef)
170
+ end
171
+
172
+ def testEnityMixin
173
+ text =
174
+ %q~A paragraph in HTML is marked-up using a <p> start tag and a </p> end tag.
175
+ Thus, the phrase "I was here." -> "<p>I was here</p>". If you want to use less
176
+ than and greater than characters you will need to put &lt; and &gt; respectively
177
+ in your HTML.~
178
+
179
+ html =
180
+ %q~<p>A paragraph in HTML is marked-up using a &lt;p&gt; start tag and a &lt;/p&gt; end tag.
181
+ Thus, the phrase "I was here." &rarr; "&lt;p&gt;I was here&lt;/p&gt;". If you want to use less
182
+ than and greater than characters you will need to put &amp;lt; and &amp;gt; respectively
183
+ in your HTML.</p>~
184
+ parser = EntityMixin.new(text)
185
+ assert_equal(html, parser.to_html)
186
+ end
48
187
  end
@@ -0,0 +1,42 @@
1
+ # $Id: test-regexp.rb 173 2006-08-21 09:19:04Z bitherder $
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
4
+
5
+ require 'test/unit'
6
+ require 'core_ext/regexp'
7
+
8
+ class TestString < Test::Unit::TestCase
9
+ def testOneLine
10
+ match = "/^(\s+)$/".to_regexp.match(" \n ")
11
+ assert_equal(" ", match[1])
12
+ end
13
+
14
+ def testMultiLine
15
+ text_in = " \n \n"
16
+ expected_match = " \n \n"
17
+ regex_from_string = '/^(\s+)$/m'.to_regexp
18
+
19
+ assert_equal(Regexp::MULTILINE, regex_from_string.options)
20
+ assert_equal('^(\s+)$', regex_from_string.source)
21
+
22
+ plain_regex = /^(\s+)$/m
23
+
24
+ assert_equal(Regexp::MULTILINE, plain_regex.options)
25
+ assert_equal('^(\s+)$', plain_regex.source)
26
+
27
+ match_from_string = regex_from_string.match(text_in)
28
+ match_from_regex = /^(\s+)$/m.match(text_in)
29
+
30
+ assert_equal(expected_match, match_from_regex[1])
31
+ assert_equal(expected_match, match_from_string[1])
32
+ end
33
+
34
+ def testWhitespaceAtEndOfLine
35
+ regexp = '/^(#{1,6})\s*([^#\s][^#]*?)(?:\s*\#+)?\s*?$/'.to_regexp
36
+ match = regexp.match "## header\n\nSome text."
37
+
38
+ assert_equal("##", match[1])
39
+ assert_equal("header", match[2])
40
+ assert_equal("## header", match[0])
41
+ end
42
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: tartan
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.0
7
- date: 2006-08-17 00:00:00 +02:00
6
+ version: 0.1.1
7
+ date: 2006-08-21 00:00:00 +02:00
8
8
  summary: A library for building text parsers
9
9
  require_paths:
10
10
  - lib
@@ -41,6 +41,7 @@ files:
41
41
  - test/test-markdown.yml
42
42
  - test/test-match-data.rb
43
43
  - test/test-readme-example.rb
44
+ - test/test-regexp.rb
44
45
  - test/test-tables.rb
45
46
  - test/test-tables.yml
46
47
  - test/test-tartan-markdown.rb
@@ -75,8 +76,10 @@ files:
75
76
  - test/MarkdownTest_1.0/Literal quotes in titles.html
76
77
  - test/MarkdownTest_1.0/Literal quotes in titles.text
77
78
  - test/MarkdownTest_1.0/Markdown Documentation - Basics.html
79
+ - test/MarkdownTest_1.0/Markdown Documentation - Basics.out
78
80
  - test/MarkdownTest_1.0/Markdown Documentation - Basics.text
79
81
  - test/MarkdownTest_1.0/Markdown Documentation - Syntax.html
82
+ - test/MarkdownTest_1.0/Markdown Documentation - Syntax.out
80
83
  - test/MarkdownTest_1.0/Markdown Documentation - Syntax.text
81
84
  - test/MarkdownTest_1.0/Nested blockquotes.html
82
85
  - test/MarkdownTest_1.0/Nested blockquotes.text
@@ -121,6 +124,7 @@ test_files:
121
124
  - test/test-markdown.rb
122
125
  - test/test-match-data.rb
123
126
  - test/test-readme-example.rb
127
+ - test/test-regexp.rb
124
128
  - test/test-tables.rb
125
129
  - test/test-tartan-markdown.rb
126
130
  - test/test-tartan.rb