coradoc 2.0.1 → 2.0.3

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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +77 -146
  3. data/coradoc-adoc/lib/coradoc/asciidoc/model/base.rb +4 -3
  4. data/coradoc-adoc/lib/coradoc/asciidoc/model/document.rb +1 -1
  5. data/coradoc-adoc/lib/coradoc/asciidoc/model/include.rb +1 -1
  6. data/coradoc-adoc/lib/coradoc/asciidoc/model/resolver.rb +2 -2
  7. data/coradoc-adoc/lib/coradoc/asciidoc/model/serialization/asciidoc_transform.rb +3 -3
  8. data/coradoc-adoc/lib/coradoc/asciidoc/model/table_row.rb +1 -1
  9. data/coradoc-adoc/lib/coradoc/asciidoc/model/text_element.rb +4 -8
  10. data/coradoc-adoc/lib/coradoc/asciidoc/parse_error.rb +6 -6
  11. data/coradoc-adoc/lib/coradoc/asciidoc/serializer/adoc_serializer.rb +5 -10
  12. data/coradoc-adoc/lib/coradoc/asciidoc/serializer/formatter.rb +4 -3
  13. data/coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/base.rb +8 -20
  14. data/coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/block/core.rb +1 -1
  15. data/coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/document.rb +3 -6
  16. data/coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/inline/strikethrough.rb +1 -1
  17. data/coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/list/item.rb +5 -9
  18. data/coradoc-adoc/lib/coradoc/asciidoc/transform/from_core_model.rb +26 -34
  19. data/coradoc-adoc/lib/coradoc/asciidoc/transform/from_core_model_registrations.rb +18 -18
  20. data/coradoc-adoc/lib/coradoc/asciidoc/transform/to_core_model.rb +96 -123
  21. data/coradoc-adoc/lib/coradoc/asciidoc/transform/to_core_model_registrations.rb +10 -6
  22. data/coradoc-adoc/lib/coradoc/asciidoc/transformer/header_rules.rb +5 -5
  23. data/coradoc-adoc/lib/coradoc/asciidoc/transformer/list_rules.rb +2 -2
  24. data/coradoc-adoc/lib/coradoc/asciidoc/transformer/structural_rules.rb +1 -1
  25. data/coradoc-adoc/lib/coradoc/asciidoc/transformer.rb +5 -5
  26. data/coradoc-adoc/lib/coradoc/asciidoc.rb +1 -1
  27. data/coradoc-adoc/lib/coradoc/util/asciidoc.rb +4 -3
  28. data/coradoc-adoc/spec/coradoc/asciidoc/transform/from_core_model_spec.rb +4 -2
  29. data/coradoc-docx/lib/coradoc/docx/transform/context.rb +1 -1
  30. data/coradoc-docx/lib/coradoc/docx/transform/from_core_model.rb +13 -6
  31. data/coradoc-docx/lib/coradoc/docx/transform/numbering_resolver.rb +9 -7
  32. data/coradoc-docx/lib/coradoc/docx/transform/ordered_content.rb +2 -2
  33. data/coradoc-docx/lib/coradoc/docx/transform/rules/image_rule.rb +4 -1
  34. data/coradoc-docx/lib/coradoc/docx/transform/rules/math_rule.rb +2 -1
  35. data/coradoc-docx/lib/coradoc/docx/transform/rules/run_rule.rb +20 -30
  36. data/coradoc-docx/lib/coradoc/docx/transform/rules/simple_field_rule.rb +7 -5
  37. data/coradoc-docx/lib/coradoc/docx/transform/rules/table_rule.rb +3 -5
  38. data/coradoc-docx/lib/coradoc/docx/transform/style_resolver.rb +19 -24
  39. data/coradoc-docx/lib/coradoc/docx/transform/to_core_model.rb +18 -11
  40. data/coradoc-docx/lib/coradoc/docx.rb +6 -4
  41. data/coradoc-docx/spec/coradoc/docx/transform/from_core_model_spec.rb +5 -2
  42. data/coradoc-docx/spec/coradoc/docx/transform/rules/rule_unit_spec.rb +27 -7
  43. data/coradoc-docx/spec/coradoc/docx/transform/to_core_model_spec.rb +6 -2
  44. data/coradoc-html/lib/coradoc/html/base.rb +3 -7
  45. data/coradoc-html/lib/coradoc/html/converter_base.rb +5 -15
  46. data/coradoc-html/lib/coradoc/html/converters/base.rb +22 -28
  47. data/coradoc-html/lib/coradoc/html/converters/comment_line.rb +2 -2
  48. data/coradoc-html/lib/coradoc/html/converters/link.rb +1 -1
  49. data/coradoc-html/lib/coradoc/html/converters/list_item.rb +3 -3
  50. data/coradoc-html/lib/coradoc/html/converters/ordered.rb +1 -1
  51. data/coradoc-html/lib/coradoc/html/converters/span.rb +2 -2
  52. data/coradoc-html/lib/coradoc/html/converters/table.rb +3 -3
  53. data/coradoc-html/lib/coradoc/html/converters/table_cell.rb +14 -28
  54. data/coradoc-html/lib/coradoc/html/converters/table_row.rb +2 -2
  55. data/coradoc-html/lib/coradoc/html/converters/text_element.rb +1 -5
  56. data/coradoc-html/lib/coradoc/html/input/converters/a.rb +2 -2
  57. data/coradoc-html/lib/coradoc/html/input/converters/dl.rb +1 -1
  58. data/coradoc-html/lib/coradoc/html/input/converters/figure.rb +2 -2
  59. data/coradoc-html/lib/coradoc/html/input/converters/markup.rb +3 -3
  60. data/coradoc-html/lib/coradoc/html/input/converters/p.rb +1 -1
  61. data/coradoc-html/lib/coradoc/html/input/converters/td.rb +1 -1
  62. data/coradoc-html/lib/coradoc/html/input/converters.rb +1 -2
  63. data/coradoc-html/lib/coradoc/html/input/html_converter.rb +3 -3
  64. data/coradoc-html/lib/coradoc/html/input/plugin.rb +2 -2
  65. data/coradoc-html/lib/coradoc/html/renderer.rb +4 -6
  66. data/coradoc-html/lib/coradoc/html/theme/base.rb +2 -3
  67. data/coradoc-html/lib/coradoc/html/theme/classic_renderer.rb +9 -12
  68. data/coradoc-html/lib/coradoc/html/theme/modern/serializers/document_serializer.rb +3 -3
  69. data/coradoc-html/lib/coradoc/html.rb +1 -1
  70. data/coradoc-markdown/lib/coradoc/markdown/model/base.rb +6 -5
  71. data/coradoc-markdown/lib/coradoc/markdown/serializer.rb +2 -2
  72. data/coradoc-markdown/lib/coradoc/markdown/toc_generator.rb +4 -5
  73. data/coradoc-markdown/lib/coradoc/markdown/transform/from_core_model.rb +2 -2
  74. data/coradoc-markdown/lib/coradoc/markdown/transformer.rb +5 -3
  75. data/coradoc-markdown/lib/coradoc/markdown.rb +1 -1
  76. data/lib/coradoc/configurable.rb +6 -2
  77. data/lib/coradoc/coradoc.rb +18 -16
  78. data/lib/coradoc/core_model/base.rb +3 -3
  79. data/lib/coradoc/core_model/list_item.rb +3 -3
  80. data/lib/coradoc/core_model/toc_generator.rb +1 -1
  81. data/lib/coradoc/document_manipulator.rb +9 -13
  82. data/lib/coradoc/format_module.rb +16 -4
  83. data/lib/coradoc/input.rb +1 -1
  84. data/lib/coradoc/output.rb +1 -1
  85. data/lib/coradoc/query.rb +38 -186
  86. data/lib/coradoc/registry.rb +5 -7
  87. data/lib/coradoc/serializer/registry.rb +3 -5
  88. data/lib/coradoc/validation.rb +40 -21
  89. data/lib/coradoc/version.rb +1 -1
  90. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 728aadf584ed71846c925bd918143307f1a67c1c50b03e1d088dc232578a92d4
4
- data.tar.gz: 8588d96dc42f3710f6103220f150bedd86b6f445ddb9aa142f2af3322b1cb766
3
+ metadata.gz: 7f2699bddcd303d5c58e2f3e6a7d4c4341a8f06dc06df44785a97aa48ad7e055
4
+ data.tar.gz: 8e696cec10f047229d67806d5d93d21bcd02465ef57da243295f13906ccfc91d
5
5
  SHA512:
6
- metadata.gz: e88d156f5149cddb4f5f3f70765dfc67e4b0f8f44537034f0ea9bd55ef1553a2092a6edf2aa8ec51e0bca5e9622bc3e18da6680ef0aa7b4610eabdcdccf283c9
7
- data.tar.gz: 500056c39061e779033c830560c16026828e881f55f13ae97ebcf42d7d6acb4ef1a9383cfa628b126bfe5c6ad4357459b102b9fba12a1ce4f8396255861614cf
6
+ metadata.gz: 8b313846dc7365da7c399117c33119c28009df2009d478345157839c29e9bf30a152fb0000ab56c7202ea7cb784e661ba2a3b61bfa7a40f7616440182994f718
7
+ data.tar.gz: 42118e1947a3c609110786b7f906412080a79e518b02e101a4cc19d696e790849d93cdc049334829837a44a18308a34a03e3d6caf8fac83628a8119c1d35cfcc
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-04-22 10:56:31 UTC using RuboCop version 1.75.8.
3
+ # on 2026-05-07 12:19:03 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
@@ -17,39 +17,25 @@ Gemspec/RequiredRubyVersion:
17
17
 
18
18
  # Offense count: 1
19
19
  # This cop supports safe autocorrection (--autocorrect).
20
- # Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
21
- # SupportedStyles: case, end
22
- Layout/CaseIndentation:
20
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
21
+ # SupportedStyles: with_first_argument, with_fixed_indentation
22
+ Layout/ArgumentAlignment:
23
23
  Exclude:
24
- - 'coradoc-markdown/lib/coradoc/markdown/parser/ast_processor.rb'
24
+ - 'coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/document.rb'
25
25
 
26
26
  # Offense count: 1
27
27
  # This cop supports safe autocorrection (--autocorrect).
28
- # Configuration parameters: AllowForAlignment.
29
- Layout/CommentIndentation:
30
- Exclude:
31
- - 'coradoc-markdown/lib/coradoc/markdown/parser/ast_processor.rb'
32
-
33
- # Offense count: 2
34
- # This cop supports safe autocorrection (--autocorrect).
35
- Layout/ElseAlignment:
28
+ Layout/ClosingParenthesisIndentation:
36
29
  Exclude:
37
- - 'coradoc-markdown/lib/coradoc/markdown/parser/ast_processor.rb'
30
+ - 'lib/coradoc/document_manipulator.rb'
38
31
 
39
32
  # Offense count: 1
40
33
  # This cop supports safe autocorrection (--autocorrect).
41
- # Configuration parameters: EnforcedStyleAlignWith, Severity.
42
- # SupportedStylesAlignWith: keyword, variable, start_of_line
43
- Layout/EndAlignment:
44
- Exclude:
45
- - 'coradoc-markdown/lib/coradoc/markdown/parser/ast_processor.rb'
46
-
47
- # Offense count: 4
48
- # This cop supports safe autocorrection (--autocorrect).
49
- # Configuration parameters: Width, AllowedPatterns.
50
- Layout/IndentationWidth:
34
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
35
+ # SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
36
+ Layout/FirstArgumentIndentation:
51
37
  Exclude:
52
- - 'coradoc-markdown/lib/coradoc/markdown/parser/ast_processor.rb'
38
+ - 'lib/coradoc/document_manipulator.rb'
53
39
 
54
40
  # Offense count: 6
55
41
  # This cop supports safe autocorrection (--autocorrect).
@@ -58,33 +44,26 @@ Layout/IndentationWidth:
58
44
  Layout/LineLength:
59
45
  Max: 235
60
46
 
61
- # Offense count: 2
47
+ # Offense count: 1
62
48
  # This cop supports safe autocorrection (--autocorrect).
63
- # Configuration parameters: EnforcedStyle, IndentationWidth.
64
- # SupportedStyles: aligned, indented, indented_relative_to_receiver
65
- Layout/MultilineMethodCallIndentation:
49
+ # Configuration parameters: EnforcedStyle.
50
+ # SupportedStyles: symmetrical, new_line, same_line
51
+ Layout/MultilineMethodCallBraceLayout:
66
52
  Exclude:
67
- - 'coradoc-html/lib/coradoc/html/input/converters/h.rb'
53
+ - 'lib/coradoc/document_manipulator.rb'
68
54
 
69
55
  # Offense count: 1
70
56
  # This cop supports safe autocorrection (--autocorrect).
71
57
  # Configuration parameters: AllowInHeredoc.
72
58
  Layout/TrailingWhitespace:
73
59
  Exclude:
74
- - 'lib/coradoc/normalize.rb'
60
+ - 'coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/document.rb'
75
61
 
76
62
  # Offense count: 1
77
63
  Lint/BinaryOperatorWithIdenticalOperands:
78
64
  Exclude:
79
65
  - 'coradoc-html/lib/coradoc/html/converters/attribute_reference.rb'
80
66
 
81
- # Offense count: 2
82
- # Configuration parameters: AllowedMethods.
83
- # AllowedMethods: enums
84
- Lint/ConstantDefinitionInBlock:
85
- Exclude:
86
- - 'spec/transform/helpers_spec.rb'
87
-
88
67
  # Offense count: 3
89
68
  # This cop supports safe autocorrection (--autocorrect).
90
69
  # Configuration parameters: AutoCorrect, AllowComments.
@@ -100,12 +79,11 @@ Lint/EmptyWhen:
100
79
  Exclude:
101
80
  - 'coradoc-markdown/lib/coradoc/markdown/parser/ast_processor.rb'
102
81
 
103
- # Offense count: 7
82
+ # Offense count: 6
104
83
  Lint/IneffectiveAccessModifier:
105
84
  Exclude:
106
85
  - 'coradoc-html/lib/coradoc/html/spa.rb'
107
86
  - 'coradoc-html/lib/coradoc/html/static.rb'
108
- - 'lib/coradoc/configurable.rb'
109
87
 
110
88
  # Offense count: 4
111
89
  # Configuration parameters: AllowedParentClasses.
@@ -134,13 +112,17 @@ Lint/UnderscorePrefixedVariableName:
134
112
  - 'coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/title.rb'
135
113
  - 'coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/video.rb'
136
114
 
137
- # Offense count: 4
115
+ # Offense count: 1
116
+ Lint/UnreachableCode:
117
+ Exclude:
118
+ - 'coradoc-adoc/lib/coradoc/asciidoc/serializer/adoc_serializer.rb'
119
+
120
+ # Offense count: 3
138
121
  # This cop supports safe autocorrection (--autocorrect).
139
122
  # Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
140
123
  # NotImplementedExceptions: NotImplementedError
141
124
  Lint/UnusedMethodArgument:
142
125
  Exclude:
143
- - 'lib/coradoc/performance_regression.rb'
144
126
  - 'lib/coradoc/query.rb'
145
127
  - 'lib/coradoc/serializer/registry.rb'
146
128
 
@@ -151,12 +133,12 @@ Lint/Void:
151
133
  Exclude:
152
134
  - 'coradoc-html/lib/coradoc/html.rb'
153
135
 
154
- # Offense count: 240
136
+ # Offense count: 236
155
137
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
156
138
  Metrics/AbcSize:
157
139
  Max: 178
158
140
 
159
- # Offense count: 14
141
+ # Offense count: 15
160
142
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
161
143
  # AllowedMethods: refine
162
144
  Metrics/BlockLength:
@@ -172,31 +154,31 @@ Metrics/BlockNesting:
172
154
  Metrics/ClassLength:
173
155
  Max: 556
174
156
 
175
- # Offense count: 191
157
+ # Offense count: 181
176
158
  # Configuration parameters: AllowedMethods, AllowedPatterns.
177
159
  Metrics/CyclomaticComplexity:
178
- Max: 33
160
+ Max: 32
179
161
 
180
- # Offense count: 398
162
+ # Offense count: 384
181
163
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
182
164
  Metrics/MethodLength:
183
165
  Max: 246
184
166
 
185
- # Offense count: 22
167
+ # Offense count: 21
186
168
  # Configuration parameters: CountComments, CountAsOne.
187
169
  Metrics/ModuleLength:
188
170
  Max: 2128
189
171
 
190
- # Offense count: 6
172
+ # Offense count: 4
191
173
  # Configuration parameters: CountKeywordArgs.
192
174
  Metrics/ParameterLists:
193
- Max: 8
175
+ Max: 7
194
176
  MaxOptionalParameters: 4
195
177
 
196
- # Offense count: 134
178
+ # Offense count: 123
197
179
  # Configuration parameters: AllowedMethods, AllowedPatterns.
198
180
  Metrics/PerceivedComplexity:
199
- Max: 28
181
+ Max: 27
200
182
 
201
183
  # Offense count: 2
202
184
  Naming/AccessorMethodName:
@@ -219,11 +201,13 @@ Naming/MethodName:
219
201
  Exclude:
220
202
  - 'coradoc-markdown/lib/coradoc/markdown.rb'
221
203
 
222
- # Offense count: 18
204
+ # Offense count: 17
223
205
  # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
224
206
  # AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
225
207
  Naming/MethodParameterName:
226
208
  Exclude:
209
+ - 'coradoc-docx/lib/coradoc/docx/transform/from_core_model.rb'
210
+ - 'coradoc-docx/lib/coradoc/docx/transform/rules/run_rule.rb'
227
211
  - 'coradoc-html/lib/coradoc/html/converters/base.rb'
228
212
  - 'coradoc-markdown/lib/coradoc/markdown/parser/block_parser.rb'
229
213
  - 'coradoc-markdown/lib/coradoc/markdown/parser/inline_parser.rb'
@@ -231,9 +215,8 @@ Naming/MethodParameterName:
231
215
  - 'coradoc-markdown/lib/coradoc/markdown/transform/from_core_model.rb'
232
216
  - 'coradoc-markdown/lib/coradoc/markdown/transform/to_core_model.rb'
233
217
  - 'coradoc-markdown/lib/coradoc/markdown/transformer.rb'
234
- - 'lib/coradoc/lazy.rb'
235
218
 
236
- # Offense count: 13
219
+ # Offense count: 10
237
220
  # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
238
221
  # NamePrefix: is_, has_, have_, does_
239
222
  # ForbiddenPrefixes: is_, has_, have_, does_
@@ -246,8 +229,6 @@ Naming/PredicateName:
246
229
  - 'coradoc-html/lib/coradoc/html/entity.rb'
247
230
  - 'coradoc-markdown/lib/coradoc/markdown/parser/parslet_extras.rb'
248
231
  - 'lib/coradoc/core_model/builder/detection.rb'
249
- - 'lib/coradoc/extensions.rb'
250
- - 'lib/coradoc/streaming.rb'
251
232
  - 'utils/parser_analyzer.rb'
252
233
 
253
234
  # Offense count: 3
@@ -265,48 +246,30 @@ RSpec/BeforeAfterAll:
265
246
  - '**/spec/support/**/*.rb'
266
247
  - 'spec/benchmark/performance_spec.rb'
267
248
 
268
- # Offense count: 14
249
+ # Offense count: 19
269
250
  # Configuration parameters: IgnoredMetadata.
270
251
  RSpec/DescribeClass:
271
- Exclude:
272
- - '**/spec/features/**/*'
273
- - '**/spec/requests/**/*'
274
- - '**/spec/routing/**/*'
275
- - '**/spec/system/**/*'
276
- - '**/spec/views/**/*'
277
- - 'coradoc-adoc/spec/coradoc/asciidoc/list_continuation_spec.rb'
278
- - 'coradoc-adoc/spec/coradoc/asciidoc/parser/parser_spec.rb'
279
- - 'coradoc-docx/spec/integration/docx_to_adoc_spec.rb'
280
- - 'coradoc-html/spec/coradoc/html/converters/paragraph_e2e_spec.rb'
281
- - 'coradoc-html/spec/coradoc/html/output_integration_spec.rb'
282
- - 'coradoc-markdown/spec/kramdown_test_suite_spec.rb'
283
- - 'coradoc-markdown/spec/model/abbreviation_spec.rb'
284
- - 'coradoc-markdown/spec/model/auto_id_spec.rb'
285
- - 'coradoc-markdown/spec/model/definition_list_spec.rb'
286
- - 'coradoc-markdown/spec/model/footnote_spec.rb'
287
- - 'spec/benchmark/performance_spec.rb'
288
- - 'spec/coradoc/document_manipulator_spec.rb'
289
- - 'spec/integration/cross_format_spec.rb'
252
+ Enabled: false
290
253
 
291
- # Offense count: 476
254
+ # Offense count: 485
292
255
  # Configuration parameters: CountAsOne.
293
256
  RSpec/ExampleLength:
294
- Max: 34
257
+ Max: 36
295
258
 
296
- # Offense count: 8
259
+ # Offense count: 3
297
260
  # This cop supports safe autocorrection (--autocorrect).
298
261
  RSpec/ExpectActual:
299
262
  Exclude:
300
263
  - '**/spec/routing/**/*'
301
264
  - 'coradoc-markdown/spec/model/abbreviation_spec.rb'
302
- - 'spec/plugin_discovery_spec.rb'
265
+ - 'spec/coradoc/api_spec.rb'
303
266
 
304
267
  # Offense count: 1
305
268
  RSpec/IdenticalEqualityAssertion:
306
269
  Exclude:
307
270
  - 'spec/registry_spec.rb'
308
271
 
309
- # Offense count: 38
272
+ # Offense count: 36
310
273
  # Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
311
274
  RSpec/IndexedLet:
312
275
  Exclude:
@@ -319,27 +282,17 @@ RSpec/IndexedLet:
319
282
  - 'spec/core_model/structural_element_spec.rb'
320
283
  - 'spec/core_model/table_spec.rb'
321
284
  - 'spec/core_model/term_spec.rb'
322
- - 'spec/lazy_spec.rb'
323
285
 
324
- # Offense count: 14
286
+ # Offense count: 30
325
287
  # Configuration parameters: AssignmentOnly.
326
288
  RSpec/InstanceVariable:
327
289
  Exclude:
290
+ - 'coradoc-docx/spec/coradoc/docx/transform/from_core_model_spec.rb'
291
+ - 'coradoc-docx/spec/integration/builder_fixture_spec.rb'
328
292
  - 'spec/input_spec.rb'
329
293
  - 'spec/output_spec.rb'
330
294
 
331
- # Offense count: 1
332
- # This cop supports safe autocorrection (--autocorrect).
333
- RSpec/IteratedExpectation:
334
- Exclude:
335
- - 'spec/plugin_discovery_spec.rb'
336
-
337
- # Offense count: 5
338
- RSpec/LeakyConstantDeclaration:
339
- Exclude:
340
- - 'spec/transform/helpers_spec.rb'
341
-
342
- # Offense count: 8
295
+ # Offense count: 9
343
296
  # Configuration parameters: .
344
297
  # SupportedStyles: have_received, receive
345
298
  RSpec/MessageSpies:
@@ -349,7 +302,7 @@ RSpec/MessageSpies:
349
302
  RSpec/MultipleDescribes:
350
303
  Enabled: false
351
304
 
352
- # Offense count: 599
305
+ # Offense count: 613
353
306
  RSpec/MultipleExpectations:
354
307
  Max: 12
355
308
 
@@ -371,19 +324,13 @@ RSpec/NamedSubject:
371
324
  - 'coradoc-markdown/spec/parser/markdown_spec.rb'
372
325
  - 'spec/visitor_spec.rb'
373
326
 
374
- # Offense count: 1
375
- # Configuration parameters: AllowedGroups.
376
- RSpec/NestedGroups:
377
- Max: 4
378
-
379
- # Offense count: 4
327
+ # Offense count: 3
380
328
  # Configuration parameters: AllowedPatterns.
381
329
  # AllowedPatterns: ^expect_, ^assert_
382
330
  RSpec/NoExpectationExample:
383
331
  Exclude:
384
332
  - 'coradoc-html/spec/coradoc/html/converters/paragraph_e2e_spec.rb'
385
333
  - 'coradoc-markdown/spec/parser/markdown_spec.rb'
386
- - 'spec/streaming_spec.rb'
387
334
 
388
335
  # Offense count: 2
389
336
  RSpec/RepeatedDescription:
@@ -395,34 +342,31 @@ RSpec/RepeatedExample:
395
342
  Exclude:
396
343
  - 'coradoc-html/spec/coradoc/html/converters/paragraph_e2e_spec.rb'
397
344
 
345
+ # Offense count: 2
346
+ RSpec/RepeatedExampleGroupBody:
347
+ Exclude:
348
+ - 'spec/coradoc/api_spec.rb'
349
+
398
350
  # Offense count: 2
399
351
  RSpec/RepeatedExampleGroupDescription:
400
352
  Exclude:
401
353
  - 'spec/coradoc/cli/cli_spec.rb'
402
354
 
403
- # Offense count: 73
355
+ # Offense count: 69
404
356
  # Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
405
357
  # Include: **/*_spec.rb
406
358
  RSpec/SpecFilePathFormat:
407
359
  Enabled: false
408
360
 
409
- # Offense count: 58
361
+ # Offense count: 32
410
362
  # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
411
363
  RSpec/VerifiedDoubles:
412
364
  Exclude:
413
365
  - 'coradoc-adoc/spec/coradoc/asciidoc/parse_error_spec.rb'
414
366
  - 'spec/core_model/base_spec.rb'
415
- - 'spec/lazy_spec.rb'
416
367
  - 'spec/query_spec.rb'
417
- - 'spec/streaming_spec.rb'
418
- - 'spec/transform/helpers_spec.rb'
419
368
  - 'spec/validation_spec.rb'
420
369
 
421
- # Offense count: 1
422
- Security/MarshalLoad:
423
- Exclude:
424
- - 'lib/coradoc/transformation_cache.rb'
425
-
426
370
  # Offense count: 4
427
371
  # This cop supports safe autocorrection (--autocorrect).
428
372
  # Configuration parameters: AllowOnConstant, AllowOnSelfClass.
@@ -437,15 +381,7 @@ Style/ClassVars:
437
381
  - 'coradoc-adoc/lib/coradoc/asciidoc/serializer/element_registry.rb'
438
382
  - 'coradoc-html/lib/coradoc/html/input/converters.rb'
439
383
 
440
- # Offense count: 1
441
- # This cop supports safe autocorrection (--autocorrect).
442
- # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
443
- # SupportedStyles: assign_to_condition, assign_inside_condition
444
- Style/ConditionalAssignment:
445
- Exclude:
446
- - 'coradoc-markdown/lib/coradoc/markdown/parser/ast_processor.rb'
447
-
448
- # Offense count: 289
384
+ # Offense count: 291
449
385
  # Configuration parameters: AllowedConstants.
450
386
  Style/Documentation:
451
387
  Enabled: false
@@ -460,14 +396,12 @@ Style/EmptyElse:
460
396
  - 'coradoc-html/lib/coradoc/html/input/converters/text.rb'
461
397
  - 'lib/coradoc/core_model/toc_generator.rb'
462
398
 
463
- # Offense count: 13
399
+ # Offense count: 3
464
400
  # This cop supports safe autocorrection (--autocorrect).
465
- # Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, Mode, AllowedMethods, AllowedPatterns.
401
+ # Configuration parameters: MaxUnannotatedPlaceholdersAllowed, Mode, AllowedMethods, AllowedPatterns.
466
402
  # SupportedStyles: annotated, template, unannotated
467
403
  Style/FormatStringToken:
468
- Exclude:
469
- - 'coradoc-html/lib/coradoc/html/theme/modern/tailwind_config_builder.rb'
470
- - 'lib/coradoc/performance_regression.rb'
404
+ EnforcedStyle: unannotated
471
405
 
472
406
  # Offense count: 8
473
407
  # Configuration parameters: AllowedVariables.
@@ -483,6 +417,20 @@ Style/HashLikeCase:
483
417
  - 'coradoc-html/lib/coradoc/html/input/converters/table.rb'
484
418
  - 'coradoc-html/lib/coradoc/html/input/converters/td.rb'
485
419
 
420
+ # Offense count: 1
421
+ # This cop supports safe autocorrection (--autocorrect).
422
+ Style/MultilineIfModifier:
423
+ Exclude:
424
+ - 'coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/document.rb'
425
+
426
+ # Offense count: 1
427
+ # This cop supports unsafe autocorrection (--autocorrect-all).
428
+ # Configuration parameters: EnforcedStyle.
429
+ # SupportedStyles: literals, strict
430
+ Style/MutableConstant:
431
+ Exclude:
432
+ - 'lib/coradoc/visitor.rb'
433
+
486
434
  # Offense count: 1
487
435
  # Configuration parameters: AllowedMethods.
488
436
  # AllowedMethods: respond_to_missing?
@@ -490,12 +438,6 @@ Style/OptionalBooleanParameter:
490
438
  Exclude:
491
439
  - 'coradoc-adoc/lib/coradoc/asciidoc/parser/content.rb'
492
440
 
493
- # Offense count: 1
494
- # This cop supports safe autocorrection (--autocorrect).
495
- Style/RedundantAssignment:
496
- Exclude:
497
- - 'lib/coradoc/normalize.rb'
498
-
499
441
  # Offense count: 1
500
442
  # This cop supports unsafe autocorrection (--autocorrect-all).
501
443
  # Configuration parameters: Mode.
@@ -503,18 +445,7 @@ Style/StringConcatenation:
503
445
  Exclude:
504
446
  - 'coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/document_attributes.rb'
505
447
 
506
- # Offense count: 4
507
- # This cop supports safe autocorrection (--autocorrect).
508
- # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
509
- # SupportedStyles: single_quotes, double_quotes
510
- Style/StringLiterals:
511
- Exclude:
512
- - 'lib/coradoc/core_model/block.rb'
513
- - 'lib/coradoc/core_model/inline_element.rb'
514
- - 'lib/coradoc/core_model/list_item.rb'
515
- - 'lib/coradoc/core_model/table.rb'
516
-
517
- # Offense count: 29
448
+ # Offense count: 44
518
449
  # This cop supports safe autocorrection (--autocorrect).
519
450
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
520
451
  # URISchemes: http, https
@@ -51,12 +51,13 @@ module Coradoc
51
51
  return element if element.nil?
52
52
 
53
53
  element = yield element, :pre
54
- element = if element.respond_to?(:visit)
54
+ element = case element
55
+ when Coradoc::AsciiDoc::Model::Base
55
56
  element.visit(&block)
56
- elsif element.is_a?(Array)
57
+ when Array
57
58
  element.map { |child| visit(child, &block) }
58
59
  .flatten.compact
59
- elsif element.is_a?(Hash)
60
+ when Hash
60
61
  result = {}
61
62
  element.each do |k, v|
62
63
  result[k] = visit(v, &block)
@@ -176,7 +176,7 @@ module Coradoc
176
176
  end
177
177
 
178
178
  # Merge the line break into the previous element if it has a line_break attribute
179
- if prev.respond_to?(:line_break=)
179
+ if prev.is_a?(Coradoc::AsciiDoc::Model::Base) && prev.class.attributes.key?(:line_break)
180
180
  prev.line_break = prev.line_break.to_s + line_break.line_break.to_s
181
181
  sections.delete_at(i)
182
182
  # Don't increment i since we deleted an element
@@ -46,7 +46,7 @@ module Coradoc
46
46
  # @return [Hash] include options (leveloffset, lines, tags, etc.)
47
47
  def reference_options
48
48
  options = {}
49
- if attributes.respond_to?(:named)
49
+ if attributes.is_a?(Coradoc::AsciiDoc::Model::AttributeList)
50
50
  attributes.named.each do |attr|
51
51
  case attr.name.to_s
52
52
  when 'leveloffset'
@@ -142,7 +142,7 @@ module Coradoc
142
142
  return resolved.map { |n| resolve_node_recursive(n, base_dir, depth) }.flatten if resolved.is_a?(Array)
143
143
 
144
144
  # Handle nodes with nested content
145
- if resolved.respond_to?(:contents) && resolved.contents
145
+ if resolved.is_a?(Coradoc::AsciiDoc::Model::Base) && resolved.class.attributes.key?(:contents) && resolved.contents
146
146
  resolved = deep_copy_node(resolved)
147
147
  resolved.contents = resolved.contents.map do |child|
148
148
  resolve_node_recursive(child, base_dir, depth + 1)
@@ -150,7 +150,7 @@ module Coradoc
150
150
  end
151
151
 
152
152
  # Handle sections with nested content
153
- if resolved.respond_to?(:sections) && resolved.sections && !resolved.is_a?(Document)
153
+ if resolved.is_a?(Coradoc::AsciiDoc::Model::Base) && resolved.class.attributes.key?(:sections) && resolved.sections && !resolved.is_a?(Document)
154
154
  resolved = deep_copy_node(resolved)
155
155
  resolved.sections = resolved.sections.map do |child|
156
156
  resolve_node_recursive(child, base_dir, depth + 1)
@@ -76,7 +76,7 @@ module Coradoc
76
76
  end
77
77
 
78
78
  # Apply value map if present
79
- value = apply_value_map(value, rule.value_map(:from, options), attr) if rule.respond_to?(:value_map)
79
+ value = apply_value_map(value, rule.value_map(:from, options), attr)
80
80
 
81
81
  # Set the value
82
82
  instance.public_send(:"#{rule.to}=", value) if value
@@ -123,7 +123,7 @@ module Coradoc
123
123
 
124
124
  # Set on target instance
125
125
  target_attr = rule.name || rule.to
126
- instance.public_send(:"#{target_attr}=", value) if instance.respond_to?("#{target_attr}=")
126
+ instance.public_send(:"#{target_attr}=", value)
127
127
  end
128
128
 
129
129
  instance
@@ -154,7 +154,7 @@ module Coradoc
154
154
  when Coradoc::Element::Base
155
155
  # Already a Coradoc element, may need conversion
156
156
  if attr&.type&.<(Lutaml::Model::Type::Value)
157
- value.respond_to?(:content) ? value.content : value.to_s
157
+ value.is_a?(Coradoc::AsciiDoc::Model::Base) && value.class.attributes.key?(:content) ? value.content : value.to_s
158
158
  else
159
159
  value
160
160
  end
@@ -12,7 +12,7 @@ module Coradoc
12
12
  end
13
13
 
14
14
  def asciidoc?
15
- columns&.any? { |c| c.respond_to?(:asciidoc?) && c.asciidoc? } || false
15
+ columns&.any? { |c| c.is_a?(Coradoc::AsciiDoc::Model::TableCell) && c.asciidoc? } || false
16
16
  end
17
17
 
18
18
  # NOTE: underline_for provides trailing newline for table row serialization.
@@ -34,13 +34,10 @@ module Coradoc
34
34
  content
35
35
  when Array
36
36
  content.map(&:to_s).join
37
+ when Coradoc::AsciiDoc::Model::Base
38
+ content.to_adoc
37
39
  when Lutaml::Model::Serializable
38
- # Handle Lutaml models - try to extract text properly
39
- if content.respond_to?(:to_adoc)
40
- content.to_adoc
41
- elsif content.respond_to?(:text)
42
- content.text.to_s
43
- elsif content.respond_to?(:content)
40
+ if content.class.attributes.key?(:content)
44
41
  content.content.to_s
45
42
  else
46
43
  ''
@@ -48,8 +45,7 @@ module Coradoc
48
45
  when nil
49
46
  ''
50
47
  else
51
- # Only use to_s for simple types that respond to to_str
52
- content.respond_to?(:to_str) ? content.to_s : ''
48
+ content.is_a?(String) ? content.to_s : ''
53
49
  end
54
50
  end
55
51
 
@@ -112,14 +112,14 @@ module Coradoc
112
112
  # @param exception [Parslet::ParseFailed] The Parslet exception
113
113
  # @return [Array<Integer, Integer>] Line and column numbers
114
114
  def self.extract_location(exception)
115
- return [nil, nil] unless exception.respond_to?(:cause)
115
+ return [nil, nil] unless exception.is_a?(Parslet::ParseFailed)
116
116
 
117
117
  cause = exception.cause
118
- if cause.respond_to?(:source_line) && cause.respond_to?(:source_column)
119
- [cause.source_line, cause.source_column]
120
- else
121
- [nil, nil]
122
- end
118
+ return [nil, nil] unless cause
119
+
120
+ [cause.source_line, cause.source_column]
121
+ rescue NoMethodError
122
+ [nil, nil]
123
123
  end
124
124
 
125
125
  # Extract the relevant source line
@@ -28,14 +28,9 @@ module Coradoc
28
28
  when Coradoc::AsciiDoc::Model::Base
29
29
  serialize_model(model, options)
30
30
  when Lutaml::Model::Serializable
31
- # Handle Lutaml::Model objects that have to_adoc method
32
- if model.respond_to?(:to_adoc)
33
- model.to_adoc
34
- else
35
- raise ArgumentError,
36
- "Cannot serialize #{model.class.name} to AsciiDoc. " \
37
- 'Expected a model with #to_adoc or a registered serializer.'
38
- end
31
+ raise ArgumentError,
32
+ "Cannot serialize #{model.class.name} to AsciiDoc. " \
33
+ 'Expected a Coradoc::AsciiDoc::Model::Base with a registered serializer.'
39
34
  else
40
35
  raise ArgumentError,
41
36
  "Unknown element type for AsciiDoc serialization: #{model.class}. " \
@@ -53,8 +48,8 @@ module Coradoc
53
48
  return serializer_class.new
54
49
  end
55
50
 
56
- # Fallback: if model has to_adoc method, use it directly
57
- return FallbackSerializer.new if model.respond_to?(:to_adoc)
51
+ # Fallback: use FallbackSerializer which raises a clear error
52
+ return FallbackSerializer.new
58
53
 
59
54
  raise ArgumentError, "No serializer registered for #{model.class.name} and model doesn't respond to to_adoc"
60
55
  end
@@ -12,15 +12,16 @@ module Coradoc
12
12
  def attribute_list(attrs)
13
13
  return '' if attrs.nil?
14
14
 
15
- # Delegate to the attribute list's serialization
16
- attrs.respond_to?(:to_s) ? attrs.to_s : ''
15
+ attrs.to_s
17
16
  end
18
17
 
19
18
  # Format block attributes (anchor, role, options, etc.)
20
19
  # @param attrs [Hash, Coradoc::AsciiDoc::Model::AttributeList] Block attributes
21
20
  # @return [String] Formatted block attributes
22
21
  def block_attributes(attrs)
23
- return '' if attrs.nil? || (attrs.respond_to?(:empty?) && attrs.empty?)
22
+ return '' if attrs.nil?
23
+ return '' if attrs.is_a?(String) && attrs.empty?
24
+ return '' if attrs.is_a?(Hash) && attrs.empty?
24
25
 
25
26
  # If it's an AttributeList model, use its serialization
26
27
  return attribute_list(attrs) if attrs.is_a?(Coradoc::AsciiDoc::Model::AttributeList)