class RD::RD2tDiaryVisitor
Public Class Methods
new( date=nil, idx=nil, opt=nil, author=nil )
click to toggle source
Calls superclass method
# File lib/tdiary/style/rd.rb, line 9 def initialize( date=nil, idx=nil, opt=nil, author=nil ) @td_date = date @td_idx = idx @td_opt = opt @td_author = author super() end
Public Instance Methods
apply_to_DescListItem(element, term, description)
click to toggle source
# File lib/tdiary/style/rd.rb, line 39 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)
click to toggle source
# File lib/tdiary/style/rd.rb, line 17 def apply_to_DocumentElement(element, content) ret = "" ret << html_body(content) + "\n" ret end
apply_to_Footnote(element, content)
click to toggle source
# File lib/tdiary/style/rd.rb, line 84 def apply_to_Footnote(element, content) escaped_content = content.join.gsub( /%>/, "%%>" ) %Q|<%=fn apply_plugin( #{escaped_content.dump} ) %>| end
apply_to_Headline(element, title)
click to toggle source
# File lib/tdiary/style/rd.rb, line 28 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)
click to toggle source
use for native html
# File lib/tdiary/style/rd.rb, line 80 def apply_to_Index(element, content) CGI.unescapeHTML(content.join) end
apply_to_Keyboard(element, content)
click to toggle source
use for tDiary plugin :-p
# File lib/tdiary/style/rd.rb, line 74 def apply_to_Keyboard(element, content) plugin, args = CGI.unescapeHTML(content.join("")).split(/\s+/, 2) %Q[<%=#{plugin} #{args}%>] end
apply_to_MethodList(element, items)
click to toggle source
# File lib/tdiary/style/rd.rb, line 48 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)
click to toggle source
Calls superclass method
# File lib/tdiary/style/rd.rb, line 56 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)
click to toggle source
# File lib/tdiary/style/rd.rb, line 89 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
Private Instance Methods
categorized_subtitle( title )
click to toggle source
# File lib/tdiary/style/rd.rb, line 109 def categorized_subtitle( title ) cat = /^(\[(.*?)\])+/.match(title.to_s).to_a[0] subtitle = $' if cat r = cat.scan(/\[(.*?)\]/).collect do |c| %Q|<%= category_anchor("#{c[0]}") %>| end.join + subtitle else r = title.to_s end r end
html_body(contents)
click to toggle source
# File lib/tdiary/style/rd.rb, line 23 def html_body(contents) content = contents.join("\n") end
ref_ext_IMG(label, content, src)
click to toggle source
# File lib/tdiary/style/rd.rb, line 137 def ref_ext_IMG(label, content, src) label.to_s == content.to_s and content = src %Q[<img src="#{src}" alt="#{content}">] end
ref_ext_RAA(label, content, name)
click to toggle source
# File lib/tdiary/style/rd.rb, line 131 def ref_ext_RAA(label, content, name) name = CGI.escape(name) content = "[#{label}]" if label == content %Q[<a href="http://raa.ruby-lang.org/list.rhtml?name=#{ name }">#{ content }</a>] end
ref_ext_RubyML(label, content, ml, article)
click to toggle source
# File lib/tdiary/style/rd.rb, line 124 def ref_ext_RubyML(label, content, ml, article) article.sub!(/^0+/, '') content = "[#{label}]" if label == content %Q[<a href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/#{ ml }/#{ article }">#{ content }</a>] end