% $Id: tex4ht-docbook-xtpipes.tex 740 2020-06-13 22:35:32Z karl $ % htlatex tex4ht-docbook-xtpipes "xhtml,next,3" "" "-d./" % % Copyright 2009-2020 TeX Users Group % Copyright 2000-2009 Eitan M. Gurari % Released under LPPL 1.3c+. % See tex4ht-cpright.tex for license text. \documentclass{article} \Configure{ProTex}{log,<<<>>>,title,list,`,[[]]} \begin{document} \input{common} \input{tex4ht-cpright} \input{tex4ht-dir} %%%%%%%%%%%%%%%%%% \part{Post Processing for DocBook Output Mode} %%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%% \section{Outline} %%%%%%%%%%%%%%%%%% \AtEndDocument{\OutputCodE\} \Needs{"xmllint --valid --noout docbook.4xt"} \<<< ` ` ` >>> \AtEndDocument{\OutputCodE\} \ifdojava \Needs{" javac DbUtilities.java -d \XTPIPES "} \fi \<<< package tex4ht; /* DbUtilities.java (`version), generated from `jobname.tex Copyright (C) 2009-2010 TeX Users Group Copyright (C) `CopyYear.2008. Eitan M. Gurari ` */ import org.w3c.dom.*; public class DbUtilities { ` ` } >>> %%%%%%%%%%%%%%%%%% \section{Trim Spaces of Paragraphs} %%%%%%%%%%%%%%%%%% \<<< >>> \<<< public static void para(Node dom) { Node pNode = dom.getFirstChild(); if( pNode.hasChildNodes() ){ Node child = pNode.getFirstChild(); if( child != null ){ if( (child.getNodeType() == Node.TEXT_NODE) && ((Text) child).getWholeText().trim().equals("") ){ pNode.removeChild( child ); } } } if( pNode.hasChildNodes() ){ Node child = pNode.getLastChild(); if( child != null ){ if( (child.getNodeType() == Node.TEXT_NODE) && ((Text) child).getWholeText().trim().equals("") ){ pNode.removeChild( child ); } } } if( pNode.hasChildNodes() ){ Node child = pNode.getFirstChild(); if( (child != null) && (child.getNextSibling() == null) && (child.getNodeType() == Node.TEXT_NODE) ){ String txt = ((Text) child).getWholeText(); String trm = txt.trim(); if( !trm.equals(txt) ){ ((Text)child).replaceWholeText(trm); } } } } >>> %%%%%%%%%%%%%%%%%% \section{Title Elements} %%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%% \section{Internal Links} %%%%%%%%%%%%%%%%%% Anchor within the document should use \begin{center} \verb+...+ \end{center} without the `\verb+#+' character. The ulink element is used for URLs. \begin{center} \verb+...+ \end{center} \<<< >>> \<<< >>> %%%%%%%%%%%%%%%%%% \section{tabular hor lines} %%%%%%%%%%%%%%%%%% %%%%%%%%%%%%% \subsection{Outline} %%%%%%%%%%%%% \<<< >>> \<<< public static void cline(Node dom) { Node row, entry, para, nextrow; Node node = dom.getFirstChild(); if( node != null ){ ` ` } } >>> \<<< row = node.getLastChild(); while( (row != null) && ( (entry = row.getLastChild()) != null) && ( (para = entry.getFirstChild()) != null) && ( para.getNextSibling() == null) && ( para.getFirstChild() == null) ){ node.removeChild(row); row = node.getLastChild(); } >>> The merging of rows deal with cases similar to the following one. \begin{verbatim} 1 2 to 3 \end{verbatim} \<<< row = node.getFirstChild(); while( row != null ){ if( (row.getNodeType() == Node.ELEMENT_NODE) && ((Element) row).getAttribute("rowsep").equals("") && !((Element) row).getAttribute("role" ).equals("cline") && ((nextrow = row.getNextSibling()) != null) && (nextrow.getNodeType() == Node.ELEMENT_NODE) && ((Element) nextrow).getAttribute("role" ).equals("cline") ){ ` if( compatible ){ ` node.removeChild(nextrow); } } row = row.getNextSibling(); } >>> \<<< boolean compatible = true; Node entry1 = row.getFirstChild(); Node entry2 = nextrow.getFirstChild(); while( true ){ if( (entry1 == null) || (entry2 == null) ){ break; } int range; try{ range = Integer.parseInt( ((Element) entry1).getAttribute("nameend") ) - Integer.parseInt( ((Element) entry1).getAttribute("namest") ) + 1; } catch( Exception e){ range = 1;} if( range > 1 ){ String rowsep = ((Element) entry2).getAttribute("rowsep"); while( --range > 0 ){ entry2 = entry2.getNextSibling(); if( entry2 == null ){ compatible = false; break; } String value = ((Element) entry2).getAttribute("rowsep"); if( !value.equals( rowsep ) ){ compatible = false; break; } } } if( !compatible ){ break; } entry1 = entry1.getNextSibling(); entry2 = entry2.getNextSibling(); } >>> \<<< entry1 = row.getFirstChild(); entry2 = nextrow.getFirstChild(); while( true ){ if( (entry1 == null) || (entry2 == null) ){ break; } int range; try{ range = Integer.parseInt( ((Element) entry1).getAttribute("nameend") ) - Integer.parseInt( ((Element) entry1).getAttribute("namest") ) + 1; } catch( Exception e){ range = 1;} ((Element) entry1).setAttribute( "rowsep", ((Element) entry2).getAttribute("rowsep") ); while( --range > 0 ){ entry2 = entry2.getNextSibling(); } entry1 = entry1.getNextSibling(); entry2 = entry2.getNextSibling(); } >>> %%%%%%%%%%%%% \subsection{Dirt Lines} %%%%%%%%%%%%% Can they be removed earlier at the latex pass? \<<< >>> %%%%%%%%%%%%% \subsection{hline} %%%%%%%%%%%%% \<<< >>> \<<< 1 >>> %%%%%%%%%%%%% \subsection{cline} %%%%%%%%%%%%% \<<< >>> \<<< >>> \<<< >>> %%%%%%%%%%%%%%%%%% \section{Shared} %%%%%%%%%%%%%%%%%% \<<< >>> \<<< ]]> >>> \<<< x >>> %%%%%%%%%%%%%%%%%% \section{Copyright} %%%%%%%%%%%%%%%%%% \let\newfilename=\relax \<<< /**********************************************************/ >>> \<<< /* */ /* This work may be distributed and/or modified under the */ /* conditions of the LaTeX Project Public License, either */ /* version 1.3 of this license or (at your option) any */ /* later version. The latest version of this license is */ /* in */ /* http://www.latex-project.org/lppl.txt */ /* and version 1.3 or later is part of all distributions */ /* of LaTeX version 2003/12/01 or later. */ /* */ /* This work has the LPPL maintenance status "maintained".*/ /* */ /* The Current Maintainer of this work */ /* is the TeX4ht Project . */ >>> \ifdojava \AtEndDocument{\Needs{% "pushd \XTPIPES || exit 1 ; jar cf tex4ht.jar * ; popd ; mv \XTPIPES tex4ht.jar \TEXMFTEXivBIN ; cp \XTPIPES xtpipes/lib/* \TEXMFTEXivXTPIPES "}} \fi %%%%%%%%%%%%%%%%%%%%%%%%%%%% \end{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%