feat: Add C.F.R. part/section separation support#7
Merged
beshkenadze merged 1 commit intomainfrom Aug 21, 2025
Merged
Conversation
Add proper support for separating C.F.R. citations into part and section
components, eliminating the need for manual string splitting.
Changes:
- Add `part` field to Metadata interface and FullLawCitation getters
- Update C.F.R. regex patterns to capture part and section separately
- Maintain backward compatibility with combined section getter
- Fix ID resolution logic to handle part.section substitution correctly
- Add comprehensive test suite for C.F.R. part/section parsing
- Update existing tests to work with new part/section structure
Breaking changes: None (backward compatible)
Resolves user request to avoid manual parsing of "778.113" into
part "778" and section "113" components.
Before:
```typescript
const [part, section] = citation.section.split('.')
```
After:
```typescript
const part = citation.part // "778"
const section = citation.sectionOnly // "113"
const combined = citation.section // "778.113" (backward compatible)
```
Owner
Author
|
🚀 Thanks for the PR! The CI checks are running. Once they pass, this PR will be ready for review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds proper support for separating C.F.R. citations into part and section components, eliminating the need for manual string splitting of citations like
"778.113"into part"778"and section"113".Changes Made
Core Implementation
partfield toMetadatainterfacepart,sectionOnly, and backward-compatiblesectiongetters toFullLawCitationlaws.jsonto capture part and section separatelyresolve.tsto handle part.section substitution correctlyTesting
tests/cfr-part-section.test.ts) with 11 test casesAPI Changes
New Properties Available
Before vs After
Before (manual parsing required):
After (direct access):
Backward Compatibility
✅ No breaking changes - All existing code continues to work unchanged.
✅ The
sectiongetter still returns the combined"778.113"format for backward compatibility.✅ New functionality is additive only.
Test Results
Coverage
29 C.F.R. § 778.113→ part:"778", section:"113"29 C.F.R. §§ 778.113, 778.114(maintains original behavior)29 C.F.R. § 1910.1200→ part:"1910", section:"1200"29 C.F.R. § 778.113(a)→ part:"778", section:"113", pinCite:"(a)"Id. § 778.114(a)(5)correctly substitutes both part and sectionDemo
The demo script (
demo-citation-extraction.ts) shows the new functionality in action with real C.F.R. and U.S.C. citations.Resolves the user's request to avoid manual string parsing of C.F.R. part.section identifiers.