Module: Coradoc::AsciiDoc::Parser::AttributeList
- Defined in:
- lib/coradoc/asciidoc/parser/attribute_list.rb
Instance Method Summary collapse
- #attribute_list(name = :attribute_list) ⇒ Object
- #named_attribute ⇒ Object
- #named_attribute_name ⇒ Object
- #named_key ⇒ Object
- #named_many ⇒ Object
- #named_value ⇒ Object
- #named_value_double_quote ⇒ Object
- #named_value_noquote ⇒ Object
- #named_value_single_quote ⇒ Object
- #positional_attribute ⇒ Object
- #positional_many ⇒ Object
- #positional_many_named_many ⇒ Object
- #positional_one_named_many ⇒ Object
- #positional_value_double_quote ⇒ Object
- #positional_value_single_quote ⇒ Object
- #positional_value_unquoted ⇒ Object
- #positional_zero_or_one ⇒ Object
Instance Method Details
#attribute_list(name = :attribute_list) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/coradoc/asciidoc/parser/attribute_list.rb', line 99 def attribute_list(name = :attribute_list) str('[').present? >> str('[') >> str('[').absent? >> (named_many | positional_one_named_many | positional_many_named_many | positional_many | positional_zero_or_one ).as(:attribute_array).as(name) >> str(']') end |
#named_attribute ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/coradoc/asciidoc/parser/attribute_list.rb', line 38 def named_attribute (named_key >> str(' ').maybe >> str('=') >> str(' ').maybe >> named_value >> str(' ').maybe ).as(:named) end |
#named_attribute_name ⇒ Object
7 8 9 |
# File 'lib/coradoc/asciidoc/parser/attribute_list.rb', line 7 def named_attribute_name attribute_name end |
#named_key ⇒ Object
34 35 36 |
# File 'lib/coradoc/asciidoc/parser/attribute_list.rb', line 34 def named_key match('[a-zA-Z0-9_-]').repeat(1).as(:named_key) end |
#named_many ⇒ Object
74 75 76 77 |
# File 'lib/coradoc/asciidoc/parser/attribute_list.rb', line 74 def named_many (named_attribute.repeat(1, 1) >> (str(',') >> space.maybe >> named_attribute).repeat(0)) end |
#named_value ⇒ Object
27 28 29 30 31 32 |
# File 'lib/coradoc/asciidoc/parser/attribute_list.rb', line 27 def named_value (named_value_single_quote | named_value_double_quote | named_value_noquote ).as(:named_value) end |
#named_value_double_quote ⇒ Object
21 22 23 24 25 |
# File 'lib/coradoc/asciidoc/parser/attribute_list.rb', line 21 def named_value_double_quote str('"') >> match('[^"]').repeat(1) >> str('"') end |
#named_value_noquote ⇒ Object
11 12 13 |
# File 'lib/coradoc/asciidoc/parser/attribute_list.rb', line 11 def named_value_noquote match('[^\],]').repeat(1) end |
#named_value_single_quote ⇒ Object
15 16 17 18 19 |
# File 'lib/coradoc/asciidoc/parser/attribute_list.rb', line 15 def named_value_single_quote str("'") >> match("[^']").repeat(1) >> str("'") end |
#positional_attribute ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/coradoc/asciidoc/parser/attribute_list.rb', line 65 def positional_attribute ((positional_value_single_quote | positional_value_double_quote | positional_value_unquoted ) >> str('=').absent? ).as(:positional) end |
#positional_many ⇒ Object
90 91 92 93 |
# File 'lib/coradoc/asciidoc/parser/attribute_list.rb', line 90 def positional_many (positional_attribute.repeat(1, 1) >> (str(',') >> space.maybe >> positional_attribute).repeat(0)) end |
#positional_many_named_many ⇒ Object
84 85 86 87 88 |
# File 'lib/coradoc/asciidoc/parser/attribute_list.rb', line 84 def positional_many_named_many (positional_attribute.repeat(1, 1) >> (str(',') >> space.maybe >> positional_attribute).repeat(1) >> (str(',') >> space.maybe >> named_attribute).repeat(1)) end |
#positional_one_named_many ⇒ Object
79 80 81 82 |
# File 'lib/coradoc/asciidoc/parser/attribute_list.rb', line 79 def positional_one_named_many (positional_attribute.repeat(1, 1) >> (str(',') >> space.maybe >> named_attribute).repeat(1)) end |
#positional_value_double_quote ⇒ Object
59 60 61 62 63 |
# File 'lib/coradoc/asciidoc/parser/attribute_list.rb', line 59 def positional_value_double_quote str('"') >> match('[^"]').repeat(1) >> str('"') end |
#positional_value_single_quote ⇒ Object
53 54 55 56 57 |
# File 'lib/coradoc/asciidoc/parser/attribute_list.rb', line 53 def positional_value_single_quote str("'") >> match("[^']").repeat(1) >> str("'") end |
#positional_value_unquoted ⇒ Object
46 47 48 49 50 51 |
# File 'lib/coradoc/asciidoc/parser/attribute_list.rb', line 46 def positional_value_unquoted # Exclude `=` so that `key=value` is matched by `named_attribute` # rather than swallowed as a single positional token. A positional # value that legitimately contains `=` must be quoted. match('[^\],=]').repeat(1) end |
#positional_zero_or_one ⇒ Object
95 96 97 |
# File 'lib/coradoc/asciidoc/parser/attribute_list.rb', line 95 def positional_zero_or_one positional_attribute.repeat(0, 1) end |