From: Niki Roo Date: Thu, 22 Mar 2018 15:59:09 +0000 (+0100) Subject: Add URL footnotes X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=880740c458956524bfe1e5f7c1f40b98d054bbe4;p=gofetch.git Add URL footnotes --- 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; } }