class AsciidoctorBibtex::CitationMacro
Class to hold information about a citation macro. A citation macro has type, text and an array of citation items.
This class also provides a class method to extract macros from a line of text.
Constants
- CITATION_ITEM
matches a citation item (key + locator), such as 'Dan2012(99-100)'
- CITATION_LIST
- CITATION_LIST_TAIL
matches a citation list
- CITATION_MACRO
matches the full citation macro
- CITATION_PRETEXT
- CITATION_TYPE
matches a citation type
Attributes
items[R]
pretext[R]
text[R]
type[R]
Public Class Methods
extract_macros(line)
click to toggle source
Given a line, return a list of CitationData instances containing information on each set of citation information
# File lib/asciidoctor-bibtex/citation_macro.rb, line 57 def self.extract_macros(line) result = [] full = CITATION_MACRO.match line while full text = full[0] type = full[1] pretext = full[2] items = [] item = CITATION_ITEM.match full[3] while item locator = nil locator = item[2][1...-1] if item[2] items << CitationItem.new(item[1], locator) # look for next ref within citation item = CITATION_ITEM.match item.post_match end result << CitationMacro.new(text, type, pretext, items) # look for next citation on line full = CITATION_MACRO.match full.post_match end result end
new(text, type, pretext, items)
click to toggle source
Create a CitationMacro
object
text: the full macro text matched by CITATION_MACRO
type: cite or citenp pretext: some small texts. items: An array of citation items
# File lib/asciidoctor-bibtex/citation_macro.rb, line 89 def initialize(text, type, pretext, items) @text = text @type = type @pretext = pretext @items = items end