coradoc 2.0.3 → 2.0.5
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 +4 -4
- data/.rubocop_todo.yml +24 -11
- data/coradoc-adoc/lib/coradoc/asciidoc/model/attached.rb +3 -0
- data/coradoc-adoc/lib/coradoc/asciidoc/model/base.rb +10 -0
- data/coradoc-adoc/lib/coradoc/asciidoc/model/break.rb +7 -0
- data/coradoc-adoc/lib/coradoc/asciidoc/model/comment_block.rb +4 -0
- data/coradoc-adoc/lib/coradoc/asciidoc/model/image/block_image.rb +4 -0
- data/coradoc-adoc/lib/coradoc/asciidoc/model/image/inline_image.rb +4 -0
- data/coradoc-adoc/lib/coradoc/asciidoc/model/inline/base.rb +3 -0
- data/coradoc-adoc/lib/coradoc/asciidoc/model/inline/hard_line_break.rb +3 -0
- data/coradoc-adoc/lib/coradoc/asciidoc/model/list/core.rb +4 -0
- data/coradoc-adoc/lib/coradoc/asciidoc/model/list/item.rb +0 -17
- data/coradoc-adoc/lib/coradoc/asciidoc/model/section.rb +4 -0
- data/coradoc-adoc/lib/coradoc/asciidoc/model/table.rb +4 -0
- data/coradoc-adoc/lib/coradoc/asciidoc/model/text_element.rb +4 -0
- data/coradoc-adoc/lib/coradoc/asciidoc/parser/base.rb +1 -0
- data/coradoc-adoc/lib/coradoc/asciidoc/parser/block.rb +5 -5
- data/coradoc-adoc/lib/coradoc/asciidoc/parser/content.rb +11 -3
- data/coradoc-adoc/lib/coradoc/asciidoc/parser/inline.rb +15 -15
- data/coradoc-adoc/lib/coradoc/asciidoc/parser/list.rb +2 -2
- data/coradoc-adoc/lib/coradoc/asciidoc/parser/section.rb +1 -0
- data/coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/base.rb +0 -11
- data/coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/document.rb +4 -1
- data/coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/list/item.rb +4 -10
- data/coradoc-adoc/lib/coradoc/asciidoc/serializer/spacing_strategy.rb +4 -18
- data/coradoc-adoc/lib/coradoc/asciidoc/transform/to_core_model.rb +12 -2
- data/coradoc-adoc/lib/coradoc/asciidoc/transform/to_core_model_registrations.rb +8 -1
- data/coradoc-adoc/lib/coradoc/asciidoc/transformer/misc_rules.rb +5 -0
- data/coradoc-adoc/lib/coradoc/asciidoc/transformer/structural_rules.rb +8 -8
- data/coradoc-adoc/lib/coradoc/asciidoc/transformer.rb +22 -5
- data/coradoc-adoc/spec/coradoc/asciidoc/integration_pipeline_spec.rb +344 -0
- data/coradoc-adoc/spec/coradoc/asciidoc/list_continuation_spec.rb +1 -1
- data/coradoc-adoc/spec/coradoc/asciidoc/model/base_spec.rb +16 -2
- data/coradoc-adoc/spec/coradoc/asciidoc/model/element_classification_spec.rb +146 -0
- data/coradoc-adoc/spec/coradoc/asciidoc/round_trip_spec.rb +0 -1
- data/coradoc-adoc/spec/coradoc/developer_experience_spec.rb +0 -1
- data/coradoc-html/spec/input/converters/converters_spec.rb +5 -7
- data/lib/coradoc/core_model/structural_element.rb +4 -0
- data/lib/coradoc/document_manipulator.rb +3 -1
- data/lib/coradoc/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ba4d5d05249449db87eabe01151f28977069d451c5d8b3069d8c7c59238e05df
|
|
4
|
+
data.tar.gz: 225bfd2be3033634b97443c5949ca0a4c9851c4a2cdfdbfe7059edbdd6d44d1d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e5fce433e6b057839f9cb93efc4ac9722dcf812046667082121586a975f273da925d5a87c2cd3c46cd0456dd06f104c36df51a3f9012a043f8ec04674c7fa7ea
|
|
7
|
+
data.tar.gz: df5ee8e79dad51920ee9a5bc89ddd90f159396d2cd76c8956323b1439129ea6f9f56c2a6b2f5b2cad518c5c93fd0c04a0668006126deb1cda33d7651b6d0137a
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on 2026-05-
|
|
3
|
+
# on 2026-05-08 15:00:33 UTC using RuboCop version 1.75.8.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
@@ -29,6 +29,12 @@ Layout/ClosingParenthesisIndentation:
|
|
|
29
29
|
Exclude:
|
|
30
30
|
- 'lib/coradoc/document_manipulator.rb'
|
|
31
31
|
|
|
32
|
+
# Offense count: 1
|
|
33
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
34
|
+
Layout/EmptyLineAfterGuardClause:
|
|
35
|
+
Exclude:
|
|
36
|
+
- 'coradoc-adoc/spec/coradoc/asciidoc/integration_pipeline_spec.rb'
|
|
37
|
+
|
|
32
38
|
# Offense count: 1
|
|
33
39
|
# This cop supports safe autocorrection (--autocorrect).
|
|
34
40
|
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
|
@@ -133,7 +139,7 @@ Lint/Void:
|
|
|
133
139
|
Exclude:
|
|
134
140
|
- 'coradoc-html/lib/coradoc/html.rb'
|
|
135
141
|
|
|
136
|
-
# Offense count:
|
|
142
|
+
# Offense count: 237
|
|
137
143
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
|
138
144
|
Metrics/AbcSize:
|
|
139
145
|
Max: 178
|
|
@@ -142,7 +148,7 @@ Metrics/AbcSize:
|
|
|
142
148
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
|
|
143
149
|
# AllowedMethods: refine
|
|
144
150
|
Metrics/BlockLength:
|
|
145
|
-
Max:
|
|
151
|
+
Max: 151
|
|
146
152
|
|
|
147
153
|
# Offense count: 4
|
|
148
154
|
# Configuration parameters: CountBlocks, CountModifierForms.
|
|
@@ -154,12 +160,12 @@ Metrics/BlockNesting:
|
|
|
154
160
|
Metrics/ClassLength:
|
|
155
161
|
Max: 556
|
|
156
162
|
|
|
157
|
-
# Offense count:
|
|
163
|
+
# Offense count: 180
|
|
158
164
|
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
159
165
|
Metrics/CyclomaticComplexity:
|
|
160
166
|
Max: 32
|
|
161
167
|
|
|
162
|
-
# Offense count:
|
|
168
|
+
# Offense count: 385
|
|
163
169
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
164
170
|
Metrics/MethodLength:
|
|
165
171
|
Max: 246
|
|
@@ -201,11 +207,12 @@ Naming/MethodName:
|
|
|
201
207
|
Exclude:
|
|
202
208
|
- 'coradoc-markdown/lib/coradoc/markdown.rb'
|
|
203
209
|
|
|
204
|
-
# Offense count:
|
|
210
|
+
# Offense count: 20
|
|
205
211
|
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
|
206
212
|
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
|
|
207
213
|
Naming/MethodParameterName:
|
|
208
214
|
Exclude:
|
|
215
|
+
- 'coradoc-adoc/spec/coradoc/asciidoc/integration_pipeline_spec.rb'
|
|
209
216
|
- 'coradoc-docx/lib/coradoc/docx/transform/from_core_model.rb'
|
|
210
217
|
- 'coradoc-docx/lib/coradoc/docx/transform/rules/run_rule.rb'
|
|
211
218
|
- 'coradoc-html/lib/coradoc/html/converters/base.rb'
|
|
@@ -246,12 +253,12 @@ RSpec/BeforeAfterAll:
|
|
|
246
253
|
- '**/spec/support/**/*.rb'
|
|
247
254
|
- 'spec/benchmark/performance_spec.rb'
|
|
248
255
|
|
|
249
|
-
# Offense count:
|
|
256
|
+
# Offense count: 21
|
|
250
257
|
# Configuration parameters: IgnoredMetadata.
|
|
251
258
|
RSpec/DescribeClass:
|
|
252
259
|
Enabled: false
|
|
253
260
|
|
|
254
|
-
# Offense count:
|
|
261
|
+
# Offense count: 500
|
|
255
262
|
# Configuration parameters: CountAsOne.
|
|
256
263
|
RSpec/ExampleLength:
|
|
257
264
|
Max: 36
|
|
@@ -302,7 +309,7 @@ RSpec/MessageSpies:
|
|
|
302
309
|
RSpec/MultipleDescribes:
|
|
303
310
|
Enabled: false
|
|
304
311
|
|
|
305
|
-
# Offense count:
|
|
312
|
+
# Offense count: 628
|
|
306
313
|
RSpec/MultipleExpectations:
|
|
307
314
|
Max: 12
|
|
308
315
|
|
|
@@ -381,7 +388,7 @@ Style/ClassVars:
|
|
|
381
388
|
- 'coradoc-adoc/lib/coradoc/asciidoc/serializer/element_registry.rb'
|
|
382
389
|
- 'coradoc-html/lib/coradoc/html/input/converters.rb'
|
|
383
390
|
|
|
384
|
-
# Offense count:
|
|
391
|
+
# Offense count: 292
|
|
385
392
|
# Configuration parameters: AllowedConstants.
|
|
386
393
|
Style/Documentation:
|
|
387
394
|
Enabled: false
|
|
@@ -417,6 +424,12 @@ Style/HashLikeCase:
|
|
|
417
424
|
- 'coradoc-html/lib/coradoc/html/input/converters/table.rb'
|
|
418
425
|
- 'coradoc-html/lib/coradoc/html/input/converters/td.rb'
|
|
419
426
|
|
|
427
|
+
# Offense count: 5
|
|
428
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
429
|
+
Style/IfUnlessModifier:
|
|
430
|
+
Exclude:
|
|
431
|
+
- 'coradoc-adoc/spec/coradoc/asciidoc/integration_pipeline_spec.rb'
|
|
432
|
+
|
|
420
433
|
# Offense count: 1
|
|
421
434
|
# This cop supports safe autocorrection (--autocorrect).
|
|
422
435
|
Style/MultilineIfModifier:
|
|
@@ -445,7 +458,7 @@ Style/StringConcatenation:
|
|
|
445
458
|
Exclude:
|
|
446
459
|
- 'coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/document_attributes.rb'
|
|
447
460
|
|
|
448
|
-
# Offense count:
|
|
461
|
+
# Offense count: 43
|
|
449
462
|
# This cop supports safe autocorrection (--autocorrect).
|
|
450
463
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
|
|
451
464
|
# URISchemes: http, https
|
|
@@ -35,6 +35,16 @@ module Coradoc
|
|
|
35
35
|
|
|
36
36
|
attribute :id, :string
|
|
37
37
|
|
|
38
|
+
# Element classification for spacing and serialization decisions.
|
|
39
|
+
# Subclasses override these to declare their level.
|
|
40
|
+
def block_level?
|
|
41
|
+
false
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def inline?
|
|
45
|
+
false
|
|
46
|
+
end
|
|
47
|
+
|
|
38
48
|
# Generate a warning message whenever this method is called.
|
|
39
49
|
def simplify_block_content(content)
|
|
40
50
|
warn '[DEPRECATION] #simplify_block_content is called inside a Lutaml Model. This is still a WIP.'
|
|
@@ -20,6 +20,13 @@ module Coradoc
|
|
|
20
20
|
#
|
|
21
21
|
class ThematicBreak < Base
|
|
22
22
|
end
|
|
23
|
+
|
|
24
|
+
# Page break for AsciiDoc documents.
|
|
25
|
+
#
|
|
26
|
+
# Represented by <<< in AsciiDoc. Layout-only element;
|
|
27
|
+
# has no CoreModel equivalent and is filtered during ToCoreModel.
|
|
28
|
+
class PageBreak < Base
|
|
29
|
+
end
|
|
23
30
|
end
|
|
24
31
|
end
|
|
25
32
|
end
|
|
@@ -5,6 +5,10 @@ module Coradoc
|
|
|
5
5
|
module Model
|
|
6
6
|
module Image
|
|
7
7
|
class BlockImage < Coradoc::AsciiDoc::Model::Image::Core
|
|
8
|
+
def block_level?
|
|
9
|
+
true
|
|
10
|
+
end
|
|
11
|
+
|
|
8
12
|
# Autoload nested AttributeList class
|
|
9
13
|
autoload :AttributeList, 'coradoc/asciidoc/model/image/block_image/attribute_list'
|
|
10
14
|
|
|
@@ -65,23 +65,6 @@ module Coradoc
|
|
|
65
65
|
initialize_empty: true
|
|
66
66
|
|
|
67
67
|
attribute :nested, Coradoc::AsciiDoc::Model::List::Nestable
|
|
68
|
-
|
|
69
|
-
HARDBREAK_MARKERS = %i[hardbreak init].freeze
|
|
70
|
-
STRIP_UNICODE_BEGIN_MARKERS = (HARDBREAK_MARKERS.dup + [false]).freeze
|
|
71
|
-
STRIP_UNICODE_END_MARKERS = [:hardbreak, :end, false].freeze
|
|
72
|
-
|
|
73
|
-
def inline?(elem)
|
|
74
|
-
case elem
|
|
75
|
-
when Inline::HardLineBreak
|
|
76
|
-
:hardbreak
|
|
77
|
-
when ->(i) { i.class.name.to_s.include? '::Inline::' }
|
|
78
|
-
true
|
|
79
|
-
when String, TextElement, Image::InlineImage
|
|
80
|
-
true
|
|
81
|
-
else
|
|
82
|
-
false
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
68
|
end
|
|
86
69
|
end
|
|
87
70
|
end
|
|
@@ -76,7 +76,7 @@ module Coradoc
|
|
|
76
76
|
def block_content(n_deep = 3)
|
|
77
77
|
c = block_image |
|
|
78
78
|
list |
|
|
79
|
-
text_line |
|
|
79
|
+
text_line(false, unguarded: true) |
|
|
80
80
|
empty_line.as(:line_break)
|
|
81
81
|
c |= block(n_deep - 1) if n_deep.positive?
|
|
82
82
|
c.repeat(1)
|
|
@@ -124,7 +124,7 @@ module Coradoc
|
|
|
124
124
|
closing_pattern = str(delim_str) >> newline
|
|
125
125
|
|
|
126
126
|
# Build content that doesn't match the closing delimiter
|
|
127
|
-
content = block_image | list | text_line | empty_line.as(:line_break)
|
|
127
|
+
content = block_image | list | text_line(false, unguarded: true) | empty_line.as(:line_break)
|
|
128
128
|
if n_deep.positive?
|
|
129
129
|
# For nested blocks, also prevent them from consuming the closing delimiter
|
|
130
130
|
content |= block(n_deep - 1)
|
|
@@ -139,7 +139,7 @@ module Coradoc
|
|
|
139
139
|
line_start? >>
|
|
140
140
|
current_delimiter.as(:delimiter) >> newline >>
|
|
141
141
|
if type == :pass
|
|
142
|
-
(text_line | empty_line.as(:line_break)).repeat(1).as(:lines)
|
|
142
|
+
(text_line(false, unguarded: true) | empty_line.as(:line_break)).repeat(1).as(:lines)
|
|
143
143
|
else
|
|
144
144
|
# Use dynamic block content that respects closing delimiter
|
|
145
145
|
block_content_with_closing.as(:lines)
|
|
@@ -161,7 +161,7 @@ module Coradoc
|
|
|
161
161
|
delim_str = c.captures[:delimit].to_s.strip
|
|
162
162
|
closing_pattern = str(delim_str) >> newline
|
|
163
163
|
|
|
164
|
-
content = block_image | list | text_line | empty_line.as(:line_break)
|
|
164
|
+
content = block_image | list | text_line(false, unguarded: true) | empty_line.as(:line_break)
|
|
165
165
|
content |= block(n_deep - 1) if n_deep.positive?
|
|
166
166
|
|
|
167
167
|
(closing_pattern.absent? >> content).repeat(1)
|
|
@@ -172,7 +172,7 @@ module Coradoc
|
|
|
172
172
|
line_start? >>
|
|
173
173
|
current_delimiter.as(:delimiter) >> newline >>
|
|
174
174
|
if type == :pass
|
|
175
|
-
(text_line | empty_line.as(:line_break)).repeat(1).as(:lines)
|
|
175
|
+
(text_line(false, unguarded: true) | empty_line.as(:line_break)).repeat(1).as(:lines)
|
|
176
176
|
else
|
|
177
177
|
block_content_with_closing.as(:lines)
|
|
178
178
|
end >>
|
|
@@ -22,9 +22,13 @@ module Coradoc
|
|
|
22
22
|
|
|
23
23
|
# Text
|
|
24
24
|
# :zero :one :many
|
|
25
|
-
def text_line(many_breaks = false)
|
|
26
|
-
tl =
|
|
27
|
-
|
|
25
|
+
def text_line(many_breaks = false, unguarded: false)
|
|
26
|
+
tl = if unguarded
|
|
27
|
+
literal_space? >> text_any.as(:text)
|
|
28
|
+
else
|
|
29
|
+
(asciidoc_char_with_id.absent? | element_id_inline) >>
|
|
30
|
+
literal_space? >> text_any.as(:text)
|
|
31
|
+
end
|
|
28
32
|
if many_breaks
|
|
29
33
|
tl >> (line_ending.repeat(1).as(:line_break) | eof?)
|
|
30
34
|
else
|
|
@@ -60,6 +64,10 @@ module Coradoc
|
|
|
60
64
|
def glossaries
|
|
61
65
|
glossary.repeat(1)
|
|
62
66
|
end
|
|
67
|
+
|
|
68
|
+
def page_break
|
|
69
|
+
str('<<<') >> line_ending
|
|
70
|
+
end
|
|
63
71
|
end
|
|
64
72
|
end
|
|
65
73
|
end
|
|
@@ -12,7 +12,7 @@ module Coradoc
|
|
|
12
12
|
|
|
13
13
|
def bold_constrained
|
|
14
14
|
(str('*').present? >> str('*') >>
|
|
15
|
-
match('[
|
|
15
|
+
match('[^*\n]').repeat(1).as(:text).repeat(1, 1) >>
|
|
16
16
|
str('*') >> str('*').absent? >>
|
|
17
17
|
str("\n\n").absent?
|
|
18
18
|
).as(:bold_constrained)
|
|
@@ -20,7 +20,7 @@ module Coradoc
|
|
|
20
20
|
|
|
21
21
|
def bold_unconstrained
|
|
22
22
|
(str('**').present? >> str('**') >>
|
|
23
|
-
match('[
|
|
23
|
+
match('[^*\n]').repeat(1).as(:text).repeat(1, 1) >>
|
|
24
24
|
str('**')
|
|
25
25
|
).as(:bold_unconstrained)
|
|
26
26
|
end
|
|
@@ -28,7 +28,7 @@ module Coradoc
|
|
|
28
28
|
def span_constrained
|
|
29
29
|
(attribute_list >>
|
|
30
30
|
str('#') >>
|
|
31
|
-
match('[
|
|
31
|
+
match('[^#\n]').repeat(1).as(:text) >>
|
|
32
32
|
str('#') >> str('#').absent?
|
|
33
33
|
).as(:span_constrained)
|
|
34
34
|
end
|
|
@@ -36,63 +36,63 @@ module Coradoc
|
|
|
36
36
|
def span_unconstrained
|
|
37
37
|
(attribute_list >>
|
|
38
38
|
str('##') >>
|
|
39
|
-
match('[
|
|
39
|
+
match('[^#\n]').repeat(1).as(:text) >>
|
|
40
40
|
str('##')
|
|
41
41
|
).as(:span_unconstrained)
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def italic_constrained
|
|
45
45
|
(str('_') >> str('_').absent? >>
|
|
46
|
-
match('[^_]').repeat(1).as(:text).repeat(1, 1) >>
|
|
46
|
+
match('[^_\n]').repeat(1).as(:text).repeat(1, 1) >>
|
|
47
47
|
str('_') >> str('_').absent?
|
|
48
48
|
).as(:italic_constrained)
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def italic_unconstrained
|
|
52
52
|
(str('__') >>
|
|
53
|
-
match('[^_]').repeat(1).as(:text).repeat(1, 1) >>
|
|
53
|
+
match('[^_\n]').repeat(1).as(:text).repeat(1, 1) >>
|
|
54
54
|
str('__')
|
|
55
55
|
).as(:italic_unconstrained)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
def highlight_constrained
|
|
59
59
|
(str('#') >>
|
|
60
|
-
match('[
|
|
60
|
+
match('[^#\n]').repeat(1).as(:text).repeat(1, 1) >>
|
|
61
61
|
str('#') >> str('#').absent?
|
|
62
62
|
).as(:highlight_constrained)
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
def highlight_unconstrained
|
|
66
66
|
(str('##') >>
|
|
67
|
-
match('[
|
|
67
|
+
match('[^#\n]').repeat(1).as(:text).repeat(1, 1) >>
|
|
68
68
|
str('##')
|
|
69
69
|
).as(:highlight_unconstrained)
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
def monospace_constrained
|
|
73
73
|
(str('`') >>
|
|
74
|
-
match('[
|
|
74
|
+
match('[^`\n]').repeat(1).as(:text).repeat(1, 1) >>
|
|
75
75
|
str('`') >> str('`').absent?
|
|
76
76
|
).as(:monospace_constrained)
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
def monospace_unconstrained
|
|
80
80
|
(str('``') >>
|
|
81
|
-
match('[
|
|
81
|
+
match('[^`\n]').repeat(1).as(:text).repeat(1, 1) >>
|
|
82
82
|
str('``')
|
|
83
83
|
).as(:monospace_unconstrained)
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
def superscript
|
|
87
87
|
(str('^') >>
|
|
88
|
-
match('[
|
|
88
|
+
match('[^^\n]').repeat(1).as(:text).repeat(1, 1) >>
|
|
89
89
|
str('^')
|
|
90
90
|
).as(:superscript)
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
def subscript
|
|
94
94
|
(str('~') >>
|
|
95
|
-
match('[
|
|
95
|
+
match('[^~\n]').repeat(1).as(:text).repeat(1, 1) >>
|
|
96
96
|
str('~')
|
|
97
97
|
).as(:subscript)
|
|
98
98
|
end
|
|
@@ -100,7 +100,7 @@ module Coradoc
|
|
|
100
100
|
def span
|
|
101
101
|
attribute_list >>
|
|
102
102
|
(str('#') >>
|
|
103
|
-
match('[
|
|
103
|
+
match('[^#\n]').repeat(1).as(:text) >>
|
|
104
104
|
str('#') >> str('#').absent?
|
|
105
105
|
).as(:span)
|
|
106
106
|
end
|
|
@@ -126,7 +126,7 @@ module Coradoc
|
|
|
126
126
|
def underline
|
|
127
127
|
(attribute_list >> match('\\[.underline\\]').as(:role) >>
|
|
128
128
|
str('#') >>
|
|
129
|
-
match('[
|
|
129
|
+
match('[^#\n]').repeat(1).as(:text) >>
|
|
130
130
|
str('#')
|
|
131
131
|
).as(:underline)
|
|
132
132
|
end
|
|
@@ -134,7 +134,7 @@ module Coradoc
|
|
|
134
134
|
def small
|
|
135
135
|
(attribute_list >> match('\\[.small\\]').as(:role) >>
|
|
136
136
|
str('#') >>
|
|
137
|
-
match('[
|
|
137
|
+
match('[^#\n]').repeat(1).as(:text) >>
|
|
138
138
|
str('#')
|
|
139
139
|
).as(:small)
|
|
140
140
|
end
|
|
@@ -55,7 +55,7 @@ module Coradoc
|
|
|
55
55
|
|
|
56
56
|
def olist_item(nesting_level = 1)
|
|
57
57
|
item = olist_marker(nesting_level).as(:marker) >>
|
|
58
|
-
match("\n").absent? >> space >> text_line(true)
|
|
58
|
+
match("\n").absent? >> space >> text_line(true, unguarded: true)
|
|
59
59
|
# >>
|
|
60
60
|
# (list_continuation.present? >> list_continuation >>
|
|
61
61
|
# paragraph #| example_block(n_deep: 1)
|
|
@@ -86,7 +86,7 @@ module Coradoc
|
|
|
86
86
|
def ulist_item(nesting_level = 1)
|
|
87
87
|
item = ulist_marker(nesting_level).as(:marker) >>
|
|
88
88
|
str(' [[[').absent? >>
|
|
89
|
-
match("\n").absent? >> space >> text_line(true)
|
|
89
|
+
match("\n").absent? >> space >> text_line(true, unguarded: true)
|
|
90
90
|
|
|
91
91
|
att = (list_continuation.present? >>
|
|
92
92
|
list_continuation >>
|
|
@@ -120,17 +120,6 @@ module Coradoc
|
|
|
120
120
|
end
|
|
121
121
|
end
|
|
122
122
|
|
|
123
|
-
# Helper to check if element is block-level
|
|
124
|
-
# @param element [Object] Element to check
|
|
125
|
-
# @return [Boolean] True if block-level
|
|
126
|
-
def block_level_element?(element)
|
|
127
|
-
element.is_a?(Coradoc::AsciiDoc::Model::Block::Core) ||
|
|
128
|
-
element.is_a?(Coradoc::AsciiDoc::Model::Section) ||
|
|
129
|
-
element.is_a?(Coradoc::AsciiDoc::Model::Paragraph) ||
|
|
130
|
-
element.is_a?(Coradoc::AsciiDoc::Model::List) ||
|
|
131
|
-
element.is_a?(Coradoc::AsciiDoc::Model::Table)
|
|
132
|
-
end
|
|
133
|
-
|
|
134
123
|
# Helper to add spacing between elements
|
|
135
124
|
# @param elements [Array] Elements to space
|
|
136
125
|
# @param options [Hash] Spacing options
|
|
@@ -31,7 +31,10 @@ module Coradoc
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
# Only serialize document_attributes if it has data
|
|
34
|
-
|
|
34
|
+
if @model.document_attributes&.data && !@model.document_attributes.data.empty?
|
|
35
|
+
parts << serialize_child(@model.document_attributes,
|
|
36
|
+
@context)
|
|
37
|
+
end
|
|
35
38
|
|
|
36
39
|
# Serialize sections with last_element tracking
|
|
37
40
|
parts << serialize_sections_with_last_element if @model.sections && !@model.sections.empty?
|
|
@@ -94,16 +94,10 @@ module Coradoc
|
|
|
94
94
|
private
|
|
95
95
|
|
|
96
96
|
def inline?(elem)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
true
|
|
102
|
-
when String, Coradoc::AsciiDoc::Model::TextElement, Coradoc::AsciiDoc::Model::Image::InlineImage
|
|
103
|
-
true
|
|
104
|
-
else
|
|
105
|
-
false
|
|
106
|
-
end
|
|
97
|
+
return true if elem.is_a?(String)
|
|
98
|
+
return false unless elem.is_a?(Coradoc::AsciiDoc::Model::Base)
|
|
99
|
+
|
|
100
|
+
elem.inline?
|
|
107
101
|
end
|
|
108
102
|
|
|
109
103
|
def gen_anchor(inline: false)
|
|
@@ -47,19 +47,11 @@ module Coradoc
|
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
# Check if element is block-level
|
|
51
|
-
# @param element [Object] Element to check
|
|
52
|
-
# @return [Boolean] True if block-level
|
|
53
50
|
def block_level?(element)
|
|
54
51
|
return false if element.nil?
|
|
52
|
+
return true if element.is_a?(String)
|
|
55
53
|
|
|
56
|
-
element.
|
|
57
|
-
element.is_a?(Coradoc::AsciiDoc::Model::Section) ||
|
|
58
|
-
element.is_a?(Coradoc::AsciiDoc::Model::Paragraph) ||
|
|
59
|
-
element.is_a?(Coradoc::AsciiDoc::Model::List) ||
|
|
60
|
-
element.is_a?(Coradoc::AsciiDoc::Model::Table) ||
|
|
61
|
-
element.is_a?(Coradoc::AsciiDoc::Model::CommentBlock) ||
|
|
62
|
-
element.is_a?(Coradoc::AsciiDoc::Model::Admonition)
|
|
54
|
+
element.block_level?
|
|
63
55
|
end
|
|
64
56
|
|
|
65
57
|
# Check if element is inline-level
|
|
@@ -67,15 +59,9 @@ module Coradoc
|
|
|
67
59
|
# @return [Boolean] True if inline-level
|
|
68
60
|
def inline_level?(element)
|
|
69
61
|
return false if element.nil?
|
|
62
|
+
return true if element.is_a?(String)
|
|
70
63
|
|
|
71
|
-
element.
|
|
72
|
-
element.is_a?(Coradoc::AsciiDoc::Model::TextElement) ||
|
|
73
|
-
element.is_a?(Coradoc::AsciiDoc::Model::Inline::Bold) ||
|
|
74
|
-
element.is_a?(Coradoc::AsciiDoc::Model::Inline::Italic) ||
|
|
75
|
-
element.is_a?(Coradoc::AsciiDoc::Model::Inline::Monospace) ||
|
|
76
|
-
element.is_a?(Coradoc::AsciiDoc::Model::Inline::Highlight) ||
|
|
77
|
-
element.is_a?(Coradoc::AsciiDoc::Model::Inline::Superscript) ||
|
|
78
|
-
element.is_a?(Coradoc::AsciiDoc::Model::Inline::Subscript)
|
|
64
|
+
element.inline?
|
|
79
65
|
end
|
|
80
66
|
end
|
|
81
67
|
end
|