Skip to content

Fix nested brace handling in LaTeX definition parser#102

Merged
izzortsi merged 2 commits intofeature/automated-semantic-analysisfrom
copilot/sub-pr-79
Nov 14, 2025
Merged

Fix nested brace handling in LaTeX definition parser#102
izzortsi merged 2 commits intofeature/automated-semantic-analysisfrom
copilot/sub-pr-79

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 14, 2025

The regex pattern r'\\definition\{([^}]+)\}\{([^}]+)\}' fails on nested braces, stopping at the first } encountered. This breaks parsing of definitions like \definition{term}{text with \emph{nested} braces}.

Changes

  • Added _extract_latex_arg() method using depth-counting algorithm to properly match braces
  • Refactored _extract_definitions() to use the parser instead of regex
  • Handles escaped characters (\\{, \\}) correctly

Example

# Before: Would extract only "text with \emph{nested"
# After: Correctly extracts full definition
\definition{Complex Term}{Definition with \emph{nested} braces}
\definition{Formatted}{Text with \textbf{bold} and \emph{italic} markup}

The parser tracks brace depth and only terminates when depth returns to zero, ensuring all nested structures are captured.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: izzortsi <35747979+izzortsi@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on automated semantic analysis workflow Fix nested brace handling in LaTeX definition parser Nov 14, 2025
Copilot AI requested a review from izzortsi November 14, 2025 01:33
@izzortsi izzortsi marked this pull request as ready for review November 14, 2025 02:41
@izzortsi izzortsi merged commit b8d4723 into feature/automated-semantic-analysis Nov 14, 2025
@izzortsi izzortsi deleted the copilot/sub-pr-79 branch November 14, 2025 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants