prosereflect 0.1.0 → 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 (70) 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 +143 -174
  6. data/CLAUDE.md +78 -0
  7. data/Gemfile +8 -4
  8. data/README.adoc +193 -12
  9. data/Rakefile +3 -3
  10. data/lib/prosereflect/attribute/base.rb +32 -0
  11. data/lib/prosereflect/attribute/bold.rb +18 -0
  12. data/lib/prosereflect/attribute/href.rb +22 -0
  13. data/lib/prosereflect/attribute/id.rb +24 -0
  14. data/lib/prosereflect/attribute.rb +10 -0
  15. data/lib/prosereflect/blockquote.rb +84 -0
  16. data/lib/prosereflect/bullet_list.rb +84 -0
  17. data/lib/prosereflect/code_block.rb +135 -0
  18. data/lib/prosereflect/code_block_wrapper.rb +65 -0
  19. data/lib/prosereflect/document.rb +93 -26
  20. data/lib/prosereflect/hard_break.rb +13 -11
  21. data/lib/prosereflect/heading.rb +63 -0
  22. data/lib/prosereflect/horizontal_rule.rb +70 -0
  23. data/lib/prosereflect/image.rb +126 -0
  24. data/lib/prosereflect/input/html.rb +484 -0
  25. data/lib/prosereflect/input.rb +7 -0
  26. data/lib/prosereflect/list_item.rb +64 -0
  27. data/lib/prosereflect/mark/base.rb +47 -0
  28. data/lib/prosereflect/mark/bold.rb +13 -0
  29. data/lib/prosereflect/mark/code.rb +12 -0
  30. data/lib/prosereflect/mark/italic.rb +13 -0
  31. data/lib/prosereflect/mark/link.rb +16 -0
  32. data/lib/prosereflect/mark/strike.rb +13 -0
  33. data/lib/prosereflect/mark/subscript.rb +13 -0
  34. data/lib/prosereflect/mark/superscript.rb +13 -0
  35. data/lib/prosereflect/mark/underline.rb +13 -0
  36. data/lib/prosereflect/mark.rb +15 -0
  37. data/lib/prosereflect/node.rb +181 -32
  38. data/lib/prosereflect/ordered_list.rb +86 -0
  39. data/lib/prosereflect/output/html.rb +376 -0
  40. data/lib/prosereflect/output.rb +7 -0
  41. data/lib/prosereflect/paragraph.rb +29 -20
  42. data/lib/prosereflect/parser.rb +101 -33
  43. data/lib/prosereflect/table.rb +42 -12
  44. data/lib/prosereflect/table_cell.rb +36 -11
  45. data/lib/prosereflect/table_header.rb +92 -0
  46. data/lib/prosereflect/table_row.rb +34 -11
  47. data/lib/prosereflect/text.rb +15 -19
  48. data/lib/prosereflect/user.rb +63 -0
  49. data/lib/prosereflect/version.rb +1 -1
  50. data/lib/prosereflect.rb +27 -11
  51. data/prosereflect.gemspec +17 -15
  52. data/spec/prosereflect/document_spec.rb +477 -75
  53. data/spec/prosereflect/hard_break_spec.rb +226 -30
  54. data/spec/prosereflect/input/html_spec.rb +797 -0
  55. data/spec/prosereflect/node_spec.rb +307 -137
  56. data/spec/prosereflect/output/html_spec.rb +369 -0
  57. data/spec/prosereflect/paragraph_spec.rb +458 -82
  58. data/spec/prosereflect/parser_spec.rb +311 -93
  59. data/spec/prosereflect/table_cell_spec.rb +282 -71
  60. data/spec/prosereflect/table_row_spec.rb +218 -48
  61. data/spec/prosereflect/table_spec.rb +415 -82
  62. data/spec/prosereflect/text_spec.rb +231 -72
  63. data/spec/prosereflect/user_spec.rb +76 -0
  64. data/spec/prosereflect_spec.rb +30 -23
  65. data/spec/spec_helper.rb +6 -6
  66. data/spec/support/matchers.rb +6 -6
  67. data/spec/support/shared_examples.rb +79 -50
  68. metadata +53 -6
  69. data/debug_loading.rb +0 -34
  70. data/spec/prosereflect/version_spec.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4932ddc045360d00a528353acb8c741642588d3c0d180e62752d4090f47d28d
4
- data.tar.gz: 646f972a327d8a8a735904bc31f64f2778232e077e6b1fcf6e888b1d6452ac25
3
+ metadata.gz: f5c6ec18ecdd44c7efaba52819b0763d35c829c7af571ef7b423da2863d29caf
4
+ data.tar.gz: ed3ed8a65bb95e4dbc89a0e96efe4f2dd4a2c57b0cc7210f6296c03a6b8c5d66
5
5
  SHA512:
6
- metadata.gz: fd539de5ef42d23b9d1cb4ab07a6dc2f6ea0466e02230016b09ce6f6c90dc6ab947ceaa82ee5f0058030cb0fee82484d6a676ad5841b8d6207d45dec717f785a
7
- data.tar.gz: 38e6f185405e0dd9fdd56aa9821253442f545aac7944c54e909a6e5c5ee430c7d610caac53d4d32e4de1fd5ebb7b125822e1465ce3d01e8aa745621efaae603e
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,228 +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:
25
- 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:
10
+ Gemspec/RequiredRubyVersion:
32
11
  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
58
+ Exclude:
59
+ - 'lib/prosereflect/input/html.rb'
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'
74
69
 
75
- # Offense count: 23
76
- # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
77
- # AllowedMethods: refine
78
- Metrics/BlockLength:
79
- Max: 201
70
+ # Offense count: 1
71
+ # Configuration parameters: CountBlocks, CountModifierForms.
72
+ Metrics/BlockNesting:
73
+ Max: 4
80
74
 
81
- # Offense count: 4
82
- # Configuration parameters: AllowedMethods, AllowedPatterns.
75
+ # Offense count: 30
76
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
83
77
  Metrics/CyclomaticComplexity:
84
- Max: 30
85
-
86
- # Offense count: 6
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
87
93
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
88
94
  Metrics/MethodLength:
89
- Max: 47
95
+ Max: 84
90
96
 
91
- # Offense count: 3
92
- # Configuration parameters: AllowedMethods, AllowedPatterns.
93
- Metrics/PerceivedComplexity:
94
- Max: 32
97
+ # Offense count: 2
98
+ # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
99
+ Metrics/ParameterLists:
100
+ Max: 8
95
101
 
96
- # Offense count: 9
97
- # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
98
- # SupportedStyles: snake_case, normalcase, non_integer
99
- # AllowedIdentifiers: TLS1_1, TLS1_2, capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
100
- Naming/VariableNumber:
102
+ # Offense count: 30
103
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
104
+ Metrics/PerceivedComplexity:
101
105
  Exclude:
102
- - 'e118_entry.rb'
103
-
104
- # Offense count: 2
105
- # This cop supports safe autocorrection (--autocorrect).
106
- # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
107
- # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
108
- # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
109
- # FunctionalMethods: let, let!, subject, watch
110
- # AllowedMethods: lambda, proc, it
111
- Style/BlockDelimiters:
112
- Exclude:
113
- - 'bin/extract-ituob-amendments.rb'
114
-
115
- # Offense count: 11
116
- # Configuration parameters: AllowedConstants.
117
- Style/Documentation:
118
- Exclude:
119
- - 'spec/**/*'
120
- - 'test/**/*'
121
- - 'e118_amendment.rb'
122
- - 'e118_entry.rb'
123
- - 'lib/prosereflect/document.rb'
124
- - 'lib/prosereflect/hard_break.rb'
106
+ - 'lib/prosereflect/code_block.rb'
107
+ - 'lib/prosereflect/input/html.rb'
125
108
  - 'lib/prosereflect/node.rb'
126
- - 'lib/prosereflect/paragraph.rb'
109
+ - 'lib/prosereflect/output/html.rb'
127
110
  - 'lib/prosereflect/parser.rb'
128
- - 'lib/prosereflect/table.rb'
129
- - 'lib/prosereflect/table_cell.rb'
130
- - 'lib/prosereflect/table_row.rb'
131
- - 'lib/prosereflect/text.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'
132
117
 
133
- # Offense count: 1
134
- # This cop supports unsafe autocorrection (--autocorrect-all).
135
- # Configuration parameters: EnforcedStyle.
136
- # SupportedStyles: always, always_true, never
137
- 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:
138
122
  Exclude:
139
- - '**/*.arb'
140
- - 'bin/extract-ituob-amendments.rb'
123
+ - 'lib/prosereflect/schema/fragment.rb'
124
+ - 'lib/prosereflect/schema/node.rb'
141
125
 
142
- # Offense count: 7
143
- # This cop supports safe autocorrection (--autocorrect).
144
- Style/IfUnlessModifier:
145
- Exclude:
146
- - 'e118_amendment.rb'
147
- - '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'
148
147
 
149
148
  # Offense count: 1
150
- # This cop supports safe autocorrection (--autocorrect).
151
- # Configuration parameters: EnforcedStyle, MinBodyLength, AllowConsecutiveConditionals.
152
- # SupportedStyles: skip_modifier_ifs, always
153
- Style/Next:
149
+ # Configuration parameters: MinSize.
150
+ Performance/CollectionLiteralInLoop:
154
151
  Exclude:
155
- - 'e118_amendment.rb'
152
+ - 'lib/prosereflect/input/html.rb'
156
153
 
157
- # Offense count: 9
158
- # This cop supports unsafe autocorrection (--autocorrect-all).
159
- # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
160
- # SupportedStyles: predicate, comparison
161
- Style/NumericPredicate:
154
+ # Offense count: 7
155
+ # Configuration parameters: Prefixes, AllowedPatterns.
156
+ # Prefixes: when, with, without
157
+ RSpec/ContextWording:
162
158
  Exclude:
163
- - 'spec/**/*'
164
- - 'e118_amendment.rb'
165
- - 'e118_entry.rb'
166
- - 'lib/prosereflect/table.rb'
159
+ - 'spec/prosereflect/parser_spec.rb'
160
+ - 'spec/prosereflect/schema/conftest.rb'
161
+ - 'spec/support/shared_examples.rb'
167
162
 
168
- # Offense count: 1
169
- # This cop supports safe autocorrection (--autocorrect).
170
- Style/ParallelAssignment:
171
- Exclude:
172
- - 'e118_amendment.rb'
163
+ # Offense count: 142
164
+ # Configuration parameters: CountAsOne.
165
+ RSpec/ExampleLength:
166
+ Max: 134
173
167
 
174
- # Offense count: 1
175
- # This cop supports safe autocorrection (--autocorrect).
176
- Style/RedundantSelf:
177
- Exclude:
178
- - 'e118_amendment.rb'
168
+ # Offense count: 73
169
+ RSpec/MultipleExpectations:
170
+ Max: 8
179
171
 
180
- # Offense count: 1
181
- # This cop supports safe autocorrection (--autocorrect).
182
- # Configuration parameters: EnforcedStyle.
183
- # SupportedStyles: implicit, explicit
184
- Style/RescueStandardError:
185
- Exclude:
186
- - 'bin/extract-ituob-amendments.rb'
187
-
188
- # Offense count: 4
189
- # This cop supports unsafe autocorrection (--autocorrect-all).
190
- # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
191
- # AllowedMethods: present?, blank?, presence, try, try!
192
- Style/SafeNavigation:
193
- Exclude:
194
- - 'e118_amendment.rb'
172
+ # Offense count: 7
173
+ # Configuration parameters: AllowedGroups.
174
+ RSpec/NestedGroups:
175
+ Max: 4
195
176
 
196
- # Offense count: 1
177
+ # Offense count: 2
197
178
  # This cop supports unsafe autocorrection (--autocorrect-all).
198
- Style/SlicingWithRange:
179
+ Style/IdenticalConditionalBranches:
199
180
  Exclude:
200
- - 'lib/prosereflect/table.rb'
181
+ - 'lib/prosereflect/schema/mark.rb'
201
182
 
202
- # Offense count: 38
183
+ # Offense count: 2
203
184
  # This cop supports safe autocorrection (--autocorrect).
204
- # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
205
- # SupportedStyles: single_quotes, double_quotes
206
- Style/StringLiterals:
207
- Exclude:
208
- - 'Gemfile'
209
- - 'Rakefile'
210
- - 'bin/console'
211
- - 'bin/extract-ituob-amendments.rb'
212
- - 'lib/prosereflect.rb'
213
- - 'lib/prosereflect/version.rb'
214
- - 'prosereflect.gemspec'
215
-
216
- # Offense count: 7
217
- # This cop supports unsafe autocorrection (--autocorrect-all).
218
- Style/ZeroLengthPredicate:
185
+ # Configuration parameters: EnforcedStyleForMultiline.
186
+ # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
187
+ Style/TrailingCommaInArguments:
219
188
  Exclude:
220
- - 'e118_amendment.rb'
221
- - 'e118_entry.rb'
189
+ - 'spec/prosereflect/schema/conftest.rb'
222
190
 
223
- # Offense count: 6
191
+ # Offense count: 4
224
192
  # This cop supports safe autocorrection (--autocorrect).
225
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
226
- # URISchemes: http, https
227
- Layout/LineLength:
228
- 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"