summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2019-02-09 23:10:00 -0700
committerGitHub <noreply@github.com>2019-02-09 23:10:00 -0700
commit420babf0029df88cfebdc4ea26200026c65098c9 (patch)
tree9a1c0149a1b7eef20acea3ae65059467420f9db7
parentca6f0d918cfa9b0019afdedf22efb04f95fc580b (diff)
resolves #3060 require setext section title to have at least one alphanumeric character (PR #3061)
- although documented this way, the parser was checking for at least one word character, which is different
-rw-r--r--CHANGELOG.adoc1
-rw-r--r--lib/asciidoctor.rb2
-rw-r--r--test/sections_test.rb24
3 files changed, 26 insertions, 1 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index 534a4852..401deae4 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -66,6 +66,7 @@ Improvements::
Bug Fixes::
* don't fail to parse Markdown-style quote block that only contains attribution line (#2989)
+ * enforce rule that Setext section title must have at least one alphanumeric character; fixes problem w/ block nested inside quote block (#3060)
* don't fail if value of pygments-style attribute is not recognized; gracefully fallback to default style (#2106)
* do not alter the $LOAD_PATH (#2764)
* remove conditional comment for IE in output of built-in HTML converter; fixes sidebar table of contents (#2983)
diff --git a/lib/asciidoctor.rb b/lib/asciidoctor.rb
index 2b52c21a..bc956b96 100644
--- a/lib/asciidoctor.rb
+++ b/lib/asciidoctor.rb
@@ -603,7 +603,7 @@ module Asciidoctor
# Matches the title only (first line) of an Setext (two-line) section title.
# The title cannot begin with a dot and must have at least one alphanumeric character.
- SetextSectionTitleRx = /^((?!\.)#{CC_ANY}*?#{CG_WORD}#{CC_ANY}*)$/
+ SetextSectionTitleRx = /^((?!\.)#{CC_ANY}*?#{CG_ALNUM}#{CC_ANY}*)$/
# Matches an anchor (i.e., id + optional reference text) inside a section title.
#
diff --git a/test/sections_test.rb b/test/sections_test.rb
index a2c04c4f..ddfabebe 100644
--- a/test/sections_test.rb
+++ b/test/sections_test.rb
@@ -528,6 +528,30 @@ context 'Sections' do
assert_includes result, '----^^----'
end
+ test 'should not recognize section title that does not contain alphanumeric character' do
+ input = <<~'EOS'
+ !@#$
+ ----
+ EOS
+
+ using_memory_logger do |logger|
+ result = convert_string_to_embedded input
+ assert_css 'h2', result, 0
+ end
+ end
+
+ test 'should not recognize section title that consists of only underscores' do
+ input = <<~'EOS'
+ ____
+ ----
+ EOS
+
+ using_memory_logger do |logger|
+ result = convert_string_to_embedded input
+ assert_css 'h2', result, 0
+ end
+ end
+
test 'should preprocess second line of setext section title' do
input = <<~'EOS'
Section Title