class Qiita::Markdown::Filters::Footnote

Public Instance Methods

call() click to toggle source
# File lib/qiita/markdown/filters/footnote.rb, line 5
def call
  doc.search("sup > a").each do |a|
    footnote = find_footnote(a)
    next unless footnote

    a[:title] = footnote.text.gsub(/\A\n/, "").gsub(/ ↩\n\z/, "")
  end
  doc
end

Private Instance Methods

find_footnote(a) click to toggle source
# File lib/qiita/markdown/filters/footnote.rb, line 17
def find_footnote(a)
  href = a["href"]
  return nil if !href || href.match(/\A#fn\d+\z/).nil?

  doc.search(href).first
end