Sha256: 62e68f0deb1bbb0145851741f2f7990195d8a2bd0bd4617a143ce8c8c58d754e
Contents?: true
Size: 1.8 KB
Versions: 18
Compression:
Stored size: 1.8 KB
Contents
# # bitclust/htmlutils.rb # # Copyright (C) 2006-2008 Minero Aoki # # This program is free software. # You can distribute/modify this program under the Ruby License. # require 'bitclust/nameutils' module BitClust # Utility functions for HTML tag generation module HTMLUtils include NameUtils private # make method anchor from MethodEntry def link_to_method(m, specp = false) label = specp ? m.label : m.short_label a_href(@urlmapper.method_url(methodid2specstring(m.id)), label) end def library_link(name, label = nil, frag = nil) a_href(@urlmapper.library_url(name) + fragment(frag), label || name) end def class_link(name, label = nil, frag = nil) a_href(@urlmapper.class_url(name) + fragment(frag), label || name) end def method_link(spec, label = nil, frag = nil) a_href(method_url(spec, frag), label || spec) end def method_url(spec, frag = nil) @urlmapper.method_url(spec) + fragment(frag) end def function_link(name, label = nil, frag = nil) a_href(@urlmapper.function_url(name) + fragment(frag), label || name) end def document_link(name, label = nil, frag = nil) a_href(@urlmapper.document_url(name) + fragment(frag), label || @option[:database].get_doc(name).title) end def fragment(str) str ? '#' + str : '' end def a_href(url, label) %Q(<a href="#{escape_html(url)}">#{escape_html(label)}</a>) end ESC = { '&' => '&', '"' => '"', '<' => '<', '>' => '>' } def escape_html(str) table = ESC # optimize str.gsub(/[&"<>]/) {|s| table[s] } end ESCrev = ESC.invert def unescape_html(str) table = ESCrev # optimize str.gsub(/&\w+;/) {|s| table[s] } end end end
Version data entries
18 entries across 18 versions & 1 rubygems