diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2017-06-19 23:38:16 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-19 23:38:16 -0600 |
| commit | 4ac7d2b6db8159c7e8a995fea5687922cb5afcb6 (patch) | |
| tree | a1973f9fdee0f8b6f6e0e8025780d98060dadaa9 | |
| parent | 4f78f60871f67e9ede404d443679d69cb94c8551 (diff) | |
resolves #2153 allow compat-mode in AsciiDoc table cell to inherit from parent document (#2267)
| -rw-r--r-- | lib/asciidoctor/document.rb | 7 | ||||
| -rw-r--r-- | test/tables_test.rb | 76 |
2 files changed, 64 insertions, 19 deletions
diff --git a/lib/asciidoctor/document.rb b/lib/asciidoctor/document.rb index 58207f41..9bb40a2d 100644 --- a/lib/asciidoctor/document.rb +++ b/lib/asciidoctor/document.rb @@ -197,7 +197,7 @@ class Document < AbstractBlock attr_overrides.delete 'toc-placement' attr_overrides.delete 'toc-position' @safe = parent_doc.safe - @compat_mode = parent_doc.compat_mode + @attributes['compat-mode'] = '' if (@compat_mode = parent_doc.compat_mode) @sourcemap = parent_doc.sourcemap @converter = parent_doc.converter initialize_extensions = false @@ -769,11 +769,8 @@ class Document < AbstractBlock attrs['toc-class'] ||= default_toc_class if default_toc_class end - if attrs.key? 'compat-mode' + if (@compat_mode = attrs.key? 'compat-mode') attrs['source-language'] = attrs['language'] if attrs.key? 'language' - @compat_mode = true - else - @compat_mode = false end # NOTE pin the outfilesuffix after the header is parsed diff --git a/test/tables_test.rb b/test/tables_test.rb index 3f153ca7..18eec714 100644 --- a/test/tables_test.rb +++ b/test/tables_test.rb @@ -1024,20 +1024,6 @@ doctype={doctype} assert_includes result, '{backend-html5-doctype-article}' end - test 'compat mode can be activated in asciidoc table cell' do - input = <<-EOS -|=== -a| -:compat-mode: - -'italic' -|=== - EOS - - result = render_embedded_string input - assert_css 'table.tableblock td em', result, 1 - end - test 'asciidoc content' do input = <<-EOS [cols="1e,1,5a",frame="topbot",options="header"] @@ -1169,6 +1155,68 @@ key: value <1> end end + test 'compat mode can be activated in AsciiDoc table cell' do + input = <<-EOS +|=== +a| +:compat-mode: + +The word 'italic' is emphasized. +|=== + EOS + + result = render_embedded_string input + assert_xpath '//em[text()="italic"]', result, 1 + end + + test 'compat mode in AsciiDoc table cell inherits from parent document' do + input = <<-EOS +:compat-mode: + +The word 'italic' is emphasized. + +[cols=1*] +|=== +|The word 'oblique' is emphasized. +a| +The word 'slanted' is emphasized. +|=== + +The word 'askew' is emphasized. + EOS + + result = render_embedded_string input + assert_xpath '//em[text()="italic"]', result, 1 + assert_xpath '//em[text()="oblique"]', result, 1 + assert_xpath '//em[text()="slanted"]', result, 1 + assert_xpath '//em[text()="askew"]', result, 1 + end + + test 'compat mode in AsciiDoc table cell can be unset if set in parent document' do + input = <<-EOS +:compat-mode: + +The word 'italic' is emphasized. + +[cols=1*] +|=== +|The word 'oblique' is emphasized. +a| +:!compat-mode: + +The word 'slanted' is not emphasized. +|=== + +The word 'askew' is emphasized. + EOS + + result = render_embedded_string input + assert_xpath '//em[text()="italic"]', result, 1 + assert_xpath '//em[text()="oblique"]', result, 1 + assert_xpath '//em[text()="slanted"]', result, 0 + assert_xpath '//em[text()="askew"]', result, 1 + end + test 'nested table' do input = <<-EOS [cols="1,2a"] |
