% $Id: tex4ht-html-speech-xtpipes.tex 740 2020-06-13 22:35:32Z karl $
% htlatex tex4ht-html-speech-xtpipes "html,next,3" "" "-d./"
%
% Copyright 2009-2020 TeX Users Group
% Copyright 2006-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-dir}
\input{tex4ht-cpright}
%%%%%%%%%%%%%%%%%%
\part{Script for xtpipes}
%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%
\section{Outline}
%%%%%%%%%%%%%%%%%%
\AtEndDocument{\OutputCodE\}
\Needs{"xmllint --valid --noout htspk.4xt"}
\<<<
`
`
`
`
`
`
`
`
`
`
`
`
`
>>>
\<<<
>>>
\<<<
>>>
\<<<
`
`
`
`<'minus' into 'negative'`>
`
`
>>>
\<<<
`
`
`
`
>>>
\marginpar{Can dom be prevented from creating an xml declaration in
the output? The xslt part is there just to remove the undesirable
declaration.}
\<<<
`
`
>>>
\AtEndDocument{\OutputCodE\}
\ifdojava
\Needs{"
javac HtSpk.java -d \XTPIPES .
"}
\fi
\<<<
package tex4ht;
/* HtSpk.java (`version), generated from `jobname.tex
Copyright (C) 2009-2010 TeX Users Group
Copyright (C) `CopyYear.2006. Eitan M. Gurari
` */
import org.w3c.dom.*;
public class HtSpk {
`
`
`
}
>>>
%%%%%%%%%%%%%%%%%%
\section{Line Break Elements}
%%%%%%%%%%%%%%%%%%
Avoid short versions \verb+
+.
\<<<
>>>
%%%%%%%%%%%%%%%%%%
\section{Capital Letters in Math}
%%%%%%%%%%%%%%%%%%
\<<<
>>>
% (translate(.,'abcdefghijklmnopqrstuvwxyz',
% 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') = . )
% and
\<<<
capital
>>>
%%%%%%%%%%%%%%%%%%
\section{Superscripts and Subscripts}
%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%
\subsection{Insert Sub-Levels Info}
%%%%%%%%%%%%%
\<<<
`
>>>
\<<<
public static void scriptLevel(Node dom) {
setScriptLevel(dom.getFirstChild(), "");
}
private static void setScriptLevel(Node node, String prefix) {
String clName = null;
if (node.hasChildNodes()) {
if (node.hasAttributes()) {
Node cl = node.getAttributes().getNamedItem("class");
if (cl != null) {
clName = cl.getNodeValue();
if( clName.equals("mrow-sub")
||
clName.equals("mrow-super")
){
`
} else if(
clName.equals("msqrt")
){ prefix = ""; }
} }
`
>>>
\<<<
`
`
`
>>>
\<<<
>>>
\begin{verbatim}
.........
superscript
baseline
\end{verbatim}
%%%%%%%%%%%%%
\subsection{Squared}
%%%%%%%%%%%%%
\<<<
`
`
`
>>>
\<<<
>>>
\<<<
not(
child::span[ (@class = 'mrow-base') ]
/ child::span[ not( @title = 'speech-extra' ) ]
[ position() = last() ]
/ self::* [ @class = 'mo-op' ]
)
>>>
\<<<
squared
>>>
\begin{verbatim}
cos
superscript
2
baseline
\end{verbatim}
\<<<
>>>
\<<<
cube
>>>
\<<<
`
`
`
>>>
\<<<
msub
>>>
\<<<
squared-super
squared
>>>
\<<<
msub
>>>
\<<<
cube-super
cube
>>>
%%%%%%%%%%%%%
\subsection{Numeric Subscripts (Rule 77)}
%%%%%%%%%%%%%
\<<<
`
`
`
>>>
\<<<
>>>
Emacspeak doesn't read fluently numbers with commas. For instance `10,000' is
treated as `ten comma zero zero zero'.
\begin{verbatim}
x
subscript
1
baseline
\end{verbatim}
%%%%%%%%%%%%%
\subsection{Primes}
%%%%%%%%%%%%%
\<<<
>>>
\<<<
>>>
\begin{verbatim}
x
superscript
double prime
baseline
\end{verbatim}
\<<<
`
`
`
>>>
\<<<
msub
>>>
\begin{verbatim}
x
......
superscript
prime
\end{verbatim}
%%%%%%%%%%%%%%%%%%
\section{Over and Under Limit Scripts}
%%%%%%%%%%%%%%%%%%
\<<<
>>>
\<<<
>>>
\<<<
end scripts
end script
>>>
\<<<
>>>
\<<<
over
>>>
\<<<
under
>>>
%%%%%%%%%%%%%%%%%%
\section{Fractions}
%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%
\subsection{Outline}
%%%%%%%%%%%%%
\<<<
>>>
\<<<
`
`
`
>>>
%%%%%%%%%%%%%
\subsection{Continuos Fractions}
%%%%%%%%%%%%%
%%%%%%%%%%%%%
\subsubsection{Get Three Bottom Levels}
%%%%%%%%%%%%%
\<<<
`
>>>
\<<<
( normalize-space(
child::span[ @class = 'mrow-numerator' ])
and
normalize-space(
child::span[ @class = 'mrow-enumerator' ] /
child::span[ @class = 'mfrac' ] /
child::span[ @class = 'mrow-numerator' ])
)
and
( normalize-space(
child::span[ @class = 'mrow-enumerator' ] /
child::span[ @class = 'mfrac' ] /
child::span[ @class = 'mrow-numerator' ])
and
normalize-space(
child::span[ @class = 'mrow-enumerator' ] /
child::span[ @class = 'mfrac' ] /
child::span[ @class = 'mrow-enumerator' ] /
child::span[ @class = 'mfrac' ] /
child::span[ @class = 'mrow-numerator' ])
)
>>>
\<<<
( child::span[ @class = 'mrow-enumerator' ] /
child::span[ @class = 'mfrac' ] /
preceding-sibling::*[1][@class = 'mo-bin']
)
and
( normalize-space(
child::span[ @class = 'mrow-enumerator' ] /
child::span[ @class = 'mfrac' ] /
preceding-sibling::*[1] )
=
normalize-space(
child::span[ @class = 'mrow-enumerator' ] /
child::span[ @class = 'mfrac' ] /
child::span[ @class = 'mrow-enumerator' ] /
child::span[ @class = 'mfrac' ] /
preceding-sibling::*[1] )
)
>>>
\<<<
>>>
\<<<
>>>
%%%%%%%%%%%%%
\subsubsection{Prepend Existing one}
%%%%%%%%%%%%%
\<<<
`
>>>
\<<<
(
normalize-space(
child::span[ @class = 'mrow-enumerator' ] /
child::span[ @class = 'mfrac' ] /
preceding-sibling::*[1] )
=
normalize-space(
child::span[ @class = 'mrow-enumerator' ] /
child::span[ @class = 'mfrac' ] /
child::span[ @class = 'mrow-enumerator' ] /
child::span[ @class = 'continuous-mfrac' ] /
preceding-sibling::*[1] )
)
>>>
\<<<
>>>
%%%%%%%%%%%%%
\subsection{Word Fractions}
%%%%%%%%%%%%%
\<<<
`
word-frac
`
`
>>>
\<<<
>>>
\<<<
one
two
three
four
five
six
seven
eight
nine
>>>
\<<<
half
third
fourth
fifth
sixth
seventh
eighth
nineth
s
>>>
%%%%%%%%%%%%%
\subsection{Prefix `and' Connectors}
%%%%%%%%%%%%%
\<<<
and
>>>
%%%%%%%%%%%%%
\subsection{Hyper Complex Fractions}
%%%%%%%%%%%%%
\<<<
`
>>>
\<<<
public static void fracLevel(Node dom) {
setFracLevel(dom.getFirstChild(), 0);
}
private static int setFracLevel(Node node, int cont) {
int level = 0;
String clName = null;
if (node.hasChildNodes()) {
if (node.hasAttributes()) {
Node cl = node.getAttributes().getNamedItem("class");
if (cl != null) { clName = cl.getNodeValue(); }
}
`
if( clName != null ){
`
`
if (clName.equals("mfrac")) {
if( cont > 0 ){
`
} else if( level > 0 ){
`
}
level++;
} } }
return level;
}
>>>
\<<<
NodeList children = node.getChildNodes();
int max = 0;
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
int d = setFracLevel(child,
(clName != null) &&
clName.equals("continuous-mfrac")?
2 :
((clName != null) &&
clName.equals("continuous-mfrac")?
(cont-1) : cont)
);
if (d > max) { max = d; }
} }
level += max;
>>>
The `cont' parameter is for determining whether the parent and the
grandparent are frac elements marked as continuous.
\<<<
if( clName.equals("msub") || clName.equals("msup") ||
clName.equals("msubsup")
) {
return 0;
}
>>>
\<<<
if( clName.equals("continuous-mfrac") ) {
if( cont > 0 ){
`
} else { ` } `%root of continuous chain`%
return 0;
}
>>>
\<<<
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
Node cls = child.getAttributes()
.getNamedItem("class");
if (cls != null) {
String clsName = cls.getNodeValue();
if (clsName.equals("begin-end")) {
child = child.getFirstChild();
String s = child.getNodeValue();
String bg = "", ov = "", en = "";
for(int j=0; j>>
\<<<
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
Node cls = child.getAttributes()
.getNamedItem("class");
if (cls != null) {
String clsName = cls.getNodeValue();
if ( clsName.equals("begin-end")) {
child = child.getFirstChild();
String s = child.getNodeValue();
s = s.replaceFirst("begin", "begin continued");
s = s.replaceFirst("end", "end continued");
((org.w3c.dom.Text) child).setData(s);
} } } }
>>>
\<<<
Node child = node.getLastChild();
if (child.getNodeType() == Node.ELEMENT_NODE) {
Node cls = child.getAttributes() .getNamedItem("class");
if (cls != null) {
String clsName = cls.getNodeValue();
if ( clsName.equals("begin-end")) {
node.removeChild( child );
} } }
>>>
%%%%%%%%%%%%%
\subsection{Set Levels on Roots}
%%%%%%%%%%%%%
\<<<
`
>>>
\<<<
public static void rootLevel(Node dom) {
setRootLevel(dom.getFirstChild());
}
private static int setRootLevel( Node node ){
int level = 0;
String clName = null;
if (node.hasChildNodes()) {
if (node.hasAttributes()) {
Node cl = node.getAttributes().getNamedItem("class");
if (cl != null) { clName = cl.getNodeValue(); }
}
`
if( clName != null ){
`
if( clName.equals("msqrt") || clName.equals("root") ){
`
level++;
} } }
return level;
}
>>>
\<<<
NodeList children = node.getChildNodes();
int max = 0;
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
int d = setRootLevel(child);
if( d > max ){ max = d; }
} }
level += max;
>>>
\<<<
if( clName.equals("msub") || clName.equals("msup") ||
clName.equals("msubsup")
) {
return 0;
}
>>>
\<<<
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
Node cls = child.getAttributes()
.getNamedItem("class");
if (cls != null) {
String clsName = cls.getNodeValue();
if( clsName.equals("begin-root")
|| clsName.equals("mid-root")
|| clsName.equals("end-root")
){
child = child.getFirstChild();
String s = child.getNodeValue();
String nested = "";
for(int j=0; j>>
%%%%%%%%%%%%%%%%%%
\section{Odd Ends}
%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%
\subsection{Remove Empty Array Cells}
%%%%%%%%%%%%%
Empty array celles at end of rows can make it more difficult to
detect deletable baseline indicators.
\<<<
>>>
\<<<
>>>
%%%%%%%%%%%%%
\subsection{'minus' into 'negative'}
%%%%%%%%%%%%%
\<'minus' into 'negative'\><<<
mo-unary
>>>
\<'minus' into 'negative'\><<<
>>>
\begin{verbatim}
subscript
minus
2
\end{verbatim}
\<'minus' into 'negative'\><<<
negative
>>>
%%%%%%%%%%%%%
\subsection{Short-Cuts for Modifiers}
%%%%%%%%%%%%%
\<<<
>>>
\<<<
>>>
\<<<
under bar
>>>
\<<<
over bar
>>>
\begin{verbatim}
modified above
bold
capital
Z
with bar
\end{verbatim}
\begin{verbatim}
modified under
x
with bar
\end{verbatim}
%%%%%%%%%%%%%
\subsection{Font Decorations}
%%%%%%%%%%%%%
\<<<
>>>
\