w2x: epub 3 semantic inflection

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@252 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
henrikjust 2015-06-12 11:47:39 +00:00
parent 062d444e3d
commit 442a22f6c0
6 changed files with 54 additions and 34 deletions

View file

@ -2,11 +2,12 @@ Changelog for Writer2LaTeX version 1.4 -> 1.6
---------- version 1.5.3 ----------
[w2x] Added support for semantic inflection in EPUB 3 export for the types toc, index
[w2x] Added support for semantic inflection in EPUB 3 export for the types footnote(s), endnote(s), toc, index
and bibliography
(http://www.idpf.org/epub/30/spec/epub30-contentdocs.html#sec-xhtml-semantic-inflection).
[w2x] Improved the semantic markup of the table of contents and the alphabetical index in HTML export using sections,
headings and lists
[w2x] Improved the semantic markup of footnotes, endnotes, table of contents and alphabetical index in HTML export
using sections, asides, headings and lists
[w2x] Added support for background color of alphabetical index and bibliography

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.6 (2015-05-29)
* Version 1.6 (2015-06-12)
*
*/
@ -33,7 +33,7 @@ public class ConverterFactory {
// Version information
private static final String VERSION = "1.5.3";
private static final String DATE = "2015-05-29";
private static final String DATE = "2015-06-12";
/** Return the Writer2LaTeX version in the form
* (major version).(minor version).(patch level)<br/>

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.6 (2015-06-11)
* Version 1.6 (2015-06-12)
*
*/
package writer2latex.xhtml;
@ -51,20 +51,21 @@ public class BibliographyConverter extends ConverterHelper {
// so we have to recreate the bibliography from the template.
Node body = Misc.getChildByTagName(onode,XMLString.TEXT_INDEX_BODY);
if (body!=null) {
Element div = converter.createElement("div");
Element container = converter.createElement(converter.isHTML5() ? "section" : "div");
String sStyleName = Misc.getAttribute(onode,XMLString.TEXT_STYLE_NAME);
if (sStyleName!=null) {
StyleInfo sectionInfo = new StyleInfo();
getSectionSc().applyStyle(sStyleName,sectionInfo);
applyStyle(sectionInfo,div);
applyStyle(sectionInfo,container);
}
converter.addTarget(div,"bibliography");
hnode.appendChild(div);
converter.addTarget(container,"bibliography");
converter.addEpubType(container, "bibliography");
hnode.appendChild(container);
//asapNode = converter.createTarget("bibliography");
Node title = Misc.getChildByTagName(body,XMLString.TEXT_INDEX_TITLE);
if (title!=null) { getTextCv().traverseBlockText(title,div); }
getTextCv().traverseBlockText(body,div);
if (title!=null) { getTextCv().traverseBlockText(title,container); }
getTextCv().traverseBlockText(body,container);
}
}

View file

@ -20,11 +20,12 @@
*
* All Rights Reserved.
*
* Version 1.6 (2015-06-11)
* Version 1.6 (2015-06-12)
*
*/
package writer2latex.xhtml;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import writer2latex.office.OfficeReader;
@ -42,8 +43,9 @@ public class EndnoteConverter extends NoteConverter {
public void insertEndnotes(Node hnode) {
if (hasNotes()) {
if (config.getXhtmlSplitLevel()>0) { hnode = converter.nextOutFile(); }
insertNoteHeading(hnode, config.getEndnotesHeading(), "endnotes");
insertNotes(hnode);
Element section = createNoteSection(hnode, "rearnotes");
insertNoteHeading(section, config.getEndnotesHeading(), "endnotes");
flushNotes(section,"rearnote");
}
}
}

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.6 (2015-06-11)
* Version 1.6 (2015-06-12)
*
*/
package writer2latex.xhtml;
@ -53,20 +53,24 @@ public class FootnoteConverter extends NoteConverter {
*/
public void insertFootnotes(Node hnode, boolean bFinal) {
if (hasNotes()) {
if (bFootnotesAtPage) { // Add footnote rule
if (bFootnotesAtPage) {
Element section = createNoteSection(hnode, "footnotes");
// Add footnote rule
Element rule = converter.createElement("hr");
StyleInfo info = new StyleInfo();
getPageSc().applyFootnoteRuleStyle(info);
getPageSc().applyStyle(info, rule);
hnode.appendChild(rule);
}
else if (bFinal) { // New page if required for footnotes as endnotes
if (config.getXhtmlSplitLevel()>0) { hnode = converter.nextOutFile(); }
insertNoteHeading(hnode, config.getFootnotesHeading(), "footnotes");
}
section.appendChild(rule);
if (bFinal || bFootnotesAtPage) { // Insert the footnotes
insertNotes(hnode);
flushNotes(section,"footnote");
}
else if (bFinal) {
// New page if required for footnotes as endnotes
if (config.getXhtmlSplitLevel()>0) { hnode = converter.nextOutFile(); }
Element section = createNoteSection(hnode, "footnotes");
insertNoteHeading(section, config.getFootnotesHeading(), "footnotes");
flushNotes(section,"footnote");
}
}
}

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.6 (2015-06-11)
* Version 1.6 (2015-06-12)
*
*/
package writer2latex.xhtml;
@ -41,7 +41,7 @@ import writer2latex.util.Misc;
public class NoteConverter extends ConverterHelper {
// The notes configuration
private PropertySet configuration;
private PropertySet noteConfig;
// The collection of notes
private List<Node> notes = new ArrayList<Node>();
@ -55,7 +55,7 @@ public class NoteConverter extends ConverterHelper {
*/
public NoteConverter(OfficeReader ofr, XhtmlConfig config, Converter converter, PropertySet noteConfig) {
super(ofr,config,converter);
this.configuration = noteConfig;
this.noteConfig = noteConfig;
}
/** Handle a footnote or endnote. This method inserts the citation and stores the actual note for later processing
@ -65,12 +65,13 @@ public class NoteConverter extends ConverterHelper {
*/
public void handleNote(Node onode, Node hnode) {
// Create a style span for the citation
String sCitBodyStyle = configuration.getProperty(XMLString.TEXT_CITATION_BODY_STYLE_NAME);
String sCitBodyStyle = noteConfig.getProperty(XMLString.TEXT_CITATION_BODY_STYLE_NAME);
Element span = getTextCv().createInline((Element) hnode,sCitBodyStyle);
// Add target and back-link to the span
String sId = Misc.getAttribute(onode,XMLString.TEXT_ID);
Element link = converter.createLink(sId);
converter.addTarget(link,"body"+sId);
converter.addEpubType(link, "noteref");
span.appendChild(link);
// Get the citation
Element citation = Misc.getChildByTagName(onode,XMLString.TEXT_NOTE_CITATION);
@ -91,6 +92,13 @@ public class NoteConverter extends ConverterHelper {
protected boolean hasNotes() {
return notes.size()>0;
}
protected Element createNoteSection(Node hnode, String sEpubType) {
Element section = converter.createElement(converter.isHTML5() ? "section" : "div");
hnode.appendChild(section);
converter.addEpubType(section, sEpubType);
return section;
}
protected void insertNoteHeading(Node hnode, String sHeading, String sTarget) {
if (sHeading.length()>0) {
@ -111,10 +119,14 @@ public class NoteConverter extends ConverterHelper {
}
}
protected void insertNotes(Node hnode) {
protected void flushNotes(Node hnode, String sEpubType) {
int nSize = notes.size();
for (int i=0; i<nSize; i++) {
Node note = notes.get(i);
// Create container
Element aside = converter.createElement(converter.isHTML5() ? "aside" : "div");
hnode.appendChild(aside);
converter.addEpubType(aside, sEpubType);
// Get the citation
Node citation = Misc.getChildByTagName(note,XMLString.TEXT_NOTE_CITATION);
if (citation==null) { // try old format
@ -134,7 +146,7 @@ public class NoteConverter extends ConverterHelper {
// Export the note
String sId = Misc.getAttribute(note,XMLString.TEXT_ID);
createAnchor(sId,citation);
getTextCv().traverseBlockText(body,hnode);
getTextCv().traverseBlockText(body,aside);
}
notes.clear();
}
@ -145,13 +157,13 @@ public class NoteConverter extends ConverterHelper {
converter.addTarget(link,sId);
// Style it
String sCitStyle = configuration.getProperty(XMLString.TEXT_CITATION_STYLE_NAME);
String sCitStyle = noteConfig.getProperty(XMLString.TEXT_CITATION_STYLE_NAME);
StyleInfo linkInfo = new StyleInfo();
getTextSc().applyStyle(sCitStyle,linkInfo);
applyStyle(linkInfo,link);
// Add prefix
String sPrefix = configuration.getProperty(XMLString.STYLE_NUM_PREFIX);
String sPrefix = noteConfig.getProperty(XMLString.STYLE_NUM_PREFIX);
if (sPrefix!=null) {
link.appendChild(converter.createTextNode(sPrefix));
}
@ -160,7 +172,7 @@ public class NoteConverter extends ConverterHelper {
getTextCv().traversePCDATA(citation,link);
// Add suffix
String sSuffix = configuration.getProperty(XMLString.STYLE_NUM_SUFFIX);
String sSuffix = noteConfig.getProperty(XMLString.STYLE_NUM_SUFFIX);
if (sSuffix!=null) {
link.appendChild(converter.createTextNode(sSuffix));
}