Module Generators::MarkUp
In: 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 rdoc/generators/html_generator.rb, line 265
265:     def cvs_url(url, full_path)
266:       if /%s/ =~ url
267:         return sprintf( url, full_path )
268:       else
269:         return url + full_path
270:       end
271:     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 rdoc/generators/html_generator.rb, line 204
204:     def markup(str, remove_para=false)
205:       return '' unless str
206:       unless defined? @markup
207:         @markup = SM::SimpleMarkup.new
208: 
209:         # class names, variable names, file names, or instance variables
210:         @markup.add_special(/(
211:                                \b([A-Z]\w*(::\w+)*[.\#]\w+)  #    A::B.meth
212:                              | \b([A-Z]\w+(::\w+)*)       #    A::B..
213:                              | \#\w+[!?=]?                #    #meth_name 
214:                              | \b\w+([_\/\.]+\w+)+[!?=]?  #    meth_name
215:                              )/x, 
216:                             :CROSSREF)
217: 
218:         # external hyperlinks
219:         @markup.add_special(/((link:|https?:|mailto:|ftp:|www\.)\S+\w)/, :HYPERLINK)
220: 
221:         # and links of the form  <text>[<url>]
222:         @markup.add_special(/(((\{.*?\})|\b\S+?)\[\S+?\.\S+?\])/, :TIDYLINK)
223: #        @markup.add_special(/\b(\S+?\[\S+?\.\S+?\])/, :TIDYLINK)
224: 
225:       end
226:       unless defined? @html_formatter
227:         @html_formatter = HyperlinkHtml.new(self.path, self)
228:       end
229: 
230:       # Convert leading comment markers to spaces, but only
231:       # if all non-blank lines have them
232: 
233:       if str =~ /^(?>\s*)[^\#]/
234:         content = str
235:       else
236:         content = str.gsub(/^\s*(#+)/)  { $1.tr('#',' ') }
237:       end
238: 
239:       res = @markup.convert(content, @html_formatter)
240:       if remove_para
241:         res.sub!(/^<p>/, '')
242:         res.sub!(/<\/p>$/, '')
243:       end
244:       res
245:     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 rdoc/generators/html_generator.rb, line 251
251:     def style_url(path, css_name=nil)
252: #      $stderr.puts "style_url( #{path.inspect}, #{css_name.inspect} )"
253:       css_name ||= CSS_NAME
254:       if %r{^(https?:/)?/} =~ css_name
255:         return css_name
256:       else
257:         return HTMLGenerator.gen_url(path, css_name)
258:       end
259:     end

Search

Google

Ruby API Docs

Links