Z namespace of different types - #428
kavitharaju wants to merge 15 commits into
Conversation
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| def read_to_object(self,file_content=None, file_path=None): | ||
| if file_path and file_content is None: | ||
| file_content = open(file_path, 'r', encoding='utf-8').read() | ||
| self.lines = file_content.splitlines() |
There was a problem hiding this comment.
Suggestion: Reading new content does not clear self.extensions, so reused readers retain markers from earlier files and replace markers that belong only to stale state. [stale reference]
Assessment: 🟠 Major · 🔁 Occurrence: Rarely
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** py-usfm-parser/src/usfm_grammar/markers_ext_reader.py
**Line:** 57:57
**Comment:**
*Stale Reference: Reading new content does not clear `self.extensions`, so reused readers retain markers from earlier files and replace markers that belong only to stale state.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| def replace_custom_markers(self, usfm_string): | ||
| modified_usfm = usfm_string | ||
| for marker in self.extensions: | ||
| marker_type = type_map[self.extensions[marker]['category']] |
There was a problem hiding this comment.
Suggestion: Unsupported or missing categories raise KeyError, so malformed extension blocks abort parsing instead of being ignored like the other parsers. [api mismatch]
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** py-usfm-parser/src/usfm_grammar/markers_ext_reader.py
**Line:** 81:81
**Comment:**
*Api Mismatch: Unsupported or missing categories raise `KeyError`, so malformed extension blocks abort parsing instead of being ignored like the other parsers.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| xt: $ => prec.right(0,seq("\\xt ", optional($.crossrefText),optional(choice($.defaultAttribute, $._attributesInCrossref)), | ||
| optional("\\xt*"))), |
There was a problem hiding this comment.
Suggestion: The added cross-reference content rules allow closing markers to be omitted, so truncated \xt and similar content is accepted instead of reported as malformed USFM. [api mismatch]
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** tree-sitter-usfm3/grammar.js
**Line:** 452:453
**Comment:**
*Api Mismatch: The added cross-reference content rules allow closing markers to be omitted, so truncated `\xt` and similar content is accepted instead of reported as malformed USFM.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| zNameSpaceNote: $=> prec.right(0, seq($.zNameSpaceNote, $.caller, //repeat(choice($._footnoteContents, $._crossrefContents, $.zNameSpaceChar)), $.zSpaceCloseNote)), | ||
| repeat($.zNameSpaceChar), $.zNameSpaceNote)), |
There was a problem hiding this comment.
Suggestion: zNameSpaceNote recursively requires itself before consuming its opening marker, so custom note input cannot match this rule and produces parse errors. [logic error]
Assessment: 🔴 Critical · 🔁 Occurrence: Often
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** tree-sitter-usfm3/grammar.js
**Line:** 671:672
**Comment:**
*Logic Error: `zNameSpaceNote` recursively requires itself before consuming its opening marker, so custom note input cannot match this rule and produces parse errors.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| if (usfmString.includes('\\custom')) { | ||
| console.log('Modified USFM:', modifiedUsfm); | ||
| } |
There was a problem hiding this comment.
Suggestion: Parsing custom USFM logs the entire modified document, exposing Scripture or user content in browser consoles whenever custom markers are present. [security]
Assessment: 🟠 Major · 🔁 Occurrence: Rarely
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** web-usfm-parser/src/markersExtReader.js
**Line:** 83:85
**Comment:**
*Security: Parsing custom USFM logs the entire modified document, exposing Scripture or user content in browser consoles whenever custom markers are present.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| return; | ||
| } | ||
|
|
||
| const customJsonObj = { type: nodeType }; |
There was a problem hiding this comment.
Suggestion: Custom nodes do not consume pending vid state, so an explicit vid is lost and may incorrectly attach to the following node. [stale reference]
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** web-usfm-parser/src/usjGenerator.js
**Line:** 501:501
**Comment:**
*Stale Reference: Custom nodes do not consume pending `vid` state, so an explicit `vid` is lost and may incorrectly attach to the following node.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| try { | ||
| const data = fs.readFileSync(inputUsfmPath, 'utf8'); | ||
| let testParser = new USFMParser(data); | ||
| let testParser = new USFMParser(data, null, null, null, null, customMarkersExt); |
There was a problem hiding this comment.
Suggestion: Every baseline fixture now uses customMarkersExt, so these tests no longer verify parser behavior without extensions and can miss default-path regressions. [incomplete implementation]
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** node-usfm-parser/test/config.js
**Line:** 148:148
**Comment:**
*Incomplete Implementation: Every baseline fixture now uses `customMarkersExt`, so these tests no longer verify parser behavior without extensions and can miss default-path regressions.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| const markerType = typeMap[category]; | ||
| if (markerType === undefined) { | ||
| continue; | ||
| } | ||
| const replacement = replacementMap[markerType]; | ||
| const markerPattern = new RegExp(`\\\\${marker}(?=[^\\w-]|$)`, 'g'); | ||
| modifiedUsfm = modifiedUsfm.replace( | ||
| markerPattern, | ||
| `\\${replacement}${marker}`, | ||
| ); |
There was a problem hiding this comment.
Suggestion: The milestone category has no entry in replacementMap, so milestone markers become \undefinedz... and cannot be parsed. [api mismatch]
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** node-usfm-parser/src/markersExtReader.js
**Line:** 71:80
**Comment:**
*Api Mismatch: The `milestone` category has no entry in `replacementMap`, so milestone markers become `\undefinedz...` and cannot be parsed.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
CodeAnt Nitpicks2 code suggestions1. This only checks whether any custom namespace node exists, so a missing custom marker passes whenever another unrelated custom marker appears in the same file.Incorrect condition logic · 2.
|
User description
CodeAnt-AI Description
Support typed custom z markers across parser formats
What Changed
Impact
✅ Custom z markers parse across all supported runtimes✅ Custom marker content survives USJ and USX conversion✅ Clearer warnings for mismatched custom marker closures💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.