summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2020-10-30 18:40:32 -0600
committerGitHub <noreply@github.com>2020-10-30 18:40:32 -0600
commitca2ca428aacfcde709db739bc3cf94beb21b7692 (patch)
treeb454716be790f3750bb250bc47ab791cdbd6c951 /test
parentb765ec86a6367d871d8ac4e223ecb4dced18d975 (diff)
resolves #3760 apply text formatting to table cells in header row when column has a or l style (PR #3790)
Diffstat (limited to 'test')
-rw-r--r--test/tables_test.rb129
1 files changed, 129 insertions, 0 deletions
diff --git a/test/tables_test.rb b/test/tables_test.rb
index 3afab5e3..61ede120 100644
--- a/test/tables_test.rb
+++ b/test/tables_test.rb
@@ -791,6 +791,63 @@ context 'Tables' do
assert_xpath '(//td)[1]/p', output, 2
end
+ test 'should format first cell as literal if there is no implicit header row and column has l style' do
+ input = <<~'EOS'
+ [cols="1l,1"]
+ |===
+ |literal
+ |normal
+ |===
+ EOS
+
+ output = convert_string_to_embedded input
+ assert_css 'tbody pre', output, 1
+ assert_css 'tbody p.tableblock', output, 1
+ end
+
+ test 'wip should format first cell as AsciiDoc if there is no implicit header row and column has a style' do
+ input = <<~'EOS'
+ [cols="1a,1"]
+ |===
+ | * list
+ | normal
+ |===
+ EOS
+
+ output = convert_string_to_embedded input
+ assert_css 'tbody .ulist', output, 1
+ assert_css 'tbody p.tableblock', output, 1
+ end
+
+ test 'should interpret leading indent if first cell is AsciiDoc and there is no implicit header row' do
+ # NOTE cannot use single-quoted heredoc because of https://github.com/jruby/jruby/issues/4260
+ input = <<~EOS
+ [cols="1a,1"]
+ |===
+ |
+ literal
+ | normal
+ |===
+ EOS
+
+ output = convert_string_to_embedded input
+ assert_css 'tbody pre', output, 1
+ assert_css 'tbody p.tableblock', output, 1
+ end
+
+ test 'should format first cell as AsciiDoc if there is no implicit header row and cell has a style' do
+ input = <<~'EOS'
+ |===
+ a| * list
+ | normal
+ |===
+ EOS
+
+ output = convert_string_to_embedded input
+ assert_css 'tbody .ulist', output, 1
+ assert_css 'tbody p.tableblock', output, 1
+ end
+
test 'no implicit header row if AsciiDoc cell in first line spans multiple lines' do
input = <<~'EOS'
[cols=2*]
@@ -885,6 +942,39 @@ context 'Tables' do
assert_css 'table > tbody > tr > td > p > em > a', output, 1
end
+ test 'should apply text formatting to cells in implicit header row when column has a style' do
+ input = <<~'EOS'
+ [cols="2*a"]
+ |===
+ | _foo_ | *bar*
+
+ | * list item
+ | paragraph
+ |===
+ EOS
+ output = convert_string_to_embedded input
+ assert_xpath '(//thead/tr/th)[1]/em[text()="foo"]', output, 1
+ assert_xpath '(//thead/tr/th)[2]/strong[text()="bar"]', output, 1
+ assert_css 'tbody .ulist', output, 1
+ assert_css 'tbody .paragraph', output, 1
+ end
+
+ test 'should apply style and text formatting to cells in first row if no implicit header' do
+ input = <<~'EOS'
+ [cols="s,e"]
+ |===
+ | _strong_ | *emphasis*
+ | strong
+ | emphasis
+ |===
+ EOS
+ output = convert_string_to_embedded input
+ assert_xpath '((//tbody/tr)[1]/td)[1]//strong/em[text()="strong"]', output, 1
+ assert_xpath '((//tbody/tr)[1]/td)[2]//em/strong[text()="emphasis"]', output, 1
+ assert_xpath '((//tbody/tr)[2]/td)[1]//strong[text()="strong"]', output, 1
+ assert_xpath '((//tbody/tr)[2]/td)[2]//em[text()="emphasis"]', output, 1
+ end
+
test 'vertical table headers use th element instead of header class' do
input = <<~'EOS'
[cols="1h,1s,1e"]
@@ -1430,6 +1520,45 @@ context 'Tables' do
assert_xpath '(//table/tbody/tr)[2]//th//a[@id="grays-peak"]', output, 1
end
+ test 'should catalog anchor at start of cell in implicit header row when column has a style' do
+ input = <<~'EOS'
+ [cols=1a]
+ |===
+ |[[foo,Foo]]* not AsciiDoc
+
+ | AsciiDoc
+ |===
+ EOS
+ doc = document_from_string input
+ refs = doc.catalog[:refs]
+ assert refs.key?('foo')
+ end
+
+ test 'should catalog anchor at start of cell in explicit header row when column has a style' do
+ input = <<~'EOS'
+ [%header,cols=1a]
+ |===
+ |[[foo,Foo]]* not AsciiDoc
+ | AsciiDoc
+ |===
+ EOS
+ doc = document_from_string input
+ refs = doc.catalog[:refs]
+ assert refs.key?('foo')
+ end
+
+ test 'should catalog anchor at start of cell in first row' do
+ input = <<~'EOS'
+ |===
+ |[[foo,Foo]]foo
+ | bar
+ |===
+ EOS
+ doc = document_from_string input
+ refs = doc.catalog[:refs]
+ assert refs.key?('foo')
+ end
+
test 'footnotes should not be shared between an AsciiDoc table cell and the main document' do
input = <<~'EOS'
|===