org-ruby 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/History.txt +81 -77
  2. data/README.rdoc +66 -66
  3. data/Rakefile +28 -28
  4. data/bin/org-ruby +40 -40
  5. data/lib/org-ruby.rb +50 -50
  6. data/lib/org-ruby/headline.rb +102 -120
  7. data/lib/org-ruby/html_output_buffer.rb +174 -156
  8. data/lib/org-ruby/line.rb +206 -260
  9. data/lib/org-ruby/output_buffer.rb +227 -191
  10. data/lib/org-ruby/parser.rb +320 -272
  11. data/lib/org-ruby/regexp_helper.rb +156 -156
  12. data/lib/org-ruby/textile_output_buffer.rb +67 -68
  13. data/spec/data/freeform-example.org +113 -113
  14. data/spec/data/freeform.org +111 -111
  15. data/spec/data/hyp-planning.org +335 -335
  16. data/spec/data/remember.org +53 -53
  17. data/spec/headline_spec.rb +55 -55
  18. data/spec/html_examples/advanced-code.html +36 -36
  19. data/spec/html_examples/advanced-code.org +53 -53
  20. data/spec/html_examples/advanced-lists.html +31 -31
  21. data/spec/html_examples/advanced-lists.org +31 -31
  22. data/spec/html_examples/block_code.html +28 -28
  23. data/spec/html_examples/block_code.org +35 -35
  24. data/spec/html_examples/blockquote.html +7 -7
  25. data/spec/html_examples/blockquote.org +13 -13
  26. data/spec/html_examples/code-comment.html +18 -18
  27. data/spec/html_examples/code-comment.org +22 -22
  28. data/spec/html_examples/custom-seq-todo.html +15 -15
  29. data/spec/html_examples/custom-seq-todo.org +24 -24
  30. data/spec/html_examples/custom-todo.html +15 -15
  31. data/spec/html_examples/custom-todo.org +24 -24
  32. data/spec/html_examples/custom-typ-todo.html +15 -15
  33. data/spec/html_examples/custom-typ-todo.org +24 -24
  34. data/spec/html_examples/entities.html +4 -4
  35. data/spec/html_examples/entities.org +11 -11
  36. data/spec/html_examples/escape-pre.html +6 -6
  37. data/spec/html_examples/escape-pre.org +6 -6
  38. data/spec/html_examples/export-exclude-only.html +13 -13
  39. data/spec/html_examples/export-exclude-only.org +81 -81
  40. data/spec/html_examples/export-keywords.html +4 -4
  41. data/spec/html_examples/export-keywords.org +18 -18
  42. data/spec/html_examples/export-tags.html +8 -8
  43. data/spec/html_examples/export-tags.org +82 -82
  44. data/spec/html_examples/export-title.html +2 -2
  45. data/spec/html_examples/export-title.org +4 -4
  46. data/spec/html_examples/html-literal.html +2 -2
  47. data/spec/html_examples/html-literal.org +6 -6
  48. data/spec/html_examples/inline-formatting.html +10 -10
  49. data/spec/html_examples/inline-formatting.org +17 -17
  50. data/spec/html_examples/link-features.html +8 -8
  51. data/spec/html_examples/link-features.org +19 -19
  52. data/spec/html_examples/lists.html +19 -19
  53. data/spec/html_examples/lists.org +36 -36
  54. data/spec/html_examples/metadata-comment.html +27 -27
  55. data/spec/html_examples/metadata-comment.org +30 -30
  56. data/spec/html_examples/only-list.html +5 -5
  57. data/spec/html_examples/only-list.org +3 -3
  58. data/spec/html_examples/only-table.html +6 -6
  59. data/spec/html_examples/only-table.org +5 -5
  60. data/spec/html_examples/skip-header.html +3 -3
  61. data/spec/html_examples/skip-header.org +28 -28
  62. data/spec/html_examples/skip-table.html +4 -4
  63. data/spec/html_examples/skip-table.org +19 -19
  64. data/spec/html_examples/tables.html +20 -20
  65. data/spec/html_examples/tables.org +26 -26
  66. data/spec/html_examples/text.html +2 -2
  67. data/spec/html_examples/text.org +16 -16
  68. data/spec/line_spec.rb +151 -151
  69. data/spec/output_buffer_spec.rb +19 -0
  70. data/spec/parser_spec.rb +152 -166
  71. data/spec/regexp_helper_spec.rb +57 -57
  72. data/spec/spec_helper.rb +21 -21
  73. data/spec/textile_examples/block_code.org +35 -35
  74. data/spec/textile_examples/block_code.textile +29 -29
  75. data/spec/textile_examples/blockquote.org +13 -13
  76. data/spec/textile_examples/blockquote.textile +11 -11
  77. data/spec/textile_examples/keywords.org +13 -13
  78. data/spec/textile_examples/keywords.textile +11 -11
  79. data/spec/textile_examples/links.org +11 -11
  80. data/spec/textile_examples/links.textile +10 -10
  81. data/spec/textile_examples/lists.org +36 -36
  82. data/spec/textile_examples/lists.textile +20 -20
  83. data/spec/textile_examples/single-space-plain-list.org +13 -13
  84. data/spec/textile_examples/single-space-plain-list.textile +10 -10
  85. data/spec/textile_examples/tables.org +26 -26
  86. data/spec/textile_examples/tables.textile +23 -23
  87. data/spec/textile_output_buffer_spec.rb +21 -21
  88. data/tasks/test_case.rake +49 -49
  89. metadata +3 -2
@@ -1,4 +1,4 @@
1
- <p class="title">skip-table.org</p>
2
- <p>Checking that tables are skipped when directed.</p>
3
- <p>For grins, here&#8217;s another table without a header. Just keep the bases covered.</p>
4
- <p>Again, in the HTML output, you should see <b>no tables</b>.</p>
1
+ <p class="title">skip-table.org</p>
2
+ <p>Checking that tables are skipped when directed.</p>
3
+ <p>For grins, here&#8217;s another table without a header. Just keep the bases covered.</p>
4
+ <p>Again, in the HTML output, you should see <b>no tables</b>.</p>
@@ -1,19 +1,19 @@
1
- #+TITLE: skip-table.org
2
- #+OPTIONS: |:nil
3
-
4
- Checking that tables are skipped when directed.
5
-
6
- | One | Two | Three |
7
- |-------+-------+-------|
8
- | Four | Five | Six |
9
- | Seven | Eight | Nine |
10
-
11
-
12
- For grins, here's another table without a header. Just keep the bases
13
- covered.
14
-
15
- | One | Two | Three |
16
- | Four | Five | Six |
17
- | Seven | Eight | Nine |
18
-
19
- Again, in the HTML output, you should see *no tables*.
1
+ #+TITLE: skip-table.org
2
+ #+OPTIONS: |:nil
3
+
4
+ Checking that tables are skipped when directed.
5
+
6
+ | One | Two | Three |
7
+ |-------+-------+-------|
8
+ | Four | Five | Six |
9
+ | Seven | Eight | Nine |
10
+
11
+
12
+ For grins, here's another table without a header. Just keep the bases
13
+ covered.
14
+
15
+ | One | Two | Three |
16
+ | Four | Five | Six |
17
+ | Seven | Eight | Nine |
18
+
19
+ Again, in the HTML output, you should see *no tables*.
@@ -1,20 +1,20 @@
1
- <p class="title">TABLES</p>
2
- <p>Different types of ORG tables.</p>
3
- <h1>Simple table, no header.</h1>
4
- <table>
5
- <tr><td>Cell one</td><td>Cell two</td></tr>
6
- <tr><td>Cell three</td><td>Cell four</td></tr>
7
- </table>
8
- <h1>Indented table</h1>
9
- <table>
10
- <tr><td>Cell one</td></tr>
11
- <tr><td>Cell two</td></tr>
12
- </table>
13
- <p>And here&#8217;s some paragraph content. The line breaks will need to get removed here, but not for the tables.</p>
14
- <h1>Table with header</h1>
15
- <table>
16
- <tr><th>One</th><th>Two</th><th>Three</th></tr>
17
- <tr><td>Four</td><td>Five</td><td>Six</td></tr>
18
- <tr><td>Seven</td><td>Eight</td><td>Nine</td></tr>
19
- </table>
20
- <p>The separator row should not get printed out.</p>
1
+ <p class="title">TABLES</p>
2
+ <p>Different types of ORG tables.</p>
3
+ <h1>Simple table, no header.</h1>
4
+ <table>
5
+ <tr><td>Cell one</td><td>Cell two</td></tr>
6
+ <tr><td>Cell three</td><td>Cell four</td></tr>
7
+ </table>
8
+ <h1>Indented table</h1>
9
+ <table>
10
+ <tr><td>Cell one</td></tr>
11
+ <tr><td>Cell two</td></tr>
12
+ </table>
13
+ <p>And here&#8217;s some paragraph content. The line breaks will need to get removed here, but not for the tables.</p>
14
+ <h1>Table with header</h1>
15
+ <table>
16
+ <tr><th>One</th><th>Two</th><th>Three</th></tr>
17
+ <tr><td>Four</td><td>Five</td><td>Six</td></tr>
18
+ <tr><td>Seven</td><td>Eight</td><td>Nine</td></tr>
19
+ </table>
20
+ <p>The separator row should not get printed out.</p>
@@ -1,26 +1,26 @@
1
- TABLES
2
-
3
- Different types of ORG tables.
4
-
5
- * Simple table, no header.
6
-
7
- | Cell one | Cell two |
8
- | Cell three | Cell four |
9
-
10
-
11
- * Indented table
12
-
13
- | Cell one |
14
- | Cell two |
15
-
16
- And here's some paragraph content. The line breaks will need to get
17
- removed here, but not for the tables.
18
-
19
- * Table with header
20
-
21
- | One | Two | Three |
22
- |-------+-------+-------|
23
- | Four | Five | Six |
24
- | Seven | Eight | Nine |
25
-
26
- The separator row should not get printed out.
1
+ TABLES
2
+
3
+ Different types of ORG tables.
4
+
5
+ * Simple table, no header.
6
+
7
+ | Cell one | Cell two |
8
+ | Cell three | Cell four |
9
+
10
+
11
+ * Indented table
12
+
13
+ | Cell one |
14
+ | Cell two |
15
+
16
+ And here's some paragraph content. The line breaks will need to get
17
+ removed here, but not for the tables.
18
+
19
+ * Table with header
20
+
21
+ | One | Two | Three |
22
+ |-------+-------+-------|
23
+ | Four | Five | Six |
24
+ | Seven | Eight | Nine |
25
+
26
+ The separator row should not get printed out.
@@ -1,2 +1,2 @@
1
- <p class="title">The simplest case: translating plain text.</p>
2
- <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
1
+ <p class="title">The simplest case: translating plain text.</p>
2
+ <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
@@ -1,16 +1,16 @@
1
- The simplest case: translating plain text.
2
-
3
- Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
4
- nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
5
- sed diam voluptua. At vero eos et accusam et justo duo dolores et ea
6
- rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem
7
- ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur
8
- sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et
9
- dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam
10
- et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea
11
- takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit
12
- amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
13
- invidunt ut labore et dolore magna aliquyam erat, sed diam
14
- voluptua. At vero eos et accusam et justo duo dolores et ea
15
- rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem
16
- ipsum dolor sit amet.
1
+ The simplest case: translating plain text.
2
+
3
+ Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
4
+ nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
5
+ sed diam voluptua. At vero eos et accusam et justo duo dolores et ea
6
+ rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem
7
+ ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur
8
+ sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et
9
+ dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam
10
+ et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea
11
+ takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit
12
+ amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
13
+ invidunt ut labore et dolore magna aliquyam erat, sed diam
14
+ voluptua. At vero eos et accusam et justo duo dolores et ea
15
+ rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem
16
+ ipsum dolor sit amet.
data/spec/line_spec.rb CHANGED
@@ -1,151 +1,151 @@
1
- require File.join(File.dirname(__FILE__), %w[spec_helper])
2
-
3
- describe Orgmode::Line do
4
-
5
- it "should tell comments" do
6
- comments = ["# hello", "#hello", " #hello", "\t#hello\n"]
7
- comments.each do |c|
8
- line = Orgmode::Line.new c
9
- line.comment?.should be_true
10
- end
11
-
12
- not_comments = ["", "\n", "hello\n", " foo ### bar\n"]
13
- not_comments.each do |c|
14
- line = Orgmode::Line.new c
15
- line.comment?.should_not be_true
16
- end
17
- end
18
-
19
- it "should tell blank lines" do
20
- blank = ["", " ", "\t", "\n", " \t\t\n\n"]
21
- blank.each do |b|
22
- line = Orgmode::Line.new b
23
- line.blank?.should be_true
24
- end
25
- end
26
-
27
- [": inline", " :inline", "\t\t:\tinline"].each do |inline_example|
28
- it "should recognize this inline example: #{inline_example}" do
29
- Orgmode::Line.new(inline_example).inline_example?.should be_true
30
- end
31
- end
32
-
33
-
34
- it "should recognize plain lists" do
35
- list_formats = ["-",
36
- "+",
37
- " -",
38
- " +",
39
- " 1.",
40
- " 2)"]
41
- list_formats.each do |list|
42
- line = Orgmode::Line.new list
43
- line.plain_list?.should be_true
44
- end
45
- end
46
-
47
- it "should recognize table rows" do
48
- Orgmode::Line.new("| One | Two | Three |").table_row?.should be_true
49
- Orgmode::Line.new(" |-------+-------+-------|\n").table_separator?.should be_true
50
- Orgmode::Line.new("| Four | Five | Six |").table_row?.should be_true
51
- Orgmode::Line.new("| Seven | Eight | Nine |").table_row?.should be_true
52
- end
53
-
54
- it "should recognize indentation" do
55
- Orgmode::Line.new("").indent.should eql(0)
56
- Orgmode::Line.new(" a").indent.should eql(1)
57
- Orgmode::Line.new(" ").indent.should eql(0)
58
- Orgmode::Line.new(" \n").indent.should eql(0)
59
- Orgmode::Line.new(" a").indent.should eql(3)
60
- end
61
-
62
- it "should return paragraph type" do
63
- Orgmode::Line.new("").paragraph_type.should eql(:blank)
64
- Orgmode::Line.new("1. foo").paragraph_type.should eql(:ordered_list)
65
- Orgmode::Line.new("- [ ] checkbox").paragraph_type.should eql(:unordered_list)
66
- Orgmode::Line.new("hello!").paragraph_type.should eql(:paragraph)
67
- end
68
-
69
- it "should recognize BEGIN and END comments" do
70
- begin_examples = {
71
- "#+BEGIN_SRC emacs-lisp -n -r\n" => "SRC",
72
- "#+BEGIN_EXAMPLE" => "EXAMPLE",
73
- "\t#+BEGIN_QUOTE " => "QUOTE"
74
- }
75
-
76
- end_examples = {
77
- "#+END_SRC" => "SRC",
78
- "#+END_EXAMPLE" => "EXAMPLE",
79
- "\t#+END_QUOTE " => "QUOTE"
80
- }
81
-
82
- begin_examples.each_key do |str|
83
- line = Orgmode::Line.new str
84
- line.comment?.should be_true
85
- line.begin_block?.should be_true
86
- line.block_type.should eql(begin_examples[str])
87
- end
88
-
89
- end_examples.each_key do |str|
90
- line = Orgmode::Line.new str
91
- line.comment?.should be_true
92
- line.end_block?.should be_true
93
- line.block_type.should eql(end_examples[str])
94
- end
95
- end
96
-
97
- it "should accept assigned types" do
98
- cases = {
99
- "# this looks like a comment" => :comment,
100
- " 1. This looks like an ordered list" => :ordered_list,
101
- " - this looks like an # unordered list" => :unordered_list,
102
- " | one | two | table! | \n" => :table_row,
103
- "\n" => :blank,
104
- " |-----+-----+--------| \n" => :table_separator
105
- }
106
-
107
- cases.each_pair do |key, value|
108
- l = Orgmode::Line.new key
109
- l.paragraph_type.should eql(value)
110
- l.assigned_paragraph_type = :paragraph
111
- l.paragraph_type.should eql(:paragraph)
112
- l.assigned_paragraph_type = nil
113
- l.paragraph_type.should eql(value)
114
- end
115
- end
116
-
117
- it "should parse in-buffer settings" do
118
- cases = {
119
- "#+ARCHIVE: %s_done" => { :key => "ARCHIVE", :value => "%s_done" },
120
- "#+CATEGORY: foo" => { :key => "CATEGORY", :value => "foo"},
121
- "#+BEGIN_EXAMPLE:" => { :key => "BEGIN_EXAMPLE", :value => "" },
122
- "#+A:" => { :key => "A", :value => "" } # Boundary: Smallest keyword is one letter
123
- }
124
- cases.each_pair do |key, value|
125
- l = Orgmode::Line.new key
126
- l.in_buffer_setting?.should be_true
127
- called = nil
128
- l.in_buffer_setting? do |k, v|
129
- k.should eql(value[:key])
130
- v.should eql(value[:value])
131
- called = true
132
- end
133
- called.should be_true
134
- end
135
- end
136
-
137
- it "should reject ill-formed settings" do
138
- cases = [
139
- "##+ARCHIVE: blah",
140
- "#CATEGORY: foo",
141
- "",
142
- "\n",
143
- " #+BEGIN_EXAMPLE:\n"
144
- ]
145
-
146
- cases.each do |c|
147
- l = Orgmode::Line.new c
148
- l.in_buffer_setting?.should be_nil
149
- end
150
- end
151
- end
1
+ require File.join(File.dirname(__FILE__), %w[spec_helper])
2
+
3
+ describe Orgmode::Line do
4
+
5
+ it "should tell comments" do
6
+ comments = ["# hello", "#hello", " #hello", "\t#hello\n"]
7
+ comments.each do |c|
8
+ line = Orgmode::Line.new c
9
+ line.comment?.should be_true
10
+ end
11
+
12
+ not_comments = ["", "\n", "hello\n", " foo ### bar\n"]
13
+ not_comments.each do |c|
14
+ line = Orgmode::Line.new c
15
+ line.comment?.should_not be_true
16
+ end
17
+ end
18
+
19
+ it "should tell blank lines" do
20
+ blank = ["", " ", "\t", "\n", " \t\t\n\n"]
21
+ blank.each do |b|
22
+ line = Orgmode::Line.new b
23
+ line.blank?.should be_true
24
+ end
25
+ end
26
+
27
+ [": inline", " :inline", "\t\t:\tinline"].each do |inline_example|
28
+ it "should recognize this inline example: #{inline_example}" do
29
+ Orgmode::Line.new(inline_example).inline_example?.should be_true
30
+ end
31
+ end
32
+
33
+
34
+ it "should recognize plain lists" do
35
+ list_formats = ["-",
36
+ "+",
37
+ " -",
38
+ " +",
39
+ " 1.",
40
+ " 2)"]
41
+ list_formats.each do |list|
42
+ line = Orgmode::Line.new list
43
+ line.plain_list?.should be_true
44
+ end
45
+ end
46
+
47
+ it "should recognize table rows" do
48
+ Orgmode::Line.new("| One | Two | Three |").table_row?.should be_true
49
+ Orgmode::Line.new(" |-------+-------+-------|\n").table_separator?.should be_true
50
+ Orgmode::Line.new("| Four | Five | Six |").table_row?.should be_true
51
+ Orgmode::Line.new("| Seven | Eight | Nine |").table_row?.should be_true
52
+ end
53
+
54
+ it "should recognize indentation" do
55
+ Orgmode::Line.new("").indent.should eql(0)
56
+ Orgmode::Line.new(" a").indent.should eql(1)
57
+ Orgmode::Line.new(" ").indent.should eql(0)
58
+ Orgmode::Line.new(" \n").indent.should eql(0)
59
+ Orgmode::Line.new(" a").indent.should eql(3)
60
+ end
61
+
62
+ it "should return paragraph type" do
63
+ Orgmode::Line.new("").paragraph_type.should eql(:blank)
64
+ Orgmode::Line.new("1. foo").paragraph_type.should eql(:ordered_list)
65
+ Orgmode::Line.new("- [ ] checkbox").paragraph_type.should eql(:unordered_list)
66
+ Orgmode::Line.new("hello!").paragraph_type.should eql(:paragraph)
67
+ end
68
+
69
+ it "should recognize BEGIN and END comments" do
70
+ begin_examples = {
71
+ "#+BEGIN_SRC emacs-lisp -n -r\n" => "SRC",
72
+ "#+BEGIN_EXAMPLE" => "EXAMPLE",
73
+ "\t#+BEGIN_QUOTE " => "QUOTE"
74
+ }
75
+
76
+ end_examples = {
77
+ "#+END_SRC" => "SRC",
78
+ "#+END_EXAMPLE" => "EXAMPLE",
79
+ "\t#+END_QUOTE " => "QUOTE"
80
+ }
81
+
82
+ begin_examples.each_key do |str|
83
+ line = Orgmode::Line.new str
84
+ line.comment?.should be_true
85
+ line.begin_block?.should be_true
86
+ line.block_type.should eql(begin_examples[str])
87
+ end
88
+
89
+ end_examples.each_key do |str|
90
+ line = Orgmode::Line.new str
91
+ line.comment?.should be_true
92
+ line.end_block?.should be_true
93
+ line.block_type.should eql(end_examples[str])
94
+ end
95
+ end
96
+
97
+ it "should accept assigned types" do
98
+ cases = {
99
+ "# this looks like a comment" => :comment,
100
+ " 1. This looks like an ordered list" => :ordered_list,
101
+ " - this looks like an # unordered list" => :unordered_list,
102
+ " | one | two | table! | \n" => :table_row,
103
+ "\n" => :blank,
104
+ " |-----+-----+--------| \n" => :table_separator
105
+ }
106
+
107
+ cases.each_pair do |key, value|
108
+ l = Orgmode::Line.new key
109
+ l.paragraph_type.should eql(value)
110
+ l.assigned_paragraph_type = :paragraph
111
+ l.paragraph_type.should eql(:paragraph)
112
+ l.assigned_paragraph_type = nil
113
+ l.paragraph_type.should eql(value)
114
+ end
115
+ end
116
+
117
+ it "should parse in-buffer settings" do
118
+ cases = {
119
+ "#+ARCHIVE: %s_done" => { :key => "ARCHIVE", :value => "%s_done" },
120
+ "#+CATEGORY: foo" => { :key => "CATEGORY", :value => "foo"},
121
+ "#+BEGIN_EXAMPLE:" => { :key => "BEGIN_EXAMPLE", :value => "" },
122
+ "#+A:" => { :key => "A", :value => "" } # Boundary: Smallest keyword is one letter
123
+ }
124
+ cases.each_pair do |key, value|
125
+ l = Orgmode::Line.new key
126
+ l.in_buffer_setting?.should be_true
127
+ called = nil
128
+ l.in_buffer_setting? do |k, v|
129
+ k.should eql(value[:key])
130
+ v.should eql(value[:value])
131
+ called = true
132
+ end
133
+ called.should be_true
134
+ end
135
+ end
136
+
137
+ it "should reject ill-formed settings" do
138
+ cases = [
139
+ "##+ARCHIVE: blah",
140
+ "#CATEGORY: foo",
141
+ "",
142
+ "\n",
143
+ " #+BEGIN_EXAMPLE:\n"
144
+ ]
145
+
146
+ cases.each do |c|
147
+ l = Orgmode::Line.new c
148
+ l.in_buffer_setting?.should be_nil
149
+ end
150
+ end
151
+ end