From 35166676716c4e84f57977945651d99b0d5f0859 Mon Sep 17 00:00:00 2001 From: TransZAllen Date: Fri, 17 Oct 2025 12:04:02 +0800 Subject: [PATCH] refactor(ttml): extract recursion into `traverseChildNodesForNestedTags()` - Extracted child-node traversal logic from `extractText()` into a helper method `traverseChildNodesForNestedTags()`. - No functional change. --- .../schabi/newpipe/streams/SrtFromTtmlWriter.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/streams/SrtFromTtmlWriter.java b/app/src/main/java/org/schabi/newpipe/streams/SrtFromTtmlWriter.java index ad1e4d13a..bea3422fc 100644 --- a/app/src/main/java/org/schabi/newpipe/streams/SrtFromTtmlWriter.java +++ b/app/src/main/java/org/schabi/newpipe/streams/SrtFromTtmlWriter.java @@ -205,6 +205,15 @@ public class SrtFromTtmlWriter { return srtSafeText; } + // Recursively process all child nodes to ensure text inside + // nested tags (e.g., ) is also extracted. + private void traverseChildNodesForNestedTags(final Node parent, + final StringBuilder text) { + for (final Node child : parent.childNodes()) { + extractText(child, text); + } + } + // CHECKSTYLE:OFF checkstyle:JavadocStyle // checkstyle does not understand that span tags are inside a code block /** @@ -244,10 +253,8 @@ public class SrtFromTtmlWriter { text.append(NEW_LINE); } } - // Recursively process child nodes - for (final Node child : node.childNodes()) { - extractText(child, text); - } + + traverseChildNodesForNestedTags(node, text); } // CHECKSTYLE:ON