Class: RDoc::Markup::ToHtml::QuoteConverter
- Inherits:
-
Object
- Object
- RDoc::Markup::ToHtml::QuoteConverter
- Defined in:
- lib/rdoc/markup/to_html.rb
Overview
Converts ascii quote pairs to multibyte quote characters
Instance Method Summary collapse
- #convert(quote, after_word:) ⇒ Object
-
#initialize ⇒ QuoteConverter
constructor
A new instance of QuoteConverter.
Constructor Details
#initialize ⇒ QuoteConverter
Returns a new instance of QuoteConverter.
91 92 93 94 |
# 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:) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# 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 |