summaryrefslogtreecommitdiff
path: root/test/extensions_test.rb
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2019-03-22 14:03:14 -0600
committerGitHub <noreply@github.com>2019-03-22 14:03:14 -0600
commit9e95dd9d2eb87f56799a3465bc045d69c6dc8e4e (patch)
tree66b0824b8824ee2900efbe5062559f52e8bcde27 /test/extensions_test.rb
parent2a1e86c6f74b0a82e2bfc26c5b20dcaf2662351a (diff)
resolves #2134 add parse_attributes helper to base extension Processor class (PR #3189)
Diffstat (limited to 'test/extensions_test.rb')
-rw-r--r--test/extensions_test.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/extensions_test.rb b/test/extensions_test.rb
index 1f794acd..a30c1490 100644
--- a/test/extensions_test.rb
+++ b/test/extensions_test.rb
@@ -1474,6 +1474,38 @@ context 'Extensions' do
end
end
+ test 'can use parse_attributes to parse attrlist' do
+ begin
+ parsed_attrs = nil
+ Asciidoctor::Extensions.register do
+ block do
+ named :attrs
+ on_context :open
+ process do |parent, reader, attrs|
+ parsed_attrs = parse_attributes parent, reader.read_line, positional_attributes: ['a', 'b']
+ parsed_attrs.update parse_attributes parent, 'foo={foo}', sub_attributes: true
+ nil
+ end
+ end
+ end
+ input = <<~'EOS'
+ :foo: bar
+
+ [attrs]
+ --
+ a,b,c,key=val
+ --
+ EOS
+ doc = document_from_string input
+ assert_equal 'a', parsed_attrs['a']
+ assert_equal 'b', parsed_attrs['b']
+ assert_equal 'val', parsed_attrs['key']
+ assert_equal 'bar', parsed_attrs['foo']
+ ensure
+ Asciidoctor::Extensions.unregister_all
+ end
+ end
+
test 'create_section should set up all section properties' do
begin
sect = nil