123456789_123456789_123456789_123456789_123456789_

Class: RDoc::Markup::ToHtml::QuoteConverter

Relationships & Source Files
Inherits: Object
Defined in: lib/rdoc/markup/to_html.rb

Overview

Converts ascii quote pairs to multibyte quote characters

Class Method Summary

Instance Method Summary

Constructor Details

.newQuoteConverter

[ GitHub ]

  
# File 'lib/rdoc/markup/to_html.rb', line 91

def initialize
  @in_dquote = false
  @in_squote = false
end

Instance Method Details

#convert(quote, after_word:)

[ GitHub ]

  
# File 'lib/rdoc/markup/to_html.rb', line 96

def convert(quote, after_word:)
  case quote
  when '"'
    type = @in_dquote ? :close_dquote : :open_dquote
    @in_dquote = !@in_dquote
  when "'"
    if @in_squote
      type = :close_squote
      @in_squote = false
    elsif after_word
      # Mary's dog, my parents' house: do not start paired quotes
      type = :close_squote
    else
      type = :open_squote
      @in_squote = true
    end
  when '`'
    # Opening quote of <tt>`quoted sentence'</tt>.
    # This will conflict with code blocks <tt>`puts('hello')`</tt> in the future.
    if !@in_squote && !after_word
      type = :open_squote
      @in_squote = true
    end
  end
  TO_HTML_CHARACTERS[quote.encoding][type] if type
end