coradoc-adoc 2.0.25 → 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: 4ecb988af13f918e49f0249e3691e22fd98f21beffd3f0e2d6c98affc39d64dc
4
- data.tar.gz: 4db6ab5b2227364c2092f00b40167fa054ed1dd43592150baf1c745e39f98a09
3
+ metadata.gz: ac328212768fb69c29726e260db2af252ebb60fff81682bb7eed8ad9984bee1a
4
+ data.tar.gz: 4b5af72762fcbf96fe40594cd4b849e328b2fe03cc027aa37e08435869656c1c
5
5
  SHA512:
6
- metadata.gz: 26ea9aeac36925a4ce0df0221ffba1e0c5ba41fc33de0b8c0937229e353f2f758e101a873e0eab76ed46408fe71990c0001088612ecef50c0f3a22fba17646db
7
- data.tar.gz: 2a7a709b48e9c0764c12b5a54be0846ecd08551245e92dd6028deb881c1ebff634514445a72cf28d24a6e31a5bdd90b12c6519e523e440977a7bfe9f767949a5
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
@@ -71,7 +71,7 @@ module Coradoc
71
71
 
72
72
  def monospace_constrained
73
73
  (str('`') >>
74
- match('[^`\n]').repeat(1).as(:text).repeat(1, 1) >>
74
+ constrained_span_content('`').as(:text).repeat(1, 1) >>
75
75
  str('`') >> str('`').absent?
76
76
  ).as(:monospace_constrained)
77
77
  end
@@ -236,6 +236,27 @@ module Coradoc
236
236
  ).repeat(1)
237
237
  end
238
238
 
239
+ # Content model for a constrained inline span (`` `…` ``, `*…*`,
240
+ # `_…_`, `#…#`). Allows the corresponding unconstrained marker
241
+ # pair (`` `` ``, `**`, `__`, `##`) to appear inside the content
242
+ # rather than terminating the span at the first marker character.
243
+ #
244
+ # Asciidoctor treats the contents of a constrained span as an
245
+ # inline literal — nested constrained markers do not close the
246
+ # span. Without this allowance, `` `<<\`\`x\`\`>>` `` fails to
247
+ # match as a single monospace span: the parser sees the inner
248
+ # `` `` `` as a failed single-backtick close attempt, backtracks
249
+ # out of `monospace_constrained`, and the `<<…>>` payload then
250
+ # fires the `cross_reference` rule with the backticks glued
251
+ # onto the target.
252
+ #
253
+ # Single source of truth for every constrained rule's content
254
+ # model — adding a new constrained marker reuses this helper
255
+ # rather than re-spelling the alternation (DRY).
256
+ def constrained_span_content(marker)
257
+ (match("[^#{marker}\n]") | str(marker * 2)).repeat(1)
258
+ end
259
+
239
260
  def text_formatted
240
261
  (inline_chars? >> inline)
241
262
  end
@@ -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.25'
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.25
4
+ version: 2.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.