Class: YARD::Templates::Helpers::Markup::RDocMarkup
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Inherits: | Object |
Defined in: | lib/yard/templates/helpers/markup/rdoc_markup.rb |
Class Method Summary
- .new(text) ⇒ RDocMarkup constructor
Instance Attribute Summary
- #from_path rw
Instance Method Summary
- #to_html
-
#fix_dash_dash(text)
private
Don't allow -- to turn into — element.
-
#fix_typewriter(text)
private
Fixes RDoc behaviour with ++ only supporting alphanumeric text.
Constructor Details
.new(text) ⇒ RDocMarkup
# File 'lib/yard/templates/helpers/markup/rdoc_markup.rb', line 41
def initialize(text) @text = text @@mutex.synchronize do @@formatter ||= RDocMarkupToHtml.new @@markup ||= MARKUP.new end end
Instance Attribute Details
#from_path (rw)
[ GitHub ]# File 'lib/yard/templates/helpers/markup/rdoc_markup.rb', line 35
attr_accessor :from_path
Instance Method Details
#fix_dash_dash(text) (private)
TODO:
Refactor into own SimpleMarkup subclass
Don't allow -- to turn into — element. The chances of this being some --option is far more likely than the typographical meaning.
# File 'lib/yard/templates/helpers/markup/rdoc_markup.rb', line 87
def fix_dash_dash(text) text.gsub(/—(?=\S)/, '--') end
#fix_typewriter(text) (private)
TODO:
Refactor into own SimpleMarkup subclass
Fixes RDoc behaviour with ++ only supporting alphanumeric text.
# File 'lib/yard/templates/helpers/markup/rdoc_markup.rb', line 66
def fix_typewriter(text) = 0 text.gsub(%r{<(/)?(pre|code|tt)|(\s|^|>)\+(?! )([^\n\+]{1,900})(?! )\+}) do |str| closed = $1 tag = $2 first_text = $3 type_text = $4 if tag += (closed ? -1 : 1) next str end next str unless == 0 first_text + '<tt>' + type_text + '</tt>' end end
#to_html
[ GitHub ]# File 'lib/yard/templates/helpers/markup/rdoc_markup.rb', line 50
def to_html html = nil @@mutex.synchronize do @@formatter.from_path = from_path html = @@markup.convert(@text, @@formatter) end html = fix_dash_dash(html) html = fix_typewriter(html) html end