fix(translate): label paragraphs containing only dont-walk children - #2014
fix(translate): label paragraphs containing only dont-walk children#2014JoeJoeflyn wants to merge 1 commit into
Conversation
…engxi-ream#1951) SillyTavern renders narration inside <code> tags and dialogue inside <q> tags. The old walkNode filtered out isDontWalkIntoButTranslateAsChildElement children before checking hasInlineNodeChild, so a <p> containing only <code> never received PARAGRAPH_ATTRIBUTE and was skipped for translation. Dialogue paragraphs with <q> translated normally, causing the "only translates dialogue" bug. Set hasInlineNodeChild = true for non-empty dont-walk-but-translate children so the parent paragraph is labeled and the child is translated as a unit.
🦋 Changeset detectedLatest commit: 487fa0d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor trust score21/100 — New contributor This score estimates contributor familiarity with Outcome
Score breakdown
Signals used
Policy
Updated automatically when the PR changes or when a maintainer reruns the workflow. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 487fa0d207
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (isDontWalkIntoButTranslateAsChildElement(child, config) && child.textContent?.trim()) { | ||
| hasInlineNodeChild = true | ||
| } |
There was a problem hiding this comment.
Keep wrappers out of protected child elements
When this marks a parent whose only content is a dont-walk-but-translate child, the bilingual path later treats the parent as a single block source and unwrapDeepestOnlyHTMLChild can descend into that <code>/.notranslate child because it only stops on dont-walk-and-don't-translate nodes. For the target case <p><code>narration</code></p>, that appends the translation wrapper inside the <code> element rather than after the atomic child/parent, so the translated narration inherits code markup and violates the don't-walk-into boundary; prevent unwrapping into these protected children or place the wrapper outside them.
Useful? React with 👍 / 👎.
Type of Changes
Description
SillyTavern renders narration in
<code>tags and dialogue in<q>tags.CODEis inDONT_WALK_BUT_TRANSLATE_TAGS, so the oldwalkNodefiltered out<code>children before checkinghasInlineNodeChild. A<p>with only<code>never gotPARAGRAPH_ATTRIBUTEand was skipped — only<q>dialogue translated. Fix: sethasInlineNodeChild = truefor non-empty dont-walk-but-translate children.Related Issue
#1951
How Has This Been Tested?
<code>narration untranslated,<q>dialogue translated. Fixed build: all translated.<code>/<q>rendering.