fix(tts): don't let a self-closing prosody marker swallow the next expr tag#6449
Open
chuenchen309 wants to merge 1 commit into
Open
Conversation
…pr tag _EXPR_WRAP_RE matched any <expr ...type="prosody"|"spell"...> up to its next '>', which also matches a self-closing point control's own "/>". The lazy inner group then consumed everything up to the *next* </expr>, merging a following wrapping marker (e.g. spell) into its span and dropping that marker's own conversion. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
longcw
approved these changes
Jul 16, 2026
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.
What
_EXPR_WRAP_RE(the regex that matches a wrapping<expr type="prosody"|"spell">...</expr>marker) matched any<expr ...type="prosody"|"spell"...>up to its first>— which also matches the closing/>of a self-closing point control like<expr type="prosody" label="slow"/>. When a self-closing prosody marker appears before a later wrapping marker (e.g. aspelltag), the lazy inner group swallows everything up to the next</expr>, merging the two markers and dropping the second marker's own conversion.Repro (before fix):
Fix
Added a negative lookbehind (
(?<!/)) before the opening tag's closing>so_EXPR_WRAP_REnever matches a self-closing tag as a wrap opener — those are left for_EXPR_SELF_REto handle on its own pass, as intended.Testing
test_convert_expr_cartesia_self_closing_prosody_before_spell— red before the fix (asserted, see commit), green after.tests/test_expr_markup.py(42 tests) andtests/test_tokenizer_xml_markup.py(38 tests) pass.ruff check/ruff format --checkclean on both changed files.AI disclosure
Investigated and implemented with Claude Code (Claude Opus 4.8); I reviewed the diff, ran the repro and full test suite myself before opening this PR.