Fixes an exception encountered when importing a text file as a book
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good

This commit is contained in:
2025-08-08 00:49:54 +02:00
parent 8affc42eaa
commit f6d5108c7b

View File

@@ -95,8 +95,11 @@ public final class BookFormatter {
*/
public static void formatLastPageAddNewline(@NotNull List<String> rawPages, int fitsNewline) {
int pageIndex = rawPages.size() - 1;
if (rawPages.get(pageIndex).length() <= fitsNewline && !rawPages.get(pageIndex).isEmpty()) {
rawPages.set(pageIndex, (rawPages.get(pageIndex)) + "\n");
String pageContents = rawPages.get(pageIndex);
if (pageContents == null) {
rawPages.set(pageIndex, "");
} else if (pageContents.length() <= fitsNewline && !pageContents.isEmpty()) {
rawPages.set(pageIndex, pageContents + "\n");
}
}