coradoc-adoc 2.0.26 → 2.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d381a7e511028e9caa79826eccd74e14694968a18825cd179d28cbd785928c7
4
- data.tar.gz: 0646f6bf33b86848c345fa772e23583def67169f01ae9b9a905ec0f8fa1922c7
3
+ metadata.gz: ac328212768fb69c29726e260db2af252ebb60fff81682bb7eed8ad9984bee1a
4
+ data.tar.gz: 4b5af72762fcbf96fe40594cd4b849e328b2fe03cc027aa37e08435869656c1c
5
5
  SHA512:
6
- metadata.gz: 86b395057b440b17616f1743a4d4e72f8c9cffb21b344019b695233c81445450bfd2e17bfc77cb0e706d1284267c4e399680d1174818ebae709570c485c5d435
7
- data.tar.gz: 25d8a142605cd3fe9df0dbd191c1004f4d9450ba79614a7b660cd629ef7c8673045143d4b5ed9fd7c0cdf25385d94ec615c2d2591479f41c228abe1fa16c77aa
6
+ metadata.gz: 26ad434a7f144350750011ccca8a932c193ed9687c001080ce6549edcbdb1c16f2d072eb3d62dd0fa825eb744707beae7cb24be4876e03ac1054b2dffa2eaecf
7
+ data.tar.gz: bf54821072c38fc983b68be86fca0d0cd46b6358b6b2239d84697cff44aadf3ab4cc5cc88a03760b29d78929568c874367a90cb9ad9c0d3c6405fa512795ea05
@@ -3,19 +3,29 @@
3
3
  module Coradoc
4
4
  module AsciiDoc
5
5
  module Parser
6
- # Single Responsibility: parse the optional header that precedes a block.
6
+ # Single Responsibility: parse the optional header that precedes a
7
+ # structural element (block or section).
7
8
  #
8
- # Encapsulates the canonical AsciiDoc block-header grammar in one place
9
- # (DRY, MECE, single source of truth). Before this module existed, every
10
- # block-like rule (block, table, section, paragraph, block_image) inlined
11
- # its own header rule with subtly different slot orderings — and several
12
- # of them captured the same Parslet key more than once in a single
13
- # sequence, which triggered Parslet's "Duplicate subtrees while merging
14
- # result" warning and silently discarded one of the captured values.
9
+ # Encapsulates the canonical AsciiDoc header grammar in one place
10
+ # (DRY, MECE, single source of truth). Two flavours live here because
11
+ # blocks and sections have different header grammars:
15
12
  #
16
- # Canonical header shape, each component at most once:
13
+ # block_header = block_title? >> element_id? >> attribute_blocks?
14
+ # section_header = element_id? >> attribute_blocks?
17
15
  #
18
- # block_title? >> element_id? >> attribute_blocks?
16
+ # Asciidoctor does NOT permit `.Title` to apply to a section — sections
17
+ # accept `[role]` attribute lists and `[[id]]` anchors but not block
18
+ # titles. The section's heading IS its title. Mixing the two shapes
19
+ # into one rule caused `section_block` to admit `.Foo` lines that
20
+ # collided with `section_title`'s `:title` capture, triggering
21
+ # Parslet's "Duplicate subtrees while merging result … (keys:
22
+ # [:title])" warning and silently dropping the block title.
23
+ #
24
+ # Before this module existed, every block-like rule inlined its own
25
+ # header rule with subtly different slot orderings — and several
26
+ # captured the same Parslet key more than once in a single sequence,
27
+ # which triggered Parslet's "Duplicate subtrees" warning and silently
28
+ # discarded one of the captured values.
19
29
  #
20
30
  # `attribute_blocks` accepts one or more consecutive `[...]` attribute
21
31
  # lists, captured as a Parslet sequence under the :attribute_list key.
@@ -31,8 +41,11 @@ module Coradoc
31
41
  # every attribute and lets the transformer merge them into a single
32
42
  # Coradoc::AsciiDoc::Model::AttributeList downstream.
33
43
  module BlockHeader
34
- # Canonical block header rule. Single canonical order; each of title,
35
- # id, and attribute_blocks is optional and matched at most once.
44
+ # Canonical block header rule. Includes the block title every
45
+ # real block (delimited block, table, paragraph, image) accepts
46
+ # an optional `.Title` line before its body. Single canonical
47
+ # order; each of title, id, and attribute_blocks is optional and
48
+ # matched at most once.
36
49
  # @return [Parslet::Atoms::Base]
37
50
  def block_header
38
51
  block_title.maybe >>
@@ -40,6 +53,16 @@ module Coradoc
40
53
  attribute_blocks.maybe
41
54
  end
42
55
 
56
+ # Section header rule. Asciidoctor does not permit `.Title` on
57
+ # sections — the section heading itself is the title. Sections
58
+ # still accept the same element_id and attribute_blocks slots
59
+ # that blocks do (`[[anchor]]`, `[appendix]`, `[role=x]`, etc.).
60
+ # @return [Parslet::Atoms::Base]
61
+ def section_header
62
+ element_id.maybe >>
63
+ attribute_blocks.maybe
64
+ end
65
+
43
66
  # One or more consecutive attribute_list + newline sequences, captured
44
67
  # as a Parslet sequence under :attribute_list. When multiple `[...]`
45
68
  # blocks precede a delimiter, all of them reach the transformer; when
@@ -27,7 +27,7 @@ module Coradoc
27
27
  def section_block(level = 2)
28
28
  return nil if level > 8
29
29
 
30
- block_header >>
30
+ section_header >>
31
31
  section_title(level).as(:title) >>
32
32
  contents.as(:contents).maybe
33
33
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Coradoc
4
4
  module AsciiDoc
5
- VERSION = '2.0.26'
5
+ VERSION = '2.0.27'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coradoc-adoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.26
4
+ version: 2.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.