diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2014-08-06 18:26:42 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2014-08-06 18:26:42 -0600 |
| commit | 8a1bc8eb0261e3fe4e8ce343f40d47e802189fe3 (patch) | |
| tree | 4c4498d834557e9c190b26e4445b9d29119ede74 | |
| parent | 27d7367cd16eb6cd91595f6cd85be9d1f2945719 (diff) | |
allow compat-mode to be toggled in document
| -rw-r--r-- | lib/asciidoctor/document.rb | 7 | ||||
| -rw-r--r-- | test/attributes_test.rb | 24 |
2 files changed, 29 insertions, 2 deletions
diff --git a/lib/asciidoctor/document.rb b/lib/asciidoctor/document.rb index 91aed56c..da7f0919 100644 --- a/lib/asciidoctor/document.rb +++ b/lib/asciidoctor/document.rb @@ -781,10 +781,13 @@ class Document < AbstractBlock def playback_attributes(block_attributes) if block_attributes.key? :attribute_entries block_attributes[:attribute_entries].each do |entry| + name = entry.name if entry.negate - @attributes.delete(entry.name) + @attributes.delete name + @compat_mode = false if name == 'compat-mode' else - @attributes[entry.name] = entry.value + @attributes[name] = entry.value + @compat_mode = true if name == 'compat-mode' end end end diff --git a/test/attributes_test.rb b/test/attributes_test.rb index 148341da..637822c5 100644 --- a/test/attributes_test.rb +++ b/test/attributes_test.rb @@ -539,6 +539,30 @@ Belly up to the {foo}. assert_xpath '//p[text()="Belly up to the bar."]', output, 0 end + test 'should allow compat-mode to be set and unset in middle of document' do + input = <<-EOS +:foo: bar + +[[paragraph-a]] +`{foo}` + +:compat-mode!: + +[[paragraph-b]] +`{foo}` + +:compat-mode: + +[[paragraph-c]] +`{foo}` + EOS + + result = render_embedded_string input, :attributes => {'compat-mode' => '@'} + assert_xpath '/*[@id="paragraph-a"]//code[text()="{foo}"]', result, 1 + assert_xpath '/*[@id="paragraph-b"]//code[text()="bar"]', result, 1 + assert_xpath '/*[@id="paragraph-c"]//code[text()="{foo}"]', result, 1 + end + test 'does not disturb attribute-looking things escaped with backslash' do html = render_string(":foo: bar\nThis is a \\{foo} day.") result = Nokogiri::HTML(html) |
