Sha256: 577ba3929ee2cd5d00b937d7af7ba476a6e07f257a2f6030fde9cef61950ffbb
Contents?: true
Size: 1.28 KB
Versions: 6
Compression:
Stored size: 1.28 KB
Contents
# coding: utf-8 require "asciidoctor-bibliography" def init_bibliographer(options: {}) bibliographer = AsciidoctorBibliography::Bibliographer.new opts = options.dup db_path = File.join __dir__, "fixtures", opts.delete("bibliography-database") bibliographer.database = AsciidoctorBibliography::Database.new.append db_path bibliographer.options = AsciidoctorBibliography::Options.new. merge( "bibliography-hyperlinks" => "false", "bibliography-prepend-empty" => "false", ).merge(opts) bibliographer end def formatted_citation(macro, options: {}) bibliographer = init_bibliographer options: options macro.gsub(AsciidoctorBibliography::Citation::REGEXP) do citation = AsciidoctorBibliography::Citation.new(*Regexp.last_match.captures) bibliographer.add_citation(citation) citation.render bibliographer end end def formatted_bibliography(macro, options: {}) bibliographer = init_bibliographer options: options macro.gsub(AsciidoctorBibliography::Citation::REGEXP) do citation = AsciidoctorBibliography::Citation.new(*Regexp.last_match.captures) bibliographer.add_citation(citation) # citation.render bibliographer index = AsciidoctorBibliography::Index.new("bibliography", "", "") index.render(bibliographer).join end end
Version data entries
6 entries across 6 versions & 1 rubygems