# File rdoc/markup/simple_markup/to_html.rb, line 105
def accept_blank_line(am, fragment)
# @res << annotate("<p />") << "\n"
end
# File rdoc/markup/simple_markup/to_html.rb, line 109
def accept_heading(am, fragment)
@res << convert_heading(fragment.head_level, am.flow(fragment.txt))
end
# File rdoc/markup/simple_markup/to_html.rb, line 89
def accept_list_end(am, fragment)
if tag = @in_list_entry.pop
@res << annotate(tag) << "\n"
end
@res << html_list_name(fragment.type, false) <<"\n"
end
# File rdoc/markup/simple_markup/to_html.rb, line 96
def accept_list_item(am, fragment)
if tag = @in_list_entry.last
@res << annotate(tag) << "\n"
end
@res << list_item_start(am, fragment)
@res << wrap(convert_flow(am.flow(fragment.txt))) << "\n"
@in_list_entry[-1] = list_end_for(fragment.type)
end
# File rdoc/markup/simple_markup/to_html.rb, line 84
def accept_list_start(am, fragment)
@res << html_list_name(fragment.type, true) <<"\n"
@in_list_entry.push false
end
# File rdoc/markup/simple_markup/to_html.rb, line 66
def accept_paragraph(am, fragment)
@res << annotate("<p>") + "\n"
@res << wrap(convert_flow(am.flow(fragment.txt)))
@res << annotate("</p>") + "\n"
end
# File rdoc/markup/simple_markup/to_html.rb, line 78
def accept_rule(am, fragment)
size = fragment.param
size = 10 if size > 10
@res << "<hr size=\"#{size}\"></hr>"
end
# File rdoc/markup/simple_markup/to_html.rb, line 72
def accept_verbatim(am, fragment)
@res << annotate("<pre>") + "\n"
@res << CGI.escapeHTML(fragment.txt)
@res << annotate("</pre>") << "\n"
end
Add a new set of HTML tags for an attribute. We allow separate start and end tags for flexibility
# File rdoc/markup/simple_markup/to_html.rb, line 40
def add_tag(name, start, stop)
@attr_tags << InlineTag.new(SM::Attribute.bitmap_for(name), start, stop)
end
Given an HTML tag, decorate it with class information and the like if required. This is a no-op in the base class, but is overridden in HTML output classes that implement style sheets
# File rdoc/markup/simple_markup/to_html.rb, line 50
def annotate(tag)
tag
end
# File rdoc/markup/simple_markup/to_html.rb, line 62
def end_accepting
@res
end
Here’s the client side of the visitor pattern
# File rdoc/markup/simple_markup/to_html.rb, line 57
def start_accepting
@res = ""
@in_list_entry = []
end
This is a higher speed (if messier) version of wrap
# File rdoc/markup/simple_markup/to_html.rb, line 115
def wrap(txt, line_len = 76)
res = ""
sp = 0
ep = txt.length
while sp < ep
# scan back for a space
p = sp + line_len - 1
if p >= ep
p = ep
else
while p > sp and txt[p] != \s
p -= 1
end
if p <= sp
p = sp + line_len
while p < ep and txt[p] != \s
p += 1
end
end
end
res << txt[sp...p] << "\n"
sp = p
sp += 1 while sp < ep and txt[sp] == \s
end
res
end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.