mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-11-12 05:03:00 +00:00
Fix JDoc and apply suggestions
This commit is contained in:
@@ -54,18 +54,23 @@ public class SrtFromTtmlWriter {
|
|||||||
out.write(text.getBytes(charset));
|
out.write(text.getBytes(charset));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// CHECKSTYLE:OFF checkstyle:JavadocStyle
|
||||||
* Recursive method to extract text from all nodes
|
// checkstyle does not understand that span tags are inside a code block
|
||||||
* - This method processes TextNode and <br> tags, recursively
|
/**
|
||||||
* extracting text from nested tags.
|
* <p>Recursive method to extract text from all nodes.</p>
|
||||||
* For example: extract text from nested <span> tags
|
* <p>
|
||||||
* - Appends newlines for <br> tags.
|
* This method processes {@link TextNode}s and {@code <br>} tags,
|
||||||
|
* recursively extracting text from nested tags
|
||||||
|
* (e.g. extracting text from nested {@code <span>} tags).
|
||||||
|
* Newlines are added for {@code <br>} tags.
|
||||||
|
* </p>
|
||||||
|
* @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) {
|
private void extractText(final Node node, final StringBuilder text) {
|
||||||
if (node instanceof TextNode) {
|
if (node instanceof TextNode textNode) {
|
||||||
text.append(((TextNode) node).text());
|
text.append((textNode).text());
|
||||||
} else if (node instanceof Element) {
|
} else if (node instanceof Element element) {
|
||||||
final Element element = (Element) node;
|
|
||||||
// <br> is a self-closing HTML tag used to insert a line break.
|
// <br> is a self-closing HTML tag used to insert a line break.
|
||||||
if (element.tagName().equalsIgnoreCase("br")) {
|
if (element.tagName().equalsIgnoreCase("br")) {
|
||||||
// Add a newline for <br> tags
|
// Add a newline for <br> tags
|
||||||
@@ -77,6 +82,7 @@ public class SrtFromTtmlWriter {
|
|||||||
extractText(child, text);
|
extractText(child, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// CHECKSTYLE:ON
|
||||||
|
|
||||||
public void build(final SharpStream ttml) throws IOException {
|
public void build(final SharpStream ttml) throws IOException {
|
||||||
/*
|
/*
|
||||||
@@ -98,7 +104,7 @@ public class SrtFromTtmlWriter {
|
|||||||
final Elements paragraphList = doc.select("body > div > p");
|
final Elements paragraphList = doc.select("body > div > p");
|
||||||
|
|
||||||
// check if has frames
|
// check if has frames
|
||||||
if (paragraphList.size() < 1) {
|
if (paragraphList.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user