summaryrefslogtreecommitdiff
path: root/test/parser_test.rb
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2015-07-04 19:25:24 -0600
committerDan Allen <dan.j.allen@gmail.com>2015-07-05 16:57:13 -0600
commit2893d1666060fbb360e717fd503e06f8cc0f6f32 (patch)
tree4d13534b1cc76f03422a2614b6f6965c5be410fe /test/parser_test.rb
parent48cd2e921876f70399668b91ce2ff1b6c067aa66 (diff)
resolves #1170 and #841 expand tabs properly
- introduce tabsize attribute to control size of tab character - expand tabs in verbatim blocks if tab present and value of tabsize attribute is positive - rename reset_block_indent! to adjust_indentation! - only use adjust_indentation! on include if indent is specified - only expand tabs in included content if indent attribute is set - use adjust_indentation! to remove left margin in paragraphs marked normal - don't add indentation to empty lines - set tab-size property to 4 in default stylesheet - increase letter spacing in blockquote cite in default stylesheet - add and fix tests
Diffstat (limited to 'test/parser_test.rb')
-rw-r--r--test/parser_test.rb44
1 files changed, 32 insertions, 12 deletions
diff --git a/test/parser_test.rb b/test/parser_test.rb
index 09668f18..12024e48 100644
--- a/test/parser_test.rb
+++ b/test/parser_test.rb
@@ -599,7 +599,7 @@ v0.0.7, 2013-12-18
assert_equal 'SJR', blankdoc.attributes['authorinitials']
end
- test 'reset block indent to 0' do
+ test 'adjust indentation to 0' do
input = <<-EOS.chomp
def names
@@ -617,11 +617,11 @@ end
EOS
lines = input.split("\n")
- Asciidoctor::Parser.reset_block_indent! lines
+ Asciidoctor::Parser.adjust_indentation! lines
assert_equal expected, (lines * "\n")
end
- test 'reset block indent mixed with tabs and spaces to 0' do
+ test 'adjust indentation mixed with tabs and spaces to 0' do
input = <<-EOS.chomp
def names
@@ -639,11 +639,31 @@ end
EOS
lines = input.split("\n")
- Asciidoctor::Parser.reset_block_indent! lines
+ Asciidoctor::Parser.adjust_indentation! lines, 0, 4
assert_equal expected, (lines * "\n")
end
- test 'reset block indent to non-zero' do
+ test 'expands tabs to spaces' do
+ input = <<-EOS.chomp
+Filesystem Size Used Avail Use% Mounted on
+Filesystem Size Used Avail Use% Mounted on
+devtmpfs 3.9G 0 3.9G 0% /dev
+/dev/mapper/fedora-root 48G 18G 29G 39% /
+ EOS
+
+ expected = <<-EOS.chomp
+Filesystem Size Used Avail Use% Mounted on
+Filesystem Size Used Avail Use% Mounted on
+devtmpfs 3.9G 0 3.9G 0% /dev
+/dev/mapper/fedora-root 48G 18G 29G 39% /
+ EOS
+
+ lines = input.split("\n")
+ Asciidoctor::Parser.adjust_indentation! lines, 0, 4
+ assert_equal expected, (lines * "\n")
+ end
+
+ test 'adjust indentation to non-zero' do
input = <<-EOS.chomp
def names
@@ -654,18 +674,18 @@ end
expected = <<-EOS.chomp
def names
-
+
@name.split ' '
-
+
end
EOS
lines = input.split("\n")
- Asciidoctor::Parser.reset_block_indent! lines, 2
+ Asciidoctor::Parser.adjust_indentation! lines, 2
assert_equal expected, (lines * "\n")
end
- test 'preserve block indent' do
+ test 'preserve block indent if indent is -1' do
input = <<-EOS
def names
@@ -677,16 +697,16 @@ end
expected = input
lines = input.lines.entries
- Asciidoctor::Parser.reset_block_indent! lines, nil
+ Asciidoctor::Parser.adjust_indentation! lines, -1
assert_equal expected, lines.join
end
- test 'reset block indent hands empty lines gracefully' do
+ test 'adjust indentation handles empty lines gracefully' do
input = []
expected = input
lines = input.dup
- Asciidoctor::Parser.reset_block_indent! lines
+ Asciidoctor::Parser.adjust_indentation! lines
assert_equal expected, lines
end