summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2017-07-22 01:53:37 -0600
committerGitHub <noreply@github.com>2017-07-22 01:53:37 -0600
commit65e65f2b645cbd9ecf18bc70d6dab94eb330d4e0 (patch)
tree06268a1ad5636a17e451dddcc6b1218ca8659e36
parenta650c35c5fb3f00f55ecb6e6a7d46574c4fc2442 (diff)
preprocess second line of setext section title; add test (PR #2321)
-rw-r--r--lib/asciidoctor/parser.rb4
-rw-r--r--test/blocks_test.rb6
-rw-r--r--test/sections_test.rb11
3 files changed, 17 insertions, 4 deletions
diff --git a/lib/asciidoctor/parser.rb b/lib/asciidoctor/parser.rb
index 257eb3d8..376e6428 100644
--- a/lib/asciidoctor/parser.rb
+++ b/lib/asciidoctor/parser.rb
@@ -1599,7 +1599,9 @@ class Parser
if (style = attributes[1]) && (style.start_with? 'discrete', 'float') && (DiscreteHeadingStyleRx.match? style)
return
elsif reader.has_more_lines?
- Compliance.underline_style_section_titles ? is_section_title?(*reader.peek_lines(2, true)) : is_single_line_section_title?(reader.peek_line)
+ Compliance.underline_style_section_titles ?
+ is_section_title?(*reader.peek_lines(2, style ? style == 'comment' : false)) :
+ is_single_line_section_title?(reader.peek_line)
end
end
diff --git a/test/blocks_test.rb b/test/blocks_test.rb
index cb03e25a..37690f5c 100644
--- a/test/blocks_test.rb
+++ b/test/blocks_test.rb
@@ -198,9 +198,9 @@ line should not be rendered
assert_xpath '//p', output, 0
end
- # WARNING if first line of content is a directive, it will get interpretted before we know it's a comment block
- # it happens because we always look a line ahead...not sure what we can do about it
- test 'preprocessor directives should not be processed within comment paragraph' do
+ # WARNING this assertion fails if the directive is the first line of the paragraph instead of the second
+ # it happens because we always look a line ahead; not sure what we can do about it
+ test 'preprocessor directives should not be processed on subsequent lines of a comment paragraph' do
input = <<-EOS
[comment]
first line of content
diff --git a/test/sections_test.rb b/test/sections_test.rb
index fc1c2994..1825abfb 100644
--- a/test/sections_test.rb
+++ b/test/sections_test.rb
@@ -396,6 +396,17 @@ My Section
assert_includes result, '----^^----'
end
+ test 'should preprocess second line of setext section title' do
+ input = <<-EOS
+Section Title
+ifdef::asciidoctor[]
+-------------
+endif::[]
+ EOS
+ result = render_embedded_string input
+ assert_xpath '//h2', result, 1
+ end
+
test "heading title with multiline syntax cannot begin with a dot" do
title = ".My Title"
chars = "-" * title.length