- comments.add(new Comment(id, author, title, date, content));
+ Comment comment = new Comment(id, author, title, date,
+ content);
+ Comment parent = null;
+
+ Element inReplyTo = post.getElementsByClass("in-reply-to")
+ .first();
+ if (inReplyTo != null) {
+ String parentId = inReplyTo.absUrl("href");
+ if (parentId != null && parentId.contains("/")) {
+ int i = parentId.lastIndexOf('/');
+ parentId = parentId.substring(i + 1);
+ parent = story.getCommentById(parentId);
+ }
+ }
+
+ if (parent == null) {
+ comments.add(comment);
+ } else {
+ parent.add(comment);
+ }