Module: RDocF95::Generator::MarkUp

Included in:
Context, HTML, Method
Defined in:
lib/rdoc-f95/generator.rb

Overview

Handle common markup tasks for the various Context subclasses

Instance Method Summary collapse

Instance Method Details

#cvs_url(url, full_path) ⇒ Object

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.

[View source]

137
138
139
140
141
142
143
# File 'lib/rdoc-f95/generator.rb', line 137

def cvs_url(url, full_path)
  if /%s/ =~ url
    return sprintf( url, full_path )
  else
    return url + full_path
  end
end

#markup(str, remove_para = false) ⇒ Object

Convert a string in markup format into HTML.

[View source]

81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/rdoc-f95/generator.rb', line 81

def markup(str, remove_para = false)
  return '' unless str

  unless defined? @formatter then
    unless @options.mathml
      @formatter = RDocF95::Markup::ToHtmlCrossref.new(path, self,
                                                    @options.show_hash)
    else
      @formatter = RDocF95::Markup::ToXHtmlTexParser.new(path, self,
                                                      @options.show_hash, 
                                                      @options.mathml)
    end
  end

  # Convert leading comment markers to spaces, but only if all non-blank
  # lines have them
  if str =~ /^(?>\s*)[^\#]/ then
    content = str
  else
    content = str.gsub(/^\s*(#+)/) { $1.tr '#', ' ' }
  end

  unless @options.mathml
    res = @formatter.convert content
  else
    res = @formatter.convert content, @formatter.block_exceptions
  end

  if remove_para then
    res.sub!(/^<p>/, '')
    res.sub!(/<\/p>$/, '')
  end

  res
end

#style_url(path, css_name = nil) ⇒ Object

Qualify a stylesheet URL; if if css_name does not begin with ‘/’ or ‘http://’, prepend a prefix relative to path. Otherwise, return it unmodified.

[View source]

122
123
124
125
126
127
128
129
130
# File 'lib/rdoc-f95/generator.rb', line 122

def style_url(path, css_name=nil)
#      $stderr.puts "style_url( #{path.inspect}, #{css_name.inspect} )"
  css_name ||= CSS_NAME
  if %r{^(https?:/)?/} =~ css_name
    css_name
  else
    RDocF95::Generator.gen_url path, css_name
  end
end