diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2023-04-22 23:58:07 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2023-04-23 02:50:40 -0600 |
| commit | 2a8b4c0a9de073b25b3d528e23a6b3e3f9a8cd42 (patch) | |
| tree | 3a96c00ea21e607dc1fb989a47659474a90b76e2 | |
| parent | 6a33915699cf3bbff38e06840ac7ecf1391f0412 (diff) | |
minor optimization to avoid calls to regex in list parsing if precondition is not true
| -rw-r--r-- | lib/asciidoctor/parser.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/asciidoctor/parser.rb b/lib/asciidoctor/parser.rb index 82bb4fb6..0596db15 100644 --- a/lib/asciidoctor/parser.rb +++ b/lib/asciidoctor/parser.rb @@ -1447,7 +1447,7 @@ class Parser buffer.concat reader.read_lines_until terminator: match.terminator, read_last_line: true, context: nil continuation = :inactive # BlockAttributeLineRx only breaks dlist if ensuing line is not a list item - elsif dlist && continuation != :active && (BlockAttributeLineRx.match? this_line) + elsif dlist && continuation != :active && (this_line.start_with? '[') && (BlockAttributeLineRx.match? this_line) block_attribute_lines = [this_line] while (next_line = reader.peek_line) if is_delimited_block? next_line @@ -1482,7 +1482,8 @@ class Parser end continuation = :inactive # let block metadata play out until we find the block - elsif (BlockTitleRx.match? this_line) || (BlockAttributeLineRx.match? this_line) || (AttributeEntryRx.match? this_line) + elsif ((ch0 = this_line.chr) == '.' && (BlockTitleRx.match? this_line)) || + (ch0 == '[' && (BlockAttributeLineRx.match? this_line)) || (ch0 == ':' && (AttributeEntryRx.match? this_line)) buffer << this_line else if (nested_list_type = (within_nested_list ? [:dlist] : NESTABLE_LIST_CONTEXTS).find {|ctx| ListRxMap[ctx].match? this_line }) |
