prosereflect 0.1.1 → 0.2.0

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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +4 -0
  3. data/.github/workflows/release.yml +5 -0
  4. data/.rubocop.yml +19 -1
  5. data/.rubocop_todo.yml +141 -191
  6. data/CLAUDE.md +78 -0
  7. data/Gemfile +8 -4
  8. data/Rakefile +3 -3
  9. data/lib/prosereflect/attribute/base.rb +4 -6
  10. data/lib/prosereflect/attribute/bold.rb +2 -4
  11. data/lib/prosereflect/attribute/href.rb +1 -3
  12. data/lib/prosereflect/attribute/id.rb +7 -7
  13. data/lib/prosereflect/attribute.rb +4 -7
  14. data/lib/prosereflect/blockquote.rb +10 -11
  15. data/lib/prosereflect/bullet_list.rb +16 -15
  16. data/lib/prosereflect/code_block.rb +26 -26
  17. data/lib/prosereflect/code_block_wrapper.rb +12 -13
  18. data/lib/prosereflect/document.rb +14 -22
  19. data/lib/prosereflect/hard_break.rb +6 -6
  20. data/lib/prosereflect/heading.rb +14 -15
  21. data/lib/prosereflect/horizontal_rule.rb +14 -14
  22. data/lib/prosereflect/image.rb +23 -23
  23. data/lib/prosereflect/input/html.rb +83 -104
  24. data/lib/prosereflect/input.rb +7 -0
  25. data/lib/prosereflect/list_item.rb +11 -12
  26. data/lib/prosereflect/mark/base.rb +9 -11
  27. data/lib/prosereflect/mark/bold.rb +1 -3
  28. data/lib/prosereflect/mark/code.rb +1 -3
  29. data/lib/prosereflect/mark/italic.rb +1 -3
  30. data/lib/prosereflect/mark/link.rb +1 -3
  31. data/lib/prosereflect/mark/strike.rb +1 -3
  32. data/lib/prosereflect/mark/subscript.rb +1 -3
  33. data/lib/prosereflect/mark/superscript.rb +1 -3
  34. data/lib/prosereflect/mark/underline.rb +1 -3
  35. data/lib/prosereflect/mark.rb +9 -5
  36. data/lib/prosereflect/node.rb +31 -31
  37. data/lib/prosereflect/ordered_list.rb +15 -14
  38. data/lib/prosereflect/output/html.rb +52 -50
  39. data/lib/prosereflect/output.rb +7 -0
  40. data/lib/prosereflect/paragraph.rb +11 -13
  41. data/lib/prosereflect/parser.rb +47 -66
  42. data/lib/prosereflect/table.rb +12 -13
  43. data/lib/prosereflect/table_cell.rb +13 -13
  44. data/lib/prosereflect/table_header.rb +17 -17
  45. data/lib/prosereflect/table_row.rb +12 -12
  46. data/lib/prosereflect/text.rb +11 -11
  47. data/lib/prosereflect/user.rb +15 -15
  48. data/lib/prosereflect/version.rb +1 -1
  49. data/lib/prosereflect.rb +27 -17
  50. data/prosereflect.gemspec +17 -16
  51. data/spec/prosereflect/document_spec.rb +332 -330
  52. data/spec/prosereflect/hard_break_spec.rb +125 -125
  53. data/spec/prosereflect/input/html_spec.rb +522 -522
  54. data/spec/prosereflect/node_spec.rb +183 -182
  55. data/spec/prosereflect/output/html_spec.rb +105 -105
  56. data/spec/prosereflect/paragraph_spec.rb +275 -274
  57. data/spec/prosereflect/parser_spec.rb +185 -180
  58. data/spec/prosereflect/table_cell_spec.rb +183 -183
  59. data/spec/prosereflect/table_row_spec.rb +149 -149
  60. data/spec/prosereflect/table_spec.rb +320 -318
  61. data/spec/prosereflect/text_spec.rb +133 -132
  62. data/spec/prosereflect/user_spec.rb +31 -28
  63. data/spec/prosereflect_spec.rb +28 -26
  64. data/spec/spec_helper.rb +6 -6
  65. data/spec/support/matchers.rb +6 -6
  66. data/spec/support/shared_examples.rb +49 -49
  67. metadata +8 -5
  68. data/spec/prosereflect/version_spec.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b84ac8ec1c9f76d0998f9b1be06b156f7ea6788f9c1d82fd2b2a34ef328263e0
4
- data.tar.gz: 82c2549e3ae7a86cc6295e3b2230899638489743e4fa6d040a2a3f7fddbf8ffb
3
+ metadata.gz: f5c6ec18ecdd44c7efaba52819b0763d35c829c7af571ef7b423da2863d29caf
4
+ data.tar.gz: ed3ed8a65bb95e4dbc89a0e96efe4f2dd4a2c57b0cc7210f6296c03a6b8c5d66
5
5
  SHA512:
6
- metadata.gz: a7f45b590785499274eb6112a961e131af7af6a5c679a388eaf3bd01805a731f572fbf7d5efa938f5466e359e2c3dc81953816164ac3a3c0585ab9e98b97a220
7
- data.tar.gz: dd99eed85e651b903869b53a09866a550e71b5fd29efbf8fa380b6f35bee33c2189675ca1897d10f11400975a45dbb13d798fef916a466b61181a9046fee5ff2
6
+ metadata.gz: f736e62b0ef5909c60daebb95b79f29c23be47b76c56edf327adeb4bdf76df1071493def7a5530209cd5a431332f1dfec3a3428453c50c5e3e336873126be238
7
+ data.tar.gz: 56d78409069b3a61caf41ab36a44494f71b1f2be53e9ef15bd2290fad0eebab31cc3c7a22945b09b05f0dd0f011f65b77f0cc8045fa36230e723750b6796f118
@@ -8,6 +8,10 @@ on:
8
8
  tags: [ v* ]
9
9
  pull_request:
10
10
 
11
+ permissions:
12
+ contents: write
13
+ packages: write
14
+
11
15
  jobs:
12
16
  rake:
13
17
  uses: metanorma/ci/.github/workflows/generic-rake.yml@main
@@ -14,6 +14,11 @@ on:
14
14
  repository_dispatch:
15
15
  types: [ do-release ]
16
16
 
17
+ permissions:
18
+ contents: write
19
+ packages: write
20
+ id-token: write
21
+
17
22
  jobs:
18
23
  release:
19
24
  uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
data/.rubocop.yml CHANGED
@@ -1 +1,19 @@
1
- inherit_from: .rubocop_todo.yml
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ inherit_from:
4
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/main/ci/rubocop.yml
5
+ - .rubocop_todo.yml
6
+
7
+ inherit_mode:
8
+ merge:
9
+ - Exclude
10
+
11
+ # local repo-specific modifications
12
+ # ...
13
+ plugins:
14
+ - rubocop-rspec
15
+ - rubocop-performance
16
+ - rubocop-rake
17
+
18
+ AllCops:
19
+ TargetRubyVersion: 3.0
data/.rubocop_todo.yml CHANGED
@@ -1,247 +1,197 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2025-05-12 01:22:35 UTC using RuboCop version 1.75.5.
3
+ # on 2026-04-13 10:04:56 UTC using RuboCop version 1.86.1.
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
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
9
  # Offense count: 1
10
- # This cop supports safe autocorrection (--autocorrect).
11
- Layout/BlockEndNewline:
12
- Exclude:
13
- - 'bin/extract-ituob-amendments.rb'
14
-
15
- # Offense count: 2
16
- # This cop supports safe autocorrection (--autocorrect).
17
- # Configuration parameters: AllowForAlignment.
18
- Layout/CommentIndentation:
19
- Exclude:
20
- - 'e118_amendment.rb'
21
-
22
- # Offense count: 1
23
- # This cop supports safe autocorrection (--autocorrect).
24
- Layout/EmptyLineAfterGuardClause:
10
+ Gemspec/RequiredRubyVersion:
25
11
  Exclude:
26
- - 'e118_amendment.rb'
27
-
28
- # Offense count: 1
29
- # This cop supports safe autocorrection (--autocorrect).
30
- # Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
31
- Layout/EmptyLineBetweenDefs:
32
- Exclude:
33
- - 'e118_amendment.rb'
12
+ - 'prosereflect.gemspec'
34
13
 
35
- # Offense count: 2
14
+ # Offense count: 5
36
15
  # This cop supports safe autocorrection (--autocorrect).
37
- Layout/EmptyLines:
16
+ # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
17
+ # SupportedHashRocketStyles: key, separator, table
18
+ # SupportedColonStyles: key, separator, table
19
+ # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
20
+ Layout/HashAlignment:
38
21
  Exclude:
39
- - 'e118_amendment.rb'
22
+ - 'spec/prosereflect/schema/conftest.rb'
40
23
 
41
- # Offense count: 2
24
+ # Offense count: 80
42
25
  # This cop supports safe autocorrection (--autocorrect).
43
- # Configuration parameters: EnforcedStyle.
44
- # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
45
- Layout/EmptyLinesAroundClassBody:
46
- Exclude:
47
- - 'e118_amendment.rb'
26
+ # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
27
+ # URISchemes: http, https
28
+ Layout/LineLength:
29
+ Enabled: false
48
30
 
49
- # Offense count: 2
31
+ # Offense count: 5
50
32
  # This cop supports safe autocorrection (--autocorrect).
51
- # Configuration parameters: Width, AllowedPatterns.
52
- Layout/IndentationWidth:
33
+ # Configuration parameters: AllowInHeredoc.
34
+ Layout/TrailingWhitespace:
53
35
  Exclude:
54
- - 'bin/extract-ituob-amendments.rb'
55
- - 'e118_amendment.rb'
36
+ - 'spec/prosereflect/schema/conftest.rb'
56
37
 
57
- # Offense count: 1
58
- # This cop supports safe autocorrection (--autocorrect).
59
- Lint/ScriptPermission:
38
+ # Offense count: 4
39
+ # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
40
+ Lint/DuplicateBranch:
60
41
  Exclude:
61
- - 'debug_loading.rb'
42
+ - 'lib/prosereflect/input/html.rb'
43
+ - 'lib/prosereflect/schema/attribute.rb'
44
+ - 'lib/prosereflect/schema/mark.rb'
45
+ - 'lib/prosereflect/schema/schema_class.rb'
62
46
 
63
47
  # Offense count: 1
64
48
  # This cop supports safe autocorrection (--autocorrect).
65
- # Configuration parameters: AutoCorrect, ContextCreatingMethods, MethodCreatingMethods.
66
- Lint/UselessAccessModifier:
49
+ # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
50
+ # NotImplementedExceptions: NotImplementedError
51
+ Lint/UnusedMethodArgument:
67
52
  Exclude:
68
- - 'e118_amendment.rb'
53
+ - 'lib/prosereflect/schema/node.rb'
69
54
 
70
- # Offense count: 5
71
- # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
55
+ # Offense count: 34
56
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
72
57
  Metrics/AbcSize:
73
- Max: 98
74
-
75
- # Offense count: 23
76
- # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
77
- # AllowedMethods: refine
78
- Metrics/BlockLength:
79
- Exclude:
80
- - 'spec/prosereflect/input/html_spec.rb'
81
- Max: 500
82
-
83
- # Offense count: 3
84
- Metrics/ClassLength:
85
58
  Exclude:
86
59
  - 'lib/prosereflect/input/html.rb'
87
- - 'lib/prosereflect/output/html.rb'
88
60
  - 'lib/prosereflect/node.rb'
61
+ - 'lib/prosereflect/output/html.rb'
62
+ - 'lib/prosereflect/parser.rb'
63
+ - 'lib/prosereflect/schema/fragment.rb'
64
+ - 'lib/prosereflect/schema/mark_type.rb'
65
+ - 'lib/prosereflect/schema/node.rb'
66
+ - 'lib/prosereflect/schema/node_type.rb'
67
+ - 'lib/prosereflect/schema/schema_class.rb'
68
+ - 'spec/support/matchers.rb'
89
69
 
90
- # Offense count: 4
91
- # Configuration parameters: AllowedMethods, AllowedPatterns.
92
- Metrics/CyclomaticComplexity:
93
- Max: 50
70
+ # Offense count: 1
71
+ # Configuration parameters: CountBlocks, CountModifierForms.
72
+ Metrics/BlockNesting:
73
+ Max: 4
94
74
 
95
- # Offense count: 6
75
+ # Offense count: 30
76
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
77
+ Metrics/CyclomaticComplexity:
78
+ Exclude:
79
+ - 'lib/prosereflect/code_block.rb'
80
+ - 'lib/prosereflect/input/html.rb'
81
+ - 'lib/prosereflect/node.rb'
82
+ - 'lib/prosereflect/output/html.rb'
83
+ - 'lib/prosereflect/parser.rb'
84
+ - 'lib/prosereflect/schema/attribute.rb'
85
+ - 'lib/prosereflect/schema/fragment.rb'
86
+ - 'lib/prosereflect/schema/mark_type.rb'
87
+ - 'lib/prosereflect/schema/node.rb'
88
+ - 'lib/prosereflect/schema/node_type.rb'
89
+ - 'lib/prosereflect/schema/schema_class.rb'
90
+ - 'spec/support/matchers.rb'
91
+
92
+ # Offense count: 45
96
93
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
97
94
  Metrics/MethodLength:
98
- Max: 90
95
+ Max: 84
99
96
 
100
- # Offense count: 3
101
- # Configuration parameters: AllowedMethods, AllowedPatterns.
102
- Metrics/PerceivedComplexity:
103
- Max: 35
97
+ # Offense count: 2
98
+ # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
99
+ Metrics/ParameterLists:
100
+ Max: 8
104
101
 
105
- # Offense count: 9
106
- # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
107
- # SupportedStyles: snake_case, normalcase, non_integer
108
- # AllowedIdentifiers: TLS1_1, TLS1_2, capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
109
- Naming/VariableNumber:
102
+ # Offense count: 30
103
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
104
+ Metrics/PerceivedComplexity:
110
105
  Exclude:
111
- - 'e118_entry.rb'
112
-
113
- # Offense count: 2
114
- # This cop supports safe autocorrection (--autocorrect).
115
- # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
116
- # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
117
- # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
118
- # FunctionalMethods: let, let!, subject, watch
119
- # AllowedMethods: lambda, proc, it
120
- Style/BlockDelimiters:
121
- Exclude:
122
- - 'bin/extract-ituob-amendments.rb'
123
-
124
- # Offense count: 11
125
- # Configuration parameters: AllowedConstants.
126
- Style/Documentation:
127
- Exclude:
128
- - 'spec/**/*'
129
- - 'test/**/*'
130
- - 'e118_amendment.rb'
131
- - 'e118_entry.rb'
132
- - 'lib/prosereflect/document.rb'
133
- - 'lib/prosereflect/hard_break.rb'
134
- - 'lib/prosereflect/node.rb'
135
- - 'lib/prosereflect/paragraph.rb'
136
- - 'lib/prosereflect/parser.rb'
137
- - 'lib/prosereflect/table.rb'
138
- - 'lib/prosereflect/table_cell.rb'
139
- - 'lib/prosereflect/table_row.rb'
140
- - 'lib/prosereflect/text.rb'
141
- - 'lib/prosereflect/heading.rb'
142
- - 'lib/prosereflect/attribute.rb'
143
- - 'lib/prosereflect/attribute/base.rb'
144
- - 'lib/prosereflect/attribute/bold.rb'
145
- - 'lib/prosereflect/attribute/href.rb'
146
- - 'lib/prosereflect/attribute/id.rb'
106
+ - 'lib/prosereflect/code_block.rb'
147
107
  - 'lib/prosereflect/input/html.rb'
108
+ - 'lib/prosereflect/node.rb'
148
109
  - 'lib/prosereflect/output/html.rb'
149
- - 'lib/prosereflect/mark.rb'
150
- - 'lib/prosereflect/mark/base.rb'
110
+ - 'lib/prosereflect/parser.rb'
111
+ - 'lib/prosereflect/schema/fragment.rb'
112
+ - 'lib/prosereflect/schema/mark_type.rb'
113
+ - 'lib/prosereflect/schema/node.rb'
114
+ - 'lib/prosereflect/schema/node_type.rb'
115
+ - 'lib/prosereflect/schema/schema_class.rb'
116
+ - 'spec/support/matchers.rb'
151
117
 
152
- # Offense count: 1
153
- # This cop supports unsafe autocorrection (--autocorrect-all).
154
- # Configuration parameters: EnforcedStyle.
155
- # SupportedStyles: always, always_true, never
156
- Style/FrozenStringLiteralComment:
118
+ # Offense count: 4
119
+ # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
120
+ # AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
121
+ Naming/MethodParameterName:
157
122
  Exclude:
158
- - '**/*.arb'
159
- - 'bin/extract-ituob-amendments.rb'
123
+ - 'lib/prosereflect/schema/fragment.rb'
124
+ - 'lib/prosereflect/schema/node.rb'
160
125
 
161
- # Offense count: 7
162
- # This cop supports safe autocorrection (--autocorrect).
163
- Style/IfUnlessModifier:
164
- Exclude:
165
- - 'e118_amendment.rb'
166
- - 'e118_entry.rb'
126
+ # Offense count: 6
127
+ # Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
128
+ # AllowedMethods: call
129
+ # WaywardPredicates: infinite?, nonzero?
130
+ Naming/PredicateMethod:
131
+ Exclude:
132
+ - 'lib/prosereflect/schema/attribute.rb'
133
+ - 'lib/prosereflect/schema/node.rb'
134
+
135
+ # Offense count: 12
136
+ # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
137
+ # NamePrefix: is_, has_, have_, does_
138
+ # ForbiddenPrefixes: is_, has_, have_, does_
139
+ # AllowedMethods: is_a?
140
+ # MethodDefinitionMacros: define_method, define_singleton_method
141
+ Naming/PredicatePrefix:
142
+ Exclude:
143
+ - 'lib/prosereflect/schema/mark.rb'
144
+ - 'lib/prosereflect/schema/mark_type.rb'
145
+ - 'lib/prosereflect/schema/node.rb'
146
+ - 'lib/prosereflect/schema/node_type.rb'
167
147
 
168
148
  # Offense count: 1
169
- # This cop supports safe autocorrection (--autocorrect).
170
- # Configuration parameters: EnforcedStyle, MinBodyLength, AllowConsecutiveConditionals.
171
- # SupportedStyles: skip_modifier_ifs, always
172
- Style/Next:
149
+ # Configuration parameters: MinSize.
150
+ Performance/CollectionLiteralInLoop:
173
151
  Exclude:
174
- - 'e118_amendment.rb'
152
+ - 'lib/prosereflect/input/html.rb'
175
153
 
176
- # Offense count: 9
177
- # This cop supports unsafe autocorrection (--autocorrect-all).
178
- # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
179
- # SupportedStyles: predicate, comparison
180
- Style/NumericPredicate:
154
+ # Offense count: 7
155
+ # Configuration parameters: Prefixes, AllowedPatterns.
156
+ # Prefixes: when, with, without
157
+ RSpec/ContextWording:
181
158
  Exclude:
182
- - 'spec/**/*'
183
- - 'e118_amendment.rb'
184
- - 'e118_entry.rb'
185
- - 'lib/prosereflect/table.rb'
159
+ - 'spec/prosereflect/parser_spec.rb'
160
+ - 'spec/prosereflect/schema/conftest.rb'
161
+ - 'spec/support/shared_examples.rb'
186
162
 
187
- # Offense count: 1
188
- # This cop supports safe autocorrection (--autocorrect).
189
- Style/ParallelAssignment:
190
- Exclude:
191
- - 'e118_amendment.rb'
163
+ # Offense count: 142
164
+ # Configuration parameters: CountAsOne.
165
+ RSpec/ExampleLength:
166
+ Max: 134
192
167
 
193
- # Offense count: 1
194
- # This cop supports safe autocorrection (--autocorrect).
195
- Style/RedundantSelf:
196
- Exclude:
197
- - 'e118_amendment.rb'
198
-
199
- # Offense count: 1
200
- # This cop supports safe autocorrection (--autocorrect).
201
- # Configuration parameters: EnforcedStyle.
202
- # SupportedStyles: implicit, explicit
203
- Style/RescueStandardError:
204
- Exclude:
205
- - 'bin/extract-ituob-amendments.rb'
168
+ # Offense count: 73
169
+ RSpec/MultipleExpectations:
170
+ Max: 8
206
171
 
207
- # Offense count: 4
208
- # This cop supports unsafe autocorrection (--autocorrect-all).
209
- # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
210
- # AllowedMethods: present?, blank?, presence, try, try!
211
- Style/SafeNavigation:
212
- Exclude:
213
- - 'e118_amendment.rb'
172
+ # Offense count: 7
173
+ # Configuration parameters: AllowedGroups.
174
+ RSpec/NestedGroups:
175
+ Max: 4
214
176
 
215
- # Offense count: 1
177
+ # Offense count: 2
216
178
  # This cop supports unsafe autocorrection (--autocorrect-all).
217
- Style/SlicingWithRange:
179
+ Style/IdenticalConditionalBranches:
218
180
  Exclude:
219
- - 'lib/prosereflect/table.rb'
181
+ - 'lib/prosereflect/schema/mark.rb'
220
182
 
221
- # Offense count: 38
183
+ # Offense count: 2
222
184
  # This cop supports safe autocorrection (--autocorrect).
223
- # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
224
- # SupportedStyles: single_quotes, double_quotes
225
- Style/StringLiterals:
226
- Exclude:
227
- - 'Gemfile'
228
- - 'Rakefile'
229
- - 'bin/console'
230
- - 'bin/extract-ituob-amendments.rb'
231
- - 'lib/prosereflect.rb'
232
- - 'lib/prosereflect/version.rb'
233
- - 'prosereflect.gemspec'
234
-
235
- # Offense count: 7
236
- # This cop supports unsafe autocorrection (--autocorrect-all).
237
- Style/ZeroLengthPredicate:
185
+ # Configuration parameters: EnforcedStyleForMultiline.
186
+ # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
187
+ Style/TrailingCommaInArguments:
238
188
  Exclude:
239
- - 'e118_amendment.rb'
240
- - 'e118_entry.rb'
189
+ - 'spec/prosereflect/schema/conftest.rb'
241
190
 
242
- # Offense count: 6
191
+ # Offense count: 4
243
192
  # This cop supports safe autocorrection (--autocorrect).
244
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
245
- # URISchemes: http, https
246
- Layout/LineLength:
247
- Max: 153
193
+ # Configuration parameters: EnforcedStyleForMultiline.
194
+ # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
195
+ Style/TrailingCommaInHashLiteral:
196
+ Exclude:
197
+ - 'spec/prosereflect/schema/conftest.rb'
data/CLAUDE.md ADDED
@@ -0,0 +1,78 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Overview
6
+
7
+ `prosereflect` is a Ruby gem for parsing, manipulating, and traversing ProseMirror rich text editor document trees. It provides a Ruby object model over ProseMirror's JSON/YAML format with HTML import/export capabilities.
8
+
9
+ ## Commands
10
+
11
+ ```bash
12
+ # Install dependencies
13
+ bundle install
14
+
15
+ # Run tests and linting
16
+ rake
17
+
18
+ # Run tests only
19
+ rake spec
20
+
21
+ # Run a specific spec file
22
+ rspec spec/prosereflect/parser_spec.rb
23
+
24
+ # Run a specific test
25
+ rspec spec/prosereflect/parser_spec.rb:42
26
+
27
+ # Run linting only
28
+ rake rubocop
29
+ ```
30
+
31
+ ## Architecture
32
+
33
+ ### Core Classes
34
+
35
+ - **Node** (`lib/prosereflect/node.rb`) - Base class for all document elements, extends `Lutaml::Model::Serializable`. All node types inherit `type`, `attrs`, `marks`, and `content` attributes.
36
+ - **Document** (`lib/prosereflect/document.rb`) - Top-level container, extends Node. Provides convenience methods like `tables`, `paragraphs`, `find_first`, `find_all`, `find_children`.
37
+ - **Parser** (`lib/prosereflect/parser.rb`) - Converts ProseMirror JSON/YAML hash structure into Node objects via `parse_document`.
38
+
39
+ ### Node Hierarchy
40
+
41
+ All node types inherit from Node and define a `PM_TYPE` constant matching ProseMirror's type strings:
42
+ - Block nodes: `Document`, `Paragraph`, `Heading`, `Table`, `TableRow`, `TableCell`, `TableHeader`, `BulletList`, `OrderedList`, `ListItem`, `Blockquote`, `CodeBlockWrapper`, `CodeBlock`, `HorizontalRule`, `Image`, `HardBreak`
43
+ - Text nodes: `Text` with `Mark` collections (Bold, Italic, Code, Link, Strike, Subscript, Superscript, Underline)
44
+ - Special: `User` for @mentions
45
+
46
+ ### HTML Conversion
47
+
48
+ - **Input::Html** (`lib/prosereflect/input/html.rb`) - Parses HTML strings into Document using Nokogiri
49
+ - **Output::Html** (`lib/prosereflect/output/html.rb`) - Converts Document back to HTML using Nokogiri::HTML::Builder
50
+
51
+ ### Serialization
52
+
53
+ Uses `lutaml-model` for attribute serialization. The `key_value` block defines how Ruby attributes map to ProseMirror JSON keys. Override `to_h` methods handle special cases for attrs/marks serialization.
54
+
55
+ ### Key Dependencies
56
+
57
+ - `lutaml-model` (~> 0.8) - Serialization framework
58
+ - `nokogiri` (~> 1.18) - HTML parsing/generation
59
+
60
+ ## Superseding prosemirror-py
61
+
62
+ This library aims to be a full superset of the Python [prosemirror-py](https://github.com/metanorma/prosemirror-py). See `TODO.py-audit/` for detailed feature gap analysis and implementation plans to achieve complete compliance and schema validation parity.
63
+
64
+ ## Data Model Pattern
65
+
66
+ ```ruby
67
+ class SomeNode < Node
68
+ PM_TYPE = 'some_node'
69
+
70
+ attribute :custom_attr, :string
71
+
72
+ key_value do
73
+ map 'type', to: :type, render_default: true
74
+ map 'attrs', to: :attrs
75
+ map 'content', to: :content
76
+ end
77
+ end
78
+ ```
data/Gemfile CHANGED
@@ -1,10 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in prosereflect.gemspec
6
6
  gemspec
7
7
 
8
- gem 'rake'
9
- gem 'rspec'
10
- gem 'rubocop'
8
+ gem "lutaml-model", github: "lutaml/lutaml-model", branch: "main"
9
+ gem "rake"
10
+ gem "rspec"
11
+ gem "rubocop"
12
+ gem "rubocop-performance"
13
+ gem "rubocop-rake"
14
+ gem "rubocop-rspec"
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- require 'rubocop/rake_task'
8
+ require "rubocop/rake_task"
9
9
 
10
10
  RuboCop::RakeTask.new
11
11
 
@@ -1,24 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../attribute'
4
-
5
3
  module Prosereflect
6
4
  module Attribute
7
5
  class Base < Lutaml::Model::Serializable
8
- PM_TYPE = 'attribute'
6
+ PM_TYPE = "attribute"
9
7
 
10
8
  attribute :type, :string, default: lambda {
11
9
  begin
12
10
  self.class.const_get(:PM_TYPE)
13
11
  rescue StandardError
14
- 'attribute'
12
+ "attribute"
15
13
  end
16
14
  }
17
15
  attribute :value, :string
18
16
 
19
17
  key_value do
20
- map 'type', to: :type, render_default: true
21
- map 'value', to: :value
18
+ map "type", to: :type, render_default: true
19
+ map "value", to: :value
22
20
  end
23
21
 
24
22
  def self.create(type, value)
@@ -1,15 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'base'
4
-
5
3
  module Prosereflect
6
4
  module Attribute
7
5
  class Bold < Base
8
- PM_TYPE = 'bold'
6
+ PM_TYPE = "bold"
9
7
 
10
8
  def initialize(options = {})
11
9
  super
12
- self.type = 'bold'
10
+ self.type = "bold"
13
11
  end
14
12
 
15
13
  def attrs
@@ -1,11 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'base'
4
-
5
3
  module Prosereflect
6
4
  module Attribute
7
5
  class Href < Base
8
- PM_TYPE = 'href'
6
+ PM_TYPE = "href"
9
7
 
10
8
  attribute :type, :string, default: -> { PM_TYPE }
11
9
  attribute :href, :string
@@ -1,23 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'base'
4
-
5
3
  module Prosereflect
6
4
  module Attribute
7
5
  class Id < Base
8
- PM_TYPE = 'id'
6
+ PM_TYPE = "id"
9
7
 
10
- attribute :type, :string, default: -> { send('const_get', 'PM_TYPE') }
8
+ attribute :type, :string, default: -> {
9
+ self.class.send(:const_get, "PM_TYPE")
10
+ }
11
11
  attribute :id, :string
12
12
 
13
13
  key_value do
14
- map 'type', to: :type, render_default: true
15
- map 'id', to: :id
14
+ map "type", to: :type, render_default: true
15
+ map "id", to: :id
16
16
  end
17
17
 
18
18
  # Convert to hash for serialization
19
19
  def to_h
20
- { 'id' => id }
20
+ { "id" => id }
21
21
  end
22
22
  end
23
23
  end