Class: RD::RD2HTML5Visitor
- Inherits:
-
RD2HTMLVisitor
- Object
- Visitor
- OutputFormatVisitor
- RDVisitor
- RD2HTMLVisitor
- RD::RD2HTML5Visitor
- Defined in:
- lib/rd/rd2html5-lib.rb
Constant Summary collapse
- SYSTEM_NAME =
"RDtool -- RD2HTML5Visitor"- SYSTEM_VERSION =
"$Version: " + RD::VERSION + "$"
- VERSION =
Version.new_from_version_string(SYSTEM_NAME, SYSTEM_VERSION)
Constants inherited from RD2HTMLVisitor
RD::RD2HTMLVisitor::INCLUDE_SUFFIX, RD::RD2HTMLVisitor::METACHAR, RD::RD2HTMLVisitor::OUTPUT_SUFFIX
Constants included from MethodParse
Constants inherited from OutputFormatVisitor
OutputFormatVisitor::INCLUDE_SUFFIX, OutputFormatVisitor::OUTPUT_SUFFIX
Instance Attribute Summary
Attributes inherited from RD2HTMLVisitor
#charset, #css, #footnotes, #foottexts, #html_link_rel, #html_link_rev, #lang, #output_rbl, #title, #use_old_anchor
Attributes inherited from OutputFormatVisitor
#filename, #include_suffix, #input_filename
Class Method Summary collapse
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_Foottext(element, content) ⇒ Object
- #apply_to_Headline(element, title) ⇒ Object
- #apply_to_Index(element, content) ⇒ Object
- #apply_to_MethodListItem(element, term, description) ⇒ Object
Methods inherited from RD2HTMLVisitor
#add_foottext, #apply_to_Code, #apply_to_DescList, #apply_to_Emphasis, #apply_to_EnumList, #apply_to_EnumListItem, #apply_to_ItemList, #apply_to_ItemListItem, #apply_to_Keyboard, #apply_to_MethodList, #apply_to_RefToElement, #apply_to_RefToOtherFile, #apply_to_Reference_with_RDLabel, #apply_to_Reference_with_URL, #apply_to_String, #apply_to_StringElement, #apply_to_TextBlock, #apply_to_Var, #apply_to_Verb, #apply_to_Verbatim, #consist_of_one_textblock_and_sublists, #get_footnote_num, #hyphen_escape, #initialize, #is_this_textblock_only_one_block_of_parent_listitem?, #is_this_textblock_only_one_block_other_than_sublists_in_parent_listitem?, #visit
Methods included from MethodParse
analize_method, kind2num, kind2str, make_method_index, make_mindex_label, str2kind, tr_method
Methods inherited from RDVisitor
#apply_to_DescListItemTerm, #apply_to_MethodListItemTerm, #prepare_labels, #refer_external
Methods inherited from OutputFormatVisitor
#apply_to_Include, #initialize
Methods included from SearchFile
Methods inherited from Visitor
define_visit_Nonterminal, define_visit_Terminal, #visit, #visit_DescListItem, #visit_MethodListItem, #visit_Reference, #visit_children
Constructor Details
This class inherits a constructor from RD::RD2HTMLVisitor
Class Method Details
.version ⇒ Object
13 14 15 |
# File 'lib/rd/rd2html5-lib.rb', line 13 def self.version VERSION end |
Instance Method Details
#apply_to_DescListItem(element, term, description) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rd/rd2html5-lib.rb', line 56 def apply_to_DescListItem(element, term, description) anchor = get_anchor(element.term) label = hyphen_escape(element.label) term = term.join("") if description.empty? %Q[<dt id="#{anchor}">#{term}</dt><!-- RDLabel: "#{label}" -->] else %Q[<dt id="#{anchor}">#{term}</dt><!-- RDLabel: "#{label}" -->\n] + %Q[<dd>\n#{description.join("\n").chomp}\n</dd>] end end |
#apply_to_DocumentElement(element, content) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/rd/rd2html5-lib.rb', line 22 def apply_to_DocumentElement(element, content) ret = "" ret << doctype_decl + "\n" ret << html_open_tag + "\n" ret << html_head + "\n" ret << html_body(content) + "\n" ret << "</html>\n" ret end |
#apply_to_Footnote(element, content) ⇒ Object
95 96 97 98 99 100 101 102 103 |
# File 'lib/rd/rd2html5-lib.rb', line 95 def apply_to_Footnote(element, content) num = get_footnote_num(element) raise ArgumentError, "[BUG?] #{element} is not registered." unless num add_foottext(num, content) anchor = a_name("footmark", num) href = a_name("foottext", num) %Q|<a id="#{anchor}" href="##{href}"><sup><small>*#{num}</small></sup></a>| end |
#apply_to_Foottext(element, content) ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'lib/rd/rd2html5-lib.rb', line 105 def apply_to_Foottext(element, content) num = get_footnote_num(element) raise ArgumentError, "[BUG] #{element} isn't registered." unless num anchor = a_name("foottext", num) href = a_name("footmark", num) content = content.join("") %|<a id="#{anchor}" href="##{href}"><sup><small>*#{num}</small></sup></a>| + %|<small>#{content}</small><br>| end |
#apply_to_Headline(element, title) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/rd/rd2html5-lib.rb', line 48 def apply_to_Headline(element, title) anchor = get_anchor(element) label = hyphen_escape(element.label) title = title.join("") %Q[<h#{element.level} id="#{anchor}">#{title}</h#{element.level}>] + %Q[<!-- RDLabel: "#{label}" -->] end |
#apply_to_Index(element, content) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/rd/rd2html5-lib.rb', line 80 def apply_to_Index(element, content) tmp = [] element.each do |i| tmp.push(i) if i.is_a?(String) end key = (tmp.join("")) if @index.has_key?(key) %Q[<!-- Index, but conflict -->#{content.join("")}<!-- Index end -->] else num = @index[key] = @index.size anchor = a_name("index", num) %Q[<span id="#{anchor}">#{content.join("")}</span>] end end |
#apply_to_MethodListItem(element, term, description) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/rd/rd2html5-lib.rb', line 68 def apply_to_MethodListItem(element, term, description) term = parse_method(term) anchor = get_anchor(element.term) label = hyphen_escape(element.label) if description.empty? %Q[<dt id="#{anchor}"><code>#{term}</code></dt><!-- RDLabel: "#{label}" -->] else %Q[<dt id="#{anchor}"><code>#{term}</code></dt><!-- RDLabel: "#{label}" -->\n] + %Q[<dd>\n#{description.join("\n")}</dd>] end end |