| 1 |
% $Id: tex4ht-jsml-xtpipes.tex 740 2020-06-13 22:35:32Z karl $ |
| 2 |
% htlatex tex4ht-jsml-xtpipes "xhtml,next,3" "" "-d./" |
| 3 |
% |
| 4 |
% Copyright 2009-2020 TeX Users Group |
| 5 |
% Copyright 2002-2009 Eitan M. Gurari |
| 6 |
% Released under LPPL 1.3c+. |
| 7 |
% See tex4ht-cpright.tex for license text. |
| 8 |
|
| 9 |
\documentclass{article} |
| 10 |
\Configure{ProTex}{log,<<<>>>,title,list,`,[[]]} |
| 11 |
\begin{document} |
| 12 |
|
| 13 |
|
| 14 |
\input{common} |
| 15 |
\input{tex4ht-cpright} |
| 16 |
\input{tex4ht-dir} |
| 17 |
|
| 18 |
%%%%%%%%%%%%%%%%%% |
| 19 |
\part{Script for xtpipes} |
| 20 |
%%%%%%%%%%%%%%%%%% |
| 21 |
|
| 22 |
|
| 23 |
%%%%%%%%%%%%%%%%%% |
| 24 |
\section{Outline} |
| 25 |
%%%%%%%%%%%%%%%%%% |
| 26 |
|
| 27 |
\AtEndDocument{\OutputCodE\<jsml.4xt\>} |
| 28 |
|
| 29 |
\Needs{"xmllint --valid --noout jsml.4xt"} |
| 30 |
|
| 31 |
|
| 32 |
\<jsml.4xt\><<< |
| 33 |
<?xml version="1.0" encoding="UTF-8" ?> |
| 34 |
<!DOCTYPE xtpipes SYSTEM "xtpipes.dtd" > |
| 35 |
<!-- jsml.4xt (`version), generated from `jobname.tex |
| 36 |
Copyright (C) 2009-2010 TeX Users Group |
| 37 |
Copyright (C) `CopyYear.2002. Eitan M. Gurari |
| 38 |
`<TeX4ht copyright`> --> |
| 39 |
<xtpipes signature="jsml.4xt (`version)"> |
| 40 |
<sax content-handler="xtpipes.util.ScriptsManager, tex4ht.GroupMn, tex4ht.JsmlFilter" |
| 41 |
lexical-handler="xtpipes.util.ScriptsManagerLH" > |
| 42 |
`<numbers in math`> |
| 43 |
`<special sub and super scripts`> |
| 44 |
`<span frac elements`> |
| 45 |
`<short cut modifiers`> |
| 46 |
`<over and under scripts`> |
| 47 |
`<bold math`> |
| 48 |
`<capital math letters`> |
| 49 |
`<remove multline eqnum cell`> |
| 50 |
`<inline math`> |
| 51 |
`<display math`> |
| 52 |
`<replace characters`> |
| 53 |
`<remove empty split entries`> |
| 54 |
`<boundaries on theorems`> |
| 55 |
`<br into BREAK`> |
| 56 |
`<short notation for empty elements`> |
| 57 |
</sax> |
| 58 |
</xtpipes> |
| 59 |
>>> |
| 60 |
|
| 61 |
|
| 62 |
`<non short tag br elements`> |
| 63 |
|
| 64 |
`<inline math`> |
| 65 |
`<display math`> |
| 66 |
`<measure tables`> |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
\<inline math\><<< |
| 72 |
<script element="span::inline-math" > |
| 73 |
`<compress numeric subscripts`> |
| 74 |
`<set levels for hyper complex fracs`> |
| 75 |
`<set levels for sub and sup scripts`> |
| 76 |
`<set levels for roots`> |
| 77 |
<set name="inline-math" > |
| 78 |
`<open xslt script`> |
| 79 |
`<shared display and inline math 1`> |
| 80 |
`<eliminate inline math narrative`> |
| 81 |
`<close xslt script`> |
| 82 |
</set> |
| 83 |
<xslt name="." xml="." xsl="inline-math" /> |
| 84 |
`<eliminate extra math pauses`> |
| 85 |
<set name="inline-math-2" > |
| 86 |
`<open xslt script`> |
| 87 |
`<shared display and inline math 2`> |
| 88 |
`<eliminate inline math narrative 2`> |
| 89 |
`<close xslt script`> |
| 90 |
</set> |
| 91 |
<xslt name="." xml="." xsl="inline-math-2" /> |
| 92 |
</script> |
| 93 |
>>> |
| 94 |
|
| 95 |
|
| 96 |
\<display math\><<< |
| 97 |
<script element="div::display-math" > |
| 98 |
`<compress numeric subscripts`> |
| 99 |
`<set levels for hyper complex fracs`> |
| 100 |
`<set levels for sub and sup scripts`> |
| 101 |
`<set levels for roots`> |
| 102 |
<set name="display-math" > |
| 103 |
`<open xslt script`> |
| 104 |
`<shared display and inline math 1`> |
| 105 |
`<close xslt script`> |
| 106 |
</set> |
| 107 |
<xslt name="." xml="." xsl="display-math" /> |
| 108 |
`<eliminate extra math pauses`> |
| 109 |
<set name="display-math-2" > |
| 110 |
`<open xslt script`> |
| 111 |
`<shared display and inline math 2`> |
| 112 |
`<close xslt script`> |
| 113 |
</set> |
| 114 |
<xslt name="." xml="." xsl="display-math-2" /> |
| 115 |
`<set empty elements for the w3 browser`> |
| 116 |
</script> |
| 117 |
>>> |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
\<shared display and inline math 1\><<< |
| 123 |
`<remove super mn-group`> |
| 124 |
`<sayas punctuation`> |
| 125 |
`<sayas digits`> |
| 126 |
`<sayas math letters`> |
| 127 |
`<get content template`> |
| 128 |
`<eliminate baseline script marks`> |
| 129 |
`<clean begin and mid script marks`> |
| 130 |
`<mixed fractions`> |
| 131 |
`<'minus' into 'negative'`> |
| 132 |
`<compress limit script`> |
| 133 |
`<remove scrip indicators from primes`> |
| 134 |
`<remove scrip indicators from degree`> |
| 135 |
>>> |
| 136 |
|
| 137 |
|
| 138 |
\<shared display and inline math 2\><<< |
| 139 |
`<get content template`> |
| 140 |
`<replace nested baseline script marks`> |
| 141 |
`<remove marks on empty scripts`> |
| 142 |
`<eliminate begin script marks`> |
| 143 |
>>> |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
\AtEndDocument{\OutputCodE\<HtJsml.java\>} |
| 149 |
|
| 150 |
\ifdojava |
| 151 |
\Needs{" |
| 152 |
javac HtJsml.java -d \XTPIPES |
| 153 |
"} |
| 154 |
\fi |
| 155 |
|
| 156 |
\<HtJsml.java\><<< |
| 157 |
package tex4ht; |
| 158 |
/* HtJsml.java (`version), generated from `jobname.tex |
| 159 |
Copyright (C) 2009-2010 TeX Users Group |
| 160 |
Copyright (C) `CopyYear.2002. Eitan M. Gurari |
| 161 |
`<TeX4ht copyright`> */ |
| 162 |
import org.w3c.dom.*; |
| 163 |
public class HtJsml { |
| 164 |
`<HtJsml utility members`> |
| 165 |
`<static void mnGroup(dom)`> |
| 166 |
`<static void fracLevel(dom)`> |
| 167 |
`<static void scriptLevel(dom)`> |
| 168 |
`<static void rootLevel(dom)`> |
| 169 |
} |
| 170 |
>>> |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
%%%%%%%%%%%%%%%%%% |
| 176 |
\section{Numbers in Math} |
| 177 |
%%%%%%%%%%%%%%%%%% |
| 178 |
|
| 179 |
|
| 180 |
%%%%%%%%%%%%% |
| 181 |
\subsection{Group MN / MO-Punctuation} |
| 182 |
%%%%%%%%%%%%% |
| 183 |
|
| 184 |
|
| 185 |
\AtEndDocument{% |
| 186 |
\OutputCodE\<GroupMn.java\> |
| 187 |
} |
| 188 |
\ifdojava |
| 189 |
\Needs{" |
| 190 |
javac GroupMn.java -d \XTPIPES |
| 191 |
"} |
| 192 |
\fi |
| 193 |
|
| 194 |
\<GroupMn.java\><<< |
| 195 |
package tex4ht; |
| 196 |
/* GroupMn.java (`version), generated from `jobname.tex |
| 197 |
Copyright (C) 2009-2010 TeX Users Group |
| 198 |
Copyright (C) `CopyYear.2002. Eitan M. Gurari |
| 199 |
`<TeX4ht copyright`> */ |
| 200 |
import org.xml.sax.helpers.*; |
| 201 |
import org.xml.sax.*; |
| 202 |
import java.io.PrintWriter; |
| 203 |
|
| 204 |
public class GroupMn extends XMLFilterImpl { |
| 205 |
PrintWriter out = null; |
| 206 |
boolean inMn = false; |
| 207 |
String ns; |
| 208 |
int level = -1; |
| 209 |
public GroupMn( PrintWriter out, PrintWriter log, boolean trace){ |
| 210 |
this.out = out; |
| 211 |
} |
| 212 |
public void startElement(String ns, String sName, |
| 213 |
String qName, Attributes attr) { |
| 214 |
level++; |
| 215 |
try{ |
| 216 |
if( inMn ){ |
| 217 |
if( level == 0 ){ `<consider end of num`> } |
| 218 |
} else { `<consider start of num`> } |
| 219 |
super.startElement(ns, sName, qName, attr); |
| 220 |
} catch( Exception e ){ |
| 221 |
System.out.println( "--- GroupMn Error 1 --- " + e); |
| 222 |
} |
| 223 |
} |
| 224 |
public void endElement(String ns, String sName, String qName){ |
| 225 |
try{ |
| 226 |
if( level < 0) { |
| 227 |
`<endElement: consider end of num`> |
| 228 |
} |
| 229 |
super.endElement(ns, sName, qName); |
| 230 |
} catch( Exception e ){ |
| 231 |
System.out.println( "--- GroupMn Error 2 --- " + e); |
| 232 |
} |
| 233 |
level--; |
| 234 |
} |
| 235 |
public void characters(char[] ch, int start, int length){ |
| 236 |
try{ |
| 237 |
if ( inMn && (level < 0) ) { |
| 238 |
String s = new String(ch, start, length); |
| 239 |
if (!s.trim().equals("")) { |
| 240 |
inMn = false; |
| 241 |
super.endElement(ns, "mn-group", "mn-group"); |
| 242 |
} } |
| 243 |
super.characters(ch, start, length); |
| 244 |
} catch( Exception e ){ |
| 245 |
System.out.println( "--- GroupMn Error 3 --- " + e); |
| 246 |
} } } |
| 247 |
>>> |
| 248 |
|
| 249 |
\<consider start of num\><<< |
| 250 |
if( qName.equals( "mn" ) ){ |
| 251 |
inMn = true; level = 0; |
| 252 |
Attributes att = new AttributesImpl(); |
| 253 |
super.startElement(ns, "mn-group", "mn-group", att); |
| 254 |
this.ns = ns; |
| 255 |
} else if( qName.equals( "mo" ) ){ |
| 256 |
String cls = attr.getValue( "class" ); |
| 257 |
if( (cls != null) && cls.equals("MathClass-punc") ){ |
| 258 |
inMn = true; level = 0; |
| 259 |
Attributes att = new AttributesImpl(); |
| 260 |
super.startElement(ns, "mn-group", "mn-group", att); |
| 261 |
this.ns = ns; |
| 262 |
} } |
| 263 |
>>> |
| 264 |
|
| 265 |
\<consider end of num\><<< |
| 266 |
if( !qName.equals( "mn" ) ){ |
| 267 |
if( qName.equals( "mo" ) ){ |
| 268 |
String cls = attr.getValue( "class" ); |
| 269 |
if( (cls == null) || !cls.equals("MathClass-punc") ){ |
| 270 |
inMn = false; |
| 271 |
super.endElement(ns, "mn-group", "mn-group"); |
| 272 |
} |
| 273 |
} else { |
| 274 |
inMn = false; |
| 275 |
super.endElement(ns, "mn-group", "mn-group"); |
| 276 |
} } |
| 277 |
>>> |
| 278 |
|
| 279 |
\<endElement: consider end of num\><<< |
| 280 |
if( inMn ){ |
| 281 |
inMn = false; |
| 282 |
super.endElement(ns, "mn-group", "mn-group"); |
| 283 |
} |
| 284 |
>>> |
| 285 |
|
| 286 |
%%%%%%%%%%%%% |
| 287 |
\subsection{Outline of Post Original Partition} |
| 288 |
%%%%%%%%%%%%% |
| 289 |
|
| 290 |
|
| 291 |
\<numbers in math\><<< |
| 292 |
<script element="mn-group" > |
| 293 |
`<missed partitions to mn groups`> |
| 294 |
<set name="merge" > |
| 295 |
`<open xslt script`> |
| 296 |
`<merge digits`> |
| 297 |
`<close xslt script`> |
| 298 |
</set> |
| 299 |
<xslt name="." xml="." xsl="merge" /> |
| 300 |
</script> |
| 301 |
>>> |
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
\<missed partitions to mn groups\><<< |
| 306 |
<dom name="." xml="." method="mnGroup" class="tex4ht.HtJsml" /> |
| 307 |
`<remove xml declaration`> |
| 308 |
>>> |
| 309 |
|
| 310 |
|
| 311 |
\<static void mnGroup(dom)\><<< |
| 312 |
private static Document dom; |
| 313 |
public static void mnGroup(Node d) { |
| 314 |
dom = (Document) d; |
| 315 |
setMnGroup(dom.getFirstChild()); |
| 316 |
} |
| 317 |
private static void setMnGroup(Node node) { |
| 318 |
if( node.getNodeName().equals( "mn-group" ) ){ |
| 319 |
boolean bool = false; |
| 320 |
`<get mn characters`> |
| 321 |
if( bool ){ |
| 322 |
`<mark remove commas, if comma after period`> |
| 323 |
`<mark remove commas, if not spaced correctly`> |
| 324 |
`<cond remove commas`> |
| 325 |
`<remove punc, on consecutive periods`> |
| 326 |
`<remove punc at end`> |
| 327 |
} |
| 328 |
`<reset mn-group`> |
| 329 |
} else if (node.hasChildNodes()) { |
| 330 |
NodeList children = node.getChildNodes(); |
| 331 |
for (int i = 0; i < children.getLength(); i++) { |
| 332 |
Node child = children.item(i); |
| 333 |
if (child.getNodeType() == Node.ELEMENT_NODE) { |
| 334 |
setMnGroup(child); |
| 335 |
} } } } |
| 336 |
>>> |
| 337 |
|
| 338 |
%%%%%%%%%%%%% |
| 339 |
\subsection{Mark Partition of MN Group} |
| 340 |
%%%%%%%%%%%%% |
| 341 |
|
| 342 |
Consecutive digits and punctation characters are grouped together, and |
| 343 |
then ungrouped at characters that are marked by `x'. |
| 344 |
|
| 345 |
|
| 346 |
\<get mn characters\><<< |
| 347 |
NodeList children = node.getChildNodes(); |
| 348 |
int n = children.getLength(); |
| 349 |
char [] digit = new char[n]; |
| 350 |
for (int i = 0; i < n; i++) { |
| 351 |
Node child = children.item(i).getFirstChild(); |
| 352 |
if( child == null ){ |
| 353 |
digit[i] = 'x'; |
| 354 |
} else if( child.getNodeType() != Node.TEXT_NODE ){ |
| 355 |
digit[i] = 'x'; |
| 356 |
} else { |
| 357 |
String s = child.getNodeValue(); |
| 358 |
if( s.length() != 1 ){ |
| 359 |
digit[i] = 'x'; |
| 360 |
} else { |
| 361 |
char ch = s.charAt(0); |
| 362 |
if( (ch >= '0') && (ch <= '9') ){ |
| 363 |
digit[i] = '0'; bool = true; |
| 364 |
} else if( (ch == '.') || (ch == ',') ){ digit[i] = ch; } |
| 365 |
else { digit[i] = 'x';} |
| 366 |
} } } |
| 367 |
>>> |
| 368 |
|
| 369 |
\<mark remove commas, if comma after period\><<< |
| 370 |
bool = false; |
| 371 |
for (int i = 0; i < n; i++) { |
| 372 |
if( digit[i] == '.' ){ |
| 373 |
for (; i < n; i++) { |
| 374 |
if( digit[i] == ',' ){ |
| 375 |
bool = true; break; |
| 376 |
} } |
| 377 |
break; |
| 378 |
} } |
| 379 |
>>> |
| 380 |
|
| 381 |
\<mark remove commas, if not spaced correctly\><<< |
| 382 |
if( !bool ){ |
| 383 |
for (int i = 0; i < n; i++) { |
| 384 |
if( digit[i] == ',' ){ |
| 385 |
if( ( ((i+3) >= n) |
| 386 |
|| (digit[i+1] != '0') |
| 387 |
|| (digit[i+2] != '0') |
| 388 |
|| (digit[i+3] != '0') |
| 389 |
) |
| 390 |
|| |
| 391 |
( |
| 392 |
((i+4) < n) && (digit[i+4] == '0') |
| 393 |
) |
| 394 |
|| |
| 395 |
( |
| 396 |
(i>3) && (digit[i-4] == '0') |
| 397 |
) |
| 398 |
){ bool = true; break; |
| 399 |
} else { i += 3; } |
| 400 |
} } } |
| 401 |
>>> |
| 402 |
|
| 403 |
\<cond remove commas\><<< |
| 404 |
if( bool ){ |
| 405 |
for (int i = 0; i < n; i++) { |
| 406 |
if( digit[i] == ',' ){ digit[i] = 'x'; } |
| 407 |
} } |
| 408 |
>>> |
| 409 |
|
| 410 |
|
| 411 |
\<remove punc, on consecutive periods\><<< |
| 412 |
bool = false; |
| 413 |
for (int i = 0; i < n; i++) { |
| 414 |
if( (digit[i] == 'x') |
| 415 |
|| (digit[i] == ',') ){ bool = false; } |
| 416 |
else if( digit[i] == '.' ){ |
| 417 |
if( bool ){ |
| 418 |
for (int j = 0; j < n; j++) { |
| 419 |
if( (digit[j] == '.') || (digit[j] == ',') ){ |
| 420 |
digit[j] = 'x'; |
| 421 |
} } |
| 422 |
break; |
| 423 |
} |
| 424 |
bool = true; |
| 425 |
} } |
| 426 |
>>> |
| 427 |
|
| 428 |
\<remove punc at end\><<< |
| 429 |
if( digit[n-1] == '.' ){ digit[n-1] = 'x'; } |
| 430 |
>>> |
| 431 |
|
| 432 |
%%%%%%%%%%%%% |
| 433 |
\subsection{Realize the Sub Partition} |
| 434 |
%%%%%%%%%%%%% |
| 435 |
|
| 436 |
|
| 437 |
\<reset mn-group\><<< |
| 438 |
Node parent = node.getParentNode(); |
| 439 |
Element g = dom.createElement( "mn-group-s" ); |
| 440 |
Element cur = dom.createElement( "mn-group" ); |
| 441 |
for(int i=0; i<n; i++ ){ |
| 442 |
Node child = node.getFirstChild(); |
| 443 |
node.removeChild( child ); |
| 444 |
if( digit[i] == 'x' ){ |
| 445 |
if( cur.hasChildNodes() ){ g.appendChild( cur ); } |
| 446 |
g.appendChild( child ); |
| 447 |
cur = dom.createElement( "mn-group" ); |
| 448 |
} else { |
| 449 |
cur.appendChild( child ); |
| 450 |
} } |
| 451 |
if( cur.hasChildNodes() ){ g.appendChild( cur ); } |
| 452 |
parent.replaceChild( g, node ); |
| 453 |
>>> |
| 454 |
|
| 455 |
|
| 456 |
%%%%%%%%%%%%% |
| 457 |
\subsection{Reset MNs} |
| 458 |
%%%%%%%%%%%%% |
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
\<merge digits\><<< |
| 464 |
<xsl:template match="mn-group" > |
| 465 |
<xsl:choose> |
| 466 |
<xsl:when test=" not(child::mn) "> |
| 467 |
<xsl:apply-templates select="*|text()" /> |
| 468 |
</xsl:when> |
| 469 |
<xsl:otherwise> |
| 470 |
<mn> |
| 471 |
<xsl:value-of select="." /> |
| 472 |
</mn> |
| 473 |
</xsl:otherwise> |
| 474 |
</xsl:choose> |
| 475 |
</xsl:template> |
| 476 |
>>> |
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
\<remove super mn-group\><<< |
| 486 |
<xsl:template match="mn-group-s" > |
| 487 |
<xsl:apply-templates select="*|@*|text()|comment()" /> |
| 488 |
</xsl:template> |
| 489 |
>>> |
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
%%%%%%%%%%%%% |
| 494 |
\subsection{Pronounced Letters} |
| 495 |
%%%%%%%%%%%%% |
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
\<sayas math letters \><<< |
| 500 |
<xsl:template match="mi[ .='a' ]" > |
| 501 |
<xsl:copy> |
| 502 |
<xsl:apply-templates select="@*" /> |
| 503 |
<SAYAS SUB="aih">a</SAYAS> |
| 504 |
</xsl:copy> |
| 505 |
</xsl:template> |
| 506 |
>>> |
| 507 |
|
| 508 |
|
| 509 |
%%%%%%%%%%%%% |
| 510 |
\subsection{Pronounced Punctuation in math} |
| 511 |
%%%%%%%%%%%%% |
| 512 |
|
| 513 |
TTSs might ignore punctuation marks. We want these |
| 514 |
symbols in math. |
| 515 |
|
| 516 |
\<sayas punctuation\><<< |
| 517 |
<xsl:template match="mo[ |
| 518 |
(@class='MathClass-punc') |
| 519 |
and ( (.='.') or (.=',') or (.='!') |
| 520 |
or (.=';') or (.=':') or (.='?') ) |
| 521 |
]" > |
| 522 |
<xsl:copy> |
| 523 |
<xsl:apply-templates select="@*" /> |
| 524 |
<BREAK SIZE="small"/> |
| 525 |
<xsl:choose> |
| 526 |
<xsl:when test=" .='.' " > |
| 527 |
<SAYAS SUB="dot">.</SAYAS> |
| 528 |
</xsl:when> |
| 529 |
<xsl:when test=" .=',' " > |
| 530 |
<SAYAS SUB="comma">,</SAYAS> |
| 531 |
</xsl:when> |
| 532 |
<xsl:when test=" .=';' " > |
| 533 |
<SAYAS SUB="semicolon">;</SAYAS> |
| 534 |
</xsl:when> |
| 535 |
<xsl:when test=" .=':' " > |
| 536 |
<SAYAS SUB="colon">:</SAYAS> |
| 537 |
</xsl:when> |
| 538 |
<xsl:when test=" .='!' " > |
| 539 |
<SAYAS SUB="exclamation mark">!</SAYAS> |
| 540 |
</xsl:when> |
| 541 |
<xsl:when test=" .='?' " > |
| 542 |
<SAYAS SUB="question mark">?</SAYAS> |
| 543 |
</xsl:when> |
| 544 |
</xsl:choose> |
| 545 |
<BREAK SIZE="small"/> |
| 546 |
</xsl:copy> |
| 547 |
</xsl:template> |
| 548 |
>>> |
| 549 |
|
| 550 |
|
| 551 |
\<sayas digits\><<< |
| 552 |
<xsl:template match="mn[ |
| 553 |
`<mn modified above`> |
| 554 |
or |
| 555 |
`<mn modified under`> |
| 556 |
]" > |
| 557 |
<xsl:copy> |
| 558 |
<SAYAS CLASS="digits"> |
| 559 |
<xsl:value-of select="." /> |
| 560 |
</SAYAS> |
| 561 |
</xsl:copy> |
| 562 |
</xsl:template> |
| 563 |
>>> |
| 564 |
|
| 565 |
|
| 566 |
\<mn modified above\><<< |
| 567 |
ancestor::mover[ |
| 568 |
not( descendant::*[ |
| 569 |
(count( `<math content element`> ) > 1) |
| 570 |
]) |
| 571 |
and |
| 572 |
( |
| 573 |
preceding-sibling::*[1][self::dot or self::mn-group-s] |
| 574 |
or |
| 575 |
following-sibling::*[1][self::dot or self::mn-group-s] |
| 576 |
) |
| 577 |
] |
| 578 |
>>> |
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
\<mn modified under\><<< |
| 583 |
ancestor::munder[ |
| 584 |
not( descendant::*[ |
| 585 |
(count( `<math content element`> ) > 1) |
| 586 |
]) |
| 587 |
and |
| 588 |
( |
| 589 |
preceding-sibling::*[1][self::dot or self::mn-group-s] |
| 590 |
or |
| 591 |
following-sibling::*[1][self::dot or self::mn-group-s] |
| 592 |
) |
| 593 |
] |
| 594 |
>>> |
| 595 |
|
| 596 |
|
| 597 |
%%%%%%%%%%%%%%%%%% |
| 598 |
\section{Process Characters} |
| 599 |
%%%%%%%%%%%%%%%%%% |
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
%%%%%%%%%%%%% |
| 606 |
\subsection{'minus' into 'negative'} |
| 607 |
%%%%%%%%%%%%% |
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
\<'minus' into 'negative'\><<< |
| 612 |
<xsl:template match="mo[ |
| 613 |
(@class = 'MathClass-bin') |
| 614 |
and |
| 615 |
( normalize-space(.) = |
| 616 |
normalize-space(descendant::span[@class = 'ch 2212']) |
| 617 |
) |
| 618 |
and |
| 619 |
( preceding-sibling::*[1][ |
| 620 |
(@title='speech-extra') |
| 621 |
or (@class='MathClass-bin') |
| 622 |
or (@class='MathClass-rel') |
| 623 |
or (@class='MathClass-punc') |
| 624 |
or (@class='MathClass-op') |
| 625 |
or self::mn-group-s [ child::* [ |
| 626 |
(position() = last()) |
| 627 |
and |
| 628 |
(@class='MathClass-punc') |
| 629 |
] ] ] |
| 630 |
and |
| 631 |
( |
| 632 |
following-sibling::*[1][ self::mn-group-s |
| 633 |
or self::mi ] |
| 634 |
or |
| 635 |
(count(following-sibling::*[ |
| 636 |
not(@title = 'speech-extra') |
| 637 |
]) = 1) |
| 638 |
) |
| 639 |
or |
| 640 |
not(preceding-sibling::*) and following-sibling::* |
| 641 |
) |
| 642 |
]" > |
| 643 |
<xsl:copy> |
| 644 |
<xsl:attribute name="class"> |
| 645 |
<xsl:text>mo-unary</xsl:text> |
| 646 |
</xsl:attribute> |
| 647 |
<xsl:apply-templates select="*|text()|comment()" |
| 648 |
mode="minus-neg" /> |
| 649 |
</xsl:copy> |
| 650 |
</xsl:template> |
| 651 |
>>> |
| 652 |
|
| 653 |
|
| 654 |
\<'minus' into 'negative'\><<< |
| 655 |
<xsl:template match="*|@*|text()|comment()" mode="minus-neg" > |
| 656 |
<xsl:copy> |
| 657 |
<xsl:apply-templates select="*|@*|text()|comment()" |
| 658 |
mode="minus-neg" /> |
| 659 |
</xsl:copy> |
| 660 |
</xsl:template> |
| 661 |
>>> |
| 662 |
|
| 663 |
\begin{verbatim} |
| 664 |
<span class="begin-script"> subscript </span> |
| 665 |
<mo class="MathClass-bin"> |
| 666 |
<span class="char"> |
| 667 |
<span class="ch 2212">minus</span> |
| 668 |
</span> |
| 669 |
</mo> |
| 670 |
<mn>2</mn> |
| 671 |
\end{verbatim} |
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
\<'minus' into 'negative'\><<< |
| 677 |
<xsl:template match="text()" mode="minus-neg" > |
| 678 |
<xsl:choose> |
| 679 |
<xsl:when test=" . = 'minus' " > |
| 680 |
<xsl:text>negative</xsl:text> |
| 681 |
</xsl:when> |
| 682 |
<xsl:otherwise> |
| 683 |
<xsl:value-of select="." /> |
| 684 |
</xsl:otherwise> |
| 685 |
</xsl:choose> |
| 686 |
</xsl:template> |
| 687 |
>>> |
| 688 |
|
| 689 |
|
| 690 |
%%%%%%%%%%%%%%%%%% |
| 691 |
\subsection{Capital Letters in Math} |
| 692 |
%%%%%%%%%%%%%%%%%% |
| 693 |
|
| 694 |
\<capital math letters\><<< |
| 695 |
<script element="mi" > |
| 696 |
<set name="math-cap" > |
| 697 |
`<open xslt script`> |
| 698 |
`<span.mi cap letters`> |
| 699 |
`<close xslt script`> |
| 700 |
</set> |
| 701 |
<xslt name="." xml="." xsl="math-cap" /> |
| 702 |
</script> |
| 703 |
>>> |
| 704 |
|
| 705 |
|
| 706 |
\<span.mi cap letters\><<< |
| 707 |
<xsl:template match="mi" > |
| 708 |
<xsl:copy> |
| 709 |
<xsl:apply-templates select="@*" /> |
| 710 |
<xsl:if test=" string-length(.) = 1 " > |
| 711 |
<xsl:if test=" |
| 712 |
(translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ', |
| 713 |
'') = '' ) |
| 714 |
" > |
| 715 |
<span class="capital-description" |
| 716 |
title="speech-extra" > |
| 717 |
<xsl:text> capital </xsl:text> |
| 718 |
</span> |
| 719 |
</xsl:if> |
| 720 |
</xsl:if> |
| 721 |
<xsl:apply-templates select="*|text()|comment()" /> |
| 722 |
</xsl:copy> |
| 723 |
</xsl:template> |
| 724 |
>>> |
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
%%%%%%%%%%%%% |
| 729 |
\subsection{Right Apostrophes} |
| 730 |
%%%%%%%%%%%%% |
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
\<replace characters\><<< |
| 735 |
<script element="PARA" > |
| 736 |
<set name="apostro" > |
| 737 |
`<open xslt script`> |
| 738 |
`<right apostrophe in prose`> |
| 739 |
`<delimiters in marks of enumerated lists`> |
| 740 |
`<remove empty paragraphs`> |
| 741 |
`<close xslt script`> |
| 742 |
</set> |
| 743 |
<xslt name="." xml="." xsl="apostro" /> |
| 744 |
</script> |
| 745 |
>>> |
| 746 |
|
| 747 |
|
| 748 |
\<right apostrophe in prose\><<< |
| 749 |
<xsl:template match="span[ |
| 750 |
(@class = 'char-del') |
| 751 |
and child::span [ @class = 'ch 2019' ] |
| 752 |
]" > |
| 753 |
<xsl:text>'</xsl:text> |
| 754 |
</xsl:template> |
| 755 |
>>> |
| 756 |
|
| 757 |
|
| 758 |
%%%%%%%%%%%%% |
| 759 |
\subsection{Delimiters on List Marks} |
| 760 |
%%%%%%%%%%%%% |
| 761 |
|
| 762 |
|
| 763 |
|
| 764 |
\<delimiters in marks of enumerated lists\><<< |
| 765 |
<xsl:template match="PROS[ parent::SENT[@class='ol-mark'] ]" > |
| 766 |
<xsl:copy> |
| 767 |
<xsl:apply-templates |
| 768 |
select="*[not(@class='char-del')]|@*|text()|comment()" /> |
| 769 |
</xsl:copy> |
| 770 |
</xsl:template> |
| 771 |
>>> |
| 772 |
|
| 773 |
|
| 774 |
%%%%%%%%%%%%%%%%%% |
| 775 |
\section{Clean Up} |
| 776 |
%%%%%%%%%%%%%%%%%% |
| 777 |
|
| 778 |
|
| 779 |
%%%%%%%%%%%%% |
| 780 |
\subsection{Extra Math Pauses} |
| 781 |
%%%%%%%%%%%%% |
| 782 |
|
| 783 |
|
| 784 |
Deletes pauses that are not separated by text from their immediate |
| 785 |
predecessors. |
| 786 |
|
| 787 |
An earlier XSLT-based approach was very slow, and died |
| 788 |
on nodes with large numbers of children. |
| 789 |
|
| 790 |
|
| 791 |
\<eliminate extra math pauses\><<< |
| 792 |
<sax name="." xml="." content-handler="tex4ht.JsmlMathBreak" /> |
| 793 |
>>> |
| 794 |
|
| 795 |
|
| 796 |
\AtEndDocument{% |
| 797 |
\OutputCodE\<JsmlMathBreak.java\> |
| 798 |
} |
| 799 |
|
| 800 |
\ifdojava |
| 801 |
\Needs{" |
| 802 |
javac -classpath \LIB xtpipes.jar |
| 803 |
JsmlMathBreak.java |
| 804 |
-d \XTPIPES . |
| 805 |
"} |
| 806 |
\fi |
| 807 |
|
| 808 |
\<JsmlMathBreak.java\><<< |
| 809 |
package tex4ht; |
| 810 |
/* JsmlMathBreak.java (`version), generated from `jobname.tex |
| 811 |
Copyright (C) 2009-2010 TeX Users Group |
| 812 |
Copyright (C) `CopyYear.2002. Eitan M. Gurari |
| 813 |
`<TeX4ht copyright`> */ |
| 814 |
|
| 815 |
import xtpipes.XtpipesUni; |
| 816 |
import org.xml.sax.*; |
| 817 |
import org.xml.sax.helpers.DefaultHandler; |
| 818 |
import java.io.*; |
| 819 |
import java.lang.reflect.*; |
| 820 |
import java.util.HashMap; |
| 821 |
|
| 822 |
public class JsmlMathBreak extends DefaultHandler { |
| 823 |
PrintWriter out = null; |
| 824 |
boolean delete = false; |
| 825 |
public JsmlMathBreak(PrintWriter out, |
| 826 |
HashMap<String,Object> scripts, |
| 827 |
Method method, PrintWriter log, boolean trace) { |
| 828 |
this.out = out; |
| 829 |
} |
| 830 |
public void characters(char[] ch, int start, int length) { |
| 831 |
String s = XtpipesUni.toUni(ch, start, length, "<>&"); |
| 832 |
out.print( s ); |
| 833 |
if( !s.trim().equals("") ){ |
| 834 |
delete = false; |
| 835 |
} } |
| 836 |
public void startElement(String ns, String sName, |
| 837 |
String qName, |
| 838 |
Attributes atts) { |
| 839 |
if( !( delete && qName.equals("BREAK") ) ){ |
| 840 |
String s = "<" + qName + "\n"; |
| 841 |
for (int i = 0; i < atts.getLength(); i++) { |
| 842 |
String name = atts.getQName(i); |
| 843 |
if (name != "xmlns") { |
| 844 |
s += (" " + name + "=\"" |
| 845 |
+ XtpipesUni.toUni(atts.getValue(i), "<>&\"") |
| 846 |
+ "\""); |
| 847 |
} } |
| 848 |
if( qName.equals( "BREAK" ) ){ |
| 849 |
s += "/"; |
| 850 |
delete = true; |
| 851 |
} |
| 852 |
s += ">"; |
| 853 |
out.print(s); |
| 854 |
} } |
| 855 |
public void endElement(String ns, String sName, String qName) { |
| 856 |
if( !qName.equals( "BREAK" ) ){ |
| 857 |
String s = "</" + qName + ">"; |
| 858 |
out.print(s); |
| 859 |
} } } |
| 860 |
>>> |
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
\begin{verbatim} |
| 865 |
</mrow> |
| 866 |
<span class="end-root" title="speech-extra"> |
| 867 |
<BREAK SIZE="medium"/> |
| 868 |
<level prefix="end" depth="1">end end root</level> |
| 869 |
<BREAK SIZE="medium"/> |
| 870 |
</span> |
| 871 |
</mroot> |
| 872 |
<span class="end-math" title="speech-extra"> |
| 873 |
<BREAK SIZE="small"/> |
| 874 |
<PROS PITCH="-5">end math</PROS> |
| 875 |
<BREAK SIZE="medium"/> |
| 876 |
\end{verbatim} |
| 877 |
|
| 878 |
|
| 879 |
%%%%%%%%%%%%% |
| 880 |
\subsection{Line Breaks} |
| 881 |
%%%%%%%%%%%%% |
| 882 |
|
| 883 |
|
| 884 |
\<br into BREAK\><<< |
| 885 |
<script element="br" > |
| 886 |
<set name="br" > |
| 887 |
`<open xslt script`> |
| 888 |
`<append br with BREAK`> |
| 889 |
`<close xslt script`> |
| 890 |
</set> |
| 891 |
<xslt name="." xml="." xsl="br" /> |
| 892 |
</script> |
| 893 |
>>> |
| 894 |
|
| 895 |
|
| 896 |
\<append br with BREAK\><<< |
| 897 |
<xsl:template match="br" > |
| 898 |
<xsl:copy> |
| 899 |
<xsl:apply-templates select="@*" /> |
| 900 |
</xsl:copy> |
| 901 |
<BREAK SIZE="small"/> |
| 902 |
</xsl:template> |
| 903 |
>>> |
| 904 |
>>> |
| 905 |
|
| 906 |
|
| 907 |
%%%%%%%%%%%%%%%%%% |
| 908 |
\subsection{Empty Elements} |
| 909 |
%%%%%%%%%%%%%%%%%% |
| 910 |
|
| 911 |
|
| 912 |
|
| 913 |
\marginpar{??????} |
| 914 |
|
| 915 |
Can we avoid empty non-empty representations without of the |
| 916 |
following(Example: |
| 917 |
\verb+\documentclass{article} \begin{document} \section{Section One} This is Section 1 \end{document} + |
| 918 |
) |
| 919 |
|
| 920 |
|
| 921 |
\<short notation for empty elements\><<< |
| 922 |
<script element="BREAK" > |
| 923 |
<set name="BREAK" > |
| 924 |
`<open xslt script`> |
| 925 |
`<empty BREAK`> |
| 926 |
`<close xslt script`> |
| 927 |
</set> |
| 928 |
<xslt name="." xml="." xsl="BREAK" /> |
| 929 |
</script> |
| 930 |
>>> |
| 931 |
|
| 932 |
|
| 933 |
\<empty BREAK\><<< |
| 934 |
<xsl:template match="BREAK" > |
| 935 |
<xsl:copy> |
| 936 |
<xsl:apply-templates select="@*" /> |
| 937 |
</xsl:copy> |
| 938 |
</xsl:template> |
| 939 |
>>> |
| 940 |
|
| 941 |
|
| 942 |
|
| 943 |
%%%%%%%%%%%%% |
| 944 |
\subsection{Empty Array Cells} |
| 945 |
%%%%%%%%%%%%% |
| 946 |
|
| 947 |
Empty array celles at end of rows can make it more difficult to |
| 948 |
detect deletable baseline indicators. |
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
\<remove multline eqnum cell\><<< |
| 953 |
<script element="tr" > |
| 954 |
<set name="eqnum" > |
| 955 |
`<open xslt script`> |
| 956 |
`<remove empty cells from rows`> |
| 957 |
`<close xslt script`> |
| 958 |
</set> |
| 959 |
<xslt name="." xml="." xsl="eqnum" /> |
| 960 |
</script> |
| 961 |
>>> |
| 962 |
|
| 963 |
\<remove multline eqnum cell\><<< |
| 964 |
<script element="mtr" > |
| 965 |
<set name="eqnum" > |
| 966 |
`<open xslt script`> |
| 967 |
`<remove empty cells from rows`> |
| 968 |
`<close xslt script`> |
| 969 |
</set> |
| 970 |
<xslt name="." xml="." xsl="eqnum" /> |
| 971 |
</script> |
| 972 |
>>> |
| 973 |
|
| 974 |
\<remove empty cells from rows\><<< |
| 975 |
<xsl:template match="div[ |
| 976 |
(parent::tr or parent::mtr) |
| 977 |
and ( normalize-space(.) = '' ) |
| 978 |
and not( normalize-space(following-sibling::*) != '' ) |
| 979 |
]" > |
| 980 |
</xsl:template> |
| 981 |
>>> |
| 982 |
|
| 983 |
|
| 984 |
%%%%%%%%%%%%% |
| 985 |
\subsection{Paragraphs (JsmlFilter.java)} |
| 986 |
%%%%%%%%%%%%% |
| 987 |
|
| 988 |
\<remove empty paragraphs\><<< |
| 989 |
<xsl:template match=" PARA[ normalize-space(.) = '' ] " > |
| 990 |
</xsl:template> |
| 991 |
>>> |
| 992 |
|
| 993 |
|
| 994 |
The following adds PARA on `p' paragraphs, ul. |
| 995 |
|
| 996 |
|
| 997 |
|
| 998 |
|
| 999 |
\AtEndDocument{ % |
| 1000 |
\OutputCodE\<JsmlFilter.java\> |
| 1001 |
} |
| 1002 |
\ifdojava |
| 1003 |
\Needs{" |
| 1004 |
javac JsmlFilter.java -d \XTPIPES |
| 1005 |
"} |
| 1006 |
\fi |
| 1007 |
|
| 1008 |
\<JsmlFilter.java\><<< |
| 1009 |
package tex4ht; |
| 1010 |
/* JsmlFilter.java (`version), generated from `jobname.tex |
| 1011 |
Copyright (C) 2009-2010 TeX Users Group |
| 1012 |
Copyright (C) `CopyYear.2002. Eitan M. Gurari |
| 1013 |
`<TeX4ht copyright`> */ |
| 1014 |
import org.xml.sax.helpers.*; |
| 1015 |
import org.xml.sax.*; |
| 1016 |
import java.io.PrintWriter; |
| 1017 |
|
| 1018 |
public class JsmlFilter extends XMLFilterImpl { |
| 1019 |
PrintWriter out = null; |
| 1020 |
public JsmlFilter( PrintWriter out, PrintWriter log, boolean trace ){ |
| 1021 |
this.out = out; |
| 1022 |
} |
| 1023 |
public void startElement(String ns, String sName, |
| 1024 |
String qName, Attributes attr) { |
| 1025 |
try{ |
| 1026 |
if( `<elements for PARA?`> ){ |
| 1027 |
Attributes att = new AttributesImpl(); |
| 1028 |
super.startElement(ns, "PARA", "PARA", att); |
| 1029 |
} |
| 1030 |
super.startElement(ns, sName, qName, attr); |
| 1031 |
} catch( Exception e ){ |
| 1032 |
System.out.println( "--- JsmlFilter Error 1 --- " + e); |
| 1033 |
} } |
| 1034 |
public void endElement(String ns, String sName, String qName){ |
| 1035 |
try{ |
| 1036 |
super.endElement(ns, sName, qName); |
| 1037 |
if( `<elements for PARA?`> ){ |
| 1038 |
super.endElement(ns, "PARA", "PARA"); |
| 1039 |
} |
| 1040 |
} catch( Exception e ){ |
| 1041 |
System.out.println( "--- JsmlFilter Error 2 --- " + e); |
| 1042 |
} } } |
| 1043 |
>>> |
| 1044 |
|
| 1045 |
|
| 1046 |
|
| 1047 |
|
| 1048 |
\<elements for PARA?\><<< |
| 1049 |
qName.equals( "p" ) |
| 1050 |
|| qName.equals( "h2" ) |
| 1051 |
|| qName.equals( "h3" ) |
| 1052 |
|| qName.equals( "h4" ) |
| 1053 |
|| qName.equals( "ul" ) |
| 1054 |
|| qName.equals( "ol" ) |
| 1055 |
|| qName.equals( "li" ) |
| 1056 |
|| qName.equals( "dd" ) |
| 1057 |
|| qName.equals( "dl" ) |
| 1058 |
>>> |
| 1059 |
|
| 1060 |
|
| 1061 |
%%%%%%%%%%%%% |
| 1062 |
\subsection{Remove Split Arrays} |
| 1063 |
%%%%%%%%%%%%% |
| 1064 |
|
| 1065 |
\<remove empty split entries\><<< |
| 1066 |
<script element="div::split-side" > |
| 1067 |
<set name="clean-split" > |
| 1068 |
`<open xslt script`> |
| 1069 |
`<get content template`> |
| 1070 |
`<clean math split`> |
| 1071 |
`<close xslt script`> |
| 1072 |
</set> |
| 1073 |
<xslt name="." xml="." xsl="clean-split" /> |
| 1074 |
</script> |
| 1075 |
>>> |
| 1076 |
|
| 1077 |
|
| 1078 |
\<clean math split\><<< |
| 1079 |
<xsl:template match=" div[ @class='split-side' ] |
| 1080 |
" > |
| 1081 |
<xsl:variable name="content"> |
| 1082 |
<xsl:apply-templates select="*" mode="content" /> |
| 1083 |
</xsl:variable> |
| 1084 |
<xsl:if test=" |
| 1085 |
string-length( normalize-space( $content )) != 0 |
| 1086 |
" > |
| 1087 |
<xsl:copy> |
| 1088 |
<xsl:apply-templates select=" *|@*|text()|comment() " /> |
| 1089 |
</xsl:copy> |
| 1090 |
</xsl:if> |
| 1091 |
</xsl:template> |
| 1092 |
>>> |
| 1093 |
|
| 1094 |
|
| 1095 |
%%%%%%%%%%%%% |
| 1096 |
\section{Eliminate Inline Math Narrative} |
| 1097 |
%%%%%%%%%%%%% |
| 1098 |
|
| 1099 |
|
| 1100 |
%%%%%%%%%%%%% |
| 1101 |
\subsection{Core Content of One Element} |
| 1102 |
%%%%%%%%%%%%% |
| 1103 |
|
| 1104 |
|
| 1105 |
\<eliminate inline math narrative NO\><<< |
| 1106 |
<xsl:template match="span[ |
| 1107 |
(@class = 'inline-math') |
| 1108 |
and |
| 1109 |
(count( `<math content element`> ) = 1) |
| 1110 |
]" > |
| 1111 |
<xsl:copy> |
| 1112 |
<xsl:choose> |
| 1113 |
<xsl:when test="child::mfrac or child::msqrt |
| 1114 |
or child::mover or child::munder |
| 1115 |
"> |
| 1116 |
<xsl:attribute name="class"> |
| 1117 |
<xsl:text>semi-math</xsl:text> |
| 1118 |
</xsl:attribute> |
| 1119 |
<BREAK SIZE="small"/> |
| 1120 |
<xsl:apply-templates |
| 1121 |
select="`<math content element`>" /> |
| 1122 |
</xsl:when> |
| 1123 |
<xsl:otherwise> |
| 1124 |
`<non-adjacent narrative`> |
| 1125 |
</xsl:otherwise> |
| 1126 |
</xsl:choose> |
| 1127 |
</xsl:copy> |
| 1128 |
</xsl:template> |
| 1129 |
>>> |
| 1130 |
|
| 1131 |
|
| 1132 |
|
| 1133 |
\<non-adjacent narrative\><<< |
| 1134 |
<xsl:variable name="content"> |
| 1135 |
<xsl:apply-templates |
| 1136 |
select="`<math content element`>" |
| 1137 |
mode="content" /> |
| 1138 |
</xsl:variable> |
| 1139 |
<xsl:choose> |
| 1140 |
`<math narrative of length one`> |
| 1141 |
`<math narrative of just one element`> |
| 1142 |
`<simple sub or sup`> |
| 1143 |
<xsl:otherwise> |
| 1144 |
<xsl:apply-templates |
| 1145 |
select="*|@*|text()|comment()" /> |
| 1146 |
</xsl:otherwise> |
| 1147 |
</xsl:choose> |
| 1148 |
>>> |
| 1149 |
|
| 1150 |
|
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
\<math content element\><<< |
| 1155 |
child::*[ not(@title = 'speech-extra') |
| 1156 |
and not( self::BREAK ) |
| 1157 |
] |
| 1158 |
>>> |
| 1159 |
|
| 1160 |
|
| 1161 |
|
| 1162 |
|
| 1163 |
\<math narrative of length one\><<< |
| 1164 |
<xsl:when test=" |
| 1165 |
string-length( normalize-space( $content )) = 1 |
| 1166 |
" > |
| 1167 |
<xsl:attribute name="class"> |
| 1168 |
<xsl:text>semi-math</xsl:text> |
| 1169 |
</xsl:attribute> |
| 1170 |
<xsl:apply-templates |
| 1171 |
select="`<math content element`>" /> |
| 1172 |
</xsl:when> |
| 1173 |
>>> |
| 1174 |
|
| 1175 |
\<math narrative of just one element\><<< |
| 1176 |
<xsl:when test=" |
| 1177 |
not(`<math content element`> |
| 1178 |
/ descendant::* [ |
| 1179 |
count(child::*[ |
| 1180 |
not(self::BREAK) |
| 1181 |
] ) > 1 |
| 1182 |
] ) |
| 1183 |
" > |
| 1184 |
<xsl:attribute name="class"> |
| 1185 |
<xsl:text>semi-math</xsl:text> |
| 1186 |
</xsl:attribute> |
| 1187 |
<PROS PITCH="-5"> |
| 1188 |
<BREAK SIZE="small"/> |
| 1189 |
<xsl:apply-templates |
| 1190 |
select="`<math content element`>" /> |
| 1191 |
<BREAK SIZE="small"/> |
| 1192 |
</PROS> |
| 1193 |
</xsl:when> |
| 1194 |
>>> |
| 1195 |
|
| 1196 |
|
| 1197 |
\<simple sub or sup\><<< |
| 1198 |
<xsl:when test=" child::*[ |
| 1199 |
(position() = 2) |
| 1200 |
and |
| 1201 |
(self::msub or self::msup or self::msubsup) |
| 1202 |
]" > |
| 1203 |
<xsl:variable name="content"> |
| 1204 |
<xsl:apply-templates |
| 1205 |
select="child::*[2] / child::*[ |
| 1206 |
(@class = 'mrow-base') |
| 1207 |
or (@class = 'limits-mrow-base') ]" |
| 1208 |
mode="content" /> |
| 1209 |
</xsl:variable> |
| 1210 |
<xsl:choose> |
| 1211 |
<xsl:when test=" |
| 1212 |
string-length( normalize-space( $content )) = 1 |
| 1213 |
or |
| 1214 |
(translate($content,'0123456789 ','') = '') |
| 1215 |
" > |
| 1216 |
<xsl:attribute name="class"> |
| 1217 |
<xsl:text>semi-math</xsl:text> |
| 1218 |
</xsl:attribute> |
| 1219 |
<PROS PITCH="-5"> |
| 1220 |
<BREAK SIZE="small"/> |
| 1221 |
<xsl:apply-templates select="*[2]" /> |
| 1222 |
<BREAK SIZE="small"/> |
| 1223 |
</PROS> |
| 1224 |
</xsl:when> |
| 1225 |
<xsl:otherwise> |
| 1226 |
<xsl:apply-templates select="*|@*|text()" /> |
| 1227 |
</xsl:otherwise> |
| 1228 |
</xsl:choose> |
| 1229 |
</xsl:when> |
| 1230 |
>>> |
| 1231 |
|
| 1232 |
|
| 1233 |
\begin{verbatim} |
| 1234 |
<span class="inline-math"> |
| 1235 |
<msub> |
| 1236 |
<mrow class="mrow-base"> |
| 1237 |
<mi>C</mi> |
| 1238 |
</mrow> |
| 1239 |
<mrow class="mrow-sub"> |
| 1240 |
<mi>i</mi> |
| 1241 |
</mrow> |
| 1242 |
</msub> |
| 1243 |
</span> |
| 1244 |
\end{verbatim} |
| 1245 |
|
| 1246 |
|
| 1247 |
|
| 1248 |
|
| 1249 |
%%%%%%%%%%%%% |
| 1250 |
\subsection{Unary Op} |
| 1251 |
%%%%%%%%%%%%% |
| 1252 |
|
| 1253 |
The `mo-unary' is established in the first pass over inline-math, |
| 1254 |
so we need to wait for the second pass with the following. |
| 1255 |
|
| 1256 |
|
| 1257 |
\<eliminate inline math narrative NO 2\><<< |
| 1258 |
<xsl:template match="span[ |
| 1259 |
(@class = 'inline-math') |
| 1260 |
and |
| 1261 |
(count( `<math content element`> ) = 2) |
| 1262 |
and |
| 1263 |
( child::mo[ |
| 1264 |
(@class = 'mo-unary') |
| 1265 |
and |
| 1266 |
following-sibling::*[1] |
| 1267 |
/ self::mi |
| 1268 |
] |
| 1269 |
or |
| 1270 |
child::mi[ |
| 1271 |
following-sibling::*[1] |
| 1272 |
[ (@class = 'MathClass-open-close') |
| 1273 |
and |
| 1274 |
not(child::*[2] |
| 1275 |
/ child::*[ not(self::BREAK) ] |
| 1276 |
/ child::*[ not(self::BREAK) ] ) |
| 1277 |
] ] |
| 1278 |
) |
| 1279 |
]" > |
| 1280 |
<xsl:copy> |
| 1281 |
<xsl:choose> |
| 1282 |
`<when func on shallow arg`> |
| 1283 |
<xsl:otherwise> |
| 1284 |
`<unary op on short content`> |
| 1285 |
</xsl:otherwise> |
| 1286 |
</xsl:choose> |
| 1287 |
</xsl:copy> |
| 1288 |
</xsl:template> |
| 1289 |
>>> |
| 1290 |
|
| 1291 |
\<when func on shallow arg\><<< |
| 1292 |
<xsl:when test=" |
| 1293 |
child::mrow[ @class = 'MathClass-open-close' ] |
| 1294 |
" > |
| 1295 |
<xsl:attribute name="class"> |
| 1296 |
<xsl:text>semi-math</xsl:text> |
| 1297 |
</xsl:attribute> |
| 1298 |
<PROS PITCH="-5"> |
| 1299 |
<BREAK SIZE="small"/> |
| 1300 |
<xsl:apply-templates |
| 1301 |
select="`<math content element`>" /> |
| 1302 |
<BREAK SIZE="small"/> |
| 1303 |
</PROS> |
| 1304 |
</xsl:when> |
| 1305 |
>>> |
| 1306 |
|
| 1307 |
\<unary op on short content\><<< |
| 1308 |
<xsl:attribute name="class"> |
| 1309 |
<xsl:text>semi-math</xsl:text> |
| 1310 |
</xsl:attribute> |
| 1311 |
<PROS PITCH="-5"> |
| 1312 |
<BREAK SIZE="small"/> |
| 1313 |
<xsl:apply-templates |
| 1314 |
select="`<math content element`>" /> |
| 1315 |
<BREAK SIZE="small"/> |
| 1316 |
</PROS> |
| 1317 |
>>> |
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
%%%%%%%%%%%%% |
| 1322 |
\subsection{Shallow Expression} |
| 1323 |
%%%%%%%%%%%%% |
| 1324 |
|
| 1325 |
|
| 1326 |
\<eliminate inline math narrative NO 2\><<< |
| 1327 |
<xsl:template match="span[ |
| 1328 |
(@class = 'inline-math') |
| 1329 |
and |
| 1330 |
not( child::*[ |
| 1331 |
not(self::mo) |
| 1332 |
and not(self::mi) |
| 1333 |
and not(self::mn) |
| 1334 |
and not(self::mn-group-s) |
| 1335 |
and not( @title='speech-extra' ) |
| 1336 |
and not( self::mfrac[ |
| 1337 |
preceding-sibling::*[1][self::mn ] |
| 1338 |
] |
| 1339 |
) |
| 1340 |
and not( self::msub |
| 1341 |
/ child::*[1][ |
| 1342 |
child::mo[ @class = 'MathClass-op' ] |
| 1343 |
and |
| 1344 |
not(child::*[2]) |
| 1345 |
] |
| 1346 |
) |
| 1347 |
] ) |
| 1348 |
]" > |
| 1349 |
<xsl:copy> |
| 1350 |
`<shallow expression`> |
| 1351 |
</xsl:copy> |
| 1352 |
</xsl:template> |
| 1353 |
>>> |
| 1354 |
|
| 1355 |
\<shallow expression\><<< |
| 1356 |
<xsl:attribute name="class"> |
| 1357 |
<xsl:text>semi-math</xsl:text> |
| 1358 |
</xsl:attribute> |
| 1359 |
<PROS PITCH="-5"> |
| 1360 |
<BREAK SIZE="small"/> |
| 1361 |
<xsl:apply-templates |
| 1362 |
select="`<math content element`> | text()" /> |
| 1363 |
<BREAK SIZE="small"/> |
| 1364 |
</PROS> |
| 1365 |
>>> |
| 1366 |
|
| 1367 |
|
| 1368 |
|
| 1369 |
|
| 1370 |
%%%%%%%%%%%%% |
| 1371 |
\subsection{Shallow Delimited Expression} |
| 1372 |
%%%%%%%%%%%%% |
| 1373 |
|
| 1374 |
|
| 1375 |
\<eliminate inline math narrative NO 2\><<< |
| 1376 |
<xsl:template match="span[ |
| 1377 |
(@class = 'inline-math') |
| 1378 |
and |
| 1379 |
(count( `<math content element`> ) = 1) |
| 1380 |
and |
| 1381 |
child::mrow[ @class='MathClass-open-close' ] |
| 1382 |
/ child::mrow[ |
| 1383 |
not( child::*[ |
| 1384 |
not(self::mo) and not(self::mn-group-s) |
| 1385 |
and not(self::mi) and not(self::BREAK) |
| 1386 |
and not( @title='speech-extra' ) |
| 1387 |
]) |
| 1388 |
] |
| 1389 |
]" > |
| 1390 |
<xsl:copy> |
| 1391 |
`<shallow delimited expression`> |
| 1392 |
</xsl:copy> |
| 1393 |
</xsl:template> |
| 1394 |
>>> |
| 1395 |
|
| 1396 |
\<shallow delimited expression\><<< |
| 1397 |
<xsl:attribute name="class"> |
| 1398 |
<xsl:text>semi-math</xsl:text> |
| 1399 |
</xsl:attribute> |
| 1400 |
<PROS PITCH="-5"> |
| 1401 |
<BREAK SIZE="small"/> |
| 1402 |
<xsl:apply-templates select="mrow" /> |
| 1403 |
<BREAK SIZE="small"/> |
| 1404 |
</PROS> |
| 1405 |
>>> |
| 1406 |
|
| 1407 |
|
| 1408 |
|
| 1409 |
%%%%%%%%%%%%%%%%%% |
| 1410 |
\section{Superscripts and Subscripts} |
| 1411 |
%%%%%%%%%%%%%%%%%% |
| 1412 |
|
| 1413 |
%%%%%%%%%%%%% |
| 1414 |
\subsection{Insert Sub-Levels Info} |
| 1415 |
%%%%%%%%%%%%% |
| 1416 |
|
| 1417 |
|
| 1418 |
|
| 1419 |
|
| 1420 |
\<set levels for sub and sup scripts\><<< |
| 1421 |
<dom name="." xml="." method="scriptLevel" class="tex4ht.HtJsml" /> |
| 1422 |
`<remove xml declaration`> |
| 1423 |
>>> |
| 1424 |
|
| 1425 |
|
| 1426 |
|
| 1427 |
\<static void scriptLevel(dom)\><<< |
| 1428 |
public static void scriptLevel(Node dom) { |
| 1429 |
setScriptLevel(dom.getFirstChild(), ""); |
| 1430 |
} |
| 1431 |
private static void setScriptLevel(Node node, String prefix) { |
| 1432 |
String clName = null; |
| 1433 |
if (node.hasChildNodes()) { |
| 1434 |
if (node.hasAttributes()) { |
| 1435 |
Node cl = node.getAttributes().getNamedItem("class"); |
| 1436 |
if (cl != null) { |
| 1437 |
clName = cl.getNodeValue(); |
| 1438 |
if( clName.equals("mrow-sub") |
| 1439 |
|| |
| 1440 |
clName.equals("mrow-super") |
| 1441 |
){ |
| 1442 |
`<append script prefix`> |
| 1443 |
} } } |
| 1444 |
String ndName = node.getNodeName(); |
| 1445 |
if( |
| 1446 |
ndName.equals("msqrt") |
| 1447 |
|| |
| 1448 |
ndName.equals("mroot") |
| 1449 |
){ prefix = ""; } |
| 1450 |
`<script invoke children`> |
| 1451 |
} } |
| 1452 |
>>> |
| 1453 |
|
| 1454 |
\<script invoke children\><<< |
| 1455 |
NodeList children = node.getChildNodes(); |
| 1456 |
for (int i = 0; i < children.getLength(); i++) { |
| 1457 |
Node child = children.item(i); |
| 1458 |
if (child.getNodeType() == Node.ELEMENT_NODE) { |
| 1459 |
setScriptLevel(child, prefix); |
| 1460 |
} } |
| 1461 |
>>> |
| 1462 |
|
| 1463 |
\<append script prefix\><<< |
| 1464 |
if( !prefix.equals("") ){ |
| 1465 |
`<use current script prefix`> |
| 1466 |
} |
| 1467 |
if( clName.equals( "mrow-sub" ) ){ |
| 1468 |
prefix += " sub "; |
| 1469 |
} else if( clName.equals( "mrow-super" ) ){ |
| 1470 |
prefix += " super "; |
| 1471 |
} |
| 1472 |
>>> |
| 1473 |
|
| 1474 |
|
| 1475 |
\<use current script prefix\><<< |
| 1476 |
Node child = node.getFirstChild(); |
| 1477 |
if( (child.getNodeType() == Node.ELEMENT_NODE) |
| 1478 |
&& |
| 1479 |
child.hasAttributes() |
| 1480 |
){ |
| 1481 |
Node cls = child.getAttributes().getNamedItem("class"); |
| 1482 |
if (cls != null) { |
| 1483 |
String clsName = cls.getNodeValue(); |
| 1484 |
if ( clsName.equals("begin-script") |
| 1485 |
|| |
| 1486 |
clsName.equals("mid-script") |
| 1487 |
) { |
| 1488 |
child = child.getFirstChild(); |
| 1489 |
String s = child.getNodeValue(); |
| 1490 |
((org.w3c.dom.Text) child).setData( prefix + s ); |
| 1491 |
} } } |
| 1492 |
>>> |
| 1493 |
|
| 1494 |
|
| 1495 |
|
| 1496 |
%%%%%%%%%%%%% |
| 1497 |
\subsection{Eliminate End Script Marks} |
| 1498 |
%%%%%%%%%%%%% |
| 1499 |
|
| 1500 |
|
| 1501 |
The following takes care of end-scripts that semantically can be |
| 1502 |
merged into other end markers. |
| 1503 |
|
| 1504 |
\<eliminate baseline script marks\><<< |
| 1505 |
<xsl:template match="span[ |
| 1506 |
(@class = 'end-script') |
| 1507 |
and |
| 1508 |
ancestor::* [ following-sibling::* [ |
| 1509 |
not( @class = 'content-less' ) |
| 1510 |
] |
| 1511 |
][1] |
| 1512 |
/ following-sibling::* [ |
| 1513 |
not( @class = 'content-less' ) |
| 1514 |
][1] |
| 1515 |
/ self::* |
| 1516 |
[ |
| 1517 |
(@class = 'end-math') |
| 1518 |
or |
| 1519 |
(@class = 'end-script') |
| 1520 |
or |
| 1521 |
(@class = 'end-root') |
| 1522 |
or |
| 1523 |
(@class = 'end-stack') |
| 1524 |
or |
| 1525 |
(@class = 'mid-stack') |
| 1526 |
or |
| 1527 |
(@class = 'end-array') |
| 1528 |
or |
| 1529 |
self::td or self::mtd or self::tr or self::mtr |
| 1530 |
or |
| 1531 |
(@title = 'implicit-baseline') |
| 1532 |
] |
| 1533 |
]" > |
| 1534 |
<BREAK SIZE="small"/> |
| 1535 |
</xsl:template> |
| 1536 |
>>> |
| 1537 |
|
| 1538 |
|
| 1539 |
|
| 1540 |
|
| 1541 |
|
| 1542 |
|
| 1543 |
The following deals with endscripts before left sides of |
| 1544 |
tensors. |
| 1545 |
|
| 1546 |
|
| 1547 |
|
| 1548 |
\<eliminate baseline script marks\><<< |
| 1549 |
<xsl:template match="span[ |
| 1550 |
(@class = 'end-script') |
| 1551 |
and |
| 1552 |
parent::mrow / parent::msub |
| 1553 |
and |
| 1554 |
ancestor::* [ following-sibling::* ][1] |
| 1555 |
/ following-sibling::* [ normalize-space(.) != '' ][1] |
| 1556 |
[ |
| 1557 |
(self::msub or self::msubsup) |
| 1558 |
and |
| 1559 |
(normalize-space(child::mrow[ |
| 1560 |
@class = 'mrow-base' ]) = '') |
| 1561 |
] |
| 1562 |
]" > |
| 1563 |
<BREAK SIZE="small"/> |
| 1564 |
</xsl:template> |
| 1565 |
>>> |
| 1566 |
|
| 1567 |
|
| 1568 |
|
| 1569 |
\<eliminate baseline script marks\><<< |
| 1570 |
<xsl:template match="span[ |
| 1571 |
(@class = 'end-script') |
| 1572 |
and |
| 1573 |
parent::mrow /parent::*[ self::msup or self::msubsup] |
| 1574 |
and |
| 1575 |
ancestor::* [ following-sibling::* ][1] |
| 1576 |
/ following-sibling::* [ normalize-space(.) != '' ][1] |
| 1577 |
[ |
| 1578 |
self::msup |
| 1579 |
and |
| 1580 |
(normalize-space(child::mrow[ |
| 1581 |
@class = 'mrow-base' ]) = '') |
| 1582 |
] |
| 1583 |
]" > |
| 1584 |
<BREAK SIZE="small"/> |
| 1585 |
</xsl:template> |
| 1586 |
>>> |
| 1587 |
|
| 1588 |
|
| 1589 |
|
| 1590 |
|
| 1591 |
|
| 1592 |
|
| 1593 |
|
| 1594 |
|
| 1595 |
\begin{verbatim} |
| 1596 |
<span class="end-script" title="speech-extra"> |
| 1597 |
<PROS PITCH="-5"> |
| 1598 |
<BREAK SIZE="medium"/> |
| 1599 |
<span class="scripts-extra"> baseline </span> |
| 1600 |
<BREAK SIZE="small"/> |
| 1601 |
</PROS> |
| 1602 |
</span> |
| 1603 |
</mrow> |
| 1604 |
</msup> |
| 1605 |
<span class="tiny-space"/> |
| 1606 |
<msup> |
| 1607 |
<mrow class="mrow-base"/> |
| 1608 |
<mrow class="mrow-super"> |
| 1609 |
|
| 1610 |
\end{verbatim} |
| 1611 |
|
| 1612 |
%%%%%%%%%%%%% |
| 1613 |
\subsection{Clean Script Marks} |
| 1614 |
%%%%%%%%%%%%% |
| 1615 |
|
| 1616 |
|
| 1617 |
\<clean begin and mid script marks\><<< |
| 1618 |
<xsl:template match="span[ |
| 1619 |
(@class = 'begin-script') |
| 1620 |
or (@class = 'mid-script') |
| 1621 |
]" > |
| 1622 |
<xsl:copy> |
| 1623 |
<xsl:apply-templates select="@*" /> |
| 1624 |
<xsl:apply-templates select="*|text()|comment()" |
| 1625 |
mode="clean-script" /> |
| 1626 |
</xsl:copy> |
| 1627 |
</xsl:template> |
| 1628 |
<xsl:template match="*" mode="clean-script" > |
| 1629 |
<xsl:copy> |
| 1630 |
<xsl:apply-templates select="@*" /> |
| 1631 |
<xsl:apply-templates select="*|text()|comment()" |
| 1632 |
mode="clean-script" /> |
| 1633 |
</xsl:copy> |
| 1634 |
</xsl:template> |
| 1635 |
<xsl:template match="text()" mode="clean-script" > |
| 1636 |
</xsl:template> |
| 1637 |
<xsl:template match="span[@class = 'scripts-extra']" |
| 1638 |
mode="clean-script" > |
| 1639 |
<xsl:copy> |
| 1640 |
<xsl:apply-templates select="@*" /> |
| 1641 |
<xsl:value-of select=" |
| 1642 |
ancestor::span[ |
| 1643 |
(@class = 'begin-script') |
| 1644 |
or (@class = 'mid-script') ] [1] |
| 1645 |
" /> |
| 1646 |
</xsl:copy> |
| 1647 |
</xsl:template> |
| 1648 |
>>> |
| 1649 |
|
| 1650 |
The following is for script annotation on empty msu::base. |
| 1651 |
|
| 1652 |
\<remove marks on empty scripts\><<< |
| 1653 |
<xsl:template match="span[ |
| 1654 |
((@class = 'begin-script') or (@class = 'mid-script')) |
| 1655 |
and |
| 1656 |
following-sibling::* |
| 1657 |
/ following-sibling::span[ @class = 'end-script' ] |
| 1658 |
and |
| 1659 |
following-sibling::*[1] |
| 1660 |
/ descendant-or-self::*[ not(self::PROS) ][1] |
| 1661 |
/ child::*[1][ |
| 1662 |
(@class = 'mrow-base') |
| 1663 |
and |
| 1664 |
(normalize-space(.)='') |
| 1665 |
] |
| 1666 |
]" > |
| 1667 |
</xsl:template> |
| 1668 |
>>> |
| 1669 |
|
| 1670 |
\begin{verbatim} |
| 1671 |
<span class="begin-script" title="speech-extra"> |
| 1672 |
... |
| 1673 |
</span> |
| 1674 |
<PROS PITCH="+10"> |
| 1675 |
<msub> |
| 1676 |
<mrow class="mrow-base"/> |
| 1677 |
<mrow class="mrow-sub"> |
| 1678 |
... |
| 1679 |
</mrow> |
| 1680 |
</msub> |
| 1681 |
<mi>n</mi> |
| 1682 |
</PROS> |
| 1683 |
<span class="end-script" title="speech-extra"> |
| 1684 |
... |
| 1685 |
\end{verbatim} |
| 1686 |
|
| 1687 |
|
| 1688 |
|
| 1689 |
%%%%%%%%%%%%% |
| 1690 |
\subsection{Replace Nested Baseline Script Marks} |
| 1691 |
%%%%%%%%%%%%% |
| 1692 |
|
| 1693 |
|
| 1694 |
\<replace nested baseline script marks\><<< |
| 1695 |
<xsl:template match="span[ |
| 1696 |
(@class = 'end-script') |
| 1697 |
and |
| 1698 |
ancestor::*[ preceding-sibling::* [ |
| 1699 |
((@class = 'begin-script') or (@class = 'mid-script')) ]] |
| 1700 |
]" > |
| 1701 |
<xsl:copy> |
| 1702 |
<xsl:apply-templates select="@*" /> |
| 1703 |
<xsl:apply-templates select=" |
| 1704 |
ancestor::*[ preceding-sibling::* [ |
| 1705 |
((@class = 'begin-script') or |
| 1706 |
(@class = 'mid-script')) ]][1] |
| 1707 |
/ preceding-sibling::* [ |
| 1708 |
((@class = 'begin-script') or |
| 1709 |
(@class = 'mid-script')) ][1] |
| 1710 |
" mode="script-copy" /> |
| 1711 |
</xsl:copy> |
| 1712 |
</xsl:template> |
| 1713 |
>>> |
| 1714 |
|
| 1715 |
|
| 1716 |
|
| 1717 |
\<replace nested baseline script marks\><<< |
| 1718 |
<xsl:template match="*|@*|text()|comment()" |
| 1719 |
mode="script-copy" > |
| 1720 |
<xsl:copy> |
| 1721 |
<xsl:apply-templates select="*|@*|text()|comment()" /> |
| 1722 |
</xsl:copy> |
| 1723 |
</xsl:template> |
| 1724 |
<xsl:template match="span[ |
| 1725 |
(@class = 'begin-script') or |
| 1726 |
(@class = 'mid-script') ]" mode="script-copy" > |
| 1727 |
<xsl:apply-templates select="*|text()|comment()" /> |
| 1728 |
</xsl:template> |
| 1729 |
>>> |
| 1730 |
|
| 1731 |
|
| 1732 |
%%%%%%%%%%%%% |
| 1733 |
\subsection{Eliminate Begin Script Marks} |
| 1734 |
%%%%%%%%%%%%% |
| 1735 |
|
| 1736 |
|
| 1737 |
|
| 1738 |
\<eliminate begin script marks\><<< |
| 1739 |
<xsl:template match="span[ |
| 1740 |
(@class = 'begin-script') |
| 1741 |
and |
| 1742 |
following-sibling::* [1] / child::*[ |
| 1743 |
(position() = 1) |
| 1744 |
and |
| 1745 |
(@class = 'mrow-base') |
| 1746 |
and |
| 1747 |
( normalize-space(.) = '' ) |
| 1748 |
] |
| 1749 |
]" > |
| 1750 |
</xsl:template> |
| 1751 |
>>> |
| 1752 |
|
| 1753 |
|
| 1754 |
|
| 1755 |
%%%%%%%%%%%%% |
| 1756 |
\subsection{Undo Empty Scripts} |
| 1757 |
%%%%%%%%%%%%% |
| 1758 |
|
| 1759 |
|
| 1760 |
|
| 1761 |
|
| 1762 |
\<special sub and super scripts\><<< |
| 1763 |
<script element="msup" > |
| 1764 |
<set name="m-sub-sup" > |
| 1765 |
`<open xslt script`> |
| 1766 |
`<undo if empty su`> |
| 1767 |
`<close xslt script`> |
| 1768 |
</set> |
| 1769 |
<xslt name="." xml="." xsl="m-sub-sup" /> |
| 1770 |
`<superscript 2 and 3 into verbose`> |
| 1771 |
</script> |
| 1772 |
<script element="msub" > |
| 1773 |
`<sub script`> |
| 1774 |
</script> |
| 1775 |
<script element="msubsup" > |
| 1776 |
`<subsup prime`> |
| 1777 |
`<sub sup script`> |
| 1778 |
`<sub superscript 2 and 3 into verbose`> |
| 1779 |
</script> |
| 1780 |
>>> |
| 1781 |
|
| 1782 |
\<sub sup script\><<< |
| 1783 |
<set name="m-sub-sup" > |
| 1784 |
`<open xslt script`> |
| 1785 |
`<undo if empty su`> |
| 1786 |
`<close xslt script`> |
| 1787 |
</set> |
| 1788 |
<xslt name="." xml="." xsl="m-sub-sup" /> |
| 1789 |
>>> |
| 1790 |
|
| 1791 |
|
| 1792 |
|
| 1793 |
\<sub script\><<< |
| 1794 |
<set name="m-sub-sup" > |
| 1795 |
`<open xslt script`> |
| 1796 |
`<undo if empty su`> |
| 1797 |
`<msub of log`> |
| 1798 |
`<close xslt script`> |
| 1799 |
</set> |
| 1800 |
<xslt name="." xml="." xsl="m-sub-sup" /> |
| 1801 |
>>> |
| 1802 |
|
| 1803 |
\<undo if empty su\><<< |
| 1804 |
<xsl:template match="*[ |
| 1805 |
(self::msup or self::msub or self::msubsup) |
| 1806 |
and |
| 1807 |
not( |
| 1808 |
child::mrow[ @class = 'mrow-sub' ] |
| 1809 |
/ child::*[ not(@title = 'speech-extra') |
| 1810 |
and |
| 1811 |
(normalize-space(.) != '') |
| 1812 |
] |
| 1813 |
) |
| 1814 |
and |
| 1815 |
not( |
| 1816 |
child::mrow[ @class = 'mrow-super' ] |
| 1817 |
/ child::*[ not(@title = 'speech-extra') |
| 1818 |
and |
| 1819 |
(normalize-space(.) != '') |
| 1820 |
] |
| 1821 |
) |
| 1822 |
]" > |
| 1823 |
<xsl:apply-templates select="child::mrow[ |
| 1824 |
@class = 'mrow-base' ]/*" /> |
| 1825 |
</xsl:template> |
| 1826 |
>>> |
| 1827 |
|
| 1828 |
|
| 1829 |
|
| 1830 |
\begin{verbatim} |
| 1831 |
<msup> |
| 1832 |
<mrow class="mrow-base"> |
| 1833 |
......... |
| 1834 |
</mrow> |
| 1835 |
<wrow class="mrow-super"> |
| 1836 |
<span class="begin-script"> superscript </span> |
| 1837 |
<span class="end-script"> baseline </span> |
| 1838 |
</mrow> |
| 1839 |
</msup> |
| 1840 |
\end{verbatim} |
| 1841 |
|
| 1842 |
|
| 1843 |
|
| 1844 |
|
| 1845 |
%%%%%%%%%%%%% |
| 1846 |
\section{Special Subscripts and Superscripts} |
| 1847 |
%%%%%%%%%%%%% |
| 1848 |
|
| 1849 |
%%%%%%%%%%%%% |
| 1850 |
\subsection{Squared} |
| 1851 |
%%%%%%%%%%%%% |
| 1852 |
|
| 1853 |
|
| 1854 |
|
| 1855 |
\<superscript 2 and 3 into verbose\><<< |
| 1856 |
<set name="m-sup-2-3" > |
| 1857 |
`<open xslt script`> |
| 1858 |
`<superscript into squared and cube`> |
| 1859 |
`<close xslt script`> |
| 1860 |
</set> |
| 1861 |
<xslt name="." xml="." xsl="m-sup-2-3" /> |
| 1862 |
>>> |
| 1863 |
|
| 1864 |
\<superscript into squared and cube\><<< |
| 1865 |
<xsl:template match="msup[ |
| 1866 |
(normalize-space( |
| 1867 |
child::mrow[ (@class = 'mrow-super') ] |
| 1868 |
/ child::*[ not (@class = 'begin-script') |
| 1869 |
and |
| 1870 |
not (@class = 'end-script') |
| 1871 |
] |
| 1872 |
) = '2') |
| 1873 |
and `<su verbose not on op`> |
| 1874 |
and (normalize-space(mrow[@class = 'mrow-base']) != '' ) |
| 1875 |
]" > |
| 1876 |
<xsl:copy> |
| 1877 |
<xsl:apply-templates select="*|@*|text()|comment()" |
| 1878 |
mode="squared" /> |
| 1879 |
</xsl:copy> |
| 1880 |
</xsl:template> |
| 1881 |
>>> |
| 1882 |
|
| 1883 |
|
| 1884 |
\<su verbose not on op\><<< |
| 1885 |
not( |
| 1886 |
child::mrow[ @class = 'mrow-base' ] |
| 1887 |
/ child::span[ not( @title = 'speech-extra' ) ] |
| 1888 |
[ position() = last() ] |
| 1889 |
/ self::* [ @class = 'mo-op' ] |
| 1890 |
) |
| 1891 |
>>> |
| 1892 |
|
| 1893 |
|
| 1894 |
|
| 1895 |
|
| 1896 |
\<superscript into squared and cube\><<< |
| 1897 |
<xsl:template match="*|@*|text()|comment()" |
| 1898 |
mode="squared" > |
| 1899 |
<xsl:copy> |
| 1900 |
<xsl:choose> |
| 1901 |
<xsl:when test=" @class = 'mrow-super' "> |
| 1902 |
<xsl:apply-templates select="@*" /> |
| 1903 |
<mo class="mo-op"> |
| 1904 |
<xsl:text> squared </xsl:text> |
| 1905 |
</mo> |
| 1906 |
</xsl:when> |
| 1907 |
<xsl:otherwise> |
| 1908 |
<xsl:apply-templates select="*|@*|text()" /> |
| 1909 |
</xsl:otherwise> |
| 1910 |
</xsl:choose> |
| 1911 |
</xsl:copy> |
| 1912 |
</xsl:template> |
| 1913 |
>>> |
| 1914 |
|
| 1915 |
|
| 1916 |
|
| 1917 |
|
| 1918 |
|
| 1919 |
|
| 1920 |
\begin{verbatim} |
| 1921 |
<msup> |
| 1922 |
<mrow class="mrow-base"> |
| 1923 |
<mo class="mo-op">cos</mo> |
| 1924 |
</mrow> |
| 1925 |
<mrow class="mrow-super"> |
| 1926 |
<span class="begin-script"> superscript </span> |
| 1927 |
<span class="mn">2</span> |
| 1928 |
<span class="end-script"> baseline </span> |
| 1929 |
</mrow> |
| 1930 |
</msup> |
| 1931 |
\end{verbatim} |
| 1932 |
|
| 1933 |
|
| 1934 |
|
| 1935 |
|
| 1936 |
\<superscript into squared and cube\><<< |
| 1937 |
<xsl:template match="msup[ |
| 1938 |
(normalize-space( |
| 1939 |
child::mrow[ (@class = 'mrow-super') ] |
| 1940 |
/ child::*[ not (@class = 'begin-script') |
| 1941 |
and |
| 1942 |
not (@class = 'end-script') |
| 1943 |
] |
| 1944 |
) = '3') |
| 1945 |
and `<su verbose not on op`> |
| 1946 |
and (normalize-space(mrow[@class = 'mrow-base']) != '' ) |
| 1947 |
]" > |
| 1948 |
<xsl:copy> |
| 1949 |
<xsl:apply-templates select="*|@*|text()|comment()" |
| 1950 |
mode="cube" /> |
| 1951 |
</xsl:copy> |
| 1952 |
</xsl:template> |
| 1953 |
>>> |
| 1954 |
|
| 1955 |
|
| 1956 |
|
| 1957 |
\<superscript into squared and cube\><<< |
| 1958 |
<xsl:template match="*|@*|text()|comment()" |
| 1959 |
mode="cube" > |
| 1960 |
<xsl:copy> |
| 1961 |
<xsl:choose> |
| 1962 |
<xsl:when test=" @class = 'mrow-super' "> |
| 1963 |
<xsl:apply-templates select="@*" /> |
| 1964 |
<mo class="mo-op"> |
| 1965 |
<xsl:text> cube </xsl:text> |
| 1966 |
</mo> |
| 1967 |
</xsl:when> |
| 1968 |
<xsl:otherwise> |
| 1969 |
<xsl:apply-templates select="*|@*|text()" /> |
| 1970 |
</xsl:otherwise> |
| 1971 |
</xsl:choose> |
| 1972 |
</xsl:copy> |
| 1973 |
</xsl:template> |
| 1974 |
>>> |
| 1975 |
|
| 1976 |
|
| 1977 |
\<sub superscript 2 and 3 into verbose\><<< |
| 1978 |
<set name="m-subsup-2-3" > |
| 1979 |
`<open xslt script`> |
| 1980 |
`<subsup into sub squared and cube`> |
| 1981 |
`<close xslt script`> |
| 1982 |
</set> |
| 1983 |
<xslt name="." xml="." xsl="m-subsup-2-3" /> |
| 1984 |
>>> |
| 1985 |
|
| 1986 |
|
| 1987 |
|
| 1988 |
|
| 1989 |
|
| 1990 |
\<subsup into sub squared and cube\><<< |
| 1991 |
<xsl:template match="msubsup[ |
| 1992 |
(normalize-space( |
| 1993 |
child::mrow[ (@class = 'mrow-super') ] |
| 1994 |
/ child::span[ (@class != 'mid-script') |
| 1995 |
and |
| 1996 |
(@class != 'end-script') |
| 1997 |
] |
| 1998 |
) = '2') |
| 1999 |
and `<su verbose not on op`> |
| 2000 |
]" > |
| 2001 |
<xsl:copy> |
| 2002 |
<xsl:attribute name="class" > |
| 2003 |
<xsl:text>msub</xsl:text> |
| 2004 |
</xsl:attribute> |
| 2005 |
<xsl:apply-templates select="*|text()|comment()" |
| 2006 |
mode="sub-squared" /> |
| 2007 |
</xsl:copy> |
| 2008 |
</xsl:template> |
| 2009 |
>>> |
| 2010 |
|
| 2011 |
|
| 2012 |
|
| 2013 |
\<subsup into sub squared and cube\><<< |
| 2014 |
<xsl:template match="*|@*|text()|comment()" |
| 2015 |
mode="sub-squared" > |
| 2016 |
<xsl:copy> |
| 2017 |
<xsl:choose> |
| 2018 |
<xsl:when test=" @class = 'mrow-sub' "> |
| 2019 |
<xsl:apply-templates select="*[ |
| 2020 |
not( @class = 'end-script' ) |
| 2021 |
] |
| 2022 |
|@*|text()|comment()" /> |
| 2023 |
<xsl:apply-templates select=" |
| 2024 |
following-sibling::*[1] / *[ |
| 2025 |
@class = 'end-script' |
| 2026 |
] " /> |
| 2027 |
</xsl:when> |
| 2028 |
<xsl:when test=" @class = 'mrow-super' "> |
| 2029 |
<xsl:attribute name="class" > |
| 2030 |
<xsl:text>squared-super</xsl:text> |
| 2031 |
</xsl:attribute> |
| 2032 |
<mo class="mo-op"> |
| 2033 |
<xsl:text> squared </xsl:text> |
| 2034 |
</mo> |
| 2035 |
</xsl:when> |
| 2036 |
<xsl:otherwise> |
| 2037 |
<xsl:apply-templates select="*|@*|text()|comment()" /> |
| 2038 |
</xsl:otherwise> |
| 2039 |
</xsl:choose> |
| 2040 |
</xsl:copy> |
| 2041 |
</xsl:template> |
| 2042 |
>>> |
| 2043 |
|
| 2044 |
|
| 2045 |
\<subsup into sub squared and cube\><<< |
| 2046 |
<xsl:template match="msubsup[ |
| 2047 |
(normalize-space( |
| 2048 |
child::mrow[ (@class = 'mrow-super') ] |
| 2049 |
/ child::span[ (@class != 'mid-script') |
| 2050 |
and |
| 2051 |
(@class != 'end-script') |
| 2052 |
] |
| 2053 |
) = '3') |
| 2054 |
and `<su verbose not on op`> |
| 2055 |
]" > |
| 2056 |
<xsl:copy> |
| 2057 |
<xsl:attribute name="class" > |
| 2058 |
<xsl:text>msub</xsl:text> |
| 2059 |
</xsl:attribute> |
| 2060 |
<xsl:apply-templates select="*|text()|comment()" |
| 2061 |
mode="sub-cube" /> |
| 2062 |
</xsl:copy> |
| 2063 |
</xsl:template> |
| 2064 |
>>> |
| 2065 |
|
| 2066 |
|
| 2067 |
|
| 2068 |
\<subsup into sub squared and cube\><<< |
| 2069 |
<xsl:template match="*|@*|text()|comment()" |
| 2070 |
mode="sub-cube" > |
| 2071 |
<xsl:copy> |
| 2072 |
<xsl:choose> |
| 2073 |
<xsl:when test=" @class = 'mrow-sub' "> |
| 2074 |
<xsl:apply-templates select="*[ |
| 2075 |
not( @class = 'end-script' ) |
| 2076 |
] |
| 2077 |
|@*|text()|comment()" /> |
| 2078 |
<xsl:apply-templates select=" |
| 2079 |
following-sibling::*[1] / *[ |
| 2080 |
@class = 'end-script' |
| 2081 |
] " /> |
| 2082 |
</xsl:when> |
| 2083 |
<xsl:when test=" @class = 'mrow-super' "> |
| 2084 |
<xsl:attribute name="class" > |
| 2085 |
<xsl:text>cube-super</xsl:text> |
| 2086 |
</xsl:attribute> |
| 2087 |
<mo class="mo-op"> |
| 2088 |
<xsl:text> cube </xsl:text> |
| 2089 |
</mo> |
| 2090 |
</xsl:when> |
| 2091 |
<xsl:otherwise> |
| 2092 |
<xsl:apply-templates select="*|@*|text()|comment()" /> |
| 2093 |
</xsl:otherwise> |
| 2094 |
</xsl:choose> |
| 2095 |
</xsl:copy> |
| 2096 |
</xsl:template> |
| 2097 |
>>> |
| 2098 |
|
| 2099 |
|
| 2100 |
|
| 2101 |
%%%%%%%%%%%%% |
| 2102 |
\subsection{Numeric Subscripts (Rule 77)} |
| 2103 |
%%%%%%%%%%%%% |
| 2104 |
|
| 2105 |
\<compress numeric subscripts\><<< |
| 2106 |
<set name="num-sub" > |
| 2107 |
`<open xslt script`> |
| 2108 |
`<num sub`> |
| 2109 |
`<close xslt script`> |
| 2110 |
</set> |
| 2111 |
<xslt name="." xml="." xsl="num-sub" /> |
| 2112 |
>>> |
| 2113 |
|
| 2114 |
|
| 2115 |
|
| 2116 |
\<num sub\><<< |
| 2117 |
<xsl:template match="msub[ |
| 2118 |
( |
| 2119 |
`<num sub on non-primed base`> |
| 2120 |
or |
| 2121 |
`<num sub on primed base`> |
| 2122 |
) |
| 2123 |
and |
| 2124 |
child::mrow[ @class = 'mrow-sub' ] |
| 2125 |
/ child::*[ not(@title = 'speech-extra') ][1] |
| 2126 |
/ self::*[ |
| 2127 |
normalize-space(.) |
| 2128 |
= normalize-space( descendant::mn ) ] |
| 2129 |
]" > |
| 2130 |
<xsl:copy> |
| 2131 |
<xsl:apply-templates select="@*" /> |
| 2132 |
<BREAK SIZE="small"/> |
| 2133 |
<xsl:apply-templates select="*[1]" /> |
| 2134 |
<mrow class="mrow-sub"> |
| 2135 |
<xsl:apply-templates |
| 2136 |
select="*[2] / *[ |
| 2137 |
not(@title = 'speech-extra') |
| 2138 |
]" /> |
| 2139 |
<BREAK SIZE="small"/> |
| 2140 |
</mrow> |
| 2141 |
</xsl:copy> |
| 2142 |
</xsl:template> |
| 2143 |
>>> |
| 2144 |
|
| 2145 |
\<num sub on non-primed base\><<< |
| 2146 |
(count( child::mrow[ @class = 'mrow-base' ] |
| 2147 |
/ child::* ) = 1 ) |
| 2148 |
and child::mrow[ @class = 'mrow-base' ] / descendant::mi |
| 2149 |
and not( ancestor::*[ |
| 2150 |
self::msub or self::msup or self::msubsup |
| 2151 |
] ) |
| 2152 |
>>> |
| 2153 |
|
| 2154 |
\<num sub on primed base\><<< |
| 2155 |
( |
| 2156 |
count( child::mrow[ @class = 'mrow-base' ] |
| 2157 |
/ child::* [ |
| 2158 |
not(self::BREAK) |
| 2159 |
] |
| 2160 |
) = 2 ) |
| 2161 |
and child::mrow[ @class = 'mrow-base' ] [ |
| 2162 |
child::*[1][ self::mi ] |
| 2163 |
and |
| 2164 |
child::*[ |
| 2165 |
(position() > 1) |
| 2166 |
and |
| 2167 |
(normalize-space(.) = |
| 2168 |
normalize-space( |
| 2169 |
descendant-or-self::span[ |
| 2170 |
(@class = 'ch 2032') or (@class = 'ch 2033') |
| 2171 |
or (@class = 'ch 2034') |
| 2172 |
] |
| 2173 |
)) |
| 2174 |
] |
| 2175 |
] |
| 2176 |
and not( ancestor::*[ |
| 2177 |
self::msub or self::msup or self::msubsup |
| 2178 |
] ) |
| 2179 |
>>> |
| 2180 |
|
| 2181 |
\begin{verbatim} |
| 2182 |
<msub> |
| 2183 |
<mrow class="mrow-base"> |
| 2184 |
<mi>x</mi> |
| 2185 |
</mrow> |
| 2186 |
<mrow class="mrow-sub"> |
| 2187 |
<span class="begin-script" title="speech-extra"> subscript </span> |
| 2188 |
<mn>1</mn> |
| 2189 |
<span class="end-script" title="speech-extra"> baseline </span> |
| 2190 |
</mrow> |
| 2191 |
</msub> |
| 2192 |
\end{verbatim} |
| 2193 |
|
| 2194 |
|
| 2195 |
|
| 2196 |
\<num sub\><<< |
| 2197 |
<xsl:template match="msubsup[ |
| 2198 |
( |
| 2199 |
`<num sub on non-primed base`> |
| 2200 |
) |
| 2201 |
and |
| 2202 |
child::mrow[ @class = 'mrow-sub' ] |
| 2203 |
/ child::*[ not(@title = 'speech-extra') ][1] |
| 2204 |
/ self::*[ |
| 2205 |
normalize-space(.) |
| 2206 |
= normalize-space( descendant::mn ) ] |
| 2207 |
]" > |
| 2208 |
<msup> |
| 2209 |
<BREAK SIZE="small"/> |
| 2210 |
<xsl:apply-templates select="*[1]" /> |
| 2211 |
<mrow class="mrow-sub"> |
| 2212 |
<xsl:apply-templates |
| 2213 |
select="*[2] / *[ |
| 2214 |
not(@title = 'speech-extra') |
| 2215 |
]" /> |
| 2216 |
<BREAK SIZE="small"/> |
| 2217 |
</mrow> |
| 2218 |
<xsl:apply-templates select="*[3]" /> |
| 2219 |
</msup> |
| 2220 |
</xsl:template> |
| 2221 |
>>> |
| 2222 |
|
| 2223 |
%%%%%%%%%%%%% |
| 2224 |
\subsection{Primes} |
| 2225 |
%%%%%%%%%%%%% |
| 2226 |
|
| 2227 |
\<remove scrip indicators from primes\><<< |
| 2228 |
<xsl:template match="span[ |
| 2229 |
(@class = 'begin-script') |
| 2230 |
and |
| 2231 |
following-sibling::*[ not(@title = 'speech-extra') ] [1] |
| 2232 |
/ descendant-or-self::*[ not( self::PROS ) ][1] |
| 2233 |
/ |
| 2234 |
child::span / child::span[ |
| 2235 |
(@class = 'ch 2032') or (@class = 'ch 2033') |
| 2236 |
or (@class = 'ch 2034') |
| 2237 |
] |
| 2238 |
]" > |
| 2239 |
<BREAK SIZE="small"/> |
| 2240 |
</xsl:template> |
| 2241 |
>>> |
| 2242 |
|
| 2243 |
|
| 2244 |
\<remove scrip indicators from primes\><<< |
| 2245 |
<xsl:template match="span[ |
| 2246 |
(@class = 'end-script') |
| 2247 |
and |
| 2248 |
preceding-sibling::*[ not(@title = 'speech-extra') ] [1] |
| 2249 |
/ descendant-or-self::*[ not( self::PROS ) ][1] |
| 2250 |
/ |
| 2251 |
child::span / child::span[ |
| 2252 |
(@class = 'ch 2032') or (@class = 'ch 2033') |
| 2253 |
or (@class = 'ch 2034') |
| 2254 |
] |
| 2255 |
]" > |
| 2256 |
<BREAK SIZE="small"/> |
| 2257 |
</xsl:template> |
| 2258 |
>>> |
| 2259 |
|
| 2260 |
|
| 2261 |
|
| 2262 |
\begin{verbatim} |
| 2263 |
<span class="msup"> |
| 2264 |
<span class="mrow-base"> |
| 2265 |
<span class="mi">x</span> |
| 2266 |
</span> |
| 2267 |
<span class="mrow-super"> |
| 2268 |
<span class="begin-script"> superscript </span> |
| 2269 |
<span class="mo-op"> |
| 2270 |
<span class="char"> |
| 2271 |
<span class="ch 2033">double prime</span> |
| 2272 |
</span> |
| 2273 |
</span> |
| 2274 |
<span class="end-script"> baseline </span> |
| 2275 |
</span> |
| 2276 |
</span> |
| 2277 |
\end{verbatim} |
| 2278 |
|
| 2279 |
\<subsup prime\><<< |
| 2280 |
<set name="subsup-prime" > |
| 2281 |
`<open xslt script`> |
| 2282 |
`<compress subsup prime`> |
| 2283 |
`<close xslt script`> |
| 2284 |
</set> |
| 2285 |
<xslt name="." xml="." xsl="subsup-prime" /> |
| 2286 |
>>> |
| 2287 |
|
| 2288 |
|
| 2289 |
\<compress subsup prime\><<< |
| 2290 |
<xsl:template match="msubsup[ |
| 2291 |
(count( |
| 2292 |
child::mrow [ @class='mrow-super' ] |
| 2293 |
/ child::* [ not(@title = 'speech-extra') ] |
| 2294 |
) = 1) |
| 2295 |
and |
| 2296 |
not( |
| 2297 |
child::mrow [ @class='mrow-super' ] |
| 2298 |
/ child::* [ not(@title = 'speech-extra') ] |
| 2299 |
/ descendant::*[ preceding-sibling::* |
| 2300 |
or following-sibling::*] |
| 2301 |
) |
| 2302 |
and |
| 2303 |
child::mrow [ @class='mrow-super' ] |
| 2304 |
/ child::* [ not(@title = 'speech-extra') ] |
| 2305 |
/ descendant-or-self::span[ @class='char' ] |
| 2306 |
/ child::span[ |
| 2307 |
(@class = 'ch 2032') or (@class = 'ch 2033') |
| 2308 |
or (@class = 'ch 2034') |
| 2309 |
] |
| 2310 |
]" > |
| 2311 |
<msub> |
| 2312 |
<mrow class="mrow-base"> |
| 2313 |
<xsl:apply-templates select=" |
| 2314 |
child::mrow[@class = 'mrow-base'] / * |
| 2315 |
" /> |
| 2316 |
<BREAK SIZE="small"/> |
| 2317 |
<xsl:apply-templates select=" |
| 2318 |
child::mrow[@class = 'mrow-super'] |
| 2319 |
/ child::* [ not(@title = 'speech-extra') ] |
| 2320 |
" /> |
| 2321 |
</mrow> |
| 2322 |
<mrow class="mrow-sub"> |
| 2323 |
<xsl:apply-templates |
| 2324 |
select="*[@class = 'mrow-sub'] /* " /> |
| 2325 |
<xsl:apply-templates select=" |
| 2326 |
child::mrow[@class = 'mrow-super'] |
| 2327 |
/ child::* [ @class = 'end-script' ] |
| 2328 |
" /> |
| 2329 |
</mrow> |
| 2330 |
</msub> |
| 2331 |
</xsl:template> |
| 2332 |
>>> |
| 2333 |
|
| 2334 |
|
| 2335 |
|
| 2336 |
\begin{verbatim} |
| 2337 |
<span class="msubsup"> |
| 2338 |
<span class="mrow-base"> |
| 2339 |
<span class="mi">x</span> |
| 2340 |
</span> |
| 2341 |
<span class="mrow-sub"> |
| 2342 |
...... |
| 2343 |
</span> |
| 2344 |
<span class="mrow-super"> |
| 2345 |
<span class="mid-script" title="speech-extra"> superscript </span> |
| 2346 |
<span class="mi"> |
| 2347 |
<span class="char" title="ch-verbose"> |
| 2348 |
<span class="ch 2032" title="ch-verbose">prime</span> |
| 2349 |
</span> |
| 2350 |
</span> |
| 2351 |
</span> |
| 2352 |
</span> |
| 2353 |
\end{verbatim} |
| 2354 |
|
| 2355 |
|
| 2356 |
|
| 2357 |
%%%%%%%%%%%%% |
| 2358 |
\subsection{Degree} |
| 2359 |
%%%%%%%%%%%%% |
| 2360 |
|
| 2361 |
\<remove scrip indicators from degree\><<< |
| 2362 |
<xsl:template match="mrow[ |
| 2363 |
(@class = 'mrow-super') |
| 2364 |
and |
| 2365 |
parent::msup |
| 2366 |
and |
| 2367 |
(count( `<math content element`> ) = 1) |
| 2368 |
and |
| 2369 |
`<math content element`> [1][ |
| 2370 |
normalize-space(.) |
| 2371 |
= |
| 2372 |
normalize-space( |
| 2373 |
descendant::span[@class = 'ch 2218'] |
| 2374 |
) |
| 2375 |
] |
| 2376 |
]" > |
| 2377 |
<xsl:copy> |
| 2378 |
<xsl:apply-templates select="@*" /> |
| 2379 |
<xsl:apply-templates |
| 2380 |
select="*[not(@title = 'speech-extra') |
| 2381 |
and |
| 2382 |
not(self::BREAK) |
| 2383 |
]" |
| 2384 |
mode="degree" /> |
| 2385 |
<BREAK SIZE="small"/> |
| 2386 |
</xsl:copy> |
| 2387 |
</xsl:template> |
| 2388 |
>>> |
| 2389 |
|
| 2390 |
\<remove scrip indicators from degree\><<< |
| 2391 |
<xsl:template match="*" mode="degree" > |
| 2392 |
<xsl:copy> |
| 2393 |
<xsl:apply-templates select="@*" /> |
| 2394 |
<xsl:choose> |
| 2395 |
<xsl:when test="self::span[ @class='ch 2218' ]" > |
| 2396 |
<xsl:text>degree</xsl:text> |
| 2397 |
</xsl:when> |
| 2398 |
<xsl:otherwise> |
| 2399 |
<xsl:apply-templates |
| 2400 |
select="*[not(self::BREAK)]|text()" |
| 2401 |
mode="degree"/> |
| 2402 |
</xsl:otherwise> |
| 2403 |
</xsl:choose> |
| 2404 |
</xsl:copy> |
| 2405 |
</xsl:template> |
| 2406 |
>>> |
| 2407 |
|
| 2408 |
|
| 2409 |
|
| 2410 |
|
| 2411 |
|
| 2412 |
%%%%%%%%%%%%% |
| 2413 |
\subsection{Logarithms} |
| 2414 |
%%%%%%%%%%%%% |
| 2415 |
|
| 2416 |
\<msub of log\><<< |
| 2417 |
<xsl:template match=" |
| 2418 |
msub [ |
| 2419 |
normalize-space(child::*[1]) = 'log' |
| 2420 |
or |
| 2421 |
normalize-space(child::*[1]) = 'ln' |
| 2422 |
]" > |
| 2423 |
<xsl:copy> |
| 2424 |
<xsl:apply-templates select="@*" /> |
| 2425 |
<xsl:apply-templates select="child::*[1]" /> |
| 2426 |
<xsl:apply-templates select="child::*[2]" |
| 2427 |
mode="log" /> |
| 2428 |
</xsl:copy> |
| 2429 |
</xsl:template> |
| 2430 |
>>> |
| 2431 |
|
| 2432 |
\<msub of log\><<< |
| 2433 |
<xsl:template match="*" mode="log" > |
| 2434 |
<xsl:copy> |
| 2435 |
<xsl:apply-templates select="@*" /> |
| 2436 |
<xsl:choose> |
| 2437 |
<xsl:when test="parent::mrow[ @class = 'mrow-sub' ]" > |
| 2438 |
<BREAK SIZE="small"/> |
| 2439 |
<xsl:apply-templates select="*" /> |
| 2440 |
<BREAK SIZE="small"/> |
| 2441 |
<span title="speech-extra"> |
| 2442 |
<xsl:text>of</xsl:text> |
| 2443 |
</span> |
| 2444 |
<BREAK SIZE="small"/> |
| 2445 |
</xsl:when> |
| 2446 |
<xsl:otherwise> |
| 2447 |
<xsl:apply-templates |
| 2448 |
select="*[ not(@title = 'speech-extra') ]" |
| 2449 |
mode="log" /> |
| 2450 |
</xsl:otherwise> |
| 2451 |
</xsl:choose> |
| 2452 |
</xsl:copy> |
| 2453 |
</xsl:template> |
| 2454 |
>>> |
| 2455 |
|
| 2456 |
\begin{verbatim} |
| 2457 |
<msub> |
| 2458 |
<mrow class="mrow-base"> |
| 2459 |
<mo class="MathClass-op">log<BREAK SIZE="small"/></mo> |
| 2460 |
</mrow> |
| 2461 |
<mrow class="mrow-sub"> |
| 2462 |
<span class="begin-script" title="speech-extra"> |
| 2463 |
... |
| 2464 |
</span> |
| 2465 |
<PROS PITCH="-10"> |
| 2466 |
<mn>2</mn> |
| 2467 |
</PROS> |
| 2468 |
<span class="end-script" title="speech-extra"> |
| 2469 |
... |
| 2470 |
</span> |
| 2471 |
</mrow> |
| 2472 |
</msub> |
| 2473 |
<mi>x</mi> |
| 2474 |
\end{verbatim} |
| 2475 |
|
| 2476 |
|
| 2477 |
%%%%%%%%%%%%%%%%%% |
| 2478 |
\section{Fractions (Stage 1)} |
| 2479 |
%%%%%%%%%%%%%%%%%% |
| 2480 |
|
| 2481 |
%%%%%%%%%%%%% |
| 2482 |
\subsection{Outline} |
| 2483 |
%%%%%%%%%%%%% |
| 2484 |
|
| 2485 |
|
| 2486 |
|
| 2487 |
\<span frac elements\><<< |
| 2488 |
<script element="mfrac" > |
| 2489 |
<set name="mfrac" > |
| 2490 |
`<open xslt script`> |
| 2491 |
`<frac templates`> |
| 2492 |
`<close xslt script`> |
| 2493 |
</set> |
| 2494 |
<xslt name="." xml="." xsl="mfrac" /> |
| 2495 |
</script> |
| 2496 |
>>> |
| 2497 |
|
| 2498 |
\<frac templates\><<< |
| 2499 |
<xsl:template match="mfrac" > |
| 2500 |
<xsl:copy> |
| 2501 |
<xsl:choose> |
| 2502 |
`<word fracs`> |
| 2503 |
`<prepend continued fractions`> |
| 2504 |
`<tail continued fractions`> |
| 2505 |
<xsl:otherwise> |
| 2506 |
<xsl:apply-templates select="*|@*|text()|comment()" /> |
| 2507 |
</xsl:otherwise> |
| 2508 |
</xsl:choose> |
| 2509 |
</xsl:copy> |
| 2510 |
</xsl:template> |
| 2511 |
>>> |
| 2512 |
|
| 2513 |
|
| 2514 |
%%%%%%%%%%%%% |
| 2515 |
\subsection{Word Fractions} |
| 2516 |
%%%%%%%%%%%%% |
| 2517 |
|
| 2518 |
Example: `\verb+1 \ove 2+' int `one half' |
| 2519 |
|
| 2520 |
\<word fracs\><<< |
| 2521 |
<xsl:when test=" |
| 2522 |
(string-length( |
| 2523 |
normalize-space(child::mrow[ @class = 'mrow-numerator' ][1]) |
| 2524 |
) = 1) |
| 2525 |
and |
| 2526 |
(string-length( |
| 2527 |
normalize-space(child::mrow[ @class = 'mrow-enumerator' ][1]) |
| 2528 |
) = 1) |
| 2529 |
"> |
| 2530 |
`<a := numerator; b := enumerator`> |
| 2531 |
<xsl:choose> |
| 2532 |
<xsl:when test=" |
| 2533 |
(translate($a,'123456789','') != '') |
| 2534 |
or |
| 2535 |
(translate($b,'123456789','') != '') |
| 2536 |
" > |
| 2537 |
<xsl:apply-templates select="*|@*|text()|comment()" /> |
| 2538 |
</xsl:when> |
| 2539 |
<xsl:when test=" $a < $b "> |
| 2540 |
<xsl:attribute name="class"> |
| 2541 |
<xsl:text>word-frac</xsl:text> |
| 2542 |
</xsl:attribute> |
| 2543 |
`<word numerator`> |
| 2544 |
`<word enumerator`> |
| 2545 |
</xsl:when> |
| 2546 |
<xsl:otherwise> |
| 2547 |
<xsl:apply-templates select="*|@*|text()|comment()" /> |
| 2548 |
</xsl:otherwise> |
| 2549 |
</xsl:choose> |
| 2550 |
</xsl:when> |
| 2551 |
>>> |
| 2552 |
|
| 2553 |
|
| 2554 |
\<a := numerator; b := enumerator\><<< |
| 2555 |
<xsl:variable name="a"> |
| 2556 |
<xsl:value-of select=" |
| 2557 |
normalize-space(child::mrow[ @class = 'mrow-numerator' ][1]) |
| 2558 |
" /> |
| 2559 |
</xsl:variable> |
| 2560 |
<xsl:variable name="b"> |
| 2561 |
<xsl:value-of select=" |
| 2562 |
normalize-space(child::mrow[ @class = 'mrow-enumerator' ][1]) |
| 2563 |
" /> |
| 2564 |
</xsl:variable> |
| 2565 |
>>> |
| 2566 |
|
| 2567 |
|
| 2568 |
\<word numerator\><<< |
| 2569 |
<xsl:choose> |
| 2570 |
<xsl:when test=" $a = 1 "><xsl:text> one </xsl:text></xsl:when> |
| 2571 |
<xsl:when test=" $a = 2 "><xsl:text> two </xsl:text></xsl:when> |
| 2572 |
<xsl:when test=" $a = 3 "><xsl:text> three </xsl:text></xsl:when> |
| 2573 |
<xsl:when test=" $a = 4 "><xsl:text> four </xsl:text></xsl:when> |
| 2574 |
<xsl:when test=" $a = 5 "><xsl:text> five </xsl:text></xsl:when> |
| 2575 |
<xsl:when test=" $a = 6 "><xsl:text> six </xsl:text></xsl:when> |
| 2576 |
<xsl:when test=" $a = 7 "><xsl:text> seven </xsl:text></xsl:when> |
| 2577 |
<xsl:when test=" $a = 8 "><xsl:text> eight </xsl:text></xsl:when> |
| 2578 |
<xsl:when test=" $a = 9 "><xsl:text> nine </xsl:text></xsl:when> |
| 2579 |
</xsl:choose> |
| 2580 |
>>> |
| 2581 |
|
| 2582 |
|
| 2583 |
\<word enumerator\><<< |
| 2584 |
<xsl:choose> |
| 2585 |
<xsl:when test=" $b = 2 "><xsl:text> half</xsl:text></xsl:when> |
| 2586 |
<xsl:when test=" $b = 3 "><xsl:text> third</xsl:text></xsl:when> |
| 2587 |
<xsl:when test=" $b = 4 "><xsl:text> fourth</xsl:text></xsl:when> |
| 2588 |
<xsl:when test=" $b = 5 "><xsl:text> fifth</xsl:text></xsl:when> |
| 2589 |
<xsl:when test=" $b = 6 "><xsl:text> sixth</xsl:text></xsl:when> |
| 2590 |
<xsl:when test=" $b = 7 "><xsl:text> seventh</xsl:text></xsl:when> |
| 2591 |
<xsl:when test=" $b = 8 "><xsl:text> eighth</xsl:text></xsl:when> |
| 2592 |
<xsl:when test=" $b = 9 "><xsl:text> nineth</xsl:text></xsl:when> |
| 2593 |
</xsl:choose> |
| 2594 |
<xsl:if test=" $a > 1 "><xsl:text>s</xsl:text></xsl:if> |
| 2595 |
<xsl:text> </xsl:text> |
| 2596 |
>>> |
| 2597 |
|
| 2598 |
|
| 2599 |
|
| 2600 |
%%%%%%%%%%%%% |
| 2601 |
\subsection{Mixed Fractions} |
| 2602 |
%%%%%%%%%%%%% |
| 2603 |
|
| 2604 |
Examples: `\verb+2{3\over 4}+' |
| 2605 |
into `2 and three forth', |
| 2606 |
and `\verb+10{25\over 39}+' into `10 and 25 over 39'. |
| 2607 |
|
| 2608 |
\<mixed fractions\><<< |
| 2609 |
<xsl:template match="mfrac[ |
| 2610 |
( |
| 2611 |
(translate( |
| 2612 |
concat( |
| 2613 |
mrow[ (@class = 'mrow-numerator')], |
| 2614 |
mrow[ (@class = 'mrow-enumerator')] |
| 2615 |
) ,'0123456789','') = '') |
| 2616 |
and |
| 2617 |
not(descendant::*/descendant::* |
| 2618 |
/descendant::mn-group-s) |
| 2619 |
or |
| 2620 |
(@class = 'word-frac') |
| 2621 |
) |
| 2622 |
and |
| 2623 |
preceding-sibling::*[1] |
| 2624 |
/ self::mn-group-s[ child::*[ |
| 2625 |
(position() = last()) |
| 2626 |
and |
| 2627 |
self::mn |
| 2628 |
] ] |
| 2629 |
]" > |
| 2630 |
<xsl:text> and </xsl:text> |
| 2631 |
<xsl:copy> |
| 2632 |
<xsl:apply-templates select="*|@*|text()|comment()" /> |
| 2633 |
</xsl:copy> |
| 2634 |
</xsl:template> |
| 2635 |
>>> |
| 2636 |
|
| 2637 |
|
| 2638 |
|
| 2639 |
|
| 2640 |
%%%%%%%%%%%%% |
| 2641 |
\subsection{Continued Fractions Conditions (Rule 69)} |
| 2642 |
%%%%%%%%%%%%% |
| 2643 |
|
| 2644 |
|
| 2645 |
|
| 2646 |
\begin{verbatim} |
| 2647 |
1 |
| 2648 |
1 + --------------------------------------- |
| 2649 |
1 |
| 2650 |
2 + --------------------------------------- |
| 2651 |
1 |
| 2652 |
2 + --------------------------------------- |
| 2653 |
2 + ... |
| 2654 |
\end{verbatim} |
| 2655 |
|
| 2656 |
|
| 2657 |
The fractions are processed recusrively from inside out. The `tail' |
| 2658 |
is the one to discover the inner most part of a continued fraction |
| 2659 |
(i.e., the bottom rows). Higher levels add to the nucleous built |
| 2660 |
already under them. |
| 2661 |
|
| 2662 |
In Stage 1 the members of the continued fractions are marked as |
| 2663 |
such. In the second stage they being are procesed. |
| 2664 |
|
| 2665 |
|
| 2666 |
The minimum conditions here are three un-interrupted levels of |
| 2667 |
fractions. |
| 2668 |
|
| 2669 |
\begin{verbatim} |
| 2670 |
<mfrac> |
| 2671 |
<mrow class="mrow-enumerator"> |
| 2672 |
<mn>1</mn> |
| 2673 |
<mo class="MathClass-bin">...</mo> |
| 2674 |
<mfrac> |
| 2675 |
<span class="begin-end" ...>begin fraction</span> |
| 2676 |
<mrow class="mrow-numerator"> ... </mrow> |
| 2677 |
<span class="begin-end" ...>over</span> |
| 2678 |
<mrow class="mrow-enumerator">...</mrow> |
| 2679 |
<span class="begin-end" ...>end fraction</span> |
| 2680 |
</mfrac> |
| 2681 |
\end{verbatim} |
| 2682 |
|
| 2683 |
\<a,b := top 2 pre op values\><<< |
| 2684 |
<xsl:variable name="a"> |
| 2685 |
<xsl:apply-templates select=" |
| 2686 |
child::mrow[ @class = 'mrow-enumerator' ] / |
| 2687 |
child::mfrac / |
| 2688 |
preceding-sibling::*[2] |
| 2689 |
" mode="enum-op" /> |
| 2690 |
</xsl:variable> |
| 2691 |
<xsl:variable name="b"> |
| 2692 |
<xsl:apply-templates select=" |
| 2693 |
child::mrow[ @class = 'mrow-enumerator' ] / |
| 2694 |
child::mfrac / |
| 2695 |
child::mrow[ @class = 'mrow-enumerator' ] / |
| 2696 |
child::mfrac / |
| 2697 |
preceding-sibling::*[2] |
| 2698 |
" mode="enum-op" /> |
| 2699 |
</xsl:variable> |
| 2700 |
<xsl:variable name="c"> |
| 2701 |
<xsl:value-of select=" |
| 2702 |
normalize-space( |
| 2703 |
child::mrow[ @class = 'mrow-enumerator' ] / |
| 2704 |
child::mfrac / |
| 2705 |
child::mrow[ @class = 'mrow-enumerator' ] / |
| 2706 |
child::mfrac / |
| 2707 |
child::mrow[ @class = 'mrow-enumerator' ] ) |
| 2708 |
" /> |
| 2709 |
</xsl:variable> |
| 2710 |
>>> |
| 2711 |
|
| 2712 |
\<frac templates\><<< |
| 2713 |
<xsl:template match="*" mode="enum-op"> |
| 2714 |
<xsl:if test="preceding-sibling::*" > |
| 2715 |
<xsl:apply-templates select=" preceding-sibling::*[1] " /> |
| 2716 |
</xsl:if> |
| 2717 |
<xsl:value-of select="." /> |
| 2718 |
</xsl:template> |
| 2719 |
>>> |
| 2720 |
|
| 2721 |
|
| 2722 |
|
| 2723 |
|
| 2724 |
|
| 2725 |
%%%%%%%%%%%%% |
| 2726 |
\subsection{Nucleous of Continued Fractions} |
| 2727 |
%%%%%%%%%%%%% |
| 2728 |
|
| 2729 |
We are looking for the three most internal (bottom) fractions that |
| 2730 |
belong to a continued fraction. |
| 2731 |
|
| 2732 |
|
| 2733 |
\<tail continued fractions\><<< |
| 2734 |
<xsl:when test=" `%check numeral numerator`% |
| 2735 |
(translate( |
| 2736 |
normalize-space( |
| 2737 |
child::mrow[ @class = 'mrow-numerator' ]), |
| 2738 |
'0123456789','')= '') |
| 2739 |
and `<check equality of numerators`> |
| 2740 |
and `<check ops before two top fracs`> |
| 2741 |
"> |
| 2742 |
`<a,b := top 2 pre op values`> |
| 2743 |
<xsl:choose> |
| 2744 |
<xsl:when test=" |
| 2745 |
( translate($a,'0123456789 ','') = '') |
| 2746 |
and (normalize-space($a)=normalize-space($b)) |
| 2747 |
and starts-with( $c, normalize-space( $a )) |
| 2748 |
and starts-with( |
| 2749 |
normalize-space( |
| 2750 |
substring-after( $c, normalize-space( $a )) ) |
| 2751 |
, |
| 2752 |
normalize-space( |
| 2753 |
child::mrow[ @class = 'mrow-enumerator' ] / |
| 2754 |
child::mfrac / |
| 2755 |
preceding-sibling::*[1] ) |
| 2756 |
) |
| 2757 |
" > |
| 2758 |
<xsl:attribute name="class"> |
| 2759 |
<xsl:value-of select=" 'continued-mfrac' " /> |
| 2760 |
</xsl:attribute> |
| 2761 |
<xsl:apply-templates select="*|text()|comment()" /> |
| 2762 |
</xsl:when> |
| 2763 |
<xsl:otherwise> |
| 2764 |
<xsl:apply-templates select="*|@*|text()|comment()" /> |
| 2765 |
</xsl:otherwise> |
| 2766 |
</xsl:choose> |
| 2767 |
</xsl:when> |
| 2768 |
>>> |
| 2769 |
|
| 2770 |
|
| 2771 |
|
| 2772 |
|
| 2773 |
|
| 2774 |
\<check equality of numerators\><<< |
| 2775 |
( normalize-space( |
| 2776 |
child::mrow[ @class = 'mrow-numerator' ]) |
| 2777 |
and |
| 2778 |
normalize-space( |
| 2779 |
child::mrow[ @class = 'mrow-enumerator' ] / |
| 2780 |
child::mfrac / |
| 2781 |
child::mrow[ @class = 'mrow-numerator' ]) |
| 2782 |
) |
| 2783 |
and |
| 2784 |
( normalize-space( |
| 2785 |
child::mrow[ @class = 'mrow-enumerator' ] / |
| 2786 |
child::mfrac / |
| 2787 |
child::mrow[ @class = 'mrow-numerator' ]) |
| 2788 |
and |
| 2789 |
normalize-space( |
| 2790 |
child::mrow[ @class = 'mrow-enumerator' ] / |
| 2791 |
child::mfrac / |
| 2792 |
child::mrow[ @class = 'mrow-enumerator' ] / |
| 2793 |
child::mfrac / |
| 2794 |
child::mrow[ @class = 'mrow-numerator' ]) |
| 2795 |
) |
| 2796 |
>>> |
| 2797 |
|
| 2798 |
|
| 2799 |
|
| 2800 |
\<check ops before two top fracs\><<< |
| 2801 |
( child::mrow[ @class = 'mrow-enumerator' ] / |
| 2802 |
child::mfrac / |
| 2803 |
preceding-sibling::*[1][@class = 'MathClass-bin'] |
| 2804 |
) |
| 2805 |
and |
| 2806 |
( normalize-space( |
| 2807 |
child::mrow[ @class = 'mrow-enumerator' ] / |
| 2808 |
child::mfrac / |
| 2809 |
preceding-sibling::*[1] ) |
| 2810 |
= |
| 2811 |
normalize-space( |
| 2812 |
child::mrow[ @class = 'mrow-enumerator' ] / |
| 2813 |
child::mfrac / |
| 2814 |
child::mrow[ @class = 'mrow-enumerator' ] / |
| 2815 |
child::mfrac / |
| 2816 |
preceding-sibling::*[1] ) |
| 2817 |
) |
| 2818 |
>>> |
| 2819 |
|
| 2820 |
|
| 2821 |
|
| 2822 |
|
| 2823 |
%%%%%%%%%%%%% |
| 2824 |
\subsection{Prepend Existing Continued Fractions} |
| 2825 |
%%%%%%%%%%%%% |
| 2826 |
|
| 2827 |
|
| 2828 |
\<prepend continued fractions\><<< |
| 2829 |
<xsl:when test=" |
| 2830 |
self::mfrac |
| 2831 |
and |
| 2832 |
child::mrow[ @class = 'mrow-enumerator' ] |
| 2833 |
/ child::mfrac[ @class = 'continued-mfrac' ] |
| 2834 |
and |
| 2835 |
( normalize-space( |
| 2836 |
child::mrow[ @class = 'mrow-numerator' ] |
| 2837 |
) |
| 2838 |
= |
| 2839 |
normalize-space( |
| 2840 |
child::mrow[ @class = 'mrow-enumerator' ] |
| 2841 |
/ child::mfrac[ @class = 'continued-mfrac' ] |
| 2842 |
/ child::mrow[ @class = 'mrow-numerator' ] |
| 2843 |
) |
| 2844 |
) |
| 2845 |
and `<check equality of op with cont frac`> |
| 2846 |
" > |
| 2847 |
`<a,b := cont top 2 pre op values`> |
| 2848 |
<xsl:choose> |
| 2849 |
<xsl:when test=" |
| 2850 |
normalize-space($a)=normalize-space($b) |
| 2851 |
" > |
| 2852 |
<xsl:attribute name="class"> |
| 2853 |
<xsl:value-of select=" 'continued-mfrac' " /> |
| 2854 |
</xsl:attribute> |
| 2855 |
<xsl:apply-templates select="*|text()|comment()" /> |
| 2856 |
</xsl:when> |
| 2857 |
<xsl:otherwise> |
| 2858 |
<xsl:apply-templates select="*|@*|text()|comment()" /> |
| 2859 |
</xsl:otherwise> |
| 2860 |
</xsl:choose> |
| 2861 |
</xsl:when> |
| 2862 |
>>> |
| 2863 |
|
| 2864 |
|
| 2865 |
|
| 2866 |
\<check equality of op with cont frac\><<< |
| 2867 |
( |
| 2868 |
normalize-space( |
| 2869 |
child::span[ @class = 'mrow-enumerator' ] / |
| 2870 |
child::mfrac / |
| 2871 |
preceding-sibling::*[1] ) |
| 2872 |
= |
| 2873 |
normalize-space( |
| 2874 |
child::span[ @class = 'mrow-enumerator' ] / |
| 2875 |
child::mfrac / |
| 2876 |
child::span[ @class = 'mrow-enumerator' ] / |
| 2877 |
child::span[ @class = 'continued-mfrac' ] / |
| 2878 |
preceding-sibling::*[1] ) |
| 2879 |
) |
| 2880 |
>>> |
| 2881 |
|
| 2882 |
|
| 2883 |
\<a,b := cont top 2 pre op values\><<< |
| 2884 |
<xsl:variable name="a"> |
| 2885 |
<xsl:apply-templates select=" |
| 2886 |
child::span[ @class = 'mrow-enumerator' ] / |
| 2887 |
child::span[ @class = 'mcontinued-mfrac' ] / |
| 2888 |
preceding-sibling::*[2] |
| 2889 |
" mode="enum-op" /> |
| 2890 |
</xsl:variable> |
| 2891 |
<xsl:variable name="b"> |
| 2892 |
<xsl:apply-templates select=" |
| 2893 |
child::span[ @class = 'mrow-enumerator' ] / |
| 2894 |
child::span[ @class = 'mcontinued-mfrac' ] / |
| 2895 |
child::span[ @class = 'mrow-enumerator' ] / |
| 2896 |
child::span[ |
| 2897 |
self::mfrac or (@class = 'mcontinued-mfrac') |
| 2898 |
] / |
| 2899 |
preceding-sibling::*[2] |
| 2900 |
" mode="enum-op" /> |
| 2901 |
</xsl:variable> |
| 2902 |
>>> |
| 2903 |
|
| 2904 |
|
| 2905 |
|
| 2906 |
|
| 2907 |
%%%%%%%%%%%%%%%%%% |
| 2908 |
\section{Fractions (Stage 2)} |
| 2909 |
%%%%%%%%%%%%%%%%%% |
| 2910 |
|
| 2911 |
%%%%%%%%%%%%% |
| 2912 |
\subsection{Outline} |
| 2913 |
%%%%%%%%%%%%% |
| 2914 |
|
| 2915 |
|
| 2916 |
\<set levels for hyper complex fracs\><<< |
| 2917 |
<dom name="." xml="." method="fracLevel" class="tex4ht.HtJsml" /> |
| 2918 |
`<remove xml declaration`> |
| 2919 |
>>> |
| 2920 |
|
| 2921 |
|
| 2922 |
|
| 2923 |
\<static void fracLevel(dom)\><<< |
| 2924 |
public static void fracLevel(Node d) { |
| 2925 |
dom = (Document) d; |
| 2926 |
setFracLevel(dom.getFirstChild(), 0); |
| 2927 |
} |
| 2928 |
private static int setFracLevel(Node node, int cont) { |
| 2929 |
int level = 0; |
| 2930 |
if (node.hasChildNodes()) { |
| 2931 |
String ndName = node.getNodeName(); |
| 2932 |
int prevCont = cont; |
| 2933 |
String clValue = null; |
| 2934 |
if (ndName.equals("mfrac")) { |
| 2935 |
`<clValue := class of mfrac`> |
| 2936 |
`<cont := distance from mfrac(continued-frac)`> |
| 2937 |
} |
| 2938 |
`<level += inherited from children`> |
| 2939 |
`<return 0 if barier`> |
| 2940 |
if (ndName.equals("mfrac")) { |
| 2941 |
`<return 0 if mfrac barier`> |
| 2942 |
if( cont > 0 ){ |
| 2943 |
if ( prevCont == 0 ){ |
| 2944 |
`<set start continued fracs mark`> |
| 2945 |
} |
| 2946 |
`<remove end of non-tail continued frac`> |
| 2947 |
level = 0; |
| 2948 |
} else if ( prevCont > 0 ){ |
| 2949 |
`<set end continued fracs mark`> |
| 2950 |
level = 0; |
| 2951 |
} else |
| 2952 |
if( level > 0 ){ |
| 2953 |
`<set extra levels for frac`> |
| 2954 |
} |
| 2955 |
level++; |
| 2956 |
} } |
| 2957 |
return level; |
| 2958 |
} |
| 2959 |
>>> |
| 2960 |
|
| 2961 |
|
| 2962 |
|
| 2963 |
%%%%%%%%%%%%%%%%%% |
| 2964 |
\subsection{Level Indicators for Nesting (Hyper Complex Fractions)} |
| 2965 |
%%%%%%%%%%%%%%%%%% |
| 2966 |
|
| 2967 |
\begin{verbatim} |
| 2968 |
${a\over b}\over c$ |
| 2969 |
|
| 2970 |
begin begin fraction |
| 2971 |
begin fraction a |
| 2972 |
over b |
| 2973 |
end fraction |
| 2974 |
over over c |
| 2975 |
end end fraction |
| 2976 |
\end{verbatim} |
| 2977 |
|
| 2978 |
\<set extra levels for frac\><<< |
| 2979 |
for (int i = 0; i < children.getLength(); i++) { |
| 2980 |
Node child = children.item(i); |
| 2981 |
if (child.getNodeType() == Node.ELEMENT_NODE) { |
| 2982 |
Node cls = child.getAttributes() |
| 2983 |
.getNamedItem("class"); |
| 2984 |
if (cls != null) { |
| 2985 |
String clsName = cls.getNodeValue(); |
| 2986 |
if (clsName.equals("begin-end")) { |
| 2987 |
insertLevelPrefix(child, level); |
| 2988 |
} } } } |
| 2989 |
>>> |
| 2990 |
|
| 2991 |
\<HtJsml utility members\><<< |
| 2992 |
private static void insertLevelPrefix(Node node, int level){ |
| 2993 |
if( level == 0 ){ return; } |
| 2994 |
if (node.getNodeType() == Node.ELEMENT_NODE) { |
| 2995 |
if( node.getNodeName().equals( "level" ) ){ |
| 2996 |
`<insert level prefixes`> |
| 2997 |
} else { |
| 2998 |
NodeList children = node.getChildNodes(); |
| 2999 |
for (int i = 0; i < children.getLength(); i++) { |
| 3000 |
Node child = children.item(i); |
| 3001 |
insertLevelPrefix(child, level); |
| 3002 |
} } } } |
| 3003 |
>>> |
| 3004 |
|
| 3005 |
|
| 3006 |
|
| 3007 |
|
| 3008 |
\<insert level prefixes\><<< |
| 3009 |
Node attr = node.getAttributes().getNamedItem("prefix"); |
| 3010 |
if( attr != null ){ |
| 3011 |
String prefix = attr.getNodeValue(); |
| 3012 |
String s = ""; |
| 3013 |
for(int j=0; j<level; j++){ |
| 3014 |
s += prefix + " "; |
| 3015 |
} |
| 3016 |
((org.w3c.dom.Element) node).setAttribute( "depth", ""+level); |
| 3017 |
Node child = node.getFirstChild(); |
| 3018 |
if( child != null ){ |
| 3019 |
node.insertBefore( dom.createTextNode(s), child ); |
| 3020 |
} } |
| 3021 |
>>> |
| 3022 |
|
| 3023 |
|
| 3024 |
|
| 3025 |
\<level += inherited from children\><<< |
| 3026 |
NodeList children = node.getChildNodes(); |
| 3027 |
int max = 0; |
| 3028 |
for (int i = 0; i < children.getLength(); i++) { |
| 3029 |
Node child = children.item(i); |
| 3030 |
if (child.getNodeType() == Node.ELEMENT_NODE) { |
| 3031 |
int d = setFracLevel(child, |
| 3032 |
`<continued level counter`>); |
| 3033 |
if (d > max) { max = d; } |
| 3034 |
} } |
| 3035 |
level += max; |
| 3036 |
>>> |
| 3037 |
|
| 3038 |
|
| 3039 |
%%%%%%%%%%%%% |
| 3040 |
\subsection{Level Terminators: Scripts, Word Fracs} |
| 3041 |
%%%%%%%%%%%%% |
| 3042 |
|
| 3043 |
|
| 3044 |
\<return 0 if barier\><<< |
| 3045 |
if( ndName.equals("msub") |
| 3046 |
|| ndName.equals("msup") |
| 3047 |
|| ndName.equals("msubsup") |
| 3048 |
) { |
| 3049 |
return 0; |
| 3050 |
} |
| 3051 |
>>> |
| 3052 |
|
| 3053 |
|
| 3054 |
\<return 0 if mfrac barier\><<< |
| 3055 |
if( (clValue != null) && clValue.equals("word-frac") |
| 3056 |
) { |
| 3057 |
return 0; |
| 3058 |
} |
| 3059 |
>>> |
| 3060 |
|
| 3061 |
|
| 3062 |
|
| 3063 |
|
| 3064 |
|
| 3065 |
|
| 3066 |
|
| 3067 |
|
| 3068 |
|
| 3069 |
|
| 3070 |
%%%%%%%%%%%%% |
| 3071 |
\subsection{Bookeeping for Continued Fractions} |
| 3072 |
%%%%%%%%%%%%% |
| 3073 |
|
| 3074 |
\<continued level counter\><<< |
| 3075 |
cont |
| 3076 |
>>> |
| 3077 |
|
| 3078 |
|
| 3079 |
In the first phase, the mfrac elements in a group carry |
| 3080 |
attributes as in |
| 3081 |
|
| 3082 |
\begin{verbatim} |
| 3083 |
<mfrac class="continued-mfrac"> |
| 3084 |
\end{verbatim} |
| 3085 |
|
| 3086 |
|
| 3087 |
with the exception of the bottom (internal) most leveles. |
| 3088 |
The `cont' parameter is for determining whether the parent and the |
| 3089 |
grandparent are frac elements marked as continued. |
| 3090 |
|
| 3091 |
|
| 3092 |
|
| 3093 |
\<clValue := class of mfrac\><<< |
| 3094 |
if (node.hasAttributes()) { |
| 3095 |
Node cl = node.getAttributes().getNamedItem("class"); |
| 3096 |
if (cl != null) { clValue = cl.getNodeValue(); } |
| 3097 |
} |
| 3098 |
>>> |
| 3099 |
|
| 3100 |
\<cont := distance from mfrac(continued-frac)\><<< |
| 3101 |
if( (clValue != null) |
| 3102 |
&& clValue.equals("continued-mfrac") ) { |
| 3103 |
cont = 2; |
| 3104 |
} else { cont--; } |
| 3105 |
>>> |
| 3106 |
|
| 3107 |
|
| 3108 |
|
| 3109 |
%%%%%%%%%%%%% |
| 3110 |
\subsection{Modifications for Continued Fractions} |
| 3111 |
%%%%%%%%%%%%% |
| 3112 |
|
| 3113 |
\<remove end of non-tail continued frac\><<< |
| 3114 |
Node child = node.getLastChild(); |
| 3115 |
if (child.getNodeType() == Node.ELEMENT_NODE) { |
| 3116 |
Node cls = child.getAttributes() .getNamedItem("class"); |
| 3117 |
if (cls != null) { |
| 3118 |
String clsName = cls.getNodeValue(); |
| 3119 |
if ( clsName.equals("begin-end")) { |
| 3120 |
node.removeChild( child ); |
| 3121 |
} } } |
| 3122 |
>>> |
| 3123 |
|
| 3124 |
\<set end continued fracs mark\><<< |
| 3125 |
Node child = node.getLastChild(); |
| 3126 |
if (child.getNodeType() == Node.ELEMENT_NODE) { |
| 3127 |
Node cls = child.getAttributes() .getNamedItem("class"); |
| 3128 |
if (cls != null) { |
| 3129 |
String clsName = cls.getNodeValue(); |
| 3130 |
if ( clsName.equals("begin-end")) { |
| 3131 |
setContinuedNote(child); |
| 3132 |
} } } |
| 3133 |
>>> |
| 3134 |
|
| 3135 |
\<set start continued fracs mark\><<< |
| 3136 |
Node child = node.getFirstChild(); |
| 3137 |
if (child.getNodeType() == Node.ELEMENT_NODE) { |
| 3138 |
Node cls = child.getAttributes() .getNamedItem("class"); |
| 3139 |
if (cls != null) { |
| 3140 |
String clsName = cls.getNodeValue(); |
| 3141 |
if ( clsName.equals("begin-end")) { |
| 3142 |
setContinuedNote(child); |
| 3143 |
} } } |
| 3144 |
>>> |
| 3145 |
|
| 3146 |
|
| 3147 |
\<HtJsml utility members\><<< |
| 3148 |
private static void setContinuedNote(Node node){ |
| 3149 |
if (node.getNodeType() == Node.ELEMENT_NODE) { |
| 3150 |
if( node.getNodeName().equals( "level" ) ){ |
| 3151 |
`<fix end continued note`> |
| 3152 |
} else { |
| 3153 |
NodeList children = node.getChildNodes(); |
| 3154 |
for (int i = 0; i < children.getLength(); i++) { |
| 3155 |
Node child = children.item(i); |
| 3156 |
setContinuedNote(child); |
| 3157 |
} } } } |
| 3158 |
>>> |
| 3159 |
|
| 3160 |
\<fix end continued note\><<< |
| 3161 |
Node attr = node.getAttributes().getNamedItem("continued"); |
| 3162 |
if (attr != null) { |
| 3163 |
node = node.getFirstChild(); |
| 3164 |
if( node != null ){ |
| 3165 |
((org.w3c.dom.Text) node).setData( attr.getNodeValue() ); |
| 3166 |
} } |
| 3167 |
>>> |
| 3168 |
|
| 3169 |
|
| 3170 |
|
| 3171 |
|
| 3172 |
%%%%%%%%%%%%% |
| 3173 |
\section{Set Levels on Roots} |
| 3174 |
%%%%%%%%%%%%% |
| 3175 |
|
| 3176 |
\<set levels for roots\><<< |
| 3177 |
<dom name="." xml="." method="rootLevel" class="tex4ht.HtJsml" /> |
| 3178 |
`<remove xml declaration`> |
| 3179 |
>>> |
| 3180 |
|
| 3181 |
\<static void rootLevel(dom)\><<< |
| 3182 |
public static void rootLevel(Node d) { |
| 3183 |
dom = (Document) d; |
| 3184 |
setRootLevel(d.getFirstChild()); |
| 3185 |
} |
| 3186 |
private static int setRootLevel( Node node ){ |
| 3187 |
int level = 0; |
| 3188 |
// String clName = null; |
| 3189 |
if (node.hasChildNodes()) { |
| 3190 |
`<count root levels inherited from children`> |
| 3191 |
String ndName = node.getNodeName(); |
| 3192 |
`<block for roots`> |
| 3193 |
if( ndName.equals("msqrt") || ndName.equals("mroot") ){ |
| 3194 |
`<set extra levels for roots`> |
| 3195 |
level++; |
| 3196 |
} } |
| 3197 |
return level; |
| 3198 |
} |
| 3199 |
>>> |
| 3200 |
|
| 3201 |
|
| 3202 |
\<count root levels inherited from children\><<< |
| 3203 |
NodeList children = node.getChildNodes(); |
| 3204 |
int max = 0; |
| 3205 |
for (int i = 0; i < children.getLength(); i++) { |
| 3206 |
Node child = children.item(i); |
| 3207 |
if (child.getNodeType() == Node.ELEMENT_NODE) { |
| 3208 |
int d = setRootLevel(child); |
| 3209 |
if( d > max ){ max = d; } |
| 3210 |
} } |
| 3211 |
level += max; |
| 3212 |
>>> |
| 3213 |
|
| 3214 |
|
| 3215 |
\<block for roots\><<< |
| 3216 |
if( ndName.equals("msub") || ndName.equals("msup") || |
| 3217 |
ndName.equals("msubsup") |
| 3218 |
) { |
| 3219 |
return 0; |
| 3220 |
} |
| 3221 |
>>> |
| 3222 |
|
| 3223 |
|
| 3224 |
|
| 3225 |
|
| 3226 |
\<set extra levels for roots\><<< |
| 3227 |
for (int i = 0; i < children.getLength(); i++) { |
| 3228 |
Node child = children.item(i); |
| 3229 |
if (child.getNodeType() == Node.ELEMENT_NODE) { |
| 3230 |
Node cls = child.getAttributes() |
| 3231 |
.getNamedItem("class"); |
| 3232 |
if (cls != null) { |
| 3233 |
String clsName = cls.getNodeValue(); |
| 3234 |
if( clsName.equals("begin-root") |
| 3235 |
|| clsName.equals("mid-root") |
| 3236 |
|| clsName.equals("end-root") |
| 3237 |
){ |
| 3238 |
insertLevelPrefix(child, level); |
| 3239 |
} } } } |
| 3240 |
>>> |
| 3241 |
|
| 3242 |
|
| 3243 |
|
| 3244 |
|
| 3245 |
%%%%%%%%%%%%% |
| 3246 |
\section{Modifiers} |
| 3247 |
%%%%%%%%%%%%% |
| 3248 |
|
| 3249 |
|
| 3250 |
|
| 3251 |
%%%%%%%%%%%%%%%%%% |
| 3252 |
\subsection{Over and Under Limit Scripts} |
| 3253 |
%%%%%%%%%%%%%%%%%% |
| 3254 |
|
| 3255 |
|
| 3256 |
\<over and under scripts\><<< |
| 3257 |
<script element="msub::limits-msub-msup" > |
| 3258 |
<set name="smash" > |
| 3259 |
`<open xslt script`> |
| 3260 |
`<smash over and under scripts`> |
| 3261 |
`<close xslt script`> |
| 3262 |
</set> |
| 3263 |
<xslt name="." xml="." xsl="smash" /> |
| 3264 |
</script> |
| 3265 |
>>> |
| 3266 |
|
| 3267 |
\<over and under scripts\><<< |
| 3268 |
<script element="msup::limits-msub-msup" > |
| 3269 |
<set name="smash" > |
| 3270 |
`<open xslt script`> |
| 3271 |
`<smash over and under scripts`> |
| 3272 |
`<close xslt script`> |
| 3273 |
</set> |
| 3274 |
<xslt name="." xml="." xsl="smash" /> |
| 3275 |
</script> |
| 3276 |
>>> |
| 3277 |
|
| 3278 |
\<over and under scripts\><<< |
| 3279 |
<script element="msubsup::limits-msub-msup" > |
| 3280 |
<set name="smash" > |
| 3281 |
`<open xslt script`> |
| 3282 |
`<smash over and under scripts`> |
| 3283 |
`<close xslt script`> |
| 3284 |
</set> |
| 3285 |
<xslt name="." xml="." xsl="smash" /> |
| 3286 |
</script> |
| 3287 |
>>> |
| 3288 |
|
| 3289 |
|
| 3290 |
|
| 3291 |
|
| 3292 |
|
| 3293 |
|
| 3294 |
|
| 3295 |
\<smash over and under scripts\><<< |
| 3296 |
<xsl:template match="*[ |
| 3297 |
(@class = 'limits-msub-msup') |
| 3298 |
and |
| 3299 |
child::*[ (position() = 1) |
| 3300 |
and (@class = 'limits-mrow-base') |
| 3301 |
and child::*[ (position() = 1) |
| 3302 |
and (@class = 'limits-msub-msup') |
| 3303 |
] ] |
| 3304 |
]" > |
| 3305 |
<xsl:copy> |
| 3306 |
<xsl:apply-templates select="@*" /> |
| 3307 |
<xsl:apply-templates select=" |
| 3308 |
*[1] |
| 3309 |
/ *[1] |
| 3310 |
/ *[ not(@class='limits-mrow-super') ] " /> |
| 3311 |
<xsl:apply-templates select=" *[ |
| 3312 |
preceding-sibling::* |
| 3313 |
and |
| 3314 |
not(@class='limits-mrow-super') ]" /> |
| 3315 |
<xsl:apply-templates select=" |
| 3316 |
*[1] |
| 3317 |
/ *[1] |
| 3318 |
/ *[@class='limits-mrow-super' ] " /> |
| 3319 |
<xsl:apply-templates select=" *[ |
| 3320 |
preceding-sibling::* |
| 3321 |
and |
| 3322 |
(@class='limits-mrow-super') ]" /> |
| 3323 |
</xsl:copy> |
| 3324 |
</xsl:template> |
| 3325 |
>>> |
| 3326 |
|
| 3327 |
|
| 3328 |
\<compress limit script\><<< |
| 3329 |
<xsl:template match="span[ @class = 'end-limits-script' ]" > |
| 3330 |
<xsl:if test=" parent::*[ not(following-sibling::*) ] "> |
| 3331 |
<xsl:copy> |
| 3332 |
<xsl:apply-templates select=" @* " /> |
| 3333 |
<xsl:choose> |
| 3334 |
<xsl:when test=" |
| 3335 |
parent::*[ preceding-sibling::mrow[ |
| 3336 |
@class != 'limits-mrow-base' |
| 3337 |
] ] |
| 3338 |
" > |
| 3339 |
<BREAK SIZE="small"/> |
| 3340 |
<xsl:text> end scripts </xsl:text> |
| 3341 |
<BREAK SIZE="small"/> |
| 3342 |
</xsl:when> |
| 3343 |
<xsl:otherwise> |
| 3344 |
<BREAK SIZE="small"/> |
| 3345 |
<xsl:text> end script </xsl:text> |
| 3346 |
<BREAK SIZE="small"/> |
| 3347 |
</xsl:otherwise> |
| 3348 |
</xsl:choose> |
| 3349 |
</xsl:copy> |
| 3350 |
</xsl:if> |
| 3351 |
</xsl:template> |
| 3352 |
>>> |
| 3353 |
|
| 3354 |
|
| 3355 |
\<compress limit script\><<< |
| 3356 |
<xsl:template match="span[ @class = 'begin-limits-script' ]" > |
| 3357 |
<xsl:copy> |
| 3358 |
<xsl:apply-templates select=" @* " /> |
| 3359 |
<xsl:choose> |
| 3360 |
<xsl:when test=" |
| 3361 |
parent::*[ @class = 'limits-mrow-super' ] |
| 3362 |
" > |
| 3363 |
<xsl:apply-templates |
| 3364 |
select=" parent::* |
| 3365 |
/ preceding-sibling::*[1] " |
| 3366 |
mode = "extra-over" /> |
| 3367 |
</xsl:when> |
| 3368 |
<xsl:when test=" |
| 3369 |
parent::*[ @class = 'limits-mrow-sub' ] |
| 3370 |
" > |
| 3371 |
<xsl:apply-templates |
| 3372 |
select=" parent::* |
| 3373 |
/ preceding-sibling::*[1] " |
| 3374 |
mode = "extra-under" /> |
| 3375 |
</xsl:when> |
| 3376 |
</xsl:choose> |
| 3377 |
<xsl:apply-templates select="*|text()|comment()" /> |
| 3378 |
</xsl:copy> |
| 3379 |
</xsl:template> |
| 3380 |
>>> |
| 3381 |
|
| 3382 |
|
| 3383 |
|
| 3384 |
\<compress limit script\><<< |
| 3385 |
<xsl:template match="*" mode="extra-over" > |
| 3386 |
<xsl:if test = " self::mrow[ @class = 'limits-mrow-super' ] " > |
| 3387 |
<xsl:text> over </xsl:text> |
| 3388 |
<xsl:apply-templates select=" preceding-sibling::*[1] " |
| 3389 |
mode = "extra-over" /> |
| 3390 |
</xsl:if> |
| 3391 |
</xsl:template> |
| 3392 |
>>> |
| 3393 |
|
| 3394 |
|
| 3395 |
\<compress limit script\><<< |
| 3396 |
<xsl:template match="*" mode="extra-under" > |
| 3397 |
<xsl:if test = " self::mrow[ @class = 'limits-mrow-sub' ] " > |
| 3398 |
<xsl:text> under </xsl:text> |
| 3399 |
<xsl:apply-templates select=" preceding-sibling::*[1] " |
| 3400 |
mode = "extra-under" /> |
| 3401 |
</xsl:if> |
| 3402 |
</xsl:template> |
| 3403 |
>>> |
| 3404 |
|
| 3405 |
|
| 3406 |
|
| 3407 |
|
| 3408 |
%%%%%%%%%%%%% |
| 3409 |
\subsection{Short Cuts for Math Underline} |
| 3410 |
%%%%%%%%%%%%% |
| 3411 |
|
| 3412 |
|
| 3413 |
|
| 3414 |
\<short cut modifiers\><<< |
| 3415 |
<script element="munder::munder-underline" > |
| 3416 |
<set name="munder" > |
| 3417 |
`<open xslt script`> |
| 3418 |
`<get content template`> |
| 3419 |
`<under modifier templates`> |
| 3420 |
`<close xslt script`> |
| 3421 |
</set> |
| 3422 |
<xslt name="." xml="." xsl="munder" /> |
| 3423 |
</script> |
| 3424 |
>>> |
| 3425 |
|
| 3426 |
\<under modifier templates\><<< |
| 3427 |
<xsl:template match="munder[ |
| 3428 |
(@class = 'munder-underline') |
| 3429 |
and |
| 3430 |
child::mrow[ |
| 3431 |
(@class = 'mo-0332') |
| 3432 |
and |
| 3433 |
descendant::mi |
| 3434 |
] |
| 3435 |
]" > |
| 3436 |
<xsl:variable name="content"> |
| 3437 |
<xsl:apply-templates select="*" mode="content" /> |
| 3438 |
</xsl:variable> |
| 3439 |
<xsl:choose> |
| 3440 |
<xsl:when test=" |
| 3441 |
string-length( normalize-space( $content )) = 1 |
| 3442 |
" > |
| 3443 |
<xsl:copy> |
| 3444 |
<xsl:apply-templates select="@*" /> |
| 3445 |
<xsl:apply-templates |
| 3446 |
select=" *[ @class != 'begin-end' ] " /> |
| 3447 |
<span class="begin-end" title="speech-extra" > |
| 3448 |
<BREAK SIZE="small"/> |
| 3449 |
<xsl:text> under bar </xsl:text> |
| 3450 |
<BREAK SIZE="small"/> |
| 3451 |
</span> |
| 3452 |
</xsl:copy> |
| 3453 |
</xsl:when> |
| 3454 |
<xsl:otherwise> |
| 3455 |
`<set munder`> |
| 3456 |
</xsl:otherwise> |
| 3457 |
</xsl:choose> |
| 3458 |
</xsl:template> |
| 3459 |
>>> |
| 3460 |
|
| 3461 |
|
| 3462 |
|
| 3463 |
|
| 3464 |
The following code makes to push the munder's under the mover's. |
| 3465 |
|
| 3466 |
\<set munder\><<< |
| 3467 |
<xsl:choose> |
| 3468 |
<xsl:when test="child::mrow / child::mover"> |
| 3469 |
<xsl:apply-templates select="child::mrow / child::mover" |
| 3470 |
mode="under-mover" /> |
| 3471 |
</xsl:when> |
| 3472 |
<xsl:otherwise> |
| 3473 |
<xsl:copy> |
| 3474 |
<xsl:apply-templates select=" *|@*|text() " /> |
| 3475 |
</xsl:copy> |
| 3476 |
</xsl:otherwise> |
| 3477 |
</xsl:choose> |
| 3478 |
>>> |
| 3479 |
|
| 3480 |
\<under modifier templates\><<< |
| 3481 |
<xsl:template match="*" mode="under-mover" > |
| 3482 |
<xsl:choose> |
| 3483 |
<xsl:when test="self::mover"> |
| 3484 |
<xsl:copy> |
| 3485 |
<xsl:apply-templates select="@*" /> |
| 3486 |
<xsl:apply-templates select="*" mode="under-mover" /> |
| 3487 |
</xsl:copy> |
| 3488 |
</xsl:when> |
| 3489 |
<xsl:when test="self::mrow[ parent::mover ]"> |
| 3490 |
<xsl:copy> |
| 3491 |
<xsl:apply-templates select="@*" /> |
| 3492 |
`<cont under-mover`> |
| 3493 |
</xsl:copy> |
| 3494 |
</xsl:when> |
| 3495 |
<xsl:otherwise> |
| 3496 |
<xsl:apply-templates select="." /> |
| 3497 |
</xsl:otherwise> |
| 3498 |
</xsl:choose> |
| 3499 |
</xsl:template> |
| 3500 |
>>> |
| 3501 |
|
| 3502 |
\<cont under-mover\><<< |
| 3503 |
<xsl:choose> |
| 3504 |
<xsl:when test="child::mover"> |
| 3505 |
<xsl:apply-templates select="*" mode="under-mover" /> |
| 3506 |
</xsl:when> |
| 3507 |
<xsl:otherwise> |
| 3508 |
<munder class="munder-underline"> |
| 3509 |
`<munder prefix`> |
| 3510 |
<mrow class="mo-0032"> |
| 3511 |
<xsl:apply-templates select="*" /> |
| 3512 |
</mrow> |
| 3513 |
`<munder postfix`> |
| 3514 |
</munder> |
| 3515 |
</xsl:otherwise> |
| 3516 |
</xsl:choose> |
| 3517 |
>>> |
| 3518 |
|
| 3519 |
|
| 3520 |
|
| 3521 |
\<munder prefix\><<< |
| 3522 |
<xsl:apply-templates select=" |
| 3523 |
ancestor::munder[1] / child::*[following-sibling::mrow] |
| 3524 |
"/> |
| 3525 |
>>> |
| 3526 |
|
| 3527 |
|
| 3528 |
|
| 3529 |
\<munder postfix\><<< |
| 3530 |
<xsl:apply-templates select=" |
| 3531 |
ancestor::munder[1] / child::*[preceding-sibling::mrow] |
| 3532 |
"/> |
| 3533 |
>>> |
| 3534 |
|
| 3535 |
|
| 3536 |
|
| 3537 |
\begin{verbatim} |
| 3538 |
<munder class="munder-underline"> |
| 3539 |
<span class="begin-end" title="speech-extra" > modified under </span> |
| 3540 |
<mrow class="mo-0332"> |
| 3541 |
<mi>x</mi> |
| 3542 |
</mrow> |
| 3543 |
<span class="begin-end" title="speech-extra" > with bar </span> |
| 3544 |
</munder> |
| 3545 |
\end{verbatim} |
| 3546 |
|
| 3547 |
|
| 3548 |
|
| 3549 |
%%%%%%%%%%%%% |
| 3550 |
\subsection{Short Cuts for Math Overline} |
| 3551 |
%%%%%%%%%%%%% |
| 3552 |
|
| 3553 |
|
| 3554 |
\<short cut modifiers\><<< |
| 3555 |
<script element="mover::mover-overline" > |
| 3556 |
<set name="mover" > |
| 3557 |
`<open xslt script`> |
| 3558 |
`<get content template`> |
| 3559 |
`<over modifier templates`> |
| 3560 |
`<close xslt script`> |
| 3561 |
</set> |
| 3562 |
<xslt name="." xml="." xsl="mover" /> |
| 3563 |
</script> |
| 3564 |
>>> |
| 3565 |
|
| 3566 |
|
| 3567 |
|
| 3568 |
|
| 3569 |
\<over modifier templates\><<< |
| 3570 |
<xsl:template match="mover[ |
| 3571 |
(@class = 'mover-overline') |
| 3572 |
and |
| 3573 |
child::mrow[ |
| 3574 |
(@class = 'mo-00AF') |
| 3575 |
and |
| 3576 |
descendant::mi |
| 3577 |
] |
| 3578 |
]" > |
| 3579 |
<xsl:variable name="content"> |
| 3580 |
<xsl:apply-templates select="*" mode="content" /> |
| 3581 |
</xsl:variable> |
| 3582 |
<xsl:choose> |
| 3583 |
<xsl:when test=" |
| 3584 |
string-length( normalize-space( $content )) = 1 |
| 3585 |
" > |
| 3586 |
`<set mover short cut`> |
| 3587 |
</xsl:when> |
| 3588 |
<xsl:otherwise> |
| 3589 |
<xsl:copy> |
| 3590 |
<xsl:apply-templates select="@*" /> |
| 3591 |
<xsl:apply-templates |
| 3592 |
select="*|text()|comment()" /> |
| 3593 |
</xsl:copy> |
| 3594 |
</xsl:otherwise> |
| 3595 |
</xsl:choose> |
| 3596 |
</xsl:template> |
| 3597 |
>>> |
| 3598 |
|
| 3599 |
|
| 3600 |
The following code makes to push the mover's under the munder's. |
| 3601 |
|
| 3602 |
\<set mover short cut\><<< |
| 3603 |
<BREAK SIZE="small"/> |
| 3604 |
<xsl:choose> |
| 3605 |
<xsl:when test="child::mrow / child::munder"> |
| 3606 |
<xsl:apply-templates select="child::mrow / child::munder" |
| 3607 |
mode="under-munder" /> |
| 3608 |
</xsl:when> |
| 3609 |
<xsl:otherwise> |
| 3610 |
<xsl:copy> |
| 3611 |
<xsl:apply-templates select="@*" /> |
| 3612 |
<xsl:apply-templates |
| 3613 |
select=" *[ @class != 'begin-end' ] " /> |
| 3614 |
`<mover bar short cut`> |
| 3615 |
</xsl:copy> |
| 3616 |
</xsl:otherwise> |
| 3617 |
</xsl:choose> |
| 3618 |
>>> |
| 3619 |
|
| 3620 |
\<over modifier templates\><<< |
| 3621 |
<xsl:template match="*" mode="under-munder" > |
| 3622 |
<xsl:choose> |
| 3623 |
<xsl:when test="self::munder"> |
| 3624 |
<xsl:copy> |
| 3625 |
<xsl:apply-templates select="@*" /> |
| 3626 |
<xsl:apply-templates select="*" mode="under-munder" /> |
| 3627 |
</xsl:copy> |
| 3628 |
</xsl:when> |
| 3629 |
<xsl:when test="self::mrow[ parent::munder ]"> |
| 3630 |
<xsl:copy> |
| 3631 |
<xsl:apply-templates select="@*" /> |
| 3632 |
`<cont under-munder`> |
| 3633 |
</xsl:copy> |
| 3634 |
</xsl:when> |
| 3635 |
<xsl:otherwise> |
| 3636 |
<xsl:apply-templates select="." /> |
| 3637 |
</xsl:otherwise> |
| 3638 |
</xsl:choose> |
| 3639 |
</xsl:template> |
| 3640 |
>>> |
| 3641 |
|
| 3642 |
\<cont under-munder\><<< |
| 3643 |
<xsl:choose> |
| 3644 |
<xsl:when test="child::munder"> |
| 3645 |
<xsl:apply-templates select="*" mode="under-munder" /> |
| 3646 |
</xsl:when> |
| 3647 |
<xsl:otherwise> |
| 3648 |
<mover class="mover-overline"> |
| 3649 |
<mrow class="mo-00AF"> |
| 3650 |
<xsl:apply-templates select="*" /> |
| 3651 |
</mrow> |
| 3652 |
`<mover bar short cut`> |
| 3653 |
</mover> |
| 3654 |
</xsl:otherwise> |
| 3655 |
</xsl:choose> |
| 3656 |
>>> |
| 3657 |
|
| 3658 |
|
| 3659 |
|
| 3660 |
|
| 3661 |
|
| 3662 |
\<mover bar short cut\><<< |
| 3663 |
<span class="begin-end" title="speech-extra" > |
| 3664 |
<BREAK SIZE="small"/> |
| 3665 |
<xsl:text> over bar </xsl:text> |
| 3666 |
<BREAK SIZE="small"/> |
| 3667 |
</span> |
| 3668 |
>>> |
| 3669 |
|
| 3670 |
|
| 3671 |
|
| 3672 |
|
| 3673 |
\begin{verbatim} |
| 3674 |
<mover class="mover-overline"> |
| 3675 |
<span class="begin-end" title="speech-extra"> modified above </span> |
| 3676 |
<mrow class="mo-00AF"> |
| 3677 |
<span class="mathvariant-bold"> |
| 3678 |
<span title="speech-extra" class="begin-end"> bold </span> |
| 3679 |
<mi class="mi"> |
| 3680 |
<span title="speech-extra" |
| 3681 |
class="capital-description"> capital </span> |
| 3682 |
Z |
| 3683 |
</mi> |
| 3684 |
</span> |
| 3685 |
</mrow> |
| 3686 |
<span class="begin-end" title="speech-extra"> with bar </span> |
| 3687 |
</mover> |
| 3688 |
\end{verbatim} |
| 3689 |
|
| 3690 |
|
| 3691 |
|
| 3692 |
|
| 3693 |
|
| 3694 |
|
| 3695 |
|
| 3696 |
%%%%%%%%%%%%% |
| 3697 |
\section{New Theorems} |
| 3698 |
%%%%%%%%%%%%% |
| 3699 |
|
| 3700 |
\<boundaries on theorems\><<< |
| 3701 |
<script element="div::newtheorem" > |
| 3702 |
<set name="newtheorem" > |
| 3703 |
`<open xslt script`> |
| 3704 |
`<annotate bounderies of theorems`> |
| 3705 |
`<tags for empty templates`> |
| 3706 |
`<close xslt script`> |
| 3707 |
</set> |
| 3708 |
<xslt name="." xml="." xsl="newtheorem" /> |
| 3709 |
</script> |
| 3710 |
>>> |
| 3711 |
|
| 3712 |
|
| 3713 |
\<annotate bounderies of theorems\><<< |
| 3714 |
<xsl:template match=" |
| 3715 |
div[ (@class='newtheorem') |
| 3716 |
and |
| 3717 |
descendant::*[ self::p ][1] |
| 3718 |
/ descendant::*[ self::span ][1] |
| 3719 |
[ @class = 'theorem-head' ] |
| 3720 |
] |
| 3721 |
" > |
| 3722 |
<xsl:copy> |
| 3723 |
<xsl:apply-templates select="*|@*|text()|comment()" /> |
| 3724 |
<div class="begin-end" title="speech-extra"> |
| 3725 |
<BREAK SIZE="small"/> |
| 3726 |
<xsl:value-of select=" |
| 3727 |
concat( ' end ', |
| 3728 |
substring-before(`<new theorem header`>, ' ') |
| 3729 |
) " /> |
| 3730 |
</div> |
| 3731 |
</xsl:copy> |
| 3732 |
</xsl:template> |
| 3733 |
>>> |
| 3734 |
|
| 3735 |
|
| 3736 |
\<new theorem header\><<< |
| 3737 |
concat( |
| 3738 |
normalize-space( |
| 3739 |
string( |
| 3740 |
descendant::*[ self::p ][1] |
| 3741 |
/ descendant::*[ self::span ][1] |
| 3742 |
[ @class = 'theorem-head' ] |
| 3743 |
) ) |
| 3744 |
, ' ' |
| 3745 |
) |
| 3746 |
>>> |
| 3747 |
|
| 3748 |
|
| 3749 |
%%%%%%%%%%%%%%%%%% |
| 3750 |
\section{Shared} |
| 3751 |
%%%%%%%%%%%%%%%%%% |
| 3752 |
|
| 3753 |
|
| 3754 |
|
| 3755 |
\<open xslt script\><<< |
| 3756 |
<![CDATA[ |
| 3757 |
<xsl:stylesheet version="1.0" |
| 3758 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 3759 |
> |
| 3760 |
<xsl:output omit-xml-declaration = "yes" /> |
| 3761 |
>>> |
| 3762 |
|
| 3763 |
\<close xslt script\><<< |
| 3764 |
<xsl:template match="*|@*|text()|comment()" > |
| 3765 |
<xsl:copy> |
| 3766 |
<xsl:apply-templates select="*|@*|text()|comment()" /> |
| 3767 |
</xsl:copy> |
| 3768 |
</xsl:template> |
| 3769 |
</xsl:stylesheet> |
| 3770 |
]]> |
| 3771 |
>>> |
| 3772 |
|
| 3773 |
|
| 3774 |
\<get content template\><<< |
| 3775 |
<xsl:template match="*" mode="content" > |
| 3776 |
<xsl:choose> |
| 3777 |
<xsl:when test=" @class = 'char' " > |
| 3778 |
<xsl:if test="not( child::*[ |
| 3779 |
(@class = 'ch 2032') or (@class = 'ch 2033') |
| 3780 |
or (@class = 'ch 2034') |
| 3781 |
] )"> |
| 3782 |
<xsl:text>x</xsl:text> |
| 3783 |
</xsl:if> |
| 3784 |
</xsl:when> |
| 3785 |
<xsl:when test=" not( |
| 3786 |
(@title = 'speech-extra') or (@class = 'accent-char') |
| 3787 |
) " > |
| 3788 |
<xsl:apply-templates select="*|text()" mode="content" /> |
| 3789 |
</xsl:when> |
| 3790 |
</xsl:choose> |
| 3791 |
</xsl:template> |
| 3792 |
>>> |
| 3793 |
|
| 3794 |
|
| 3795 |
|
| 3796 |
|
| 3797 |
|
| 3798 |
\marginpar{Can dom be prevented from creating an xml declaration in |
| 3799 |
the output? The xslt part is there just to remove the undesirable |
| 3800 |
declaration.} |
| 3801 |
|
| 3802 |
|
| 3803 |
\<remove xml declaration\><<< |
| 3804 |
<set name="rmXmlDecl" > |
| 3805 |
`<open xslt script`> |
| 3806 |
`<close xslt script`> |
| 3807 |
</set> |
| 3808 |
<xslt name="." xml="." xsl="rmXmlDecl" /> |
| 3809 |
>>> |
| 3810 |
|
| 3811 |
|
| 3812 |
|
| 3813 |
|
| 3814 |
|
| 3815 |
|
| 3816 |
|
| 3817 |
|
| 3818 |
\ifdojava |
| 3819 |
\AtEndDocument{\Needs{% |
| 3820 |
"pushd \XTPIPES |
| 3821 |
; |
| 3822 |
jar cf tex4ht.jar * |
| 3823 |
; |
| 3824 |
popd |
| 3825 |
; |
| 3826 |
mv \XTPIPES tex4ht.jar \TEXMFTEXivBIN |
| 3827 |
; |
| 3828 |
if [ ! -d \TEXMFTEXivXTPIPES\space]; then exit 1; fi |
| 3829 |
; |
| 3830 |
cp \XTPIPES xtpipes/lib/* |
| 3831 |
\TEXMFTEXivXTPIPES |
| 3832 |
"}} |
| 3833 |
\fi |
| 3834 |
|
| 3835 |
|
| 3836 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3837 |
\end{document} |
| 3838 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3839 |
|
| 3840 |
|
| 3841 |
|
| 3842 |
%%%%%%%%%%%%%%%%%% |
| 3843 |
\section{Odd Ends} |
| 3844 |
%%%%%%%%%%%%%%%%%% |
| 3845 |
|
| 3846 |
%%%%%%%%%%%%% |
| 3847 |
\subsection{Font Decorations} |
| 3848 |
%%%%%%%%%%%%% |
| 3849 |
|
| 3850 |
\<bold math\><<< |
| 3851 |
<script element="span::mathvariant-bold" > |
| 3852 |
<set name="bold" > |
| 3853 |
`<open xslt script`> |
| 3854 |
`<get content template`> |
| 3855 |
`<math bold templates`> |
| 3856 |
`<close xslt script`> |
| 3857 |
</set> |
| 3858 |
<xslt name="." xml="." xsl="bold" /> |
| 3859 |
</script> |
| 3860 |
>>> |
| 3861 |
|
| 3862 |
|
| 3863 |
|
| 3864 |
\<math bold templates\><<< |
| 3865 |
<xsl:template match="span[ @class = 'mathvariant-bold' ]" > |
| 3866 |
<xsl:copy> |
| 3867 |
<xsl:apply-templates select="@*" /> |
| 3868 |
<xsl:variable name="content"> |
| 3869 |
<xsl:apply-templates select="*" mode="content" /> |
| 3870 |
</xsl:variable> |
| 3871 |
<xsl:choose> |
| 3872 |
<xsl:when test=" |
| 3873 |
string-length( normalize-space( $content )) = 1 |
| 3874 |
" > |
| 3875 |
<span class="begin-end" title="speech-extra" > |
| 3876 |
<xsl:text> bold </xsl:text> |
| 3877 |
</span> |
| 3878 |
<xsl:apply-templates select="*|text()|comment()" /> |
| 3879 |
</xsl:when> |
| 3880 |
<xsl:otherwise> |
| 3881 |
<span class="begin-end" title="speech-extra" > |
| 3882 |
<xsl:text> begin bold </xsl:text> |
| 3883 |
</span> |
| 3884 |
<xsl:apply-templates select="*|text()|comment()" /> |
| 3885 |
<span class="begin-end" title="speech-extra" > |
| 3886 |
<xsl:text> end bold </xsl:text> |
| 3887 |
</span> |
| 3888 |
</xsl:otherwise> |
| 3889 |
</xsl:choose> |
| 3890 |
</xsl:copy> |
| 3891 |
</xsl:template> |
| 3892 |
>>> |
| 3893 |
|
| 3894 |
%%%%%%%%%%%%%%%%%% |
| 3895 |
\section{Empty Elements} |
| 3896 |
%%%%%%%%%%%%%%%%%% |
| 3897 |
|
| 3898 |
|
| 3899 |
|
| 3900 |
%%%%%%%%%%%%%%%%%% |
| 3901 |
\section{Prose} |
| 3902 |
%%%%%%%%%%%%%%%%%% |