coradoc 2.0.2 → 2.0.4
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 +65 -8
- 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/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/serializer/serializers/base.rb +0 -11
- 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/spec/coradoc/asciidoc/model/base_spec.rb +16 -2
- data/coradoc-adoc/spec/coradoc/asciidoc/model/element_classification_spec.rb +146 -0
- data/coradoc-docx/lib/coradoc/docx/transform/context.rb +1 -1
- data/coradoc-docx/lib/coradoc/docx/transform/from_core_model.rb +13 -6
- data/coradoc-docx/lib/coradoc/docx/transform/numbering_resolver.rb +9 -7
- data/coradoc-docx/lib/coradoc/docx/transform/ordered_content.rb +2 -2
- data/coradoc-docx/lib/coradoc/docx/transform/rules/image_rule.rb +4 -1
- data/coradoc-docx/lib/coradoc/docx/transform/rules/math_rule.rb +2 -1
- data/coradoc-docx/lib/coradoc/docx/transform/rules/run_rule.rb +17 -30
- data/coradoc-docx/lib/coradoc/docx/transform/rules/simple_field_rule.rb +3 -5
- data/coradoc-docx/lib/coradoc/docx/transform/rules/table_rule.rb +3 -4
- data/coradoc-docx/lib/coradoc/docx/transform/style_resolver.rb +19 -24
- data/coradoc-docx/lib/coradoc/docx/transform/to_core_model.rb +18 -11
- data/coradoc-html/lib/coradoc/html/base.rb +3 -7
- data/coradoc-html/lib/coradoc/html/converter_base.rb +5 -15
- data/coradoc-html/lib/coradoc/html/converters/base.rb +18 -27
- data/coradoc-html/lib/coradoc/html/converters/comment_line.rb +2 -2
- data/coradoc-html/lib/coradoc/html/converters/link.rb +1 -1
- data/coradoc-html/lib/coradoc/html/converters/list_item.rb +3 -3
- data/coradoc-html/lib/coradoc/html/converters/ordered.rb +1 -1
- data/coradoc-html/lib/coradoc/html/converters/span.rb +2 -2
- data/coradoc-html/lib/coradoc/html/converters/table.rb +3 -3
- data/coradoc-html/lib/coradoc/html/converters/table_cell.rb +14 -28
- data/coradoc-html/lib/coradoc/html/converters/table_row.rb +2 -2
- data/coradoc-html/lib/coradoc/html/converters/text_element.rb +1 -5
- data/coradoc-html/lib/coradoc/html/input/converters/a.rb +2 -2
- data/coradoc-html/lib/coradoc/html/input/converters/dl.rb +1 -1
- data/coradoc-html/lib/coradoc/html/input/converters/figure.rb +2 -2
- data/coradoc-html/lib/coradoc/html/input/converters/markup.rb +3 -3
- data/coradoc-html/lib/coradoc/html/input/converters/p.rb +1 -1
- data/coradoc-html/lib/coradoc/html/input/converters/td.rb +1 -1
- data/coradoc-html/lib/coradoc/html/input/converters.rb +1 -2
- data/coradoc-html/lib/coradoc/html/input/html_converter.rb +3 -3
- data/coradoc-html/lib/coradoc/html/input/plugin.rb +2 -2
- data/coradoc-html/lib/coradoc/html/renderer.rb +4 -6
- data/coradoc-html/lib/coradoc/html/theme/base.rb +2 -3
- data/coradoc-html/lib/coradoc/html/theme/classic_renderer.rb +9 -12
- data/coradoc-html/lib/coradoc/html/theme/modern/serializers/document_serializer.rb +3 -3
- data/coradoc-markdown/lib/coradoc/markdown/model/base.rb +6 -5
- data/coradoc-markdown/lib/coradoc/markdown/serializer.rb +2 -2
- data/coradoc-markdown/lib/coradoc/markdown/toc_generator.rb +4 -5
- data/coradoc-markdown/lib/coradoc/markdown/transformer.rb +5 -3
- data/lib/coradoc/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 69f496efd91c2d85e4e057be629f8ee00492c40497661c0af940be65f148e092
|
|
4
|
+
data.tar.gz: a2668ca45e7d23bf613d966c36b4c5da70311be0dcdbc0fba4d988844f49b65f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '04584b5faee36ac872400d4d17458221931de4f733aae75839dc40f282d4f863948c9105eb80fefb84f6945639c76c55ccf62fd93d8fd442268f36698950625d'
|
|
7
|
+
data.tar.gz: 00c91cfd40f731c1fffab6ae507d326140e5c7830a8d10bf6a5bb75857ba0b69a552fc4a27d8bd3abb95d4a16159a516df62232bc538fd79fe55a7023e95af0b
|
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 04:52:25 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
|
|
@@ -15,6 +15,28 @@ Gemspec/RequiredRubyVersion:
|
|
|
15
15
|
- 'coradoc-html/coradoc-html.gemspec'
|
|
16
16
|
- 'coradoc.gemspec'
|
|
17
17
|
|
|
18
|
+
# Offense count: 1
|
|
19
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
20
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
|
21
|
+
# SupportedStyles: with_first_argument, with_fixed_indentation
|
|
22
|
+
Layout/ArgumentAlignment:
|
|
23
|
+
Exclude:
|
|
24
|
+
- 'coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/document.rb'
|
|
25
|
+
|
|
26
|
+
# Offense count: 1
|
|
27
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
28
|
+
Layout/ClosingParenthesisIndentation:
|
|
29
|
+
Exclude:
|
|
30
|
+
- 'lib/coradoc/document_manipulator.rb'
|
|
31
|
+
|
|
32
|
+
# Offense count: 1
|
|
33
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
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:
|
|
37
|
+
Exclude:
|
|
38
|
+
- 'lib/coradoc/document_manipulator.rb'
|
|
39
|
+
|
|
18
40
|
# Offense count: 6
|
|
19
41
|
# This cop supports safe autocorrection (--autocorrect).
|
|
20
42
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
|
|
@@ -22,6 +44,21 @@ Gemspec/RequiredRubyVersion:
|
|
|
22
44
|
Layout/LineLength:
|
|
23
45
|
Max: 235
|
|
24
46
|
|
|
47
|
+
# Offense count: 1
|
|
48
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
49
|
+
# Configuration parameters: EnforcedStyle.
|
|
50
|
+
# SupportedStyles: symmetrical, new_line, same_line
|
|
51
|
+
Layout/MultilineMethodCallBraceLayout:
|
|
52
|
+
Exclude:
|
|
53
|
+
- 'lib/coradoc/document_manipulator.rb'
|
|
54
|
+
|
|
55
|
+
# Offense count: 1
|
|
56
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
57
|
+
# Configuration parameters: AllowInHeredoc.
|
|
58
|
+
Layout/TrailingWhitespace:
|
|
59
|
+
Exclude:
|
|
60
|
+
- 'coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/document.rb'
|
|
61
|
+
|
|
25
62
|
# Offense count: 1
|
|
26
63
|
Lint/BinaryOperatorWithIdenticalOperands:
|
|
27
64
|
Exclude:
|
|
@@ -96,7 +133,7 @@ Lint/Void:
|
|
|
96
133
|
Exclude:
|
|
97
134
|
- 'coradoc-html/lib/coradoc/html.rb'
|
|
98
135
|
|
|
99
|
-
# Offense count:
|
|
136
|
+
# Offense count: 236
|
|
100
137
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
|
101
138
|
Metrics/AbcSize:
|
|
102
139
|
Max: 178
|
|
@@ -117,12 +154,12 @@ Metrics/BlockNesting:
|
|
|
117
154
|
Metrics/ClassLength:
|
|
118
155
|
Max: 556
|
|
119
156
|
|
|
120
|
-
# Offense count:
|
|
157
|
+
# Offense count: 179
|
|
121
158
|
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
122
159
|
Metrics/CyclomaticComplexity:
|
|
123
160
|
Max: 32
|
|
124
161
|
|
|
125
|
-
# Offense count:
|
|
162
|
+
# Offense count: 384
|
|
126
163
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
127
164
|
Metrics/MethodLength:
|
|
128
165
|
Max: 246
|
|
@@ -138,7 +175,7 @@ Metrics/ParameterLists:
|
|
|
138
175
|
Max: 7
|
|
139
176
|
MaxOptionalParameters: 4
|
|
140
177
|
|
|
141
|
-
# Offense count:
|
|
178
|
+
# Offense count: 122
|
|
142
179
|
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
143
180
|
Metrics/PerceivedComplexity:
|
|
144
181
|
Max: 27
|
|
@@ -201,6 +238,12 @@ Naming/VariableName:
|
|
|
201
238
|
Exclude:
|
|
202
239
|
- 'coradoc-markdown/lib/coradoc/markdown.rb'
|
|
203
240
|
|
|
241
|
+
# Offense count: 12
|
|
242
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
243
|
+
RSpec/BeEq:
|
|
244
|
+
Exclude:
|
|
245
|
+
- 'coradoc-adoc/spec/coradoc/asciidoc/model/element_classification_spec.rb'
|
|
246
|
+
|
|
204
247
|
# Offense count: 1
|
|
205
248
|
RSpec/BeforeAfterAll:
|
|
206
249
|
Exclude:
|
|
@@ -209,11 +252,19 @@ RSpec/BeforeAfterAll:
|
|
|
209
252
|
- '**/spec/support/**/*.rb'
|
|
210
253
|
- 'spec/benchmark/performance_spec.rb'
|
|
211
254
|
|
|
212
|
-
# Offense count:
|
|
255
|
+
# Offense count: 20
|
|
213
256
|
# Configuration parameters: IgnoredMetadata.
|
|
214
257
|
RSpec/DescribeClass:
|
|
215
258
|
Enabled: false
|
|
216
259
|
|
|
260
|
+
# Offense count: 1
|
|
261
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
262
|
+
# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants.
|
|
263
|
+
# SupportedStyles: described_class, explicit
|
|
264
|
+
RSpec/DescribedClass:
|
|
265
|
+
Exclude:
|
|
266
|
+
- 'coradoc-adoc/spec/coradoc/asciidoc/model/base_spec.rb'
|
|
267
|
+
|
|
217
268
|
# Offense count: 485
|
|
218
269
|
# Configuration parameters: CountAsOne.
|
|
219
270
|
RSpec/ExampleLength:
|
|
@@ -265,7 +316,7 @@ RSpec/MessageSpies:
|
|
|
265
316
|
RSpec/MultipleDescribes:
|
|
266
317
|
Enabled: false
|
|
267
318
|
|
|
268
|
-
# Offense count:
|
|
319
|
+
# Offense count: 619
|
|
269
320
|
RSpec/MultipleExpectations:
|
|
270
321
|
Max: 12
|
|
271
322
|
|
|
@@ -344,7 +395,7 @@ Style/ClassVars:
|
|
|
344
395
|
- 'coradoc-adoc/lib/coradoc/asciidoc/serializer/element_registry.rb'
|
|
345
396
|
- 'coradoc-html/lib/coradoc/html/input/converters.rb'
|
|
346
397
|
|
|
347
|
-
# Offense count:
|
|
398
|
+
# Offense count: 292
|
|
348
399
|
# Configuration parameters: AllowedConstants.
|
|
349
400
|
Style/Documentation:
|
|
350
401
|
Enabled: false
|
|
@@ -380,6 +431,12 @@ Style/HashLikeCase:
|
|
|
380
431
|
- 'coradoc-html/lib/coradoc/html/input/converters/table.rb'
|
|
381
432
|
- 'coradoc-html/lib/coradoc/html/input/converters/td.rb'
|
|
382
433
|
|
|
434
|
+
# Offense count: 1
|
|
435
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
436
|
+
Style/MultilineIfModifier:
|
|
437
|
+
Exclude:
|
|
438
|
+
- 'coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/document.rb'
|
|
439
|
+
|
|
383
440
|
# Offense count: 1
|
|
384
441
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
385
442
|
# Configuration parameters: EnforcedStyle.
|
|
@@ -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.'
|
|
@@ -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
|
|
@@ -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
|
|
@@ -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
|
|
@@ -33,10 +33,24 @@ RSpec.describe Coradoc::AsciiDoc::Model::Base do
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
describe '#to_adoc' do
|
|
36
|
-
it '
|
|
36
|
+
it 'serializes via ElementRegistry' do
|
|
37
37
|
instance = test_class.new(name: 'test')
|
|
38
38
|
|
|
39
|
-
expect(instance).to
|
|
39
|
+
expect(instance).to be_a(described_class)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe 'element classification' do
|
|
44
|
+
it 'defaults block_level? to false' do
|
|
45
|
+
instance = test_class.new
|
|
46
|
+
|
|
47
|
+
expect(instance.block_level?).to be(false)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'defaults inline? to false' do
|
|
51
|
+
instance = test_class.new
|
|
52
|
+
|
|
53
|
+
expect(instance.inline?).to be(false)
|
|
40
54
|
end
|
|
41
55
|
end
|
|
42
56
|
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe 'Element classification' do
|
|
6
|
+
describe 'block_level?' do
|
|
7
|
+
it 'Section is block-level' do
|
|
8
|
+
expect(Coradoc::AsciiDoc::Model::Section.new.block_level?).to be(true)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'Paragraph is block-level' do
|
|
12
|
+
expect(Coradoc::AsciiDoc::Model::Paragraph.new.block_level?).to be(true)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'Admonition is block-level' do
|
|
16
|
+
expect(Coradoc::AsciiDoc::Model::Admonition.new.block_level?).to be(true)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'CommentBlock is block-level' do
|
|
20
|
+
expect(Coradoc::AsciiDoc::Model::CommentBlock.new.block_level?).to be(true)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'Table is block-level' do
|
|
24
|
+
expect(Coradoc::AsciiDoc::Model::Table.new.block_level?).to be(true)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'Block::Core is block-level' do
|
|
28
|
+
expect(Coradoc::AsciiDoc::Model::Block::Core.new.block_level?).to be(true)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'Block::Listing is block-level (inherits from Core)' do
|
|
32
|
+
expect(Coradoc::AsciiDoc::Model::Block::Listing.new.block_level?).to be(true)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'Block::Quote is block-level (inherits from Core)' do
|
|
36
|
+
expect(Coradoc::AsciiDoc::Model::Block::Quote.new.block_level?).to be(true)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'List::Ordered is block-level' do
|
|
40
|
+
expect(Coradoc::AsciiDoc::Model::List::Ordered.new.block_level?).to be(true)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'List::Unordered is block-level' do
|
|
44
|
+
expect(Coradoc::AsciiDoc::Model::List::Unordered.new.block_level?).to be(true)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'BlockImage is block-level' do
|
|
48
|
+
expect(Coradoc::AsciiDoc::Model::Image::BlockImage.new.block_level?).to be(true)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe 'inline?' do
|
|
53
|
+
it 'Inline::Bold is inline' do
|
|
54
|
+
expect(Coradoc::AsciiDoc::Model::Inline::Bold.new.inline?).to be(true)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'Inline::Italic is inline' do
|
|
58
|
+
expect(Coradoc::AsciiDoc::Model::Inline::Italic.new.inline?).to be(true)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it 'Inline::Monospace is inline' do
|
|
62
|
+
expect(Coradoc::AsciiDoc::Model::Inline::Monospace.new.inline?).to be(true)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'Inline::Highlight is inline' do
|
|
66
|
+
expect(Coradoc::AsciiDoc::Model::Inline::Highlight.new.inline?).to be(true)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it 'Inline::Superscript is inline' do
|
|
70
|
+
expect(Coradoc::AsciiDoc::Model::Inline::Superscript.new.inline?).to be(true)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it 'Inline::Subscript is inline' do
|
|
74
|
+
expect(Coradoc::AsciiDoc::Model::Inline::Subscript.new.inline?).to be(true)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'Inline::Link is inline' do
|
|
78
|
+
expect(Coradoc::AsciiDoc::Model::Inline::Link.new.inline?).to be(true)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'Inline::Anchor is inline' do
|
|
82
|
+
expect(Coradoc::AsciiDoc::Model::Inline::Anchor.new.inline?).to be(true)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it 'TextElement is inline' do
|
|
86
|
+
expect(Coradoc::AsciiDoc::Model::TextElement.new.inline?).to be(true)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it 'InlineImage is inline' do
|
|
90
|
+
expect(Coradoc::AsciiDoc::Model::Image::InlineImage.new.inline?).to be(true)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'HardLineBreak returns :hardbreak' do
|
|
94
|
+
expect(Coradoc::AsciiDoc::Model::Inline::HardLineBreak.new.inline?).to eq(:hardbreak)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe 'non-block, non-inline elements' do
|
|
99
|
+
it 'Title is neither block nor inline' do
|
|
100
|
+
title = Coradoc::AsciiDoc::Model::Title.new
|
|
101
|
+
expect(title.block_level?).to be(false)
|
|
102
|
+
expect(title.inline?).to be(false)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it 'List::Item is neither block nor inline' do
|
|
106
|
+
item = Coradoc::AsciiDoc::Model::List::Item.new
|
|
107
|
+
expect(item.block_level?).to be(false)
|
|
108
|
+
expect(item.inline?).to be(false)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it 'AttributeList is neither block nor inline' do
|
|
112
|
+
attrs = Coradoc::AsciiDoc::Model::AttributeList.new
|
|
113
|
+
expect(attrs.block_level?).to be(false)
|
|
114
|
+
expect(attrs.inline?).to be(false)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
describe 'SpacingStrategy integration' do
|
|
119
|
+
let(:strategy) { Coradoc::AsciiDoc::Serializer::SpacingStrategy }
|
|
120
|
+
|
|
121
|
+
it 'uses polymorphic block_level? for spacing' do
|
|
122
|
+
para = Coradoc::AsciiDoc::Model::Paragraph.new
|
|
123
|
+
section = Coradoc::AsciiDoc::Model::Section.new
|
|
124
|
+
|
|
125
|
+
expect(strategy.block_level?(para)).to be(true)
|
|
126
|
+
expect(strategy.block_level?(section)).to be(true)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it 'uses polymorphic inline? for spacing' do
|
|
130
|
+
bold = Coradoc::AsciiDoc::Model::Inline::Bold.new
|
|
131
|
+
text = Coradoc::AsciiDoc::Model::TextElement.new
|
|
132
|
+
|
|
133
|
+
expect(strategy.inline_level?(bold)).to be(true)
|
|
134
|
+
expect(strategy.inline_level?(text)).to be(true)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it 'returns false for nil' do
|
|
138
|
+
expect(strategy.block_level?(nil)).to be(false)
|
|
139
|
+
expect(strategy.inline_level?(nil)).to be(false)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it 'treats strings as inline' do
|
|
143
|
+
expect(strategy.inline_level?('text')).to be(true)
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
@@ -62,7 +62,7 @@ module Coradoc
|
|
|
62
62
|
private
|
|
63
63
|
|
|
64
64
|
def extract_paragraph_text(paragraph)
|
|
65
|
-
return '' unless paragraph.
|
|
65
|
+
return '' unless paragraph.is_a?(Uniword::Wordprocessingml::Paragraph) || paragraph.is_a?(Uniword::Wordprocessingml::Run)
|
|
66
66
|
|
|
67
67
|
paragraph.text.to_s
|
|
68
68
|
end
|
|
@@ -242,11 +242,19 @@ module Coradoc
|
|
|
242
242
|
end
|
|
243
243
|
|
|
244
244
|
def add_list_to_builder(list_block, builder)
|
|
245
|
-
|
|
245
|
+
list_method = list_block.marker_type == 'numbered' ? :numbered_list : :bullet_list
|
|
246
246
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
247
|
+
if list_method == :numbered_list
|
|
248
|
+
builder.numbered_list do |list|
|
|
249
|
+
list_block.items.each do |item|
|
|
250
|
+
list.item(item.flat_text)
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
else
|
|
254
|
+
builder.bullet_list do |list|
|
|
255
|
+
list_block.items.each do |item|
|
|
256
|
+
list.item(item.flat_text)
|
|
257
|
+
end
|
|
250
258
|
end
|
|
251
259
|
end
|
|
252
260
|
end
|
|
@@ -334,8 +342,7 @@ module Coradoc
|
|
|
334
342
|
va.value = 'superscript'
|
|
335
343
|
props.vertical_align = va
|
|
336
344
|
when 'monospace'
|
|
337
|
-
|
|
338
|
-
props.font = 'Courier New' if props.respond_to?(:font=)
|
|
345
|
+
props.fonts = Uniword::Wordprocessingml::RFonts.new(ascii: 'Courier New')
|
|
339
346
|
when 'link'
|
|
340
347
|
# Links need to be at the paragraph level (w:hyperlink)
|
|
341
348
|
# Return the run; caller should wrap in Hyperlink
|
|
@@ -61,8 +61,8 @@ module Coradoc
|
|
|
61
61
|
def build_num_map(config)
|
|
62
62
|
return {} unless config
|
|
63
63
|
|
|
64
|
-
instances = config.
|
|
65
|
-
return {} if instances.empty?
|
|
64
|
+
instances = config.instances
|
|
65
|
+
return {} if instances.nil? || instances.empty?
|
|
66
66
|
|
|
67
67
|
map = {}
|
|
68
68
|
instances.each do |inst|
|
|
@@ -73,8 +73,8 @@ module Coradoc
|
|
|
73
73
|
definition = find_definition(config, abstract_num_id)
|
|
74
74
|
next unless definition
|
|
75
75
|
|
|
76
|
-
levels = definition.
|
|
77
|
-
level = levels
|
|
76
|
+
levels = definition.levels
|
|
77
|
+
level = levels&.first
|
|
78
78
|
next unless level
|
|
79
79
|
|
|
80
80
|
fmt = extract_num_fmt(level)
|
|
@@ -93,11 +93,13 @@ module Coradoc
|
|
|
93
93
|
aid = instance.abstract_num_id
|
|
94
94
|
return nil unless aid
|
|
95
95
|
|
|
96
|
-
aid.
|
|
96
|
+
aid.is_a?(Uniword::Wordprocessingml::AbstractNumId) ? aid.val : aid
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
def find_definition(config, abstract_num_id)
|
|
100
|
-
defs = config.
|
|
100
|
+
defs = config.definitions
|
|
101
|
+
return [] unless defs
|
|
102
|
+
|
|
101
103
|
defs.find { |d| d.abstract_num_id == abstract_num_id }
|
|
102
104
|
end
|
|
103
105
|
|
|
@@ -105,7 +107,7 @@ module Coradoc
|
|
|
105
107
|
nf = level.numFmt
|
|
106
108
|
return 'bullet' unless nf
|
|
107
109
|
|
|
108
|
-
nf.
|
|
110
|
+
nf.is_a?(Uniword::Wordprocessingml::NumFmt) ? nf.val.to_s : nf.to_s
|
|
109
111
|
end
|
|
110
112
|
|
|
111
113
|
def marker_type_for(fmt)
|