From e1888ede8744829cf47716d987f2fc7d12a75de3 Mon Sep 17 00:00:00 2001 From: TobiGr Date: Wed, 27 Aug 2025 10:34:21 +0200 Subject: [PATCH] Fix JDoc and apply suggestions --- .../newpipe/streams/SrtFromTtmlWriter.java | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 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 902d5f57c..5f43185c6 100644 --- a/app/src/main/java/org/schabi/newpipe/streams/SrtFromTtmlWriter.java +++ b/app/src/main/java/org/schabi/newpipe/streams/SrtFromTtmlWriter.java @@ -54,18 +54,23 @@ public class SrtFromTtmlWriter { out.write(text.getBytes(charset)); } - /* - * Recursive method to extract text from all nodes - * - This method processes TextNode and
tags, recursively - * extracting text from nested tags. - * For example: extract text from nested tags - * - Appends newlines for
tags. + // CHECKSTYLE:OFF checkstyle:JavadocStyle + // checkstyle does not understand that span tags are inside a code block + /** + *

Recursive method to extract text from all nodes.

+ *

+ * This method processes {@link TextNode}s and {@code
} tags, + * recursively extracting text from nested tags + * (e.g. extracting text from nested {@code } tags). + * Newlines are added for {@code
} tags. + *

+ * @param node the current node to process + * @param text the {@link StringBuilder} to append the extracted text to */ private void extractText(final Node node, final StringBuilder text) { - if (node instanceof TextNode) { - text.append(((TextNode) node).text()); - } else if (node instanceof Element) { - final Element element = (Element) node; + if (node instanceof TextNode textNode) { + text.append((textNode).text()); + } else if (node instanceof Element element) { //
is a self-closing HTML tag used to insert a line break. if (element.tagName().equalsIgnoreCase("br")) { // Add a newline for
tags @@ -77,6 +82,7 @@ public class SrtFromTtmlWriter { extractText(child, text); } } + // CHECKSTYLE:ON public void build(final SharpStream ttml) throws IOException { /* @@ -98,7 +104,7 @@ public class SrtFromTtmlWriter { final Elements paragraphList = doc.select("body > div > p"); // check if has frames - if (paragraphList.size() < 1) { + if (paragraphList.isEmpty()) { return; }