Class | Asciidoctor::AttributeList |
In: |
lib/asciidoctor/attribute_list.rb
|
Parent: | Object |
Public: Handles parsing AsciiDoc attribute lists into a Hash of key/value pairs. By default, attributes must each be separated by a comma and quotes may be used around the value. If a key is not detected, the value is assigned to a 1-based positional key, The positional attributes can be "rekeyed" when given a posattrs array either during parsing or after the fact.
Examples
attrlist = Asciidoctor::AttributeList.new('astyle') attrlist.parse => {0 => 'astyle'} attrlist.rekey(['style']) => {'style' => 'astyle'} attrlist = Asciidoctor::AttributeList.new('quote, Famous Person, Famous Book (2001)') attrlist.parse(['style', 'attribution', 'citetitle']) => {'style' => 'quote', 'attribution' => 'Famous Person', 'citetitle' => 'Famous Book (2001)'}
CG_BLANK | = | '[ \\t]' | ||
CC_WORD | = | 'a-zA-Z0-9_' | ||
CG_WORD | = | '[a-zA-Z0-9_]' | ||
BoundaryRxs | = | { '"' => /.*?[^\\](?=")/, '\'' => /.*?[^\\](?=')/, ',' => /.*?(?=#{CG_BLANK}*(,|$))/ | Public: Regular expressions for detecting the boundary of a value | |
EscapedQuoteRxs | = | { '"' => /\\"/, '\'' => /\\'/ | Public: Regular expressions for unescaping quoted characters | |
NameRx | = | /#{CG_WORD}[#{CC_WORD}\-.]*/ | Public: A regular expression for an attribute name (approx. name token from XML) TODO named attributes cannot contain dash characters | |
BlankRx | = | /#{CG_BLANK}+/ | ||
SkipRxs | = | { :blank => BlankRx, ',' => /#{CG_BLANK}*(,|$)/ | Public: Regular expressions for skipping blanks and delimiters |