asciidoctor 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ require 'test_helper'
2
+
3
+ class LexerTest < Test::Unit::TestCase
4
+ # setup for test
5
+ def setup
6
+ end
7
+
8
+ def test_is_section_heading
9
+ assert Asciidoctor::Lexer.is_section_heading?("AsciiDoc Home Page", "==================")
10
+ assert Asciidoctor::Lexer.is_section_heading?("=== AsciiDoc Home Page")
11
+ end
12
+ end
@@ -29,7 +29,7 @@ context "Bulleted lists (:ulist)" do
29
29
  end
30
30
 
31
31
  test "nested elements (2) with asterisks" do
32
- output = render_string("Blah\n====\n* Foo\n** Boo\n* Blech")
32
+ output = render_string("* Foo\n** Boo\n* Blech")
33
33
  assert_xpath '//ul', output, 2
34
34
  assert_xpath '//ul/li', output, 3
35
35
  end
@@ -0,0 +1,56 @@
1
+ require 'test_helper'
2
+
3
+ class ReaderTest < Test::Unit::TestCase
4
+ # setup for test
5
+ def setup
6
+ @src_data = File.readlines(sample_doc_path(:asciidoc_index))
7
+ @reader = Asciidoctor::Reader.new @src_data
8
+ end
9
+
10
+ context "has_lines?" do
11
+ test "returns false for empty document" do
12
+ assert ! Asciidoctor::Reader.new.has_lines?
13
+ end
14
+
15
+ test "returns true with lines remaining" do
16
+ assert @reader.has_lines?, "Yo, didn't work"
17
+ end
18
+ end
19
+
20
+ context "with source data loaded" do
21
+ test "get_line returns next line" do
22
+ assert_equal @src_data[0], @reader.get_line
23
+ end
24
+
25
+ test "get_line consumes the line it returns" do
26
+ reader = Asciidoctor::Reader.new(["foo", "bar"])
27
+ _ = reader.get_line
28
+ second = reader.get_line
29
+ assert_equal "bar", second
30
+ end
31
+
32
+ test "peek_line does not consume the line it returns" do
33
+ reader = Asciidoctor::Reader.new(["foo", "bar"])
34
+ _ = reader.peek_line
35
+ second = reader.peek_line
36
+ assert_equal "foo", second
37
+ end
38
+ end
39
+
40
+ test "unshift puts line onto Reader instance for the next get_line" do
41
+ reader = Asciidoctor::Reader.new(["foo"])
42
+ reader.unshift("bar")
43
+ assert_equal "bar", reader.get_line
44
+ assert_equal "foo", reader.get_line
45
+ end
46
+
47
+ def test_grab_lines_until
48
+ pending "Not tested yet"
49
+ end
50
+
51
+ def test_sanitize_attribute_name
52
+ assert_equal 'foobar', @reader.sanitize_attribute_name("Foo Bar")
53
+ assert_equal 'foo', @reader.sanitize_attribute_name("foo")
54
+ assert_equal 'foo3-bar', @reader.sanitize_attribute_name("Foo 3^ # - Bar[")
55
+ end
56
+ end
data/test/test_helper.rb CHANGED
@@ -6,8 +6,9 @@ require "#{File.expand_path(File.dirname(__FILE__))}/../lib/asciidoctor.rb"
6
6
  require 'mocha'
7
7
  require 'htmlentities'
8
8
  require 'nokogiri'
9
+ require 'pending'
9
10
 
10
- ENV['SUPPRESS_DEBUG'] = 'true'
11
+ ENV['SUPPRESS_DEBUG'] ||= 'true'
11
12
 
12
13
  class Test::Unit::TestCase
13
14
  def sample_doc_path(name)
@@ -60,8 +61,12 @@ class Test::Unit::TestCase
60
61
  end
61
62
  end
62
63
 
64
+ def document_from_string(src)
65
+ Asciidoctor::Document.new(src.split("\n"))
66
+ end
67
+
63
68
  def render_string(src)
64
- Asciidoctor::Document.new(src.split("\n")).render
69
+ document_from_string(src).render
65
70
  end
66
71
  end
67
72
 
data/test/text_test.rb CHANGED
@@ -1,23 +1,25 @@
1
1
  require 'test_helper'
2
2
 
3
3
  context "Text" do
4
+ test 'escaped text markup' do
5
+ pending "Not done yet"
6
+ end
7
+
4
8
  test "line breaks" do
5
9
  assert_xpath "//br", render_string("Well this is +\njust fine and dandy, isn't it?"), 1
6
10
  end
7
11
 
8
- test "quotes" do
12
+ test "single- and double-quoted text" do
9
13
  rendered = render_string("``Where?,'' she said, flipping through her copy of `The New Yorker.'")
10
- assert_match /&rdquo;/, rendered
11
- assert_match /&ldquo;/, rendered
12
- assert_match /&rsquo;/, rendered
13
- assert_match /&lsquo;/, rendered
14
+ assert_match /&ldquo;Where\?,&rdquo;/, rendered
15
+ assert_match /&lsquo;The New Yorker.&rsquo;/, rendered
14
16
  end
15
17
 
16
18
  test "separator" do
17
19
  assert_xpath "//hr", render_string("This is separated.\n\n''''\n\n...from this!"), 1
18
20
  end
19
21
 
20
- test "emphasized quotes" do
22
+ test "emphasized text" do
21
23
  assert_xpath "//em", render_string("An 'emphatic' no")
22
24
  end
23
25
 
@@ -25,47 +27,51 @@ context "Text" do
25
27
  assert_no_match /#/, render_string("An #unquoted# word")
26
28
  end
27
29
 
28
- context "basic styling" do
30
+ test "backtick-escaped text followed by single-quoted text" do
31
+ assert_match /<tt>foo<\/tt>/, render_string(%Q(run `foo` 'dog'))
32
+ end
33
+
34
+ context "basic styling" do
29
35
  setup do
30
36
  @rendered = render_string("A *BOLD* word. An _italic_ word. A +mono+ word. ^superscript!^ and some ~subscript~.")
31
37
  end
32
38
 
33
- test "bold" do
34
- assert_xpath "//strong", @rendered
39
+ test "strong" do
40
+ assert_xpath "//strong", @rendered
35
41
  end
36
42
 
37
43
  test "italic" do
38
- assert_xpath "//em", @rendered
44
+ assert_xpath "//em", @rendered
39
45
  end
40
46
 
41
47
  test "monospaced" do
42
- assert_xpath "//tt", @rendered
48
+ assert_xpath "//tt", @rendered
43
49
  end
44
50
 
45
51
  test "superscript" do
46
- assert_xpath "//sup", @rendered
52
+ assert_xpath "//sup", @rendered
47
53
  end
48
54
 
49
55
  test "subscript" do
50
- assert_xpath "//sub", @rendered
56
+ assert_xpath "//sub", @rendered
51
57
  end
52
58
 
53
59
  test "backticks" do
54
60
  assert_xpath "//tt", render_string("This is `totally cool`.")
55
61
  end
56
62
 
57
- test "combined styles" do
63
+ test "nested styles" do
58
64
  rendered = render_string("Winning *big _time_* in the +city *boyeeee*+.")
59
-
65
+
60
66
  assert_xpath "//strong/em", rendered
61
67
  assert_xpath "//tt/strong", rendered
62
68
  end
63
69
 
64
- test "characters" do
70
+ test "unconstrained quotes" do
65
71
  rendered_chars = render_string("**B**__I__++M++")
66
- assert_xpath "//strong", rendered_chars
67
- assert_xpath "//em", rendered_chars
68
- assert_xpath "//tt", rendered_chars
72
+ assert_xpath "//strong", rendered_chars
73
+ assert_xpath "//em", rendered_chars
74
+ assert_xpath "//tt", rendered_chars
69
75
  end
70
- end
76
+ end
71
77
  end
metadata CHANGED
@@ -1,103 +1,122 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor
3
- version: !ruby/object:Gem::Version
4
- hash: 29
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 1
10
- version: 0.0.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Ryan Waldron
14
9
  - Jeremy McAnally
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2012-06-14 00:00:00 -05:00
20
- default_executable:
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
13
+ date: 2012-08-03 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
23
16
  name: json
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
26
18
  none: false
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 3
31
- segments:
32
- - 0
33
- version: "0"
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
34
23
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: nokogiri
38
24
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: !ruby/object:Gem::Requirement
40
26
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: tilt
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
48
39
  type: :runtime
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: mocha
52
40
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
41
+ version_requirements: !ruby/object:Gem::Requirement
54
42
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: mocha
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
62
55
  type: :development
63
- version_requirements: *id003
64
- - !ruby/object:Gem::Dependency
65
- name: nokogiri
66
56
  prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: nokogiri
65
+ requirement: !ruby/object:Gem::Requirement
68
66
  none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
76
71
  type: :development
77
- version_requirements: *id004
78
- - !ruby/object:Gem::Dependency
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ - !ruby/object:Gem::Dependency
79
80
  name: htmlentities
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :development
80
88
  prerelease: false
81
- requirement: &id005 !ruby/object:Gem::Requirement
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: pending
97
+ requirement: !ruby/object:Gem::Requirement
82
98
  none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
88
- - 0
89
- version: "0"
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
90
103
  type: :development
91
- version_requirements: *id005
92
- description: Render all the AsciiDocs! The time, she is now, for all good renders.
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: A pure Ruby processor to turn Asciidoc-formatted documents into HTML
112
+ (and, eventually, other formats perhaps).
93
113
  email: rew@erebor.com
94
- executables:
114
+ executables:
95
115
  - asciidoctor
96
116
  extensions: []
97
-
98
- extra_rdoc_files:
117
+ extra_rdoc_files:
99
118
  - LICENSE
100
- files:
119
+ files:
101
120
  - LICENSE
102
121
  - README.md
103
122
  - Rakefile
@@ -108,60 +127,59 @@ files:
108
127
  - lib/asciidoctor/debug.rb
109
128
  - lib/asciidoctor/document.rb
110
129
  - lib/asciidoctor/errors.rb
130
+ - lib/asciidoctor/lexer.rb
111
131
  - lib/asciidoctor/list_item.rb
132
+ - lib/asciidoctor/reader.rb
112
133
  - lib/asciidoctor/render_templates.rb
113
134
  - lib/asciidoctor/renderer.rb
114
135
  - lib/asciidoctor/section.rb
115
136
  - lib/asciidoctor/string.rb
116
137
  - lib/asciidoctor/version.rb
117
138
  - noof.rb
139
+ - test/attributes_test.rb
118
140
  - test/document_test.rb
119
141
  - test/fixtures/asciidoc.txt
120
142
  - test/fixtures/asciidoc_index.txt
121
143
  - test/fixtures/ascshort.txt
122
144
  - test/fixtures/list_elements.asciidoc
123
145
  - test/headers_test.rb
146
+ - test/lexer_test.rb
124
147
  - test/list_elements_test.rb
125
148
  - test/paragraphs_test.rb
149
+ - test/reader_test.rb
126
150
  - test/test_helper.rb
127
151
  - test/text_test.rb
128
- has_rdoc: true
129
152
  homepage: http://github.com/erebor/asciidoctor
130
153
  licenses: []
131
-
132
154
  post_install_message:
133
- rdoc_options:
155
+ rdoc_options:
134
156
  - --charset=UTF-8
135
- require_paths:
157
+ require_paths:
136
158
  - lib
137
- required_ruby_version: !ruby/object:Gem::Requirement
159
+ required_ruby_version: !ruby/object:Gem::Requirement
138
160
  none: false
139
- requirements:
140
- - - ">="
141
- - !ruby/object:Gem::Version
142
- hash: 3
143
- segments:
144
- - 0
145
- version: "0"
146
- required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ! '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
166
  none: false
148
- requirements:
149
- - - ">="
150
- - !ruby/object:Gem::Version
151
- hash: 3
152
- segments:
153
- - 0
154
- version: "0"
167
+ requirements:
168
+ - - ! '>='
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
155
171
  requirements: []
156
-
157
172
  rubyforge_project: asciidoctor
158
- rubygems_version: 1.6.2
173
+ rubygems_version: 1.8.23
159
174
  signing_key:
160
175
  specification_version: 2
161
176
  summary: Pure Ruby Asciidoc to HTML rendering.
162
- test_files:
177
+ test_files:
178
+ - test/attributes_test.rb
163
179
  - test/document_test.rb
164
180
  - test/headers_test.rb
181
+ - test/lexer_test.rb
165
182
  - test/list_elements_test.rb
166
183
  - test/paragraphs_test.rb
184
+ - test/reader_test.rb
167
185
  - test/text_test.rb