class Jekyll::Tags::CiteUrlTag

Citation URL tag which just pulls out the URL for the article, most useful in quote citations.

Example:

> Some Quote
{: .quote cite="{% cite_url Ramalingam_2004 %}"}

Public Class Methods

Calls superclass method
# File _plugins/jekyll-scholar.rb, line 82
def initialize(tag_name, text, tokens)
  super
  @text = text.strip
end

Public Instance Methods

# File _plugins/jekyll-scholar.rb, line 87
def render(context)
  page = context.registers[:page]
  site = context.registers[:site]
  Gtn::Scholar.load_bib(site)

  # Mark this page as having citations
  page['cited'] = true

  return "@#{@text}" if page['citation_target'] == 'R'

  # Which page is rendering this tag?
  source_page = page['path']

  # Citation Frequency
  site.config['citation_count'] = Hash.new(0) if !site.config.key?('citation_count')
  site.config['citation_count'][@text] += 1

  # If the overall cache is nil, create it
  site.config['citation_cache'] = {} if site.config['citation_cache'].nil?
  # If the individual page in the chace is nil, create it.
  site.config['citation_cache'][source_page] = [] if site.config['citation_cache'][source_page].nil?

  # Push it to our cache.
  site.config['citation_cache'][source_page].push(@text)

  begin
    doi = site.config['cached_citeproc'].items[@text].doi
    url = site.config['cached_citeproc'].items[@text].url
    if !doi.nil?
      "https://doi.org/#{doi}"
    elsif !url.nil?
      url
    end
    res = url
  rescue StandardError => e
    Jekyll.logger.warn "[GTN/scholar] Could not render #{@text} from #{source_page} (#{e})"
    res = %(<span>https://example.com/ERROR+INVALID+CITATION+#{@text}</span>)
  end
  res
end