| 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 303
303: def cvs_url(url, full_path)
304: if /%s/ =~ url
305: return sprintf( url, full_path )
306: else
307: return url + full_path
308: end
309: 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 233
233: def markup(str, remove_para=false)
234: return '' unless str
235: unless defined? @markup
236: @markup = SM::SimpleMarkup.new
237:
238: # class names, variable names, or instance variables
239: @markup.add_special(/(
240: \w+(::\w+)*[.\#]\w+(\([\.\w+\*\/\+\-\=\<\>]+\))? # A::B.meth(**) (for operator in Fortran95)
241: | \#\w+(\([.\w\*\/\+\-\=\<\>]+\))? # meth(**) (for operator in Fortran95)
242: | \b([A-Z]\w*(::\w+)*[.\#]\w+) # A::B.meth
243: | \b([A-Z]\w+(::\w+)*) # A::B..
244: | \#\w+[!?=]? # #meth_name
245: | \b\w+([_\/\.]+\w+)*[!?=]? # meth_name
246: )/x,
247: :CROSSREF)
248:
249: # file names
250: @markup.add_special(/(
251: [\w\/][\w\#\/\.\-\~\:]*[!?=]? # file_name
252: | [\w\/][\w\#\/\.\-\~\:]*(\([\.\w+\*\/\+\-\=\<\>]+\))?
253: )/x,
254: :CROSSREFFILE)
255:
256: # external hyperlinks
257: @markup.add_special(/((link:|https?:|mailto:|ftp:|www\.)\S+\w)/, :HYPERLINK)
258:
259: # and links of the form <text>[<url>]
260: @markup.add_special(/(((\{.*?\})|\b\S+?)\[\S+?\.\S+?\])/, :TIDYLINK)
261: # @markup.add_special(/\b(\S+?\[\S+?\.\S+?\])/, :TIDYLINK)
262:
263: end
264: unless defined? @html_formatter
265: @html_formatter = HyperlinkHtml.new(self.path, self)
266: end
267:
268: # Convert leading comment markers to spaces, but only
269: # if all non-blank lines have them
270:
271: if str =~ /^(?>\s*)[^\#]/
272: content = str
273: else
274: content = str.gsub(/^\s*(#+)/) { $1.tr('#',' ') }
275: end
276:
277: res = @markup.convert(content, @html_formatter)
278: if remove_para
279: res.sub!(/^<p>/, '')
280: res.sub!(/<\/p>$/, '')
281: end
282: res
283: 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 289
289: def style_url(path, css_name=nil)
290: # $stderr.puts "style_url( #{path.inspect}, #{css_name.inspect} )"
291: css_name ||= CSS_NAME
292: if %r{^(https?:/)?/} =~ css_name
293: return css_name
294: else
295: return HTMLGenerator.gen_url(path, css_name)
296: end
297: end