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,120 +1,102 @@
1
- require OrgRuby.libpath(*%w[org-ruby line])
2
-
3
- module Orgmode
4
-
5
- # Represents a headline in an orgmode file.
6
- class Headline < Line
7
-
8
- # This is the "level" of the headline
9
- attr_reader :level
10
-
11
- # This is the headline text -- the part of the headline minus the leading
12
- # asterisks, the keywords, and the tags.
13
- attr_reader :headline_text
14
-
15
- # This contains the lines that "belong" to the headline.
16
- attr_reader :body_lines
17
-
18
- # These are the headline tags
19
- attr_reader :tags
20
-
21
- # Optional keyword found at the beginning of the headline.
22
- attr_reader :keyword
23
-
24
- # Valid states for partial export.
25
- # exclude:: The entire subtree from this heading should be excluded.
26
- # headline_only:: The headline should be exported, but not the body.
27
- # all:: Everything should be exported, headline/body/children.
28
- ValidExportStates = [:exclude, :headline_only, :all]
29
-
30
- # The export state of this headline. See +ValidExportStates+.
31
- attr_accessor :export_state
32
-
33
- # This is the regex that matches a line
34
- LineRegexp = /^\*+\s+/
35
-
36
- # This matches the tags on a headline
37
- TagsRegexp = /\s*:[\w:]*:\s*$/
38
-
39
- # Special keywords allowed at the start of a line.
40
- Keywords = %w[TODO DONE]
41
-
42
- KeywordsRegexp = Regexp.new("^(#{Keywords.join('|')})\$")
43
-
44
- def initialize(line, parser = nil)
45
- super(line, parser)
46
- @body_lines = []
47
- @tags = []
48
- @export_state = :exclude
49
- if (@line =~ LineRegexp) then
50
- @level = $&.strip.length
51
- @headline_text = $'.strip
52
- if (@headline_text =~ TagsRegexp) then
53
- @tags = $&.split(/:/) # split tag text on semicolon
54
- @tags.delete_at(0) # the first item will be empty; discard
55
- @headline_text.gsub!(TagsRegexp, "") # Removes the tags from the headline
56
- end
57
- @keyword = nil
58
- parse_keywords
59
- else
60
- raise "'#{line}' is not a valid headline"
61
- end
62
- end
63
-
64
- # Determines if a line is an orgmode "headline":
65
- # A headline begins with one or more asterisks.
66
- def self.headline?(line)
67
- line =~ LineRegexp
68
- end
69
-
70
- # Converts this headline and its body to textile.
71
- def to_textile
72
- output = "h#{@level}. #{@headline_text}\n"
73
- output << Line.to_textile(@body_lines)
74
- output
75
- end
76
-
77
- def to_html(opts = {})
78
- return "" if @export_state == :exclude
79
- if opts[:decorate_title]
80
- decoration = " class=\"title\""
81
- opts.delete(:decorate_title)
82
- else
83
- decoration = ""
84
- end
85
- output = "<h#{@level}#{decoration}>"
86
- if @parser and @parser.export_heading_number? then
87
- heading_number = @parser.get_next_headline_number(@level)
88
- output << "<span class=\"heading-number heading-number-#{@level}\">#{heading_number} </span>"
89
- end
90
- if @parser and @parser.export_todo? and @keyword then
91
- output << "<span class=\"todo-keyword #{@keyword}\">#{@keyword} </span>"
92
- end
93
- output << "#{escape(@headline_text)}</h#{@level}>\n"
94
- return output if @export_state == :headline_only
95
- output << Line.to_html(@body_lines, opts)
96
- output
97
- end
98
-
99
- ######################################################################
100
- private
101
-
102
- # TODO 2009-12-29 This duplicates escape_buffer! in html_output_buffer. DRY.
103
- def escape(str)
104
- str = str.gsub(/&/, "&amp;")
105
- str = str.gsub(/</, "&lt;")
106
- str = str.gsub(/>/, "&gt;")
107
- str
108
- end
109
-
110
- def parse_keywords
111
- re = @parser.custom_keyword_regexp if @parser
112
- re ||= KeywordsRegexp
113
- words = @headline_text.split
114
- if words.length > 0 && words[0] =~ re then
115
- @keyword = words[0]
116
- @headline_text.sub!(Regexp.new("^#{@keyword}\s*"), "")
117
- end
118
- end
119
- end # class Headline
120
- end # class Orgmode
1
+ require OrgRuby.libpath(*%w[org-ruby line])
2
+
3
+ module Orgmode
4
+
5
+ # Represents a headline in an orgmode file.
6
+ class Headline < Line
7
+
8
+ # This is the "level" of the headline
9
+ attr_reader :level
10
+
11
+ # This is the headline text -- the part of the headline minus the leading
12
+ # asterisks, the keywords, and the tags.
13
+ attr_reader :headline_text
14
+
15
+ # This contains the lines that "belong" to the headline.
16
+ attr_reader :body_lines
17
+
18
+ # These are the headline tags
19
+ attr_reader :tags
20
+
21
+ # Optional keyword found at the beginning of the headline.
22
+ attr_reader :keyword
23
+
24
+ # Valid states for partial export.
25
+ # exclude:: The entire subtree from this heading should be excluded.
26
+ # headline_only:: The headline should be exported, but not the body.
27
+ # all:: Everything should be exported, headline/body/children.
28
+ ValidExportStates = [:exclude, :headline_only, :all]
29
+
30
+ # The export state of this headline. See +ValidExportStates+.
31
+ attr_accessor :export_state
32
+
33
+ # This is the regex that matches a line
34
+ LineRegexp = /^\*+\s+/
35
+
36
+ # This matches the tags on a headline
37
+ TagsRegexp = /\s*:[\w:]*:\s*$/
38
+
39
+ # Special keywords allowed at the start of a line.
40
+ Keywords = %w[TODO DONE]
41
+
42
+ KeywordsRegexp = Regexp.new("^(#{Keywords.join('|')})\$")
43
+
44
+ def initialize(line, parser = nil)
45
+ super(line, parser)
46
+ @body_lines = []
47
+ @body_lines << self # Make @body_lines contain the headline?
48
+ @tags = []
49
+ @export_state = :exclude
50
+ if (@line =~ LineRegexp) then
51
+ @level = $&.strip.length
52
+ @headline_text = $'.strip
53
+ if (@headline_text =~ TagsRegexp) then
54
+ @tags = $&.split(/:/) # split tag text on semicolon
55
+ @tags.delete_at(0) # the first item will be empty; discard
56
+ @headline_text.gsub!(TagsRegexp, "") # Removes the tags from the headline
57
+ end
58
+ @keyword = nil
59
+ parse_keywords
60
+ else
61
+ raise "'#{line}' is not a valid headline"
62
+ end
63
+ end
64
+
65
+ # Override Line.output_text. For a heading, @headline_text
66
+ # is what we should output.
67
+ def output_text
68
+ return @headline_text
69
+ end
70
+
71
+ # Determines if a line is an orgmode "headline":
72
+ # A headline begins with one or more asterisks.
73
+ def self.headline?(line)
74
+ line =~ LineRegexp
75
+ end
76
+
77
+ # Overrides Line.paragraph_type.
78
+ def paragraph_type
79
+ :"heading#{@level}"
80
+ end
81
+
82
+ # Converts this headline and its body to textile.
83
+ def to_textile
84
+ output = "h#{@level}. #{@headline_text}\n"
85
+ output << Line.to_textile(@body_lines[1..-1])
86
+ output
87
+ end
88
+
89
+ ######################################################################
90
+ private
91
+
92
+ def parse_keywords
93
+ re = @parser.custom_keyword_regexp if @parser
94
+ re ||= KeywordsRegexp
95
+ words = @headline_text.split
96
+ if words.length > 0 && words[0] =~ re then
97
+ @keyword = words[0]
98
+ @headline_text.sub!(Regexp.new("^#{@keyword}\s*"), "")
99
+ end
100
+ end
101
+ end # class Headline
102
+ end # class Orgmode
@@ -1,156 +1,174 @@
1
- require OrgRuby.libpath(*%w[org-ruby output_buffer])
2
-
3
- module Orgmode
4
-
5
- class HtmlOutputBuffer < OutputBuffer
6
-
7
- HtmlBlockTag = {
8
- :paragraph => "p",
9
- :ordered_list => "li",
10
- :unordered_list => "li",
11
- :table_row => "tr",
12
- :table_header => "tr"
13
- }
14
-
15
- ModeTag = {
16
- :unordered_list => "ul",
17
- :ordered_list => "ol",
18
- :table => "table",
19
- :blockquote => "blockquote",
20
- :example => "pre",
21
- :src => "pre",
22
- :inline_example => "pre"
23
- }
24
-
25
- attr_reader :options
26
-
27
- def initialize(output, opts = {})
28
- super(output)
29
- if opts[:decorate_title] then
30
- @title_decoration = " class=\"title\""
31
- else
32
- @title_decoration = ""
33
- end
34
- @options = opts
35
- @logger.debug "HTML export options: #{@options.inspect}"
36
- end
37
-
38
- # Output buffer is entering a new mode. Use this opportunity to
39
- # write out one of the block tags in the ModeTag constant to put
40
- # this information in the HTML stream.
41
- def push_mode(mode)
42
- if ModeTag[mode] then
43
- output_indentation
44
- css_class = ""
45
- css_class = " class=\"src\"" if mode == :src
46
- css_class = " class=\"example\"" if (mode == :example || mode == :inline_example)
47
- @logger.debug "#{mode}: <#{ModeTag[mode]}#{css_class}>\n"
48
- @output << "<#{ModeTag[mode]}#{css_class}>\n" unless mode == :table and skip_tables?
49
- # Entering a new mode obliterates the title decoration
50
- @title_decoration = ""
51
- end
52
- super(mode)
53
- end
54
-
55
- # We are leaving a mode. Close any tags that were opened when
56
- # entering this mode.
57
- def pop_mode(mode = nil)
58
- m = super(mode)
59
- if ModeTag[m] then
60
- output_indentation
61
- @logger.debug "</#{ModeTag[m]}>\n"
62
- @output << "</#{ModeTag[m]}>\n" unless mode == :table and skip_tables?
63
- end
64
- end
65
-
66
- def flush!
67
- escape_buffer!
68
- if mode_is_code(@buffer_mode) then
69
- # Whitespace is significant in :code mode. Always output the buffer
70
- # and do not do any additional translation.
71
- @logger.debug "FLUSH CODE ==========> #{@buffer.inspect}"
72
- @output << @buffer << "\n"
73
- else
74
- if (@buffer.length > 0) then
75
- unless buffer_mode_is_table? and skip_tables?
76
- @logger.debug "FLUSH ==========> #{@buffer_mode}"
77
- output_indentation
78
- @output << "<#{HtmlBlockTag[@output_type]}#{@title_decoration}>" \
79
- << inline_formatting(@buffer) \
80
- << "</#{HtmlBlockTag[@output_type]}>\n"
81
- @title_decoration = ""
82
- else
83
- @logger.debug "SKIP ==========> #{@buffer_mode}"
84
- end
85
- end
86
- end
87
- @buffer = ""
88
- @buffer_mode = nil
89
- end
90
-
91
- ######################################################################
92
- private
93
-
94
- def skip_tables?
95
- @options[:skip_tables]
96
- end
97
-
98
- def buffer_mode_is_table?
99
- @buffer_mode == :table
100
- end
101
-
102
- # Escapes any HTML content in the output accumulation buffer @buffer.
103
- def escape_buffer!
104
- @buffer.gsub!(/&/, "&amp;")
105
- @buffer.gsub!(/</, "&lt;")
106
- @buffer.gsub!(/>/, "&gt;")
107
- end
108
-
109
- def output_indentation
110
- indent = " " * (@mode_stack.length - 1)
111
- @output << indent
112
- end
113
-
114
- Tags = {
115
- "*" => { :open => "<b>", :close => "</b>" },
116
- "/" => { :open => "<i>", :close => "</i>" },
117
- "_" => { :open => "<span style=\"text-decoration:underline;\">",
118
- :close => "</span>" },
119
- "=" => { :open => "<code>", :close => "</code>" },
120
- "~" => { :open => "<code>", :close => "</code>" },
121
- "+" => { :open => "<del>", :close => "</del>" }
122
- }
123
-
124
- # Applies inline formatting rules to a string.
125
- def inline_formatting(str)
126
- str.rstrip!
127
- str = @re_help.rewrite_emphasis(str) do |marker, s|
128
- "#{Tags[marker][:open]}#{s}#{Tags[marker][:close]}"
129
- end
130
- str = @re_help.rewrite_links(str) do |link, text|
131
- text ||= link
132
- link = link.sub(/^file:(.*)::(.*?)$/) do
133
-
134
- # We don't support search links right now. Get rid of it.
135
-
136
- "file:#{$1}"
137
- end
138
- link = link.sub(/^file:/i, "") # will default to HTTP
139
- link = link.sub(/\.org$/i, ".html")
140
- "<a href=\"#{link}\">#{text}</a>"
141
- end
142
- if (@output_type == :table_row) then
143
- str.gsub!(/^\|\s*/, "<td>")
144
- str.gsub!(/\s*\|$/, "</td>")
145
- str.gsub!(/\s*\|\s*/, "</td><td>")
146
- end
147
- if (@output_type == :table_header) then
148
- str.gsub!(/^\|\s*/, "<th>")
149
- str.gsub!(/\s*\|$/, "</th>")
150
- str.gsub!(/\s*\|\s*/, "</th><th>")
151
- end
152
- str
153
- end
154
-
155
- end # class HtmlOutputBuffer
156
- end # module Orgmode
1
+ require OrgRuby.libpath(*%w[org-ruby output_buffer])
2
+
3
+ module Orgmode
4
+
5
+ class HtmlOutputBuffer < OutputBuffer
6
+
7
+ HtmlBlockTag = {
8
+ :paragraph => "p",
9
+ :ordered_list => "li",
10
+ :unordered_list => "li",
11
+ :table_row => "tr",
12
+ :table_header => "tr",
13
+ :heading1 => "h1",
14
+ :heading2 => "h2",
15
+ :heading3 => "h3",
16
+ :heading4 => "h4",
17
+ :heading5 => "h5",
18
+ :heading6 => "h6"
19
+ }
20
+
21
+ ModeTag = {
22
+ :unordered_list => "ul",
23
+ :ordered_list => "ol",
24
+ :table => "table",
25
+ :blockquote => "blockquote",
26
+ :example => "pre",
27
+ :src => "pre",
28
+ :inline_example => "pre"
29
+ }
30
+
31
+ attr_reader :options
32
+
33
+ def initialize(output, opts = {})
34
+ super(output)
35
+ if opts[:decorate_title] then
36
+ @title_decoration = " class=\"title\""
37
+ else
38
+ @title_decoration = ""
39
+ end
40
+ @options = opts
41
+ @logger.debug "HTML export options: #{@options.inspect}"
42
+ end
43
+
44
+ # Output buffer is entering a new mode. Use this opportunity to
45
+ # write out one of the block tags in the ModeTag constant to put
46
+ # this information in the HTML stream.
47
+ def push_mode(mode)
48
+ if ModeTag[mode] then
49
+ output_indentation
50
+ css_class = ""
51
+ css_class = " class=\"src\"" if mode == :src
52
+ css_class = " class=\"example\"" if (mode == :example || mode == :inline_example)
53
+ @logger.debug "#{mode}: <#{ModeTag[mode]}#{css_class}>\n"
54
+ @output << "<#{ModeTag[mode]}#{css_class}>\n" unless mode == :table and skip_tables?
55
+ # Entering a new mode obliterates the title decoration
56
+ @title_decoration = ""
57
+ end
58
+ super(mode)
59
+ end
60
+
61
+ # We are leaving a mode. Close any tags that were opened when
62
+ # entering this mode.
63
+ def pop_mode(mode = nil)
64
+ m = super(mode)
65
+ if ModeTag[m] then
66
+ output_indentation
67
+ @logger.debug "</#{ModeTag[m]}>\n"
68
+ @output << "</#{ModeTag[m]}>\n" unless mode == :table and skip_tables?
69
+ end
70
+ end
71
+
72
+ def flush!
73
+ escape_buffer!
74
+ if mode_is_code(@buffer_mode) then
75
+ # Whitespace is significant in :code mode. Always output the buffer
76
+ # and do not do any additional translation.
77
+ @logger.debug "FLUSH CODE ==========> #{@buffer.inspect}"
78
+ @output << @buffer << "\n"
79
+ else
80
+ if (@buffer.length > 0) then
81
+ unless buffer_mode_is_table? and skip_tables?
82
+ @logger.debug "FLUSH ==========> #{@buffer_mode}"
83
+ output_indentation
84
+ @output << "<#{HtmlBlockTag[@output_type]}#{@title_decoration}>"
85
+ if (@buffered_lines[0].kind_of?(Headline)) then
86
+ headline = @buffered_lines[0]
87
+ raise "Cannot be more than one headline!" if @buffered_lines.length > 1
88
+ if @options[:export_heading_number] then
89
+ level = headline.level
90
+ heading_number = get_next_headline_number(level)
91
+ output << "<span class=\"heading-number heading-number-#{level}\">#{heading_number} </span>"
92
+ end
93
+ if @options[:export_todo] and headline.keyword then
94
+ keyword = headline.keyword
95
+ output << "<span class=\"todo-keyword #{keyword}\">#{keyword} </span>"
96
+ end
97
+ end
98
+ @output << inline_formatting(@buffer)
99
+ @output << "</#{HtmlBlockTag[@output_type]}>\n"
100
+ @title_decoration = ""
101
+ else
102
+ @logger.debug "SKIP ==========> #{@buffer_mode}"
103
+ end
104
+ end
105
+ end
106
+ clear_accumulation_buffer!
107
+ end
108
+
109
+ ######################################################################
110
+ private
111
+
112
+ def skip_tables?
113
+ @options[:skip_tables]
114
+ end
115
+
116
+ def buffer_mode_is_table?
117
+ @buffer_mode == :table
118
+ end
119
+
120
+ # Escapes any HTML content in the output accumulation buffer @buffer.
121
+ def escape_buffer!
122
+ @buffer.gsub!(/&/, "&amp;")
123
+ @buffer.gsub!(/</, "&lt;")
124
+ @buffer.gsub!(/>/, "&gt;")
125
+ end
126
+
127
+ def output_indentation
128
+ indent = " " * (@mode_stack.length - 1)
129
+ @output << indent
130
+ end
131
+
132
+ Tags = {
133
+ "*" => { :open => "<b>", :close => "</b>" },
134
+ "/" => { :open => "<i>", :close => "</i>" },
135
+ "_" => { :open => "<span style=\"text-decoration:underline;\">",
136
+ :close => "</span>" },
137
+ "=" => { :open => "<code>", :close => "</code>" },
138
+ "~" => { :open => "<code>", :close => "</code>" },
139
+ "+" => { :open => "<del>", :close => "</del>" }
140
+ }
141
+
142
+ # Applies inline formatting rules to a string.
143
+ def inline_formatting(str)
144
+ str.rstrip!
145
+ str = @re_help.rewrite_emphasis(str) do |marker, s|
146
+ "#{Tags[marker][:open]}#{s}#{Tags[marker][:close]}"
147
+ end
148
+ str = @re_help.rewrite_links(str) do |link, text|
149
+ text ||= link
150
+ link = link.sub(/^file:(.*)::(.*?)$/) do
151
+
152
+ # We don't support search links right now. Get rid of it.
153
+
154
+ "file:#{$1}"
155
+ end
156
+ link = link.sub(/^file:/i, "") # will default to HTTP
157
+ link = link.sub(/\.org$/i, ".html")
158
+ "<a href=\"#{link}\">#{text}</a>"
159
+ end
160
+ if (@output_type == :table_row) then
161
+ str.gsub!(/^\|\s*/, "<td>")
162
+ str.gsub!(/\s*\|$/, "</td>")
163
+ str.gsub!(/\s*\|\s*/, "</td><td>")
164
+ end
165
+ if (@output_type == :table_header) then
166
+ str.gsub!(/^\|\s*/, "<th>")
167
+ str.gsub!(/\s*\|$/, "</th>")
168
+ str.gsub!(/\s*\|\s*/, "</th><th>")
169
+ end
170
+ str
171
+ end
172
+
173
+ end # class HtmlOutputBuffer
174
+ end # module Orgmode