aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-02-20 15:18:06 +0000
committerMichael Williamson <mike@zwobble.org>2016-02-20 15:18:06 +0000
commit32aee86473c4e0865e9ad181be2b8418cd93c9a0 (patch)
tree1520a42b5d2518a979022738103e811455972cd6 /src
parent06f44fda480492636f69b3f57f0b158c93eb2eb2 (diff)
Move note conversion into nested class
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/zwobble/mammoth/DocumentConverter.java26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/main/java/org/zwobble/mammoth/DocumentConverter.java b/src/main/java/org/zwobble/mammoth/DocumentConverter.java
index ac09c8b..d04d012 100644
--- a/src/main/java/org/zwobble/mammoth/DocumentConverter.java
+++ b/src/main/java/org/zwobble/mammoth/DocumentConverter.java
@@ -22,17 +22,7 @@ import static org.zwobble.mammoth.util.MammothMaps.map;
public class DocumentConverter {
public static List<HtmlNode> convertToHtml(String idPrefix, boolean preserveEmptyParagraphs, StyleMap styleMap, Document document) {
DocumentConverter documentConverter = new DocumentConverter(idPrefix, preserveEmptyParagraphs, styleMap);
- List<HtmlNode> mainBody = documentConverter.convertChildrenToHtml(document);
- // TODO: can you have note references inside a note?
- List<Note> notes = findNotes(document, documentConverter.noteReferences);
- if (notes.isEmpty()) {
- return mainBody;
- } else {
- HtmlNode noteNode = Html.element("ol",
- ImmutableList.copyOf(Iterables.transform(notes, documentConverter::convertToHtml)));
-
- return ImmutableList.copyOf(Iterables.concat(mainBody, list(noteNode)));
- }
+ return documentConverter.convertToHtml(document);
}
private static List<Note> findNotes(Document document, Iterable<NoteReference> noteReferences) {
@@ -57,6 +47,20 @@ public class DocumentConverter {
this.styleMap = styleMap;
}
+ private List<HtmlNode> convertToHtml(Document document) {
+ List<HtmlNode> mainBody = convertChildrenToHtml(document);
+ // TODO: can you have note references inside a note?
+ List<Note> notes = findNotes(document, noteReferences);
+ if (notes.isEmpty()) {
+ return mainBody;
+ } else {
+ HtmlNode noteNode = Html.element("ol",
+ ImmutableList.copyOf(Iterables.transform(notes, this::convertToHtml)));
+
+ return ImmutableList.copyOf(Iterables.concat(mainBody, list(noteNode)));
+ }
+ }
+
private HtmlNode convertToHtml(Note note) {
String id = generateNoteHtmlId(note.getNoteType(), note.getId());
String referenceId = generateNoteRefHtmlId(note.getNoteType(), note.getId());