org-ruby 0.6.3 → 0.6.4

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 (117) hide show
  1. data/History.txt +6 -0
  2. data/bin/org-ruby +11 -5
  3. data/lib/org-ruby.rb +21 -23
  4. data/lib/org-ruby/headline.rb +0 -2
  5. data/lib/org-ruby/html_output_buffer.rb +60 -19
  6. data/lib/org-ruby/line.rb +9 -9
  7. data/lib/org-ruby/output_buffer.rb +9 -9
  8. data/lib/org-ruby/parser.rb +4 -1
  9. data/lib/org-ruby/regexp_helper.rb +3 -3
  10. metadata +66 -153
  11. data/.bnsignore +0 -18
  12. data/.gitignore +0 -2
  13. data/Gemfile +0 -8
  14. data/Gemfile.lock +0 -36
  15. data/Rakefile +0 -26
  16. data/TAGS +0 -133
  17. data/announcement.txt +0 -19
  18. data/org-ruby.gemspec +0 -37
  19. data/spec/data/freeform-example.org +0 -113
  20. data/spec/data/freeform.org +0 -111
  21. data/spec/data/hyp-planning.org +0 -335
  22. data/spec/data/remember.org +0 -53
  23. data/spec/headline_spec.rb +0 -65
  24. data/spec/html_examples/advanced-code.html +0 -81
  25. data/spec/html_examples/advanced-code.org +0 -106
  26. data/spec/html_examples/advanced-lists.html +0 -31
  27. data/spec/html_examples/advanced-lists.org +0 -31
  28. data/spec/html_examples/block_code.html +0 -28
  29. data/spec/html_examples/block_code.org +0 -35
  30. data/spec/html_examples/blockcomment.html +0 -3
  31. data/spec/html_examples/blockcomment.org +0 -15
  32. data/spec/html_examples/blockquote.html +0 -7
  33. data/spec/html_examples/blockquote.org +0 -13
  34. data/spec/html_examples/center.html +0 -6
  35. data/spec/html_examples/center.org +0 -7
  36. data/spec/html_examples/code-comment.html +0 -18
  37. data/spec/html_examples/code-comment.org +0 -22
  38. data/spec/html_examples/comment-trees.html +0 -4
  39. data/spec/html_examples/comment-trees.org +0 -13
  40. data/spec/html_examples/custom-seq-todo.html +0 -15
  41. data/spec/html_examples/custom-seq-todo.org +0 -24
  42. data/spec/html_examples/custom-todo.html +0 -15
  43. data/spec/html_examples/custom-todo.org +0 -24
  44. data/spec/html_examples/custom-typ-todo.html +0 -15
  45. data/spec/html_examples/custom-typ-todo.org +0 -24
  46. data/spec/html_examples/deflist.html +0 -6
  47. data/spec/html_examples/deflist.org +0 -6
  48. data/spec/html_examples/entities.html +0 -4
  49. data/spec/html_examples/entities.org +0 -11
  50. data/spec/html_examples/escape-pre.html +0 -6
  51. data/spec/html_examples/escape-pre.org +0 -6
  52. data/spec/html_examples/export-exclude-only.html +0 -13
  53. data/spec/html_examples/export-exclude-only.org +0 -81
  54. data/spec/html_examples/export-keywords.html +0 -4
  55. data/spec/html_examples/export-keywords.org +0 -18
  56. data/spec/html_examples/export-tags.html +0 -8
  57. data/spec/html_examples/export-tags.org +0 -82
  58. data/spec/html_examples/export-title.html +0 -2
  59. data/spec/html_examples/export-title.org +0 -4
  60. data/spec/html_examples/footnotes.html +0 -10
  61. data/spec/html_examples/footnotes.org +0 -7
  62. data/spec/html_examples/horizontal_rule.html +0 -4
  63. data/spec/html_examples/horizontal_rule.org +0 -5
  64. data/spec/html_examples/html-literal.html +0 -2
  65. data/spec/html_examples/html-literal.org +0 -6
  66. data/spec/html_examples/inline-formatting.html +0 -25
  67. data/spec/html_examples/inline-formatting.org +0 -43
  68. data/spec/html_examples/inline-images.html +0 -10
  69. data/spec/html_examples/inline-images.org +0 -15
  70. data/spec/html_examples/link-features.html +0 -20
  71. data/spec/html_examples/link-features.org +0 -35
  72. data/spec/html_examples/lists.html +0 -23
  73. data/spec/html_examples/lists.org +0 -47
  74. data/spec/html_examples/metadata-comment.html +0 -27
  75. data/spec/html_examples/metadata-comment.org +0 -30
  76. data/spec/html_examples/only-list.html +0 -5
  77. data/spec/html_examples/only-list.org +0 -3
  78. data/spec/html_examples/only-table.html +0 -6
  79. data/spec/html_examples/only-table.org +0 -5
  80. data/spec/html_examples/skip-header.html +0 -3
  81. data/spec/html_examples/skip-header.org +0 -28
  82. data/spec/html_examples/skip-table.html +0 -4
  83. data/spec/html_examples/skip-table.org +0 -19
  84. data/spec/html_examples/subsupscript-nil.html +0 -3
  85. data/spec/html_examples/subsupscript-nil.org +0 -6
  86. data/spec/html_examples/subsupscript.html +0 -3
  87. data/spec/html_examples/subsupscript.org +0 -5
  88. data/spec/html_examples/tables.html +0 -35
  89. data/spec/html_examples/tables.org +0 -50
  90. data/spec/html_examples/text.html +0 -2
  91. data/spec/html_examples/text.org +0 -16
  92. data/spec/line_spec.rb +0 -162
  93. data/spec/output_buffer_spec.rb +0 -19
  94. data/spec/parser_spec.rb +0 -158
  95. data/spec/regexp_helper_spec.rb +0 -57
  96. data/spec/spec_helper.rb +0 -20
  97. data/spec/textile_examples/block_code.org +0 -35
  98. data/spec/textile_examples/block_code.textile +0 -29
  99. data/spec/textile_examples/blockquote.org +0 -13
  100. data/spec/textile_examples/blockquote.textile +0 -11
  101. data/spec/textile_examples/center.org +0 -7
  102. data/spec/textile_examples/center.textile +0 -6
  103. data/spec/textile_examples/footnotes.org +0 -7
  104. data/spec/textile_examples/footnotes.textile +0 -8
  105. data/spec/textile_examples/keywords.org +0 -13
  106. data/spec/textile_examples/keywords.textile +0 -11
  107. data/spec/textile_examples/links.org +0 -11
  108. data/spec/textile_examples/links.textile +0 -10
  109. data/spec/textile_examples/lists.org +0 -36
  110. data/spec/textile_examples/lists.textile +0 -20
  111. data/spec/textile_examples/single-space-plain-list.org +0 -13
  112. data/spec/textile_examples/single-space-plain-list.textile +0 -10
  113. data/spec/textile_examples/tables.org +0 -50
  114. data/spec/textile_examples/tables.textile +0 -40
  115. data/spec/textile_output_buffer_spec.rb +0 -21
  116. data/tasks/test_case.rake +0 -49
  117. data/util/gen-special-replace.el +0 -37
@@ -1,50 +0,0 @@
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.
27
-
28
- * Table with complete box
29
-
30
- |-------+-------+-------|
31
- | One | Two | Three |
32
- |-------+-------+-------|
33
- | Four | Five | Six |
34
- | Seven | Eight | Nine |
35
- |-------+-------+-------|
36
-
37
- Only the first row should be a header row.
38
-
39
- * Table with extra lines
40
-
41
- |-------+--------+--------|
42
- | One | Two | Three |
43
- |-------+--------+--------|
44
- | Four | Five | Six |
45
- | Seven | Eight | Nine |
46
- |-------+--------+--------|
47
- | Ten | Eleven | Twelve |
48
- |-------+--------+--------|
49
-
50
- Only the first row should be a header row.
@@ -1,2 +0,0 @@
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 +0,0 @@
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 DELETED
@@ -1,162 +0,0 @@
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" ]
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
- list_formats = ["- ",
34
- "+ ",
35
- " - ",
36
- " + ",
37
- " 1. ",
38
- " 2) "]
39
- list_formats.each do |list|
40
- it "should recognize this list format: '#{list}'" do
41
- line = Orgmode::Line.new list
42
- line.plain_list?.should be_true
43
- end
44
- end
45
-
46
- ["-foo", "+foo", "1.foo", "2.foo"].each do |invalid_list|
47
- it "should not recognize this invalid list: '#{invalid_list}'" do
48
- line = Orgmode::Line.new invalid_list
49
- line.plain_list?.should_not be_true
50
- end
51
- end
52
-
53
- it "should recognize horizontal rules" do
54
- Orgmode::Line.new("-----").horizontal_rule?.should be_true
55
- Orgmode::Line.new("----------").horizontal_rule?.should be_true
56
- Orgmode::Line.new(" \t ----- \t\t\t").horizontal_rule?.should be_true
57
- Orgmode::Line.new("----").horizontal_rule?.should_not be_true
58
- end
59
-
60
- it "should recognize table rows" do
61
- Orgmode::Line.new("| One | Two | Three |").table_row?.should be_true
62
- Orgmode::Line.new(" |-------+-------+-------|\n").table_separator?.should be_true
63
- Orgmode::Line.new("| Four | Five | Six |").table_row?.should be_true
64
- Orgmode::Line.new("| Seven | Eight | Nine |").table_row?.should be_true
65
- end
66
-
67
- it "should recognize indentation" do
68
- Orgmode::Line.new("").indent.should eql(0)
69
- Orgmode::Line.new(" a").indent.should eql(1)
70
- Orgmode::Line.new(" ").indent.should eql(0)
71
- Orgmode::Line.new(" \n").indent.should eql(0)
72
- Orgmode::Line.new(" a").indent.should eql(3)
73
- end
74
-
75
- it "should return paragraph type" do
76
- Orgmode::Line.new("").paragraph_type.should eql(:blank)
77
- Orgmode::Line.new("1. foo").paragraph_type.should eql(:ordered_list)
78
- Orgmode::Line.new("- [ ] checkbox").paragraph_type.should eql(:unordered_list)
79
- Orgmode::Line.new("hello!").paragraph_type.should eql(:paragraph)
80
- end
81
-
82
- it "should recognize BEGIN and END comments" do
83
- begin_examples = {
84
- "#+BEGIN_SRC emacs-lisp -n -r\n" => "SRC",
85
- "#+BEGIN_EXAMPLE" => "EXAMPLE",
86
- "\t#+BEGIN_QUOTE " => "QUOTE"
87
- }
88
-
89
- end_examples = {
90
- "#+END_SRC" => "SRC",
91
- "#+END_EXAMPLE" => "EXAMPLE",
92
- "\t#+END_QUOTE " => "QUOTE"
93
- }
94
-
95
- begin_examples.each_key do |str|
96
- line = Orgmode::Line.new str
97
- line.begin_block?.should be_true
98
- line.block_type.should eql(begin_examples[str])
99
- end
100
-
101
- end_examples.each_key do |str|
102
- line = Orgmode::Line.new str
103
- line.end_block?.should be_true
104
- line.block_type.should eql(end_examples[str])
105
- end
106
- end
107
-
108
- it "should accept assigned types" do
109
- cases = {
110
- "# this looks like a comment" => :comment,
111
- " 1. This looks like an ordered list" => :ordered_list,
112
- " - this looks like an # unordered list" => :unordered_list,
113
- " | one | two | table! | \n" => :table_row,
114
- "\n" => :blank,
115
- " |-----+-----+--------| \n" => :table_separator
116
- }
117
-
118
- cases.each_pair do |key, value|
119
- l = Orgmode::Line.new key
120
- l.paragraph_type.should eql(value)
121
- l.assigned_paragraph_type = :paragraph
122
- l.paragraph_type.should eql(:paragraph)
123
- l.assigned_paragraph_type = nil
124
- l.paragraph_type.should eql(value)
125
- end
126
- end
127
-
128
- it "should parse in-buffer settings" do
129
- cases = {
130
- "#+ARCHIVE: %s_done" => { :key => "ARCHIVE", :value => "%s_done" },
131
- "#+CATEGORY: foo" => { :key => "CATEGORY", :value => "foo"},
132
- "#+BEGIN_EXAMPLE:" => { :key => "BEGIN_EXAMPLE", :value => "" },
133
- "#+A:" => { :key => "A", :value => "" } # Boundary: Smallest keyword is one letter
134
- }
135
- cases.each_pair do |key, value|
136
- l = Orgmode::Line.new key
137
- l.in_buffer_setting?.should be_true
138
- called = nil
139
- l.in_buffer_setting? do |k, v|
140
- k.should eql(value[:key])
141
- v.should eql(value[:value])
142
- called = true
143
- end
144
- called.should be_true
145
- end
146
- end
147
-
148
- it "should reject ill-formed settings" do
149
- cases = [
150
- "##+ARCHIVE: blah",
151
- "#CATEGORY: foo",
152
- "",
153
- "\n",
154
- " #+BEGIN_EXAMPLE:\n"
155
- ]
156
-
157
- cases.each do |c|
158
- l = Orgmode::Line.new c
159
- l.in_buffer_setting?.should be_nil
160
- end
161
- end
162
- end
@@ -1,19 +0,0 @@
1
- require File.join(File.dirname(__FILE__), %w[spec_helper])
2
-
3
- describe Orgmode::OutputBuffer do
4
-
5
- it "computes outline level numbering" do
6
- output_buffer = Orgmode::OutputBuffer.new ""
7
- output_buffer.get_next_headline_number(1).should eql("1")
8
- output_buffer.get_next_headline_number(1).should eql("2")
9
- output_buffer.get_next_headline_number(1).should eql("3")
10
- output_buffer.get_next_headline_number(1).should eql("4")
11
- output_buffer.get_next_headline_number(2).should eql("4.1")
12
- output_buffer.get_next_headline_number(2).should eql("4.2")
13
- output_buffer.get_next_headline_number(1).should eql("5")
14
- output_buffer.get_next_headline_number(2).should eql("5.1")
15
- output_buffer.get_next_headline_number(2).should eql("5.2")
16
- output_buffer.get_next_headline_number(4).should eql("5.2.0.1")
17
- end
18
-
19
- end
data/spec/parser_spec.rb DELETED
@@ -1,158 +0,0 @@
1
-
2
- require File.join(File.dirname(__FILE__), %w[spec_helper])
3
-
4
- describe Orgmode::Parser do
5
- it "should open ORG files" do
6
- parser = Orgmode::Parser.load(RememberFile)
7
- end
8
-
9
- it "should fail on non-existant files" do
10
- lambda { parser = Orgmode::Parser.load("does-not-exist.org") }.should raise_error
11
- end
12
-
13
- it "should load all of the lines" do
14
- parser = Orgmode::Parser.load(RememberFile)
15
- parser.lines.length.should eql(53)
16
- end
17
-
18
- it "should find all headlines" do
19
- parser = Orgmode::Parser.load(RememberFile)
20
- parser.should have(12).headlines
21
- end
22
-
23
- it "can find a headline by index" do
24
- parser = Orgmode::Parser.load(RememberFile)
25
- parser.headlines[1].line.should eql("** YAML header in Webby\n")
26
- end
27
-
28
- it "should determine headline levels" do
29
- parser = Orgmode::Parser.load(RememberFile)
30
- parser.headlines[0].level.should eql(1)
31
- parser.headlines[1].level.should eql(2)
32
- end
33
-
34
- it "should put body lines in headlines" do
35
- parser = Orgmode::Parser.load(RememberFile)
36
- parser.headlines[0].should have(1).body_lines
37
- parser.headlines[1].should have(7).body_lines
38
- end
39
-
40
- it "should understand lines before the first headline" do
41
- parser = Orgmode::Parser.load(FreeformFile)
42
- parser.should have(19).header_lines
43
- end
44
-
45
- it "should load in-buffer settings" do
46
- parser = Orgmode::Parser.load(FreeformFile)
47
- parser.should have(12).in_buffer_settings
48
- parser.in_buffer_settings["TITLE"].should eql("Freeform")
49
- parser.in_buffer_settings["EMAIL"].should eql("bdewey@gmail.com")
50
- parser.in_buffer_settings["LANGUAGE"].should eql("en")
51
- end
52
-
53
- it "should understand OPTIONS" do
54
- parser = Orgmode::Parser.load(FreeformFile)
55
- parser.should have(19).options
56
- parser.options["TeX"].should eql("t")
57
- parser.options["todo"].should eql("t")
58
- parser.options["\\n"].should eql("nil")
59
- parser.export_todo?.should be_true
60
- parser.options.delete("todo")
61
- parser.export_todo?.should be_false
62
- end
63
-
64
- it "should skip in-buffer settings inside EXAMPLE blocks" do
65
- parser = Orgmode::Parser.load(FreeformExampleFile)
66
- parser.should have(0).in_buffer_settings
67
- end
68
-
69
- it "should return a textile string" do
70
- parser = Orgmode::Parser.load(FreeformFile)
71
- parser.to_textile.should be_kind_of(String)
72
- end
73
-
74
- it "should understand export table option" do
75
- fname = File.join(File.dirname(__FILE__), %w[html_examples skip-table.org])
76
- data = IO.read(fname)
77
- p = Orgmode::Parser.new(data)
78
- p.export_tables?.should be_false
79
- end
80
-
81
- describe "Custom keyword parser" do
82
- fname = File.join(File.dirname(__FILE__), %w[html_examples custom-todo.org])
83
- p = Orgmode::Parser.load(fname)
84
- valid_keywords = %w[TODO INPROGRESS WAITING DONE CANCELED]
85
- invalid_keywords = %w[TODOX todo inprogress Waiting done cANCELED NEXT |]
86
- valid_keywords.each do |kw|
87
- it "should match custom keyword #{kw}" do
88
- (kw =~ p.custom_keyword_regexp).should be_true
89
- end
90
- end
91
- invalid_keywords.each do |kw|
92
- it "should not match custom keyword #{kw}" do
93
- (kw =~ p.custom_keyword_regexp).should be_nil
94
- end
95
- end
96
- it "should not match blank as a custom keyword" do
97
- ("" =~ p.custom_keyword_regexp).should be_nil
98
- end
99
- end
100
-
101
- describe "Custom include/exclude parser" do
102
- fname = File.join(File.dirname(__FILE__), %w[html_examples export-tags.org])
103
- p = Orgmode::Parser.load(fname)
104
- it "should load tags" do
105
- p.should have(2).export_exclude_tags
106
- p.should have(1).export_select_tags
107
- end
108
- end
109
-
110
- describe "Export to Textile test cases" do
111
- data_directory = File.join(File.dirname(__FILE__), "textile_examples")
112
- org_files = File.expand_path(File.join(data_directory, "*.org" ))
113
- files = Dir.glob(org_files)
114
- files.each do |file|
115
- basename = File.basename(file, ".org")
116
- textile_name = File.join(data_directory, basename + ".textile")
117
- textile_name = File.expand_path(textile_name)
118
-
119
- it "should convert #{basename}.org to Textile" do
120
- expected = IO.read(textile_name)
121
- expected.should be_kind_of(String)
122
- parser = Orgmode::Parser.new(IO.read(file))
123
- actual = parser.to_textile
124
- actual.should be_kind_of(String)
125
- actual.should == expected
126
- end
127
- end
128
- end
129
-
130
- describe "Export to HTML test cases" do
131
- # Dynamic generation of examples from each *.org file in html_examples.
132
- # Each of these files is convertable to HTML.
133
- data_directory = File.join(File.dirname(__FILE__), "html_examples")
134
- org_files = File.expand_path(File.join(data_directory, "*.org" ))
135
- files = Dir.glob(org_files)
136
- files.each do |file|
137
- basename = File.basename(file, ".org")
138
- textile_name = File.join(data_directory, basename + ".html")
139
- textile_name = File.expand_path(textile_name)
140
-
141
- it "should convert #{basename}.org to HTML" do
142
- expected = IO.read(textile_name)
143
- expected.should be_kind_of(String)
144
- parser = Orgmode::Parser.new(IO.read(file))
145
- actual = parser.to_html
146
- actual.should be_kind_of(String)
147
- actual.should == expected
148
- end
149
-
150
- it "should render #{basename}.org to HTML using Tilt templates" do
151
- expected = IO.read(textile_name)
152
- template = Tilt.new(file).render
153
- template.should == expected
154
- end
155
- end
156
- end
157
- end
158
-
@@ -1,57 +0,0 @@
1
- require File.join(File.dirname(__FILE__), %w[spec_helper])
2
-
3
- describe Orgmode::RegexpHelper do
4
- it "should recognize simple markup" do
5
- e = Orgmode::RegexpHelper.new
6
- total = 0
7
- e.match_all("/italic/") do |border, string|
8
- border.should eql("/")
9
- string.should eql("italic")
10
- total += 1
11
- end
12
- total.should eql(1)
13
-
14
- total = 0
15
- borders = %w[* / ~]
16
- strings = %w[bold italic verbatim]
17
- e.match_all("This string contains *bold*, /italic/, and ~verbatim~ text.")\
18
- do |border, str|
19
- border.should eql(borders[total])
20
- str.should eql(strings[total])
21
- total += 1
22
- end
23
- total.should eql(3)
24
- end
25
-
26
- it "should not get confused by links" do
27
- e = Orgmode::RegexpHelper.new
28
- total = 0
29
- # Make sure the slashes in these links aren't treated as italics
30
- e.match_all("[[http://www.bing.com/twitter]]") do |border, str|
31
- total += 1
32
- end
33
- total.should eql(0)
34
- end
35
-
36
- it "should correctly perform substitutions" do
37
- e = Orgmode::RegexpHelper.new
38
- map = {
39
- "*" => "strong",
40
- "/" => "i",
41
- "~" => "pre"
42
- }
43
- n = e.rewrite_emphasis("This string contains *bold*, /italic/, and ~verbatim~ text.") do |border, str|
44
- "<#{map[border]}>#{str}</#{map[border]}>"
45
- end
46
- n.should eql("This string contains <strong>bold</strong>, <i>italic</i>, and <pre>verbatim</pre> text.")
47
- end
48
-
49
- it "should allow link rewriting" do
50
- e = Orgmode::RegexpHelper.new
51
- str = e.rewrite_links("[[http://www.bing.com]]") do |link,text|
52
- text ||= link
53
- "\"#{text}\":#{link}"
54
- end
55
- str.should eql("\"http://www.bing.com\":http://www.bing.com")
56
- end
57
- end # describe Orgmode::RegexpHelper