Fix WikivoyageArticle#getPartialContent
This commit is contained in:
parent
fa64c070b1
commit
baa5bee92e
1 changed files with 3 additions and 3 deletions
|
@ -98,15 +98,15 @@ public class WikivoyageArticle {
|
||||||
|
|
||||||
// 4 is the length of </p> tag
|
// 4 is the length of </p> tag
|
||||||
String firstParagraphHtml = content.substring(firstParagraphStart, firstParagraphEnd + 4);
|
String firstParagraphHtml = content.substring(firstParagraphStart, firstParagraphEnd + 4);
|
||||||
String firstParagraphText = Html.fromHtml(firstParagraphHtml).toString();
|
String firstParagraphText = Html.fromHtml(firstParagraphHtml).toString().trim();
|
||||||
String[] phrases = firstParagraphText.split("\\. ");
|
String[] phrases = firstParagraphText.split("\\. ");
|
||||||
|
|
||||||
StringBuilder res = new StringBuilder();
|
StringBuilder res = new StringBuilder();
|
||||||
int limit = Math.min(phrases.length, PARTIAL_CONTENT_PHRASES);
|
int limit = Math.min(phrases.length, PARTIAL_CONTENT_PHRASES);
|
||||||
for (int i = 0; i < limit; i++) {
|
for (int i = 0; i < limit; i++) {
|
||||||
res.append(phrases[i]).append(".");
|
res.append(phrases[i]);
|
||||||
if (i < limit - 1) {
|
if (i < limit - 1) {
|
||||||
res.append(" ");
|
res.append(". ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue