Sha256: 664c4c6d31376356b6735881c9825e99a1ba9e28699c1c383d29f499b29e2b01

Contents?: true

Size: 995 Bytes

Versions: 3

Compression:

Stored size: 995 Bytes

Contents

# Define a filter for adding citation metadata
Nanoc::Filter.define(:scholar_citation_metadata) do |content, params|
  content = content.dup

  # Create author tags
  authors = ""
  if $authors
    authors = $authors.map { |author| '<meta name="citation_author" content="' + author + '" />' }.join("\n  ")
    $authors = []
  end

  # Create optional tags
  additionalTags = params.map { |key, value| '<meta name="citation_' + key.to_s + '" content="' + value + '" />' }.join("\n  ")
  if not params[:publication_date]
    additionalTags += "\n  "
    additionalTags += '<meta name="citation_publication_date" content="' + Time.now.strftime("%Y/%m/%d") + '" />'
  end
  #params_publication_date = params[:publication_date] || Time.now.strftime("%Y/%m/%d")
  
  # Add citation meta tags at the end of the <head>
  content.gsub! %r{\<\/head\>} do |match|
    <<-HTML
  <meta name="citation_title" content="#{item[:title]}">
  #{authors}
  #{additionalTags}
</head>
    HTML
  end
  
  content
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scholarmarkdown-2.5.0 lib/scholarmarkdown/filter/citation_metadata.rb
scholarmarkdown-2.4.0 lib/scholarmarkdown/filter/citation_metadata.rb
scholarmarkdown-2.3.0 lib/scholarmarkdown/filter/citation_metadata.rb