prosereflect 0.1.1 → 0.3.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 (158) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/docs.yml +63 -0
  3. data/.github/workflows/links.yml +97 -0
  4. data/.github/workflows/rake.yml +4 -0
  5. data/.github/workflows/release.yml +5 -0
  6. data/.gitignore +4 -0
  7. data/.rubocop.yml +19 -1
  8. data/.rubocop_todo.yml +119 -183
  9. data/CLAUDE.md +78 -0
  10. data/Gemfile +8 -4
  11. data/README.adoc +2 -0
  12. data/Rakefile +3 -3
  13. data/docs/Gemfile +10 -0
  14. data/docs/INDEX.adoc +45 -0
  15. data/docs/_advanced/index.adoc +15 -0
  16. data/docs/_advanced/schema.adoc +112 -0
  17. data/docs/_advanced/step-map.adoc +66 -0
  18. data/docs/_advanced/steps.adoc +88 -0
  19. data/docs/_advanced/test-builder.adoc +61 -0
  20. data/docs/_advanced/transform.adoc +92 -0
  21. data/docs/_config.yml +174 -0
  22. data/docs/_features/html-input.adoc +69 -0
  23. data/docs/_features/html-output.adoc +45 -0
  24. data/docs/_features/index.adoc +15 -0
  25. data/docs/_features/marks.adoc +86 -0
  26. data/docs/_features/node-types.adoc +124 -0
  27. data/docs/_features/user-mentions.adoc +47 -0
  28. data/docs/_guides/custom-nodes.adoc +107 -0
  29. data/docs/_guides/index.adoc +13 -0
  30. data/docs/_guides/round-trip-html.adoc +91 -0
  31. data/docs/_guides/serialization.adoc +109 -0
  32. data/docs/_pages/index.adoc +67 -0
  33. data/docs/_reference/document-api.adoc +49 -0
  34. data/docs/_reference/index.adoc +14 -0
  35. data/docs/_reference/node-api.adoc +79 -0
  36. data/docs/_reference/schema-api.adoc +95 -0
  37. data/docs/_reference/transform-api.adoc +77 -0
  38. data/docs/_understanding/document-model.adoc +65 -0
  39. data/docs/_understanding/fragment.adoc +52 -0
  40. data/docs/_understanding/index.adoc +14 -0
  41. data/docs/_understanding/resolved-position.adoc +53 -0
  42. data/docs/_understanding/slice.adoc +54 -0
  43. data/docs/lychee.toml +63 -0
  44. data/lib/prosereflect/attribute/base.rb +4 -6
  45. data/lib/prosereflect/attribute/bold.rb +2 -4
  46. data/lib/prosereflect/attribute/href.rb +1 -3
  47. data/lib/prosereflect/attribute/id.rb +7 -7
  48. data/lib/prosereflect/attribute.rb +4 -7
  49. data/lib/prosereflect/blockquote.rb +19 -11
  50. data/lib/prosereflect/bullet_list.rb +36 -29
  51. data/lib/prosereflect/code_block.rb +23 -27
  52. data/lib/prosereflect/code_block_wrapper.rb +12 -13
  53. data/lib/prosereflect/document.rb +14 -22
  54. data/lib/prosereflect/fragment.rb +249 -0
  55. data/lib/prosereflect/hard_break.rb +6 -6
  56. data/lib/prosereflect/heading.rb +14 -15
  57. data/lib/prosereflect/horizontal_rule.rb +23 -14
  58. data/lib/prosereflect/image.rb +32 -23
  59. data/lib/prosereflect/input/html.rb +179 -104
  60. data/lib/prosereflect/input.rb +7 -0
  61. data/lib/prosereflect/list_item.rb +11 -12
  62. data/lib/prosereflect/mark/base.rb +9 -11
  63. data/lib/prosereflect/mark/bold.rb +1 -3
  64. data/lib/prosereflect/mark/code.rb +1 -3
  65. data/lib/prosereflect/mark/italic.rb +1 -3
  66. data/lib/prosereflect/mark/link.rb +1 -3
  67. data/lib/prosereflect/mark/strike.rb +1 -3
  68. data/lib/prosereflect/mark/subscript.rb +1 -3
  69. data/lib/prosereflect/mark/superscript.rb +1 -3
  70. data/lib/prosereflect/mark/underline.rb +1 -3
  71. data/lib/prosereflect/mark.rb +9 -5
  72. data/lib/prosereflect/node.rb +171 -33
  73. data/lib/prosereflect/ordered_list.rb +17 -14
  74. data/lib/prosereflect/output/html.rb +279 -50
  75. data/lib/prosereflect/output.rb +7 -0
  76. data/lib/prosereflect/paragraph.rb +11 -13
  77. data/lib/prosereflect/parser.rb +56 -66
  78. data/lib/prosereflect/resolved_pos.rb +256 -0
  79. data/lib/prosereflect/schema/attribute.rb +57 -0
  80. data/lib/prosereflect/schema/content_match.rb +656 -0
  81. data/lib/prosereflect/schema/fragment.rb +166 -0
  82. data/lib/prosereflect/schema/mark.rb +121 -0
  83. data/lib/prosereflect/schema/mark_type.rb +130 -0
  84. data/lib/prosereflect/schema/node.rb +236 -0
  85. data/lib/prosereflect/schema/node_type.rb +274 -0
  86. data/lib/prosereflect/schema/schema_main.rb +190 -0
  87. data/lib/prosereflect/schema/spec.rb +92 -0
  88. data/lib/prosereflect/schema.rb +39 -0
  89. data/lib/prosereflect/table.rb +12 -13
  90. data/lib/prosereflect/table_cell.rb +13 -13
  91. data/lib/prosereflect/table_header.rb +17 -17
  92. data/lib/prosereflect/table_row.rb +12 -12
  93. data/lib/prosereflect/text.rb +35 -11
  94. data/lib/prosereflect/transform/attr_step.rb +157 -0
  95. data/lib/prosereflect/transform/insert_step.rb +115 -0
  96. data/lib/prosereflect/transform/mapping.rb +82 -0
  97. data/lib/prosereflect/transform/mark_step.rb +269 -0
  98. data/lib/prosereflect/transform/replace_around_step.rb +181 -0
  99. data/lib/prosereflect/transform/replace_step.rb +157 -0
  100. data/lib/prosereflect/transform/slice.rb +91 -0
  101. data/lib/prosereflect/transform/step.rb +89 -0
  102. data/lib/prosereflect/transform/step_map.rb +126 -0
  103. data/lib/prosereflect/transform/structure.rb +120 -0
  104. data/lib/prosereflect/transform/transform.rb +341 -0
  105. data/lib/prosereflect/transform.rb +26 -0
  106. data/lib/prosereflect/user.rb +15 -15
  107. data/lib/prosereflect/version.rb +1 -1
  108. data/lib/prosereflect.rb +30 -17
  109. data/prosereflect.gemspec +17 -16
  110. data/spec/fixtures/documents/formatted_text.yaml +14 -0
  111. data/spec/fixtures/documents/heading_paragraph.yaml +16 -0
  112. data/spec/fixtures/documents/lists_doc.yaml +32 -0
  113. data/spec/fixtures/documents/mixed_content.yaml +40 -0
  114. data/spec/fixtures/documents/nested_doc.yaml +20 -0
  115. data/spec/fixtures/documents/simple_doc.yaml +6 -0
  116. data/spec/fixtures/documents/table_doc.yaml +32 -0
  117. data/spec/fixtures/documents/transform_test.yaml +14 -0
  118. data/spec/fixtures/schema/custom_schema.rb +37 -0
  119. data/spec/fixtures/schema/test_schema.rb +46 -0
  120. data/spec/fixtures/test_builder/helpers.rb +212 -0
  121. data/spec/prosereflect/document_spec.rb +332 -330
  122. data/spec/prosereflect/fragment_spec.rb +273 -0
  123. data/spec/prosereflect/hard_break_spec.rb +125 -125
  124. data/spec/prosereflect/input/html_spec.rb +718 -522
  125. data/spec/prosereflect/node_spec.rb +311 -182
  126. data/spec/prosereflect/output/html_spec.rb +105 -105
  127. data/spec/prosereflect/output/whitespace_spec.rb +248 -0
  128. data/spec/prosereflect/paragraph_spec.rb +275 -274
  129. data/spec/prosereflect/parser/round_trip_spec.rb +472 -0
  130. data/spec/prosereflect/parser_spec.rb +185 -180
  131. data/spec/prosereflect/resolved_pos_spec.rb +74 -0
  132. data/spec/prosereflect/schema/conftest.rb +68 -0
  133. data/spec/prosereflect/schema/content_match_spec.rb +237 -0
  134. data/spec/prosereflect/schema/mark_spec.rb +274 -0
  135. data/spec/prosereflect/schema/mark_type_spec.rb +86 -0
  136. data/spec/prosereflect/schema/node_type_spec.rb +142 -0
  137. data/spec/prosereflect/schema/schema_spec.rb +194 -0
  138. data/spec/prosereflect/table_cell_spec.rb +183 -183
  139. data/spec/prosereflect/table_row_spec.rb +149 -149
  140. data/spec/prosereflect/table_spec.rb +320 -318
  141. data/spec/prosereflect/test_builder/marks_spec.rb +127 -0
  142. data/spec/prosereflect/text_spec.rb +133 -132
  143. data/spec/prosereflect/transform/equivalence_spec.rb +487 -0
  144. data/spec/prosereflect/transform/mapping_spec.rb +226 -0
  145. data/spec/prosereflect/transform/replace_spec.rb +832 -0
  146. data/spec/prosereflect/transform/replace_step_spec.rb +157 -0
  147. data/spec/prosereflect/transform/slice_spec.rb +48 -0
  148. data/spec/prosereflect/transform/step_map_spec.rb +70 -0
  149. data/spec/prosereflect/transform/step_spec.rb +211 -0
  150. data/spec/prosereflect/transform/structure_spec.rb +98 -0
  151. data/spec/prosereflect/transform/transform_spec.rb +238 -0
  152. data/spec/prosereflect/user_spec.rb +31 -28
  153. data/spec/prosereflect_spec.rb +28 -26
  154. data/spec/spec_helper.rb +7 -6
  155. data/spec/support/matchers.rb +6 -6
  156. data/spec/support/shared_examples.rb +49 -49
  157. metadata +96 -5
  158. 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: d9f70970efc856c322c1d356262ae1492856c2432d2ed6343b7f00a4b96a97a9
4
+ data.tar.gz: 4670d12e397d85fa399ea4bd721d0eaa4d35aa24b7425c0bb7e6b61eb057a173
5
5
  SHA512:
6
- metadata.gz: a7f45b590785499274eb6112a961e131af7af6a5c679a388eaf3bd01805a731f572fbf7d5efa938f5466e359e2c3dc81953816164ac3a3c0585ab9e98b97a220
7
- data.tar.gz: dd99eed85e651b903869b53a09866a550e71b5fd29efbf8fa380b6f35bee33c2189675ca1897d10f11400975a45dbb13d798fef916a466b61181a9046fee5ff2
6
+ metadata.gz: 42bb32f0114a3cb597a65498681177c93345f3ddcff24412a2ba03dd8492b1ec0da306797ada94fac95c984e0f80a63631de555fae2a836b647c8805ab73e0b6
7
+ data.tar.gz: d6b5dcf22e6d6b0c923c5b35a1dbccecea6e7103af0001428ca567ad8f2333d2f63fe7652149f087b2ea0383beff80afc69e02b09f086f93b5fd51ee7be1dca1
@@ -0,0 +1,63 @@
1
+ name: docs
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ paths:
7
+ - 'docs/**'
8
+ pull_request:
9
+ paths:
10
+ - 'docs/**'
11
+ repository_dispatch:
12
+ workflow_dispatch:
13
+
14
+ permissions:
15
+ contents: read
16
+ pages: write
17
+ id-token: write
18
+
19
+ concurrency:
20
+ group: ${{ github.workflow }}-${{ github.ref }}
21
+ cancel-in-progress: false
22
+
23
+ jobs:
24
+ build:
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - name: Checkout
28
+ uses: actions/checkout@v6
29
+
30
+ - name: Setup Ruby
31
+ uses: ruby/setup-ruby@v1
32
+ with:
33
+ ruby-version: '3.3'
34
+ bundler-cache: true
35
+ cache-version: 0
36
+ working-directory: docs
37
+
38
+ - name: Setup Pages
39
+ id: pages
40
+ uses: actions/configure-pages@v5
41
+
42
+ - name: Build with Jekyll
43
+ run: bundle exec jekyll build --verbose --trace --baseurl "${{ steps.pages.outputs.base_path }}"
44
+ working-directory: docs
45
+ env:
46
+ JEKYLL_ENV: production
47
+
48
+ - name: Upload artifact
49
+ uses: actions/upload-pages-artifact@v4
50
+ with:
51
+ path: docs/_site
52
+
53
+ deploy:
54
+ environment:
55
+ name: github-pages
56
+ url: ${{ steps.deployment.outputs.page_url }}
57
+ if: ${{ github.ref == 'refs/heads/main' }}
58
+ runs-on: ubuntu-latest
59
+ needs: build
60
+ steps:
61
+ - name: Deploy to GitHub Pages
62
+ id: deployment
63
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,97 @@
1
+ name: links
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ paths:
8
+ - 'docs/**'
9
+ pull_request:
10
+ paths:
11
+ - 'docs/**'
12
+
13
+ # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
14
+ permissions:
15
+ contents: read
16
+ pull-requests: write
17
+
18
+ jobs:
19
+ link_checker:
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - uses: actions/checkout@v6
23
+
24
+ - uses: ruby/setup-ruby@v1
25
+ with:
26
+ ruby-version: '3.4'
27
+ bundler-cache: true
28
+ working-directory: docs
29
+
30
+ - name: Build site
31
+ env:
32
+ JEKYLL_ENV: production
33
+ run: bundle exec jekyll build --trace
34
+ working-directory: docs
35
+
36
+ - name: Restore lychee cache
37
+ uses: actions/cache@v4
38
+ with:
39
+ path: .lycheecache
40
+ key: cache-lychee-${{ github.sha }}
41
+ restore-keys: cache-lychee-
42
+
43
+ - name: Check if site was built
44
+ run: |
45
+ if [ ! -d "_site" ]; then
46
+ echo "Error: _site directory not created"
47
+ exit 1
48
+ fi
49
+ echo "Site built successfully"
50
+ ls -la _site/
51
+ working-directory: docs
52
+
53
+ - name: Link Checker (Built Site)
54
+ uses: lycheeverse/lychee-action@v2
55
+ with:
56
+ args: >-
57
+ --verbose
58
+ --no-progress
59
+ --config lychee.toml
60
+ --root-dir "$(pwd)/_site"
61
+ --scheme https,http
62
+ '_site/**/*.html'
63
+ fail: true
64
+ output: link-check-results.md
65
+ format: markdown
66
+ workingDirectory: docs
67
+
68
+ - name: Upload link check results
69
+ if: always()
70
+ uses: actions/upload-artifact@v4
71
+ with:
72
+ name: link-check-results
73
+ path: |
74
+ docs/link-check-results.md
75
+ retention-days: 30
76
+
77
+ - name: Comment PR with results
78
+ if: failure() && github.event_name == 'pull_request'
79
+ uses: actions/github-script@v7
80
+ with:
81
+ script: |
82
+ const fs = require('fs');
83
+ let comment = '## Link Check Failed\n\n';
84
+
85
+ if (fs.existsSync('docs/link-check-results.md')) {
86
+ const results = fs.readFileSync('docs/link-check-results.md', 'utf8');
87
+ comment += '### Built Site Results\n\n' + results + '\n\n';
88
+ }
89
+
90
+ comment += '\n---\n\n*Please fix the broken links and push a new commit.*';
91
+
92
+ github.rest.issues.createComment({
93
+ issue_number: context.issue.number,
94
+ owner: context.repo.owner,
95
+ repo: context.repo.repo,
96
+ body: comment
97
+ });
@@ -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/.gitignore CHANGED
@@ -10,3 +10,7 @@
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
12
  Gemfile.lock
13
+ docs/_site/
14
+ docs/.jekyll-cache/
15
+ docs/.bundle/
16
+ docs/vendor/
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,183 @@
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-14 23:12:52 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:
10
+ Gemspec/RequiredRubyVersion:
12
11
  Exclude:
13
- - 'bin/extract-ituob-amendments.rb'
12
+ - 'prosereflect.gemspec'
14
13
 
15
14
  # Offense count: 2
16
15
  # This cop supports safe autocorrection (--autocorrect).
17
- # Configuration parameters: AllowForAlignment.
18
- Layout/CommentIndentation:
16
+ Layout/ElseAlignment:
19
17
  Exclude:
20
- - 'e118_amendment.rb'
18
+ - 'lib/prosereflect/schema/schema_main.rb'
21
19
 
22
20
  # Offense count: 1
23
21
  # This cop supports safe autocorrection (--autocorrect).
24
- Layout/EmptyLineAfterGuardClause:
22
+ # Configuration parameters: EnforcedStyleAlignWith.
23
+ # SupportedStylesAlignWith: keyword, variable, start_of_line
24
+ Layout/EndAlignment:
25
25
  Exclude:
26
- - 'e118_amendment.rb'
26
+ - 'lib/prosereflect/schema/schema_main.rb'
27
27
 
28
28
  # Offense count: 1
29
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'
34
-
35
- # Offense count: 2
36
- # This cop supports safe autocorrection (--autocorrect).
37
- Layout/EmptyLines:
38
- Exclude:
39
- - 'e118_amendment.rb'
40
-
41
- # Offense count: 2
42
- # 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'
48
-
49
- # Offense count: 2
50
- # This cop supports safe autocorrection (--autocorrect).
51
- # Configuration parameters: Width, AllowedPatterns.
30
+ # Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
31
+ # SupportedStylesAlignWith: start_of_line, relative_to_receiver
52
32
  Layout/IndentationWidth:
53
33
  Exclude:
54
- - 'bin/extract-ituob-amendments.rb'
55
- - 'e118_amendment.rb'
34
+ - 'lib/prosereflect/schema/schema_main.rb'
56
35
 
57
- # Offense count: 1
36
+ # Offense count: 264
58
37
  # This cop supports safe autocorrection (--autocorrect).
59
- Lint/ScriptPermission:
38
+ # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
39
+ # URISchemes: http, https
40
+ Layout/LineLength:
41
+ Enabled: false
42
+
43
+ # Offense count: 5
44
+ # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
45
+ Lint/DuplicateBranch:
60
46
  Exclude:
61
- - 'debug_loading.rb'
47
+ - 'lib/prosereflect/input/html.rb'
48
+ - 'lib/prosereflect/schema/attribute.rb'
49
+ - 'lib/prosereflect/schema/content_match.rb'
50
+ - 'lib/prosereflect/schema/mark.rb'
51
+ - 'spec/fixtures/test_builder/helpers.rb'
62
52
 
63
53
  # Offense count: 1
64
54
  # This cop supports safe autocorrection (--autocorrect).
65
- # Configuration parameters: AutoCorrect, ContextCreatingMethods, MethodCreatingMethods.
66
- Lint/UselessAccessModifier:
55
+ # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
56
+ # NotImplementedExceptions: NotImplementedError
57
+ Lint/UnusedMethodArgument:
67
58
  Exclude:
68
- - 'e118_amendment.rb'
59
+ - 'lib/prosereflect/schema/node.rb'
69
60
 
70
- # Offense count: 5
71
- # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
61
+ # Offense count: 57
62
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
72
63
  Metrics/AbcSize:
73
- Max: 98
64
+ Enabled: false
74
65
 
75
- # Offense count: 23
76
- # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
66
+ # Offense count: 1
67
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
77
68
  # AllowedMethods: refine
78
69
  Metrics/BlockLength:
79
- Exclude:
80
- - 'spec/prosereflect/input/html_spec.rb'
81
- Max: 500
70
+ Max: 27
82
71
 
83
- # Offense count: 3
84
- Metrics/ClassLength:
85
- Exclude:
86
- - 'lib/prosereflect/input/html.rb'
87
- - 'lib/prosereflect/output/html.rb'
88
- - 'lib/prosereflect/node.rb'
72
+ # Offense count: 1
73
+ # Configuration parameters: CountBlocks, CountModifierForms.
74
+ Metrics/BlockNesting:
75
+ Max: 4
89
76
 
90
- # Offense count: 4
91
- # Configuration parameters: AllowedMethods, AllowedPatterns.
77
+ # Offense count: 57
78
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
92
79
  Metrics/CyclomaticComplexity:
93
- Max: 50
80
+ Enabled: false
94
81
 
95
- # Offense count: 6
82
+ # Offense count: 82
96
83
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
97
84
  Metrics/MethodLength:
98
- Max: 90
99
-
100
- # Offense count: 3
101
- # Configuration parameters: AllowedMethods, AllowedPatterns.
102
- Metrics/PerceivedComplexity:
103
- Max: 35
85
+ Max: 93
104
86
 
105
87
  # 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:
110
- Exclude:
111
- - 'e118_entry.rb'
88
+ # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
89
+ Metrics/ParameterLists:
90
+ Max: 8
112
91
 
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'
92
+ # Offense count: 52
93
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
94
+ Metrics/PerceivedComplexity:
95
+ Enabled: false
123
96
 
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'
147
- - 'lib/prosereflect/input/html.rb'
148
- - 'lib/prosereflect/output/html.rb'
149
- - 'lib/prosereflect/mark.rb'
150
- - 'lib/prosereflect/mark/base.rb'
97
+ # Offense count: 7
98
+ # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
99
+ # AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
100
+ Naming/MethodParameterName:
101
+ Exclude:
102
+ - 'lib/prosereflect/schema/content_match.rb'
103
+ - 'lib/prosereflect/schema/fragment.rb'
104
+ - 'lib/prosereflect/schema/mark.rb'
105
+ - 'lib/prosereflect/schema/node.rb'
106
+
107
+ # Offense count: 8
108
+ # Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
109
+ # AllowedMethods: call
110
+ # WaywardPredicates: infinite?, nonzero?
111
+ Naming/PredicateMethod:
112
+ Exclude:
113
+ - 'lib/prosereflect/schema/attribute.rb'
114
+ - 'lib/prosereflect/schema/content_match.rb'
115
+ - 'lib/prosereflect/schema/node.rb'
116
+
117
+ # Offense count: 12
118
+ # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
119
+ # NamePrefix: is_, has_, have_, does_
120
+ # ForbiddenPrefixes: is_, has_, have_, does_
121
+ # AllowedMethods: is_a?
122
+ # MethodDefinitionMacros: define_method, define_singleton_method
123
+ Naming/PredicatePrefix:
124
+ Exclude:
125
+ - 'lib/prosereflect/schema/mark.rb'
126
+ - 'lib/prosereflect/schema/mark_type.rb'
127
+ - 'lib/prosereflect/schema/node.rb'
128
+ - 'lib/prosereflect/schema/node_type.rb'
151
129
 
152
130
  # Offense count: 1
153
- # This cop supports unsafe autocorrection (--autocorrect-all).
154
- # Configuration parameters: EnforcedStyle.
155
- # SupportedStyles: always, always_true, never
156
- Style/FrozenStringLiteralComment:
131
+ # Configuration parameters: MinSize.
132
+ Performance/CollectionLiteralInLoop:
157
133
  Exclude:
158
- - '**/*.arb'
159
- - 'bin/extract-ituob-amendments.rb'
134
+ - 'lib/prosereflect/input/html.rb'
160
135
 
161
136
  # Offense count: 7
162
- # This cop supports safe autocorrection (--autocorrect).
163
- Style/IfUnlessModifier:
164
- Exclude:
165
- - 'e118_amendment.rb'
166
- - 'e118_entry.rb'
167
-
168
- # 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:
137
+ # Configuration parameters: Prefixes, AllowedPatterns.
138
+ # Prefixes: when, with, without
139
+ RSpec/ContextWording:
173
140
  Exclude:
174
- - 'e118_amendment.rb'
141
+ - 'spec/prosereflect/parser_spec.rb'
142
+ - 'spec/prosereflect/schema/conftest.rb'
143
+ - 'spec/support/shared_examples.rb'
175
144
 
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:
181
- Exclude:
182
- - 'spec/**/*'
183
- - 'e118_amendment.rb'
184
- - 'e118_entry.rb'
185
- - 'lib/prosereflect/table.rb'
145
+ # Offense count: 254
146
+ # Configuration parameters: CountAsOne.
147
+ RSpec/ExampleLength:
148
+ Max: 134
186
149
 
187
- # Offense count: 1
188
- # This cop supports safe autocorrection (--autocorrect).
189
- Style/ParallelAssignment:
190
- Exclude:
191
- - 'e118_amendment.rb'
150
+ # Offense count: 158
151
+ RSpec/MultipleExpectations:
152
+ Max: 8
192
153
 
193
- # Offense count: 1
194
- # This cop supports safe autocorrection (--autocorrect).
195
- Style/RedundantSelf:
196
- Exclude:
197
- - 'e118_amendment.rb'
154
+ # Offense count: 7
155
+ # Configuration parameters: AllowedGroups.
156
+ RSpec/NestedGroups:
157
+ Max: 4
198
158
 
199
159
  # Offense count: 1
200
- # This cop supports safe autocorrection (--autocorrect).
201
- # Configuration parameters: EnforcedStyle.
202
- # SupportedStyles: implicit, explicit
203
- Style/RescueStandardError:
160
+ # Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector.
161
+ # SupportedInflectors: default, active_support
162
+ RSpec/SpecFilePathFormat:
204
163
  Exclude:
205
- - 'bin/extract-ituob-amendments.rb'
164
+ - 'spec/prosereflect/schema/schema_spec.rb'
206
165
 
207
- # Offense count: 4
166
+ # Offense count: 2
208
167
  # This cop supports unsafe autocorrection (--autocorrect-all).
209
- # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
210
- # AllowedMethods: present?, blank?, presence, try, try!
211
- Style/SafeNavigation:
168
+ Style/IdenticalConditionalBranches:
212
169
  Exclude:
213
- - 'e118_amendment.rb'
170
+ - 'lib/prosereflect/schema/mark.rb'
214
171
 
215
172
  # Offense count: 1
216
- # This cop supports unsafe autocorrection (--autocorrect-all).
217
- Style/SlicingWithRange:
218
- Exclude:
219
- - 'lib/prosereflect/table.rb'
220
-
221
- # Offense count: 38
222
- # This cop supports safe autocorrection (--autocorrect).
223
- # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
224
- # SupportedStyles: single_quotes, double_quotes
225
- Style/StringLiterals:
173
+ # Configuration parameters: EnforcedStyle.
174
+ # SupportedStyles: allow_single_line, disallow
175
+ Style/NumberedParameters:
226
176
  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'
177
+ - 'lib/prosereflect/schema/content_match.rb'
234
178
 
235
- # Offense count: 7
236
- # This cop supports unsafe autocorrection (--autocorrect-all).
237
- Style/ZeroLengthPredicate:
179
+ # Offense count: 1
180
+ # Configuration parameters: AllowedClasses.
181
+ Style/OneClassPerFile:
238
182
  Exclude:
239
- - 'e118_amendment.rb'
240
- - 'e118_entry.rb'
241
-
242
- # Offense count: 6
243
- # 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
183
+ - 'lib/prosereflect/schema.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
+ ```