Method: TD2Planet::Formatter#move_tukkomi_link

Defined in:
lib/td2planet/formatter.rb


184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/td2planet/formatter.rb', line 184

def move_tukkomi_link(html)
  if TukkomiLinkRe =~ html
    tukkomi_link = $&
    tukkomi_uri = $1
    re = Regexp.new(Regexp.quote(tukkomi_link))
    tukkomi_moved_html = html.gsub(re, '')
    re = Regexp.new(Regexp.quote('<!--<div class="caption"></div>-->'))
    tukkomi_moved_html.sub!(re) { %Q|<div class="caption">[<a href="#{tukkomi_uri}">ツッコミを入れる</a>]</div>| }
    # other day tukkomi_link found
    if TukkomiLinkRe =~ tukkomi_moved_html
      html.gsub!(TukkomiLinkRe) { %Q|<div class="caption">[<a href="#{$1}">ツッコミを入れる</a>]</div>| }
    else
      html = tukkomi_moved_html
    end
  end
  html
end