Sha256: f0c2d9ba1372bb2e28e1129056352fcae60d71d94501b1c77fbfb18fb2518e2e
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
require 'asciidoctor/attribute_list' require_relative 'helpers' module AsciidoctorBibliography class Index REGEXP = /^(bibliography)::(\S+)?\[(|.*?[^\\])\]$/ attr_reader :macro, :target, :attributes def initialize(macro, target, attributes) @macro = macro @target = target @attributes = ::Asciidoctor::AttributeList.new(attributes).parse end def render(bibliographer) lines = [] bibliographer.occurring_keys.each_with_index do |target, index| line = '{empty}' line << "[#{index + 1}] " if bibliographer.options['citation-style'] == 'numbers' line << render_entry(target, bibliographer.index_formatter) lines << line end # Intersperse the lines with empty ones to render as paragraphs. lines.join("\n\n").lines.map(&:strip) end def render_entry_id(target) ['bibliography', target].compact.join('-') end def render_entry_label(target, formatter) Helpers.html_to_asciidoc formatter.render(:bibliography, id: target).join end def render_entry(target, formatter) "anchor:#{render_entry_id(target)}[]#{render_entry_label(target, formatter)}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
asciidoctor-bibliography-0.0.1.dev | lib/asciidoctor-bibliography/index.rb |