Module Generators::MarkUp
In: lib/rdoc/generators/html_generator.rb

Handle common markup tasks for the various Html classes

Methods

cvs_url   markup   style_url  

Public Instance methods

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.

[Source]

     # File lib/rdoc/generators/html_generator.rb, line 272
272:     def cvs_url(url, full_path)
273:       if /%s/ =~ url
274:         return sprintf( url, full_path )
275:       else
276:         return url + full_path
277:       end
278:     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.

[Source]

     # File lib/rdoc/generators/html_generator.rb, line 209
209:     def markup(str, remove_para=false)
210:       return '' unless str
211:       unless defined? @markup
212:         @markup = SM::SimpleMarkup.new
213: 
214:         # class names, variable names, or instance variables
215:         @markup.add_special(/(
216:                                \w+(::\w+)*[.\#]\w+(\([\.\w+\*\/\+\-\=\<\>]+\))?  # A::B.meth(**) (for operator in Fortran95)
217:                              | \#\w+(\([.\w\*\/\+\-\=\<\>]+\))?  #  meth(**) (for operator in Fortran95)
218:                              | \b([A-Z]\w*(::\w+)*[.\#]\w+)  #    A::B.meth
219:                              | \b([A-Z]\w+(::\w+)*)       #    A::B..
220:                              | \#\w+[!?=]?                #    #meth_name 
221:                              | \b\w+([_\/\.]+\w+)*[!?=]?  #    meth_name
222:                              )/x, 
223:                             :CROSSREF)
224: 
225:         # external hyperlinks
226:         @markup.add_special(/((link:|https?:|mailto:|ftp:|www\.)\S+\w)/, :HYPERLINK)
227: 
228:         # and links of the form  <text>[<url>]
229:         @markup.add_special(/(((\{.*?\})|\b\S+?)\[\S+?\.\S+?\])/, :TIDYLINK)
230: #        @markup.add_special(/\b(\S+?\[\S+?\.\S+?\])/, :TIDYLINK)
231: 
232:       end
233:       unless defined? @html_formatter
234:         @html_formatter = HyperlinkHtml.new(self.path, self)
235:       end
236: 
237:       # Convert leading comment markers to spaces, but only
238:       # if all non-blank lines have them
239: 
240:       if str =~ /^(?>\s*)[^\#]/
241:         content = str
242:       else
243:         content = str.gsub(/^\s*(#+)/)  { $1.tr('#',' ') }
244:       end
245: 
246:       res = @markup.convert(content, @html_formatter)
247:       if remove_para
248:         res.sub!(/^<p>/, '')
249:         res.sub!(/<\/p>$/, '')
250:       end
251:       res
252:     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.

[Source]

     # File lib/rdoc/generators/html_generator.rb, line 258
258:     def style_url(path, css_name=nil)
259: #      $stderr.puts "style_url( #{path.inspect}, #{css_name.inspect} )"
260:       css_name ||= CSS_NAME
261:       if %r{^(https?:/)?/} =~ css_name
262:         return css_name
263:       else
264:         return HTMLGenerator.gen_url(path, css_name)
265:       end
266:     end

[Validate]