coradoc-adoc 2.0.14 → 2.0.15

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: 36de3b63e2c80a4abafb35c88ca1ba80eb52603af631191e16f26d6482a5398c
4
- data.tar.gz: 53026d0cf6835c5824636ffd6455f2baceecc3ffdd510cc26c8b79910c180c4f
3
+ metadata.gz: 258eb5dcb2991ad51c70456519c056ae29672aeee86cde93e5eeb20a32d5427d
4
+ data.tar.gz: c19119a118adc0121d5d627287bd435349a09647636729a57dd0ce005de5a2f1
5
5
  SHA512:
6
- metadata.gz: 8c51394ca9c3bde2a4d7c329e01648ae54d51d6e95e767a85cbaedc8aac35894fccaa50a9d46bf629477d8ac897700b70fff92d060dcbc9acad7182f92913672
7
- data.tar.gz: 1bc422db9eeb898056d1a79150a1efdf81bddce0f0895cfc1760d9e6cc1953ccfc0d29aa2718da79c5e637ae1afca3565c8a08832950e4bfc0c3b102d3a4ea5a
6
+ metadata.gz: e7defb7e91f6db2f0b09d1a433d4f662254ebcb93c01125a419127881b9e15854c3f78c226b203dc8d818fc3c8d5f8615c05edfed2afced0f4f273881078b150
7
+ data.tar.gz: 17cc53fb4f42adcd77e2817a04087c2f49eec3643010905fecf1dfab887b936780a7a1b9e665bcbdd90a296b3fbaa7a070a7e98098364e87b7dda25d1d8879d9
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Coradoc
4
+ module AsciiDoc
5
+ module Model
6
+ module Inline
7
+ class Passthrough < Base
8
+ attribute :content, :string
9
+ attribute :form, :string, default: -> { 'triple' }
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -25,6 +25,7 @@ module Coradoc
25
25
  autoload :Small, 'coradoc/asciidoc/model/inline/small'
26
26
  autoload :Strikethrough, 'coradoc/asciidoc/model/inline/strikethrough'
27
27
  autoload :Stem, 'coradoc/asciidoc/model/inline/stem'
28
+ autoload :Passthrough, 'coradoc/asciidoc/model/inline/passthrough'
28
29
  end
29
30
  end
30
31
  end
@@ -27,6 +27,7 @@ module Coradoc
27
27
  source_block(n_deep) |
28
28
  quote_block(n_deep) |
29
29
  pass_block(n_deep) |
30
+ literal_block(n_deep) |
30
31
  open_block(n_deep)).as(:block)
31
32
  end
32
33
 
@@ -35,7 +36,7 @@ module Coradoc
35
36
  end
36
37
 
37
38
  def pass_block(n_deep)
38
- block_style(n_deep, '+', 4, :pass)
39
+ block_style(n_deep, '+', 4, verbatim: true)
39
40
  end
40
41
 
41
42
  def quote_block(n_deep)
@@ -50,13 +51,18 @@ module Coradoc
50
51
  block_style(n_deep, '-', 4, verbatim: true)
51
52
  end
52
53
 
54
+ def literal_block(n_deep)
55
+ block_style(n_deep, '.', 4, verbatim: true)
56
+ end
57
+
53
58
  # Open block: exactly 2 dashes (cannot nest within itself)
54
59
  def open_block(n_deep)
55
60
  block_style_exact(n_deep, '-', 2)
56
61
  end
57
62
 
58
63
  def block_title
59
- str('.') >> space.absent? >> text.as(:title) >> newline
64
+ (line_start? >> block_delimiter.absent?) >>
65
+ str('.') >> space.absent? >> text.as(:title) >> newline
60
66
  end
61
67
 
62
68
  def block_type(type)
@@ -83,6 +89,7 @@ module Coradoc
83
89
  str('=') |
84
90
  str('_') |
85
91
  str('+') |
92
+ str('.') |
86
93
  str('-')).repeat(4) | # 4+ characters for most blocks
87
94
  str('-').repeat(2, 2)) >> # Exactly 2 for open block
88
95
  newline
@@ -90,10 +97,10 @@ module Coradoc
90
97
 
91
98
  # Block style parser with variable delimiter length
92
99
  # @param n_deep [Integer] Nesting depth for nested blocks
93
- # @param delimiter [String] The delimiter character ("=", "-", "_", "*", "+")
100
+ # @param delimiter [String] The delimiter character ("=", "-", "_", "*", "+", ".")
94
101
  # @param repeater [Integer] Minimum number of delimiter characters (default: 4)
95
- # @param type [Symbol] Block type for special handling (e.g., :pass)
96
- def block_style(n_deep = 3, delimiter = '*', repeater = 4, type = nil, verbatim: false)
102
+ # @param verbatim [Boolean] Treat body as raw text (no substitutions, no nested blocks)
103
+ def block_style(n_deep = 3, delimiter = '*', repeater = 4, verbatim: false)
97
104
  capture_key = :"delimit_#{delimiter}_#{n_deep}"
98
105
  current_delimiter = str(delimiter).repeat(repeater).capture(capture_key)
99
106
  closing_delimiter = dynamic do |_s, c|
@@ -104,9 +111,9 @@ module Coradoc
104
111
  delim_str = c.captures[capture_key].to_s.strip
105
112
  closing_pattern = str(delim_str) >> newline
106
113
 
107
- # Verbatim blocks (source/listing) treat their body as literal
108
- # text per the AsciiDoc spec — no substitutions, no nested
109
- # blocks. Allowing nested block parsing here would consume
114
+ # Verbatim blocks (source/listing/literal/pass) treat their body
115
+ # as literal text per the AsciiDoc spec — no substitutions, no
116
+ # nested blocks. Allowing nested block parsing here would consume
110
117
  # shorter inner delimiters (e.g. `----` inside `------`) and
111
118
  # strip the original structure when serializing back.
112
119
  content = if verbatim
@@ -127,18 +134,14 @@ module Coradoc
127
134
  block_header >>
128
135
  line_start? >>
129
136
  current_delimiter.as(:delimiter) >> newline >>
130
- if type == :pass
131
- (text_line(false, unguarded: true, verbatim: verbatim) | empty_line.as(:line_break)).repeat(1).as(:lines)
132
- else
133
- block_content_with_closing.as(:lines)
134
- end >>
137
+ block_content_with_closing.as(:lines) >>
135
138
  line_start? >>
136
139
  closing_delimiter >> newline
137
140
  end
138
141
 
139
142
  # Block style parser with EXACT delimiter length (for open blocks)
140
143
  # Open blocks use exactly 2 dashes and cannot nest within themselves
141
- def block_style_exact(n_deep = 3, delimiter = '-', exact_chars = 2, type = nil)
144
+ def block_style_exact(n_deep = 3, delimiter = '-', exact_chars = 2)
142
145
  capture_key = :"delimit_#{delimiter}_exact_#{exact_chars}_#{n_deep}"
143
146
  current_delimiter = str(delimiter).repeat(exact_chars, exact_chars).capture(capture_key)
144
147
  closing_delimiter = dynamic do |_s, c|
@@ -161,11 +164,7 @@ module Coradoc
161
164
  block_header >>
162
165
  line_start? >>
163
166
  current_delimiter.as(:delimiter) >> newline >>
164
- if type == :pass
165
- (text_line(false, unguarded: true) | empty_line.as(:line_break)).repeat(1).as(:lines)
166
- else
167
- block_content_with_closing.as(:lines)
168
- end >>
167
+ block_content_with_closing.as(:lines) >>
169
168
  line_start? >>
170
169
  closing_delimiter >> newline
171
170
  end
@@ -123,6 +123,16 @@ module Coradoc
123
123
  ).as(:inline_image)
124
124
  end
125
125
 
126
+ # Triple-plus inline passthrough: `+++raw content+++`. The content
127
+ # passes through all substitutions verbatim. Common use is to embed
128
+ # raw HTML in AsciiDoc documents.
129
+ def inline_passthrough
130
+ (str('+++') >>
131
+ (str('+++').absent? >> match('[^\n]')).repeat(1).as(:raw) >>
132
+ str('+++')
133
+ ).as(:inline_passthrough)
134
+ end
135
+
126
136
  def underline
127
137
  (attribute_list >> match('\\[.underline\\]').as(:role) >>
128
138
  str('#') >>
@@ -145,6 +155,7 @@ module Coradoc
145
155
  str('https').present? |
146
156
  str('link:').present? |
147
157
  str('image:').present? |
158
+ str('+++').present? |
148
159
  term_type.present? |
149
160
  str('footnote').present? |
150
161
  stem_type.present?
@@ -171,6 +182,7 @@ module Coradoc
171
182
  stem |
172
183
  link |
173
184
  inline_image |
185
+ inline_passthrough |
174
186
  underline |
175
187
  small
176
188
  end
@@ -84,7 +84,8 @@ module Coradoc
84
84
  def preceding_verbatim_block(result)
85
85
  last = result.last
86
86
  return nil unless last.is_a?(Coradoc::CoreModel::SourceBlock) ||
87
- last.is_a?(Coradoc::CoreModel::ListingBlock)
87
+ last.is_a?(Coradoc::CoreModel::ListingBlock) ||
88
+ last.is_a?(Coradoc::CoreModel::LiteralBlock)
88
89
 
89
90
  last
90
91
  end
@@ -158,6 +158,15 @@ module Coradoc
158
158
  )
159
159
  }
160
160
  )
161
+
162
+ Registry.register(
163
+ Coradoc::AsciiDoc::Model::Inline::Passthrough,
164
+ lambda { |model|
165
+ Coradoc::CoreModel::RawInlineElement.new(
166
+ content: model.content.to_s
167
+ )
168
+ }
169
+ )
161
170
  end
162
171
 
163
172
  def register_table_transformers!
@@ -25,6 +25,7 @@ module Coradoc
25
25
  }],
26
26
  ['=', 4, nil, ->(opts, attrs) { Model::Block::Example.new(**opts.merge(attributes: attrs)) }],
27
27
  ['+', 4, nil, ->(opts, attrs) { Model::Block::Pass.new(**opts.merge(attributes: attrs)) }],
28
+ ['.', 4, nil, ->(opts, attrs) { Model::Block::Literal.new(**opts.merge(attributes: attrs)) }],
28
29
  ['_', 4, nil, ->(opts, attrs) { Model::Block::Quote.new(**opts.merge(attributes: attrs)) }],
29
30
  ['-', 4, nil, ->(opts, attrs) { Model::Block::SourceCode.new(**opts.merge(attributes: attrs)) }],
30
31
  ['-', 2, 2, ->(opts, attrs) { Model::Block::Open.new(**opts.merge(attributes: attrs)) }]
@@ -43,6 +43,14 @@ module Coradoc
43
43
  )
44
44
  end
45
45
 
46
+ # Inline passthrough (`+++raw content+++`)
47
+ rule(inline_passthrough: subtree(:passthrough)) do
48
+ Model::Inline::Passthrough.new(
49
+ content: passthrough[:raw].to_s,
50
+ form: 'triple'
51
+ )
52
+ end
53
+
46
54
  # Attribute reference
47
55
  rule(attribute_reference: simple(:name)) do
48
56
  Model::Inline::AttributeReference.new(name:)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Coradoc
4
4
  module AsciiDoc
5
- VERSION = '2.0.14'
5
+ VERSION = '2.0.15'
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.14
4
+ version: 2.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -165,6 +165,7 @@ files:
165
165
  - lib/coradoc/asciidoc/model/inline/italic.rb
166
166
  - lib/coradoc/asciidoc/model/inline/link.rb
167
167
  - lib/coradoc/asciidoc/model/inline/monospace.rb
168
+ - lib/coradoc/asciidoc/model/inline/passthrough.rb
168
169
  - lib/coradoc/asciidoc/model/inline/quotation.rb
169
170
  - lib/coradoc/asciidoc/model/inline/small.rb
170
171
  - lib/coradoc/asciidoc/model/inline/span.rb