Fix WikivoyageArticle#getPartialContent

This commit is contained in:
Alex Sytnyk 2018-04-10 14:39:47 +03:00
parent fa64c070b1
commit baa5bee92e

View file

@ -98,15 +98,15 @@ public class WikivoyageArticle {
// 4 is the length of </p> tag
String firstParagraphHtml = content.substring(firstParagraphStart, firstParagraphEnd + 4);
String firstParagraphText = Html.fromHtml(firstParagraphHtml).toString();
String firstParagraphText = Html.fromHtml(firstParagraphHtml).toString().trim();
String[] phrases = firstParagraphText.split("\\. ");
StringBuilder res = new StringBuilder();
int limit = Math.min(phrases.length, PARTIAL_CONTENT_PHRASES);
for (int i = 0; i < limit; i++) {
res.append(phrases[i]).append(".");
res.append(phrases[i]);
if (i < limit - 1) {
res.append(" ");
res.append(". ");
}
}