July 2018
Intermediate to advanced
266 pages
7h 11m
English
Some of the articles display HTML tags in the summary. Usually these tags are fine because the summary is displayed in a viewer that supports HTML, but in our case we don't, so it's better to get rid of them.
To do this, we just need to tweak asyncFetchArticles() to cut the description if a div element is found:
.map { val title = it.getElementsByTagName("title") .item(0) .textContent var summary = it.getElementsByTagName("description") .item(0) .textContent if (!summary.startsWith("<div") && summary.contains("<div")) { summary = summary.substring(0, summary.indexOf("<div")) } Article(feed.name, title, summary)}
Now all the articles look okay – notice that we cut the div only if the summary is not starting with one, ...
Read now
Unlock full access