Class: RD::RD2tDiaryVisitor
- Inherits:
-
RD2HTMLVisitor
- Object
- RD2HTMLVisitor
- RD::RD2tDiaryVisitor
- Defined in:
- lib/tdiary/style/rd.rb
Direct Known Subclasses
Instance Method Summary collapse
- #apply_to_DescListItem(element, term, description) ⇒ Object
- #apply_to_DocumentElement(element, content) ⇒ Object
- #apply_to_Footnote(element, content) ⇒ Object
- #apply_to_Headline(element, title) ⇒ Object
-
#apply_to_Index(element, content) ⇒ Object
use for native html.
-
#apply_to_Keyboard(element, content) ⇒ Object
use for tDiary plugin :-p.
- #apply_to_MethodList(element, items) ⇒ Object
- #apply_to_MethodListItem(element, term, description) ⇒ Object
- #apply_to_RefToElement(element, content) ⇒ Object
-
#initialize(date = nil, idx = nil, opt = nil, author = nil) ⇒ RD2tDiaryVisitor
constructor
A new instance of RD2tDiaryVisitor.
Constructor Details
#initialize(date = nil, idx = nil, opt = nil, author = nil) ⇒ RD2tDiaryVisitor
Returns a new instance of RD2tDiaryVisitor.
26 27 28 29 30 31 32 |
# File 'lib/tdiary/style/rd.rb', line 26 def initialize( date=nil, idx=nil, opt=nil, =nil ) @td_date = date @td_idx = idx @td_opt = opt @td_author = super() end |
Instance Method Details
#apply_to_DescListItem(element, term, description) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/tdiary/style/rd.rb', line 56 def apply_to_DescListItem(element, term, description) %Q[<dt>#{term.join}</dt>] + if description.empty? then "\n" else %Q[\n<dd>\n#{description.join("\n").chomp}\n</dd>] end end |
#apply_to_DocumentElement(element, content) ⇒ Object
34 35 36 37 38 |
# File 'lib/tdiary/style/rd.rb', line 34 def apply_to_DocumentElement(element, content) ret = "" ret << html_body(content) + "\n" ret end |
#apply_to_Footnote(element, content) ⇒ Object
101 102 103 104 |
# File 'lib/tdiary/style/rd.rb', line 101 def apply_to_Footnote(element, content) escaped_content = content.join.gsub( /%>/, "%%>" ) %Q|<%=fn apply_plugin( #{escaped_content.dump} ) %>| end |
#apply_to_Headline(element, title) ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/tdiary/style/rd.rb', line 45 def apply_to_Headline(element, title) level = element.level + TDIARY_BASE_LEVEL title = title.join if level == 3 r = %Q[<h#{level}><%= subtitle_proc( Time::at( #{@td_date.to_i} ), #{title.to_s.dump.gsub( /%/, '\\\\045' )} ) %></h#{level}>] else r = %Q[<h#{level}>#{title}</h#{level}>] end r end |
#apply_to_Index(element, content) ⇒ Object
use for native html
97 98 99 |
# File 'lib/tdiary/style/rd.rb', line 97 def apply_to_Index(element, content) CGI.unescapeHTML(content.join) end |
#apply_to_Keyboard(element, content) ⇒ Object
use for tDiary plugin :-p
91 92 93 94 |
# File 'lib/tdiary/style/rd.rb', line 91 def apply_to_Keyboard(element, content) plugin, args = CGI.unescapeHTML(content.join("")).split(/\s+/, 2) %Q[<%=#{plugin} #{args}%>] end |
#apply_to_MethodList(element, items) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/tdiary/style/rd.rb', line 65 def apply_to_MethodList(element, items) if /^(<.+>)?$/ =~ element.items[0].term.to_label %Q[#{items.join("\n").chomp}\n] else %Q[<dl>\n#{items.join("\n").chomp}\n</dl>] end end |
#apply_to_MethodListItem(element, term, description) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/tdiary/style/rd.rb', line 73 def apply_to_MethodListItem(element, term, description) case term when /^<([^\s]+)\s*.*>/ closetag = "</#{CGI.unescapeHTML($1)}>" r = CGI.unescapeHTML(term) if description.size > 0 r << %Q[\n#{description.join("\n")}\n] r << closetag end r when '' "<hr>" else super end end |
#apply_to_RefToElement(element, content) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/tdiary/style/rd.rb', line 106 def apply_to_RefToElement(element, content) label = element.to_label key, opt = label.split(/:/, 2) case key when "IMG" ref_ext_IMG(label, content.join, opt) when "RAA" ref_ext_RAA(label, content.join, opt) when /^ruby-(talk|list|dev|math|ext|core)$/ ref_ext_RubyML(label, content.join, key, opt) when /^(\d{4}|\d{6}|\d{8}|\d{8}-\d+)[^\d]*?#?([pct]\d+)?$/ %Q[<%=my "#{key}","#{content.join}"%>] else opt = "" unless opt # case of no ":" %Q[<%=a "#{key}","#{opt}","#{content.join}"%>] end end |