From 8547521ccd7df064e258a9eb12a3598a4d6c4c27 Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Sun, 25 Sep 2016 18:43:29 +0300 Subject: [PATCH] Fixed opened page divs and sections --- .../writer2latex/xhtml/GreenstoneTags.java | 24 +++++++++++-------- .../java/writer2latex/xhtml/XhtmlConfig.java | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/source/java/writer2latex/xhtml/GreenstoneTags.java b/source/java/writer2latex/xhtml/GreenstoneTags.java index 74b8e8d..81946b8 100644 --- a/source/java/writer2latex/xhtml/GreenstoneTags.java +++ b/source/java/writer2latex/xhtml/GreenstoneTags.java @@ -121,17 +121,16 @@ public class GreenstoneTags { hnode.getNodeType() == Node.ELEMENT_NODE && ((Element) hnode).getTagName().equals("div") - //&& - //((Element) hnode).getAttribute("class").equals("pageNum") ) ){ - System.out.println("TAG " + ((Element) hnode).getTagName()); - System.out.println("class " + ((Element) hnode).getAttribute("class")); hnode = hnode.getParentNode(); } - hnode = hnode.getParentNode(); - System.out.println(((Element) hnode).getTagName()); - return hnode; + Node result = hnode.getParentNode(); + if (hnode.getChildNodes().getLength() == 0){ + result.removeChild(hnode); + } + + return result; } private static String getTitle(Node currentNode) { @@ -201,9 +200,14 @@ public class GreenstoneTags { } protected static Node closePage(Node hnode){ if (pageTags.equals(SECTIONS)){ - closeSection(hnode); - } - else if (pageTags.equals(DIV)){ + //If section is empty. In case we are closing section + // the last comment is opened page section + if (hnode.getLastChild().getNodeType() == Node.COMMENT_NODE){ + hnode.removeChild(hnode.getLastChild()); + } else { + closeSection(hnode); + } + } else if (pageTags.equals(DIV)){ hnode = exitPageDiv(hnode); } pageOpened = false; diff --git a/source/java/writer2latex/xhtml/XhtmlConfig.java b/source/java/writer2latex/xhtml/XhtmlConfig.java index e91855f..5b8ec84 100644 --- a/source/java/writer2latex/xhtml/XhtmlConfig.java +++ b/source/java/writer2latex/xhtml/XhtmlConfig.java @@ -294,7 +294,7 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase { options[DIRECTORY_ICON] = new Option("directory_icon",""); options[DOCUMENT_ICON] = new Option("document_icon",""); options[HEADING_TAGS] = new Option("heading_tags","sections"); - options[PAGE_TAGS] = new Option("page_tags","div"); + options[PAGE_TAGS] = new Option("page_tags","sections"); } protected void readInner(Element elm) {