diff options
author | campbeb <bpcampbell@gmail.com> | 2012-08-09 15:30:42 +0900 |
---|---|---|
committer | campbeb <bpcampbell@gmail.com> | 2012-08-09 15:30:42 +0900 |
commit | 679dc4dd4f5ee2a9d1730e882f82c3b175c0be30 (patch) | |
tree | d0f315d4b56e50fbfd0f1183e7a3941b7cd06928 /main/src/cgeo | |
parent | 6a16f9dda1bb3dd6f27fcffb1af7673cb41fb692 (diff) | |
download | cgeo-679dc4dd4f5ee2a9d1730e882f82c3b175c0be30.zip cgeo-679dc4dd4f5ee2a9d1730e882f82c3b175c0be30.tar.gz cgeo-679dc4dd4f5ee2a9d1730e882f82c3b175c0be30.tar.bz2 |
Add handling for HTML lists
Diffstat (limited to 'main/src/cgeo')
-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 68bdb1f..96bc734 100644 --- a/main/src/cgeo/geocaching/utils/UnknownTagsHandler.java +++ b/main/src/cgeo/geocaching/utils/UnknownTagsHandler.java @@ -13,6 +13,11 @@ public class UnknownTagsHandler implements TagHandler { private static int countCells = 0; int strikePos = UNDEFINED_POSITION; private boolean problematicDetected = false; + private enum ListType { + Ordered, Unordered + } + private static int listIndex = 0; + private static ListType listType; @Override public void handleTag(boolean opening, String tag, Editable output, @@ -27,6 +32,10 @@ public class UnknownTagsHandler implements TagHandler { handleTr(opening, output); } else if (tag.equalsIgnoreCase("pre")) { handleProblematic(); + } else if (tag.equalsIgnoreCase("ol")) { + handleOl(opening); + } else if (tag.equalsIgnoreCase("li")) { + handleLi(opening, output); } } @@ -67,4 +76,25 @@ public class UnknownTagsHandler implements TagHandler { } } + // Ordered lists are handled in a simple manner. They are rendered as Arabic numbers starting at 1 + // with no handling for alpha or Roman numbers or arbitrary numbering. + private static void handleOl(boolean opening) { + if (opening) { + listIndex = 1; + listType = ListType.Ordered; + } else { + listType = ListType.Unordered; + } + } + + private static void handleLi(boolean opening, Editable output) { + if (opening) { + if (listType == ListType.Ordered) { + output.append("\n " + (listIndex++) + ". "); + } else { + output.append("\n • "); + } + } + } + } |