org-ruby 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/History.txt +45 -40
  2. data/{README.txt → README.rdoc} +66 -66
  3. data/Rakefile +28 -27
  4. data/bin/org-ruby +40 -40
  5. data/lib/org-ruby.rb +50 -50
  6. data/lib/org-ruby/headline.rb +80 -80
  7. data/lib/org-ruby/html_output_buffer.rb +117 -105
  8. data/lib/org-ruby/line.rb +178 -173
  9. data/lib/org-ruby/output_buffer.rb +172 -172
  10. data/lib/org-ruby/parser.rb +80 -80
  11. data/lib/org-ruby/regexp_helper.rb +156 -156
  12. data/lib/org-ruby/textile_output_buffer.rb +67 -67
  13. data/spec/data/freeform.org +111 -111
  14. data/spec/data/hyp-planning.org +335 -335
  15. data/spec/data/remember.org +53 -53
  16. data/spec/headline_spec.rb +55 -55
  17. data/spec/html_examples/advanced-lists.html +31 -31
  18. data/spec/html_examples/advanced-lists.org +31 -31
  19. data/spec/html_examples/block_code.html +30 -30
  20. data/spec/html_examples/block_code.org +35 -35
  21. data/spec/html_examples/blockquote.html +7 -7
  22. data/spec/html_examples/blockquote.org +13 -13
  23. data/spec/html_examples/code-comment.html +19 -0
  24. data/spec/html_examples/code-comment.org +22 -0
  25. data/spec/html_examples/escape-pre.html +7 -7
  26. data/spec/html_examples/escape-pre.org +6 -6
  27. data/spec/html_examples/html-literal.html +2 -0
  28. data/spec/html_examples/html-literal.org +6 -0
  29. data/spec/html_examples/inline-formatting.html +10 -10
  30. data/spec/html_examples/inline-formatting.org +17 -17
  31. data/spec/html_examples/lists.html +19 -19
  32. data/spec/html_examples/lists.org +36 -36
  33. data/spec/html_examples/metadata-comment.org-fail +30 -0
  34. data/spec/html_examples/only-list.html +5 -5
  35. data/spec/html_examples/only-list.org +3 -3
  36. data/spec/html_examples/only-table.html +6 -6
  37. data/spec/html_examples/only-table.org +5 -5
  38. data/spec/html_examples/tables.html +20 -20
  39. data/spec/html_examples/tables.org +26 -26
  40. data/spec/html_examples/text.html +2 -2
  41. data/spec/html_examples/text.org +16 -16
  42. data/spec/line_spec.rb +89 -89
  43. data/spec/parser_spec.rb +86 -86
  44. data/spec/regexp_helper_spec.rb +57 -57
  45. data/spec/spec_helper.rb +20 -20
  46. data/spec/textile_examples/block_code.org +35 -35
  47. data/spec/textile_examples/block_code.textile +29 -29
  48. data/spec/textile_examples/blockquote.org +13 -13
  49. data/spec/textile_examples/blockquote.textile +11 -11
  50. data/spec/textile_examples/keywords.org +13 -13
  51. data/spec/textile_examples/keywords.textile +11 -11
  52. data/spec/textile_examples/links.org +11 -11
  53. data/spec/textile_examples/links.textile +10 -10
  54. data/spec/textile_examples/lists.org +36 -36
  55. data/spec/textile_examples/lists.textile +20 -20
  56. data/spec/textile_examples/single-space-plain-list.org +13 -13
  57. data/spec/textile_examples/single-space-plain-list.textile +10 -10
  58. data/spec/textile_examples/tables.org +26 -26
  59. data/spec/textile_examples/tables.textile +23 -23
  60. data/spec/textile_output_buffer_spec.rb +21 -21
  61. data/tasks/test_case.rake +49 -49
  62. metadata +10 -6
  63. data/.bnsignore +0 -18
@@ -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,89 +1,89 @@
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
- it "should recognize plain lists" do
28
- list_formats = ["-",
29
- "+",
30
- " -",
31
- " +",
32
- " 1.",
33
- " 2)"]
34
- list_formats.each do |list|
35
- line = Orgmode::Line.new list
36
- line.plain_list?.should be_true
37
- end
38
- end
39
-
40
- it "should recognize table rows" do
41
- Orgmode::Line.new("| One | Two | Three |").table_row?.should be_true
42
- Orgmode::Line.new(" |-------+-------+-------|\n").table_separator?.should be_true
43
- Orgmode::Line.new("| Four | Five | Six |").table_row?.should be_true
44
- Orgmode::Line.new("| Seven | Eight | Nine |").table_row?.should be_true
45
- end
46
-
47
- it "should recognize indentation" do
48
- Orgmode::Line.new("").indent.should eql(0)
49
- Orgmode::Line.new(" a").indent.should eql(1)
50
- Orgmode::Line.new(" ").indent.should eql(0)
51
- Orgmode::Line.new(" \n").indent.should eql(0)
52
- Orgmode::Line.new(" a").indent.should eql(3)
53
- end
54
-
55
- it "should return paragraph type" do
56
- Orgmode::Line.new("").paragraph_type.should eql(:blank)
57
- Orgmode::Line.new("1. foo").paragraph_type.should eql(:ordered_list)
58
- Orgmode::Line.new("- [ ] checkbox").paragraph_type.should eql(:unordered_list)
59
- Orgmode::Line.new("hello!").paragraph_type.should eql(:paragraph)
60
- end
61
-
62
- it "should recognize BEGIN and END comments" do
63
- begin_examples = {
64
- "#+BEGIN_SRC emacs-lisp -n -r\n" => "SRC",
65
- "#+BEGIN_EXAMPLE" => "EXAMPLE",
66
- "\t#+BEGIN_QUOTE " => "QUOTE"
67
- }
68
-
69
- end_examples = {
70
- "#+END_SRC" => "SRC",
71
- "#+END_EXAMPLE" => "EXAMPLE",
72
- "\t#+END_QUOTE " => "QUOTE"
73
- }
74
-
75
- begin_examples.each_key do |str|
76
- line = Orgmode::Line.new str
77
- line.comment?.should be_true
78
- line.begin_block?.should be_true
79
- line.block_type.should eql(begin_examples[str])
80
- end
81
-
82
- end_examples.each_key do |str|
83
- line = Orgmode::Line.new str
84
- line.comment?.should be_true
85
- line.end_block?.should be_true
86
- line.block_type.should eql(end_examples[str])
87
- end
88
- end
89
- 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
+ it "should recognize plain lists" do
28
+ list_formats = ["-",
29
+ "+",
30
+ " -",
31
+ " +",
32
+ " 1.",
33
+ " 2)"]
34
+ list_formats.each do |list|
35
+ line = Orgmode::Line.new list
36
+ line.plain_list?.should be_true
37
+ end
38
+ end
39
+
40
+ it "should recognize table rows" do
41
+ Orgmode::Line.new("| One | Two | Three |").table_row?.should be_true
42
+ Orgmode::Line.new(" |-------+-------+-------|\n").table_separator?.should be_true
43
+ Orgmode::Line.new("| Four | Five | Six |").table_row?.should be_true
44
+ Orgmode::Line.new("| Seven | Eight | Nine |").table_row?.should be_true
45
+ end
46
+
47
+ it "should recognize indentation" do
48
+ Orgmode::Line.new("").indent.should eql(0)
49
+ Orgmode::Line.new(" a").indent.should eql(1)
50
+ Orgmode::Line.new(" ").indent.should eql(0)
51
+ Orgmode::Line.new(" \n").indent.should eql(0)
52
+ Orgmode::Line.new(" a").indent.should eql(3)
53
+ end
54
+
55
+ it "should return paragraph type" do
56
+ Orgmode::Line.new("").paragraph_type.should eql(:blank)
57
+ Orgmode::Line.new("1. foo").paragraph_type.should eql(:ordered_list)
58
+ Orgmode::Line.new("- [ ] checkbox").paragraph_type.should eql(:unordered_list)
59
+ Orgmode::Line.new("hello!").paragraph_type.should eql(:paragraph)
60
+ end
61
+
62
+ it "should recognize BEGIN and END comments" do
63
+ begin_examples = {
64
+ "#+BEGIN_SRC emacs-lisp -n -r\n" => "SRC",
65
+ "#+BEGIN_EXAMPLE" => "EXAMPLE",
66
+ "\t#+BEGIN_QUOTE " => "QUOTE"
67
+ }
68
+
69
+ end_examples = {
70
+ "#+END_SRC" => "SRC",
71
+ "#+END_EXAMPLE" => "EXAMPLE",
72
+ "\t#+END_QUOTE " => "QUOTE"
73
+ }
74
+
75
+ begin_examples.each_key do |str|
76
+ line = Orgmode::Line.new str
77
+ line.comment?.should be_true
78
+ line.begin_block?.should be_true
79
+ line.block_type.should eql(begin_examples[str])
80
+ end
81
+
82
+ end_examples.each_key do |str|
83
+ line = Orgmode::Line.new str
84
+ line.comment?.should be_true
85
+ line.end_block?.should be_true
86
+ line.block_type.should eql(end_examples[str])
87
+ end
88
+ end
89
+ end
data/spec/parser_spec.rb CHANGED
@@ -1,86 +1,86 @@
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(0).body_lines
37
- parser.headlines[1].should have(6).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 return a textile string" do
46
- parser = Orgmode::Parser.load(FreeformFile)
47
- parser.to_textile.should be_kind_of(String)
48
- end
49
-
50
- it "can translate textile files" do
51
- data_directory = File.join(File.dirname(__FILE__), "textile_examples")
52
- org_files = File.expand_path(File.join(data_directory, "*.org" ))
53
- files = Dir.glob(org_files)
54
- files.each do |file|
55
- basename = File.basename(file, ".org")
56
- textile_name = File.join(data_directory, basename + ".textile")
57
- textile_name = File.expand_path(textile_name)
58
-
59
- expected = IO.read(textile_name)
60
- expected.should be_kind_of(String)
61
- parser = Orgmode::Parser.new(IO.read(file))
62
- actual = parser.to_textile
63
- actual.should be_kind_of(String)
64
- actual.should == expected
65
- end
66
- end
67
-
68
- it "can translate to html" do
69
- data_directory = File.join(File.dirname(__FILE__), "html_examples")
70
- org_files = File.expand_path(File.join(data_directory, "*.org" ))
71
- files = Dir.glob(org_files)
72
- files.each do |file|
73
- basename = File.basename(file, ".org")
74
- textile_name = File.join(data_directory, basename + ".html")
75
- textile_name = File.expand_path(textile_name)
76
-
77
- expected = IO.read(textile_name)
78
- expected.should be_kind_of(String)
79
- parser = Orgmode::Parser.new(IO.read(file))
80
- actual = parser.to_html
81
- actual.should be_kind_of(String)
82
- actual.should == expected
83
- end
84
- end
85
- end
86
-
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(0).body_lines
37
+ parser.headlines[1].should have(6).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 return a textile string" do
46
+ parser = Orgmode::Parser.load(FreeformFile)
47
+ parser.to_textile.should be_kind_of(String)
48
+ end
49
+
50
+ it "can translate textile files" do
51
+ data_directory = File.join(File.dirname(__FILE__), "textile_examples")
52
+ org_files = File.expand_path(File.join(data_directory, "*.org" ))
53
+ files = Dir.glob(org_files)
54
+ files.each do |file|
55
+ basename = File.basename(file, ".org")
56
+ textile_name = File.join(data_directory, basename + ".textile")
57
+ textile_name = File.expand_path(textile_name)
58
+
59
+ expected = IO.read(textile_name)
60
+ expected.should be_kind_of(String)
61
+ parser = Orgmode::Parser.new(IO.read(file))
62
+ actual = parser.to_textile
63
+ actual.should be_kind_of(String)
64
+ actual.should == expected
65
+ end
66
+ end
67
+
68
+ it "can translate to html" do
69
+ data_directory = File.join(File.dirname(__FILE__), "html_examples")
70
+ org_files = File.expand_path(File.join(data_directory, "*.org" ))
71
+ files = Dir.glob(org_files)
72
+ files.each do |file|
73
+ basename = File.basename(file, ".org")
74
+ textile_name = File.join(data_directory, basename + ".html")
75
+ textile_name = File.expand_path(textile_name)
76
+
77
+ expected = IO.read(textile_name)
78
+ expected.should be_kind_of(String)
79
+ parser = Orgmode::Parser.new(IO.read(file))
80
+ actual = parser.to_html
81
+ actual.should be_kind_of(String)
82
+ actual.should == expected
83
+ end
84
+ end
85
+ end
86
+
@@ -1,57 +1,57 @@
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
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