diff options
author | campbeb <bpcampbell@gmail.com> | 2012-01-14 16:22:54 +0900 |
---|---|---|
committer | campbeb <bpcampbell@gmail.com> | 2012-01-14 16:30:24 +0900 |
commit | 78c11fb2dc606195a431a2a0ebf889558dd09f3b (patch) | |
tree | fcec2e2a5276a40c133d81a749faae87fdb66659 /main/src/cgeo/geocaching/utils | |
parent | 790628b3e3c8c707b984dd5dbd2367efa08a03d7 (diff) | |
download | cgeo-78c11fb2dc606195a431a2a0ebf889558dd09f3b.zip cgeo-78c11fb2dc606195a431a2a0ebf889558dd09f3b.tar.gz cgeo-78c11fb2dc606195a431a2a0ebf889558dd09f3b.tar.bz2 |
Add a note to the description if it contains HTML tables since we don't
format them correctly.
Add rudimentary formatting for <td> and <tr> HTML tags.
Diffstat (limited to 'main/src/cgeo/geocaching/utils')
-rw-r--r-- | main/src/cgeo/geocaching/utils/UnknownTagsHandler.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/utils/UnknownTagsHandler.java b/main/src/cgeo/geocaching/utils/UnknownTagsHandler.java index e8f524b..ade499a 100644 --- a/main/src/cgeo/geocaching/utils/UnknownTagsHandler.java +++ b/main/src/cgeo/geocaching/utils/UnknownTagsHandler.java @@ -11,11 +11,18 @@ public class UnknownTagsHandler implements TagHandler { private static final int UNDEFINED_POSITION = -1; int strikePos = UNDEFINED_POSITION; + private boolean tableDetected = false; public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) { if (tag.equalsIgnoreCase("strike") || tag.equals("s")) { handleStrike(opening, output); + } else if (tag.equalsIgnoreCase("table")) { + handleTable(); + } else if (tag.equalsIgnoreCase("td")) { + handleTd(opening, output); + } else if (tag.equalsIgnoreCase("tr")) { + handleTr(opening, output); } } @@ -30,4 +37,27 @@ public class UnknownTagsHandler implements TagHandler { } } } + + public boolean isTableDetected() { + return tableDetected; + } + + private void handleTable() { + tableDetected = true; + } + + private static void handleTd(boolean opening, Editable output) { + // insert space for each table column + if (opening) { + output.insert(output.length(), " "); + } + } + + private static void handleTr(boolean opening, Editable output) { + // insert new line for each table row + if (opening) { + output.insert(output.length(), "\n"); + } + } + } |