Skip to content

Commit 3516667

Browse files
committed
refactor(ttml): extract recursion into traverseChildNodesForNestedTags()
- Extracted child-node traversal logic from `extractText()` into a helper method `traverseChildNodesForNestedTags()`. - No functional change.
1 parent 22ee01b commit 3516667

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

app/src/main/java/org/schabi/newpipe/streams/SrtFromTtmlWriter.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ private String sanitizeFragment(final String raw) {
205205
return srtSafeText;
206206
}
207207

208+
// Recursively process all child nodes to ensure text inside
209+
// nested tags (e.g., <span>) is also extracted.
210+
private void traverseChildNodesForNestedTags(final Node parent,
211+
final StringBuilder text) {
212+
for (final Node child : parent.childNodes()) {
213+
extractText(child, text);
214+
}
215+
}
216+
208217
// CHECKSTYLE:OFF checkstyle:JavadocStyle
209218
// checkstyle does not understand that span tags are inside a code block
210219
/**
@@ -244,10 +253,8 @@ private void extractText(final Node node, final StringBuilder text) {
244253
text.append(NEW_LINE);
245254
}
246255
}
247-
// Recursively process child nodes
248-
for (final Node child : node.childNodes()) {
249-
extractText(child, text);
250-
}
256+
257+
traverseChildNodesForNestedTags(node, text);
251258
}
252259
// CHECKSTYLE:ON
253260

0 commit comments

Comments
 (0)