From 880740c458956524bfe1e5f7c1f40b98d054bbe4 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Thu, 22 Mar 2018 16:59:09 +0100 Subject: [PATCH] Add URL footnotes --- src/be/nikiroo/gofetch/support/BasicSupport.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/be/nikiroo/gofetch/support/BasicSupport.java b/src/be/nikiroo/gofetch/support/BasicSupport.java index 1258e89..4067979 100644 --- a/src/be/nikiroo/gofetch/support/BasicSupport.java +++ b/src/be/nikiroo/gofetch/support/BasicSupport.java @@ -256,6 +256,7 @@ public abstract class BasicSupport { final StringBuilder currentLine = new StringBuilder(); final List quoted = new ArrayList(); final List ignoredNodes = new ArrayList(); + final List footnotes = new ArrayList(); if (element != null) { new NodeTraversor(new NodeVisitor() { @@ -313,6 +314,11 @@ public abstract class BasicSupport { if (block && currentLine.length() > 0) { currentLine.append("\n"); } + + if (!element.absUrl("href").trim().isEmpty()) { + footnotes.add(element.absUrl("href")); + currentLine.append("[" + footnotes.size() + "]"); + } } else if (node instanceof TextNode) { TextNode textNode = (TextNode) node; String line = StringUtil.normaliseWhitespace(textNode @@ -349,6 +355,16 @@ public abstract class BasicSupport { lines.set(i, lines.get(i).replace(" ", " ").trim()); } + if (footnotes.size() > 0) { + lines.add(""); + lines.add(""); + lines.add(""); + lines.add(""); + for (int i = 0; i < footnotes.size(); i++) { + lines.add("[" + (i + 1) + "] " + footnotes.get(i)); + } + } + return lines; } } -- 2.27.0