Class: RDoc::Markup::ToTexInfo
- Defined in:
- lib/rdoc/markup/to_texinfo.rb
Overview
Convert SimpleMarkup to basic TexInfo format
TODO: WTF is AttributeManager for?
Instance Method Summary collapse
- #accept_blank_line(attributes, text) ⇒ Object
- #accept_heading(attributes, text) ⇒ Object
- #accept_list_end(attributes, text) ⇒ Object
- #accept_list_item(attributes, text) ⇒ Object
- #accept_list_start(attributes, text) ⇒ Object
- #accept_paragraph(attributes, text) ⇒ Object
- #accept_rule(attributes, text) ⇒ Object
- #accept_verbatim(attributes, text) ⇒ Object
- #end_accepting ⇒ Object
- #format(text) ⇒ Object
- #start_accepting ⇒ Object
Methods inherited from Formatter
Constructor Details
This class inherits a constructor from RDoc::Markup::Formatter
Instance Method Details
#accept_blank_line(attributes, text) ⇒ Object
48 49 50 |
# File 'lib/rdoc/markup/to_texinfo.rb', line 48 def accept_blank_line(attributes, text) @text << "\n" end |
#accept_heading(attributes, text) ⇒ Object
31 32 33 34 |
# File 'lib/rdoc/markup/to_texinfo.rb', line 31 def accept_heading(attributes, text) heading = ['@majorheading', '@chapheading'][text.head_level - 1] || '@heading' @text << "#{heading}{#{format(text)}}" end |
#accept_list_end(attributes, text) ⇒ Object
40 41 42 |
# File 'lib/rdoc/markup/to_texinfo.rb', line 40 def accept_list_end(attributes, text) @text << '@end itemize' end |
#accept_list_item(attributes, text) ⇒ Object
44 45 46 |
# File 'lib/rdoc/markup/to_texinfo.rb', line 44 def accept_list_item(attributes, text) @text << "@item\n#{format(text)}" end |
#accept_list_start(attributes, text) ⇒ Object
36 37 38 |
# File 'lib/rdoc/markup/to_texinfo.rb', line 36 def accept_list_start(attributes, text) @text << '@itemize @bullet' end |
#accept_paragraph(attributes, text) ⇒ Object
23 24 25 |
# File 'lib/rdoc/markup/to_texinfo.rb', line 23 def accept_paragraph(attributes, text) @text << format(text) end |
#accept_rule(attributes, text) ⇒ Object
52 53 54 |
# File 'lib/rdoc/markup/to_texinfo.rb', line 52 def accept_rule(attributes, text) @text << '-----' end |
#accept_verbatim(attributes, text) ⇒ Object
27 28 29 |
# File 'lib/rdoc/markup/to_texinfo.rb', line 27 def accept_verbatim(attributes, text) @text << "@verb{|#{format(text)}|}" end |
#end_accepting ⇒ Object
19 20 21 |
# File 'lib/rdoc/markup/to_texinfo.rb', line 19 def end_accepting @text.join("\n") end |
#format(text) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rdoc/markup/to_texinfo.rb', line 56 def format(text) text.txt. gsub(/@/, "@@"). gsub(/\{/, "@{"). gsub(/\}/, "@}"). # gsub(/,/, "@,"). # technically only required in cross-refs gsub(/\+([\w]+)\+/, "@code{\\1}"). gsub(/\<tt\>([^<]+)\<\/tt\>/, "@code{\\1}"). gsub(/\*([\w]+)\*/, "@strong{\\1}"). gsub(/\<b\>([^<]+)\<\/b\>/, "@strong{\\1}"). gsub(/_([\w]+)_/, "@emph{\\1}"). gsub(/\<em\>([^<]+)\<\/em\>/, "@emph{\\1}") end |
#start_accepting ⇒ Object
15 16 17 |
# File 'lib/rdoc/markup/to_texinfo.rb', line 15 def start_accepting @text = [] end |