org-ruby 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/.bnsignore +18 -0
  2. data/History.txt +24 -0
  3. data/README.txt +66 -0
  4. data/Rakefile +22 -0
  5. data/TAGS +128 -0
  6. data/bin/org-ruby +40 -0
  7. data/lib/org-ruby.rb +48 -0
  8. data/lib/org-ruby/headline.rb +75 -0
  9. data/lib/org-ruby/html_output_buffer.rb +80 -0
  10. data/lib/org-ruby/line.rb +172 -0
  11. data/lib/org-ruby/output_buffer.rb +154 -0
  12. data/lib/org-ruby/parser.rb +72 -0
  13. data/lib/org-ruby/regexp_helper.rb +156 -0
  14. data/lib/org-ruby/textile_output_buffer.rb +67 -0
  15. data/spec/data/freeform.org +111 -0
  16. data/spec/data/hyp-planning.org +335 -0
  17. data/spec/data/remember.org +53 -0
  18. data/spec/headline_spec.rb +55 -0
  19. data/spec/html_examples/block_code.html +29 -0
  20. data/spec/html_examples/block_code.org +35 -0
  21. data/spec/html_examples/blockquote.html +7 -0
  22. data/spec/html_examples/blockquote.org +13 -0
  23. data/spec/html_examples/inline-formatting.html +10 -0
  24. data/spec/html_examples/inline-formatting.org +17 -0
  25. data/spec/html_examples/lists.html +19 -0
  26. data/spec/html_examples/lists.org +36 -0
  27. data/spec/html_examples/tables.html +20 -0
  28. data/spec/html_examples/tables.org +26 -0
  29. data/spec/html_examples/text.html +2 -0
  30. data/spec/html_examples/text.org +16 -0
  31. data/spec/line_spec.rb +89 -0
  32. data/spec/parser_spec.rb +86 -0
  33. data/spec/regexp_helper_spec.rb +57 -0
  34. data/spec/spec_helper.rb +20 -0
  35. data/spec/textile_examples/block_code.org +35 -0
  36. data/spec/textile_examples/block_code.textile +29 -0
  37. data/spec/textile_examples/blockquote.org +13 -0
  38. data/spec/textile_examples/blockquote.textile +11 -0
  39. data/spec/textile_examples/keywords.org +13 -0
  40. data/spec/textile_examples/keywords.textile +11 -0
  41. data/spec/textile_examples/links.org +11 -0
  42. data/spec/textile_examples/links.textile +10 -0
  43. data/spec/textile_examples/lists.org +36 -0
  44. data/spec/textile_examples/lists.textile +20 -0
  45. data/spec/textile_examples/single-space-plain-list.org +13 -0
  46. data/spec/textile_examples/single-space-plain-list.textile +10 -0
  47. data/spec/textile_examples/tables.org +26 -0
  48. data/spec/textile_examples/tables.textile +23 -0
  49. data/spec/textile_output_buffer_spec.rb +21 -0
  50. data/test/test_orgmode_parser.rb +0 -0
  51. metadata +120 -0
data/.bnsignore ADDED
@@ -0,0 +1,18 @@
1
+ # The list of files that should be ignored by Mr Bones.
2
+ # Lines that start with '#' are comments.
3
+ #
4
+ # A .gitignore file can be used instead by setting it as the ignore
5
+ # file in your Rakefile:
6
+ #
7
+ # Bones {
8
+ # ignore_file '.gitignore'
9
+ # }
10
+ #
11
+ # For a project with a C extension, the following would be a good set of
12
+ # exclude patterns (uncomment them if you want to use them):
13
+ # *.[oa]
14
+ # *~
15
+ announcement.txt
16
+ coverage
17
+ doc
18
+ pkg
data/History.txt ADDED
@@ -0,0 +1,24 @@
1
+ == 0.2.0 / 2009-12-26
2
+
3
+ * Renamed the gem to org-ruby
4
+ * Added +to_html+ for HTML output
5
+ * Now supports the following inline markup:
6
+ * bold
7
+ * italic
8
+ * code
9
+ * verbatim
10
+ * underline
11
+ * strikethrough
12
+ * Continued code cleanup and refactoring
13
+
14
+ == 0.1.0 / 2009-12-23
15
+
16
+ * Added support for block code
17
+ * Added support for list items that wrap in the org source
18
+ * Major code cleanup:
19
+ Added +OutputBuffer+ class that should make the code more maintainable.
20
+
21
+ == 0.0.2 / 2009-12-21
22
+
23
+ * Initial version. Handles tables (but not headers), headlines,
24
+ paragraphs, block quotes, strong & emphasis formatting.
data/README.txt ADDED
@@ -0,0 +1,66 @@
1
+ org-ruby
2
+ by Brian Dewey
3
+ http://www.bdewey.com
4
+
5
+ == DESCRIPTION:
6
+
7
+ This gem contains Ruby routines for parsing org-mode files.The most
8
+ significant thing this library does today is convert org-mode files to
9
+ HTML or textile. Currently, you cannot do much to customize the
10
+ conversion. The supplied textile conversion is optimized for
11
+ extracting "content" from the orgfile as opposed to "metadata."
12
+
13
+ == FEATURES/PROBLEMS:
14
+
15
+ * Converts org-mode files to HTML or Textile
16
+ * Supports tables, block quotes, and block code
17
+ * Supports bold, italic, underline, strikethrough, and code inline formatting.
18
+ * Supports hyperlinks that are in double-brackets
19
+ * Upcoming: Handle export options specified in the org buffer.
20
+
21
+ == SYNOPSIS:
22
+
23
+ From the command line:
24
+
25
+ org-ruby sample.org
26
+
27
+ ...will output a HTML version of sample.org.
28
+
29
+ org-ruby --translate textile sample.org
30
+
31
+ ...will output a textile version of sample.org.
32
+
33
+ From Ruby code:
34
+
35
+ Orgmode::Parser.new(data)
36
+
37
+ ...will construct a new +Parser+ object.
38
+
39
+ == INSTALL:
40
+
41
+ sudo gem install org-ruby
42
+
43
+ == LICENSE:
44
+
45
+ (The MIT License)
46
+
47
+ Copyright (c) 2009 Brian Dewey
48
+
49
+ Permission is hereby granted, free of charge, to any person obtaining
50
+ a copy of this software and associated documentation files (the
51
+ 'Software'), to deal in the Software without restriction, including
52
+ without limitation the rights to use, copy, modify, merge, publish,
53
+ distribute, sublicense, and/or sell copies of the Software, and to
54
+ permit persons to whom the Software is furnished to do so, subject to
55
+ the following conditions:
56
+
57
+ The above copyright notice and this permission notice shall be
58
+ included in all copies or substantial portions of the Software.
59
+
60
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
61
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
62
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
63
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
64
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
65
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
66
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+
2
+ begin
3
+ require 'bones'
4
+ rescue LoadError
5
+ abort '### Please install the "bones" gem ###'
6
+ end
7
+
8
+ ensure_in_path 'lib'
9
+ require 'org-ruby'
10
+
11
+ task :default => 'test:run'
12
+ task 'gem:release' => 'test:run'
13
+
14
+ Bones {
15
+ name 'org-ruby'
16
+ authors 'Brian Dewey'
17
+ email 'bdewey@gmail.com'
18
+ url 'http://bdewey.com'
19
+ version OrgRuby::VERSION
20
+ }
21
+
22
+ # EOF
data/TAGS ADDED
@@ -0,0 +1,128 @@
1
+
2
+ ./spec/parser_spec.rb,0
3
+
4
+ ./spec/headline_spec.rb,0
5
+
6
+ ./spec/line_spec.rb,0
7
+
8
+ ./spec/spec_helper.rb,0
9
+
10
+ ./spec/regexp_helper_spec.rb,0
11
+
12
+ ./spec/textile_output_buffer_spec.rb,0
13
+
14
+ ./lib/org-ruby.rb,242
15
+ module OrgRuby::OrgRuby2,1
16
+ def self.version::OrgRuby.version12,251
17
+ def self.libpath::OrgRuby.libpath20,450
18
+ def self.path::OrgRuby.path28,695
19
+ def self.require_all_libs_relative_to::OrgRuby.require_all_libs_relative_to37,1082
20
+
21
+ ./lib/org-ruby/html_output_buffer.rb,349
22
+ module Orgmode::Orgmode3,54
23
+ class HtmlOutputBuffer::Orgmode::HtmlOutputBuffer5,72
24
+ def push_mode::Orgmode::HtmlOutputBuffer#push_mode22,417
25
+ def pop_mode::Orgmode::HtmlOutputBuffer#pop_mode27,525
26
+ def flush!::Orgmode::HtmlOutputBuffer#flush!32,647
27
+ def inline_formatting::Orgmode::HtmlOutputBuffer#inline_formatting62,1689
28
+
29
+ ./lib/org-ruby/output_buffer.rb,1195
30
+ module Orgmode::Orgmode3,18
31
+ class OutputBuffer::Orgmode::OutputBuffer9,297
32
+ attr_reader :buffer::Orgmode::OutputBuffer#buffer12,381
33
+ attr_reader :output::Orgmode::OutputBuffer#output15,446
34
+ attr_accessor :output_type::Orgmode::OutputBuffer#output_type18,532
35
+ def initialize::Orgmode::OutputBuffer#Orgmode::OutputBuffer.new22,686
36
+ def current_mode::Orgmode::OutputBuffer#current_mode40,1138
37
+ def current_mode_list?::Orgmode::OutputBuffer#current_mode_list?44,1197
38
+ def push_mode::Orgmode::OutputBuffer#push_mode48,1286
39
+ def pop_mode::Orgmode::OutputBuffer#pop_mode53,1421
40
+ def prepare::Orgmode::OutputBuffer#prepare61,1729
41
+ def enter_table?::Orgmode::OutputBuffer#enter_table?73,2129
42
+ def exit_table?::Orgmode::OutputBuffer#exit_table?79,2314
43
+ def <<::Orgmode::OutputBuffer#<<85,2480
44
+ def list_indent_level::Orgmode::OutputBuffer#list_indent_level90,2585
45
+ def preserve_whitespace?::Orgmode::OutputBuffer#preserve_whitespace?95,2729
46
+ def maintain_list_indent_stack::Orgmode::OutputBuffer#maintain_list_indent_stack102,2866
47
+ def should_accumulate_output?::Orgmode::OutputBuffer#should_accumulate_output?127,3724
48
+
49
+ ./lib/org-ruby/headline.rb,619
50
+ module Orgmode::Orgmode3,45
51
+ class Headline::Orgmode::Headline6,109
52
+ attr_reader :level::Orgmode::Headline#level9,178
53
+ attr_reader :headline_text::Orgmode::Headline#headline_text13,325
54
+ attr_reader :body_lines::Orgmode::Headline#body_lines16,418
55
+ attr_reader :tags::Orgmode::Headline#tags19,481
56
+ attr_reader :keyword::Orgmode::Headline#keyword22,567
57
+ def initialize::Orgmode::Headline#Orgmode::Headline.new35,896
58
+ def self.headline?::Orgmode::Headline.headline?58,1687
59
+ def to_textile::Orgmode::Headline#to_textile63,1818
60
+ def to_html::Orgmode::Headline#to_html69,1950
61
+
62
+ ./lib/org-ruby/regexp_helper.rb,1014
63
+ module Orgmode::Orgmode3,18
64
+ class RegexpHelper::Orgmode::RegexpHelper17,456
65
+ attr_reader :pre_emphasis::Orgmode::RegexpHelper#pre_emphasis42,1785
66
+ attr_reader :post_emphasis::Orgmode::RegexpHelper#post_emphasis43,1817
67
+ attr_reader :border_forbidden::Orgmode::RegexpHelper#border_forbidden44,1850
68
+ attr_reader :body_regexp::Orgmode::RegexpHelper#body_regexp45,1886
69
+ attr_reader :markers::Orgmode::RegexpHelper#markers46,1917
70
+ attr_reader :org_emphasis_regexp::Orgmode::RegexpHelper#org_emphasis_regexp48,1945
71
+ def initialize::Orgmode::RegexpHelper#Orgmode::RegexpHelper.new50,1999
72
+ def match_all::Orgmode::RegexpHelper#match_all65,2476
73
+ def rewrite_emphasis::Orgmode::RegexpHelper#rewrite_emphasis92,3413
74
+ def rewrite_links::Orgmode::RegexpHelper#rewrite_links124,4523
75
+ def build_org_emphasis_regexp::Orgmode::RegexpHelper#build_org_emphasis_regexp135,4759
76
+ def build_org_link_regexp::Orgmode::RegexpHelper#build_org_link_regexp145,5326
77
+
78
+ ./lib/org-ruby/textile_output_buffer.rb,454
79
+ module Orgmode::Orgmode3,20
80
+ class TextileOutputBuffer::Orgmode::TextileOutputBuffer5,38
81
+ def initialize::Orgmode::TextileOutputBuffer#Orgmode::TextileOutputBuffer.new7,84
82
+ def push_mode::Orgmode::TextileOutputBuffer#push_mode12,169
83
+ def pop_mode::Orgmode::TextileOutputBuffer#pop_mode17,262
84
+ def inline_formatting::Orgmode::TextileOutputBuffer#inline_formatting34,585
85
+ def flush!::Orgmode::TextileOutputBuffer#flush!48,973
86
+
87
+ ./lib/org-ruby/parser.rb,471
88
+ module Orgmode::Orgmode5,61
89
+ class Parser::Orgmode::Parser7,79
90
+ attr_reader :lines::Orgmode::Parser#lines10,140
91
+ attr_reader :headlines::Orgmode::Parser#headlines13,207
92
+ attr_reader :header_lines::Orgmode::Parser#header_lines16,287
93
+ def initialize::Orgmode::Parser#Orgmode::Parser.new20,459
94
+ def self.load::Orgmode::Parser.load48,1267
95
+ def to_textile::Orgmode::Parser#to_textile54,1433
96
+ def to_html::Orgmode::Parser#to_html63,1620
97
+
98
+ ./lib/org-ruby/line.rb,1430
99
+ module Orgmode::Orgmode1,0
100
+ class Line::Orgmode::Line4,67
101
+ attr_reader :line::Orgmode::Line#line7,114
102
+ attr_reader :indent::Orgmode::Line#indent12,300
103
+ def initialize::Orgmode::Line#Orgmode::Line.new14,325
104
+ def to_s::Orgmode::Line#to_s21,465
105
+ def comment?::Orgmode::Line#comment?26,546
106
+ def metadata?::Orgmode::Line#metadata?31,663
107
+ def nonprinting?::Orgmode::Line#nonprinting?35,755
108
+ def blank?::Orgmode::Line#blank?39,807
109
+ def plain_list?::Orgmode::Line#plain_list?43,859
110
+ def unordered_list?::Orgmode::Line#unordered_list?49,974
111
+ def strip_unordered_list_tag::Orgmode::Line#strip_unordered_list_tag53,1051
112
+ def ordered_list?::Orgmode::Line#ordered_list?59,1168
113
+ def strip_ordered_list_tag::Orgmode::Line#strip_ordered_list_tag63,1241
114
+ def plain_text?::Orgmode::Line#plain_text?67,1309
115
+ def table_row?::Orgmode::Line#table_row?71,1392
116
+ def table_separator?::Orgmode::Line#table_separator?77,1539
117
+ def table?::Orgmode::Line#table?85,1775
118
+ def begin_block?::Orgmode::Line#begin_block?91,1888
119
+ def end_block?::Orgmode::Line#end_block?95,1960
120
+ def block_type::Orgmode::Line#block_type99,2030
121
+ def paragraph_type::Orgmode::Line#paragraph_type104,2152
122
+ def self.to_textile::Orgmode::Line.to_textile115,2470
123
+ def self.to_html::Orgmode::Line.to_html121,2620
124
+ def self.translate::Orgmode::Line.translate128,2816
125
+
126
+ ./bin/org-ruby,0
127
+
128
+ ./test/test_orgmode_parser.rb,0
data/bin/org-ruby ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(
4
+ File.join(File.dirname(__FILE__), %w[.. lib org-ruby]))
5
+ require 'optparse'
6
+
7
+ # Put your code here
8
+
9
+ options = {}
10
+ options_parser = OptionParser.new do |opts|
11
+ options[:help] = false
12
+ options[:format] = :html
13
+
14
+ opts.banner = "Usage: org-ruby <file> [options]"
15
+
16
+ opts.on("-h", "--help", "Show this message") do |v|
17
+ options[:help] = true
18
+ end
19
+
20
+ opts.on("-t", "--translate FORMAT", [:html, :textile],
21
+ "Translate the ORG file to the specified format.") do |v|
22
+ options[:format] = v
23
+ end
24
+ end
25
+
26
+ begin
27
+ options_parser.parse!
28
+ if (ARGV.length == 0) then
29
+ puts options_parser
30
+ else
31
+ data = IO.read(ARGV[0])
32
+ p = Orgmode::Parser.new(data)
33
+ puts p.to_html if options[:format] == :html
34
+ puts p.to_textile if options[:format] == :textile
35
+ end
36
+ rescue OptionParser::ParseError
37
+ puts options_parser
38
+ end
39
+
40
+
data/lib/org-ruby.rb ADDED
@@ -0,0 +1,48 @@
1
+
2
+ module OrgRuby
3
+
4
+ # :stopdoc:
5
+ VERSION = '0.2.0'
6
+ LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
7
+ PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
8
+ # :startdoc:
9
+
10
+ # Returns the version string for the library.
11
+ #
12
+ def self.version
13
+ VERSION
14
+ end
15
+
16
+ # Returns the library path for the module. If any arguments are given,
17
+ # they will be joined to the end of the libray path using
18
+ # <tt>File.join</tt>.
19
+ #
20
+ def self.libpath( *args )
21
+ args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
22
+ end
23
+
24
+ # Returns the lpath for the module. If any arguments are given,
25
+ # they will be joined to the end of the path using
26
+ # <tt>File.join</tt>.
27
+ #
28
+ def self.path( *args )
29
+ args.empty? ? PATH : ::File.join(PATH, args.flatten)
30
+ end
31
+
32
+ # Utility method used to require all files ending in .rb that lie in the
33
+ # directory below this file that has the same name as the filename passed
34
+ # in. Optionally, a specific _directory_ name can be passed in such that
35
+ # the _filename_ does not have to be equivalent to the directory.
36
+ #
37
+ def self.require_all_libs_relative_to( fname, dir = nil )
38
+ dir ||= ::File.basename(fname, '.*')
39
+ search_me = ::File.expand_path(
40
+ ::File.join(::File.dirname(fname), dir, '**', '*.rb'))
41
+
42
+ Dir.glob(search_me).sort.each {|rb| require rb}
43
+ end
44
+
45
+ end # module OrgmodeParser
46
+
47
+ OrgRuby.require_all_libs_relative_to(__FILE__)
48
+
@@ -0,0 +1,75 @@
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
+ # This is the regex that matches a line
25
+ LineRegexp = /^\*+\s+/
26
+
27
+ # This matches the tags on a headline
28
+ TagsRegexp = /\s*:[\w:]*:\s*$/
29
+
30
+ # Special keywords allowed at the start of a line.
31
+ Keywords = %w[TODO DONE]
32
+
33
+ KeywordsRegexp = Regexp.new("\\s*(#{Keywords.join('|')})\\s*")
34
+
35
+ def initialize(line)
36
+ super(line)
37
+ @body_lines = []
38
+ @tags = []
39
+ if (@line =~ LineRegexp) then
40
+ @level = $&.strip.length
41
+ @headline_text = $'.strip
42
+ if (@headline_text =~ TagsRegexp) then
43
+ @tags = $&.split(/:/) # split tag text on semicolon
44
+ @tags.delete_at(0) # the first item will be empty; discard
45
+ @headline_text.gsub!(TagsRegexp, "") # Removes the tags from the headline
46
+ end
47
+ if (@headline_text =~ KeywordsRegexp) then
48
+ @headline_text = $'
49
+ @keyword = $1
50
+ end
51
+ else
52
+ raise "'#{line}' is not a valid headline"
53
+ end
54
+ end
55
+
56
+ # Determines if a line is an orgmode "headline":
57
+ # A headline begins with one or more asterisks.
58
+ def self.headline?(line)
59
+ line =~ LineRegexp
60
+ end
61
+
62
+ # Converts this headline and its body to textile.
63
+ def to_textile
64
+ output = "h#{@level}. #{@headline_text}\n"
65
+ output << Line.to_textile(@body_lines)
66
+ output
67
+ end
68
+
69
+ def to_html
70
+ output = "<h#{@level}>#{@headline_text}</h#{@level}>\n"
71
+ output << Line.to_html(@body_lines)
72
+ output
73
+ end
74
+ end # class Headline
75
+ end # class Orgmode
@@ -0,0 +1,80 @@
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
+ }
13
+
14
+ ModeTag = {
15
+ :unordered_list => "ul",
16
+ :ordered_list => "ol",
17
+ :table => "table",
18
+ :blockquote => "blockquote",
19
+ :code => "pre"
20
+ }
21
+
22
+ def push_mode(mode)
23
+ super(mode)
24
+ @output << "<#{ModeTag[mode]}>\n" if ModeTag[mode]
25
+ end
26
+
27
+ def pop_mode(mode = nil)
28
+ m = super(mode)
29
+ @output << "</#{ModeTag[m]}>\n" if ModeTag[m]
30
+ end
31
+
32
+ def flush!
33
+ @logger.debug "FLUSH ==========> #{@output_type}"
34
+ if current_mode == :code then
35
+ # Whitespace is significant in :code mode. Always output the buffer
36
+ # and do not do any additional translation.
37
+ @output << @buffer << "\n"
38
+ else
39
+ if (@buffer.length > 0) then
40
+ @output << "<#{HtmlBlockTag[@output_type]}>" \
41
+ << inline_formatting(@buffer) \
42
+ << "</#{HtmlBlockTag[@output_type]}>\n"
43
+ end
44
+ end
45
+ @buffer = ""
46
+ end
47
+
48
+ ######################################################################
49
+ private
50
+
51
+ Tags = {
52
+ "*" => { :open => "<b>", :close => "</b>" },
53
+ "/" => { :open => "<i>", :close => "</i>" },
54
+ "_" => { :open => "<span style=\"text-decoration:underline;\">",
55
+ :close => "</span>" },
56
+ "=" => { :open => "<code>", :close => "</code>" },
57
+ "~" => { :open => "<code>", :close => "</code>" },
58
+ "+" => { :open => "<del>", :close => "</del>" }
59
+ }
60
+
61
+ # Applies inline formatting rules to a string.
62
+ def inline_formatting(str)
63
+ str.rstrip!
64
+ if (@output_type == :table_row) then
65
+ str.gsub!(/^\|\s*/, "<td>")
66
+ str.gsub!(/\s*\|$/, "</td>")
67
+ str.gsub!(/\s*\|\s*/, "</td><td>")
68
+ end
69
+ str = @re_help.rewrite_emphasis(str) do |marker, s|
70
+ "#{Tags[marker][:open]}#{s}#{Tags[marker][:close]}"
71
+ end
72
+ str = @re_help.rewrite_links(str) do |link, text|
73
+ text ||= link
74
+ "<a href=\"#{link}\">#{text}</a>"
75
+ end
76
+ str
77
+ end
78
+
79
+ end # class HtmlOutputBuffer
80
+ end # module Orgmode