X-Git-Url: http://git.nikiroo.be/?p=gofetch.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fgofetch%2Fsupport%2FBasicSupport.java;fp=src%2Fbe%2Fnikiroo%2Fgofetch%2Fsupport%2FBasicSupport.java;h=42761c9a82d1a7cd39bcd3bc96dd46e862f608a2;hp=dcd5e6ea295ad11f18372035d7b9033b1b7c5ba0;hb=e818d449fee8a5397ab2f05df63bbeffc4c67dc0;hpb=a6a7ff9f2e7f42f17eaa69be2bfad201195b3eb4 diff --git a/src/be/nikiroo/gofetch/support/BasicSupport.java b/src/be/nikiroo/gofetch/support/BasicSupport.java index dcd5e6e..42761c9 100644 --- a/src/be/nikiroo/gofetch/support/BasicSupport.java +++ b/src/be/nikiroo/gofetch/support/BasicSupport.java @@ -300,21 +300,7 @@ public abstract class BasicSupport { Document doc = DataUtil.load(in, "UTF-8", url.toString()); Element article = getFullArticle(doc); if (article != null) { - StringBuilder builder = new StringBuilder(); - ElementProcessor eProc = getElementProcessorFullArticle(); - if (eProc != null) { - for (String line : toLines(article, eProc)) { - builder.append(line + "\n"); - } - } else { - builder.append(article.text()); - } - - // Content is too tight with a single break per line: - fullContent = builder.toString().replace("\n", "\n\n") // - .replace("\n\n\n\n", "\n\n") // - .replace("\n\n\n\n", "\n\n") // - .trim(); + fullContent = getArticleText(article); } if (fullContent.isEmpty()) { @@ -331,6 +317,33 @@ public abstract class BasicSupport { } } + /** + * Return the text from this {@link Element}, using the + * {@link BasicSupport#getElementProcessorFullArticle()} processor logic. + * + * @param article + * the element to extract the text from + * + * @return the text + */ + protected String getArticleText(Element article) { + StringBuilder builder = new StringBuilder(); + ElementProcessor eProc = getElementProcessorFullArticle(); + if (eProc != null) { + for (String line : toLines(article, eProc)) { + builder.append(line + "\n"); + } + } else { + builder.append(article.text()); + } + + // Content is too tight with a single break per line: + return builder.toString().replace("\n", "\n\n") // + .replace("\n\n\n\n", "\n\n") // + .replace("\n\n\n\n", "\n\n") // + .trim(); + } + /** * Return the full article if available (this is the article to retrieve * from the newly downloaded page at {@link Story#getUrlInternal()}).