Module | Generators::MarkUp |
In: |
generators/html_generator.rb
|
Build a webcvs URL with the given ‘url’ argument. URLs with a ’%s’ in them get the file‘s path sprintfed into them; otherwise they‘re just catenated together.
# File generators/html_generator.rb, line 304 304: def cvs_url(url, full_path) 305: if /%s/ =~ url 306: return sprintf( url, full_path ) 307: else 308: return url + full_path 309: end 310: end
Convert a string in markup format into HTML. We keep a cached SimpleMarkup object lying around after the first time we‘re called per object.
# File generators/html_generator.rb, line 234 234: def markup(str, remove_para=false) 235: return '' unless str 236: unless defined? @markup 237: @markup = SM::SimpleMarkup.new 238: 239: # class names, variable names, or instance variables 240: @markup.add_special(/( 241: \w+(::\w+)*[.\#]\w+(\([\.\w+\*\/\+\-\=\<\>]+\))? # A::B.meth(**) (for operator in Fortran95) 242: | \#\w+(\([.\w\*\/\+\-\=\<\>]+\))? # meth(**) (for operator in Fortran95) 243: | \b([A-Z]\w*(::\w+)*[.\#]\w+) # A::B.meth 244: | \b([A-Z]\w+(::\w+)*) # A::B.. 245: | \#\w+[!?=]? # #meth_name 246: | \b\w+([_\/\.]+\w+)*[!?=]? # meth_name 247: )/x, 248: :CROSSREF) 249: 250: # file names 251: @markup.add_special(/( 252: [\w\/][\w\#\/\.\-\~\:]*[!?=]? # file_name 253: | [\w\/][\w\#\/\.\-\~\:]*(\([\.\w+\*\/\+\-\=\<\>]+\))? 254: )/x, 255: :CROSSREFFILE) 256: 257: # external hyperlinks 258: @markup.add_special(/((link:|https?:|mailto:|ftp:|www\.)\S+\w)/, :HYPERLINK) 259: 260: # and links of the form <text>[<url>] 261: @markup.add_special(/(((\{.*?\})|\b\S+?)\[\S+?\.\S+?\])/, :TIDYLINK) 262: # @markup.add_special(/\b(\S+?\[\S+?\.\S+?\])/, :TIDYLINK) 263: 264: end 265: unless defined? @html_formatter 266: @html_formatter = HyperlinkHtml.new(self.path, self) 267: end 268: 269: # Convert leading comment markers to spaces, but only 270: # if all non-blank lines have them 271: 272: if str =~ /^(?>\s*)[^\#]/ 273: content = str 274: else 275: content = str.gsub(/^\s*(#+)/) { $1.tr('#',' ') } 276: end 277: 278: res = @markup.convert(content, @html_formatter) 279: if remove_para 280: res.sub!(/^<p>/, '') 281: res.sub!(/<\/p>$/, '') 282: end 283: res 284: end
Qualify a stylesheet URL; if if css_name does not begin with ‘/’ or ‘http[s]://’, prepend a prefix relative to path. Otherwise, return it unmodified.
# File generators/html_generator.rb, line 290 290: def style_url(path, css_name=nil) 291: # $stderr.puts "style_url( #{path.inspect}, #{css_name.inspect} )" 292: css_name ||= CSS_NAME 293: if %r{^(https?:/)?/} =~ css_name 294: return css_name 295: else 296: return HTMLGenerator.gen_url(path, css_name) 297: end 298: end