Debian Codegraph @

texmf-dist/source/generic/tex4ht/tex4ht-javahelp-xtpipes.tex

raw
1 % $Id: tex4ht-javahelp-xtpipes.tex 740 2020-06-13 22:35:32Z karl $
2 % htlatex tex4ht-javahelp-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 \usepackage{url}
12 \begin{document}
13
14 \input{common}
15 \input{tex4ht-cpright}
16 \input{tex4ht-dir}
17
18 %%%%%%%%%%%%%%%%%%
19 \part{Post Processing for Html Output Mode}
20 %%%%%%%%%%%%%%%%%%
21
22
23 %%%%%%%%%%%%%%%%%%
24 \section{Outline}
25 %%%%%%%%%%%%%%%%%%
26
27 \AtEndDocument{\OutputCodE\<javahelp.4xt\>}
28
29 \Needs{"xmllint --valid --noout javahelp.4xt"}
30
31 \<javahelp.4xt\><<<
32 <?xml version="1.0" encoding="UTF-8" ?>
33 <!DOCTYPE xtpipes SYSTEM "xtpipes.dtd" >
34 <!-- jsml.4xt (`version), generated from `jobname.tex
35 Copyright (C) 2009-2010 TeX Users Group
36 Copyright (C) `CopyYear.2002. Eitan M. Gurari
37 `<TeX4ht copyright`> -->
38 <xtpipes preamble="yes" signature="javahelp.4xt (`version)">
39 <sax content-handler="xtpipes.util.ScriptsManager"
40 lexical-handler="xtpipes.util.ScriptsManagerLH" >
41 `<tabular script`>
42 `<longtable script`>
43 `<email scriptNO`>
44 `<empty html element scriptNO`>
45 </sax>
46 </xtpipes>
47 >>>
48
49
50 %%%%%%%%%%%%%%%%%%
51 \section{email script}
52 %%%%%%%%%%%%%%%%%%
53
54 \<email script\><<<
55 <script element="span::email" >
56 `<set htm email links`>
57 </script>
58 >>>
59
60 <set name="email" >
61 `<open xslt script`>
62 `<email templates`>
63 `<close xslt script`>
64 </set>
65 <xslt name="." xml="." xsl="email" />
66
67
68 \<email templates\><<<
69 <xsl:template match=" text()[contains(.,'@')] " >
70 <span class="set-emails">
71 <xsl:copy>
72 </xsl:copy>
73 </span>
74 </xsl:template>
75 >>>
76
77
78 \<set htm email links\><<<
79 <sax name="." xml="." content-handler="tex4ht.XhtmlEmails" />
80 >>>
81
82
83 % \AtEndDocument{
84 % \OutputCodE\<XhtmlEmails.java\>
85 % }
86 % \Needs{"
87 % javac -classpath /home/4/gurari/tex4ht.dir/texmf/tex4ht/bin/tex4ht.jar
88 % XhtmlEmails.java
89 % -d /home/4/gurari/xtpipes.dir/.
90 % "}
91
92 \<XhtmlEmails.java\><<<
93 package tex4ht;
94 /* XhtmlEmails.java (`version), generated from `jobname.tex
95 Copyright (C) 2009-2010 TeX Users Group
96 Copyright (C) `CopyYear.2002. Eitan M. Gurari
97 `<TeX4ht copyright`> */
98 import xtpipes.XtpipesUni;
99 import org.xml.sax.*;
100 import org.xml.sax.helpers.DefaultHandler;
101 import java.io.*;
102 import java.lang.reflect.*;
103 import java.util.HashMap;
104
105 public class XhtmlEmails extends DefaultHandler {
106 PrintWriter out = null;
107 String data = "";
108 public XhtmlEmails(PrintWriter out,
109 HashMap<String,Object> scripts,
110 Method method, PrintWriter log, boolean trace) {
111 this.out = out;
112 }
113 public void characters(char[] ch, int start, int length) {
114 data += new String(ch, start, length);
115
116 //XtpipesUni.toUni(ch, start, length, "<>&");
117 }
118
119 public void startElement(String ns, String sName,
120 String qName,
121 Attributes atts) {
122 String s = "<" + qName + "\n";
123 for (int i = 0; i < atts.getLength(); i++) {
124 String name = atts.getQName(i);
125 s += (" " + name + "=\""
126 + XtpipesUni.toUni(atts.getValue(i), "<>&\"")
127 + "\"");
128 }
129 s += ">";
130 `<process email data`>
131 out.print(XtpipesUni.toUni(data, "&") + s);
132 data = "";
133 }
134 public void endElement(String ns, String sName, String qName) {
135 String s = "</" + qName + ">";
136 `<process email data`>
137 out.print( XtpipesUni.toUni(data, "&") + s);
138 data = "";
139 }
140
141 }
142 >>>
143
144
145 \<process email data\><<<
146 while( data.indexOf('@') >0 ){
147 `<clean prefix`>
148 `<clean postfix`>
149 }
150 data = XtpipesUni.toUni(data, "<>&");
151 >>>
152
153
154
155
156 \<clean prefix\><<<
157 String [] pre = data.split(
158 "[`<email name`>]*@"
159 , 2);
160 if( pre[0].endsWith("}") ){
161 if( pre[0].indexOf("{") != -1 ){
162 pre[0] = pre[0].substring( 0, pre[0].lastIndexOf("{") );
163 } }
164 int len = pre[0] . length();
165 if( len > 0 ){
166 out.print( XtpipesUni.toUni(pre[0], "<>&") );
167 data = data.substring(len);
168 }
169 >>>
170
171 \<clean postfix\><<<
172 String [] post = data.split(
173 "@[`<email name`>]*"
174 , 2);
175 if( post[1] . length() > 0 ){
176 data = data.substring(0, data.length() - post[1] . length());
177 }
178 `<set a link to email`>
179 data = post[1];
180 >>>
181
182
183 \<set a link to email\><<<
184 if( data.indexOf("{") == -1 ){
185 out.print(
186 "<a href=\"mailto:" + XtpipesUni.toUni(data, "&") + "\">"
187 + XtpipesUni.toUni(data, "<>&")
188 + "</a>"
189 );
190 } else {
191 int idx = data.indexOf('@');
192 String ext = data.substring(idx);
193 data = data.substring(0,idx);
194 `<clean group prefix`>
195 }
196 >>>
197
198
199
200 \<clean group prefix\><<<
201 while( true ){
202 pre = data.split(
203 "[`<email name`>]+"
204 , 2);
205 if( pre.length < 2 ){
206 out.print( XtpipesUni.toUni(data + ext, "<>&") );
207 data = "";
208 break;
209 }
210 len = pre[0] . length();
211 if( len > 0 ){
212 out.print( XtpipesUni.toUni(pre[0], "<>&") );
213 data = data.substring(len);
214 }
215 data = data.substring(0, data.length() - pre[1].length());
216 out.print(
217 "<a href=\"mailto:" + XtpipesUni.toUni(data + ext, "&") + "\">"
218 + XtpipesUni.toUni(data, "<>&")
219 + "</a>"
220 );
221 data = pre[1];
222 }
223 >>>
224
225 \<email name\><<<
226 \\p{javaLowerCase}\\p{javaUpperCase}\\d\\-_\\./&>>>
227
228
229 \url{http://tools.ietf.org/html/rfc2368}
230
231 \begin{verbatim}
232 Alice Smith" <[email protected]>
233 {alice, bob}@somewhere.com
234 [email protected], [email protected]
235 \end{verbatim}
236
237 %%%%%%%%%%%%%%%%%%
238 \section{Long Tables}
239 %%%%%%%%%%%%%%%%%%
240
241
242
243 \<longtable script\><<<
244 <script element="table::longtable" >
245 <set name="longtbl" >
246 `<open xslt script`>
247 `<longtable templates`>
248 `<close xslt script`>
249 </set>
250 <xslt name="." xml="." xsl="longtbl" />
251 </script>
252 >>>
253
254
255 \<longtable templates\><<<
256 <xsl:template match=" table[ @class='longtable' ]
257 / tr[ (normalize-space(.)='') ] " >
258 <xsl:if test=" normalize-space(following-sibling::*) != '' ">
259 <xsl:copy>
260 <xsl:apply-templates select="*|@*|text()|comment()" />
261 </xsl:copy>
262 </xsl:if>
263 </xsl:template>
264 >>>
265
266
267
268
269 %%%%%%%%%%%%%%%%%%
270 \section{Tabular}
271 %%%%%%%%%%%%%%%%%%
272
273
274
275 \<tabular script\><<<
276 <script element="table::tabular" >
277 <set name="tabular" >
278 `<open xslt script`>
279 `<tabular templates`>
280 `<close xslt script`>
281 </set>
282 <xslt name="." xml="." xsl="tabular" />
283 </script>
284 >>>
285
286
287 \<tabular templates\><<<
288 <xsl:template match=" table[ @class='tabular' ]
289 / tr[ (normalize-space(.)='') ] " >
290
291 <xsl:message terminate="no">
292 OK 1
293 </xsl:message>
294
295 <xsl:if test=" normalize-space(following-sibling::*) != '' ">
296 <xsl:copy>
297 <xsl:apply-templates select="*|@*|text()|comment()" />
298 <xsl:message terminate="no">
299 OK 2
300 </xsl:message>
301 </xsl:copy>
302 </xsl:if>
303 </xsl:template>
304 >>>
305
306
307
308
309
310 \<tabular templates\><<<
311 <xsl:template match=" tr[ (normalize-space(.)='')
312 and
313 (parent::table[ @class='tabular' ])
314 ] " >
315
316 <xsl:message terminate="no">
317 OK 1
318 </xsl:message>
319
320 <xsl:if test=" normalize-space(following-sibling::*) != '' ">
321 <xsl:copy>
322 <xsl:apply-templates select="*|@*|text()|comment()" />
323 <xsl:message terminate="no">
324 OK 2
325 </xsl:message>
326 </xsl:copy>
327 </xsl:if>
328 </xsl:template>
329 >>>
330
331
332 %%%%%%%%%%%%%%%%%%
333 \section{Empty HTML Element Script}
334 %%%%%%%%%%%%%%%%%%
335
336 \<empty html element script\><<<
337 <script element="meta" >
338 <set name="meta" >
339 `<open xslt script`>
340 <xsl:template match="meta" >
341 <xsl:text disable-output-escaping="yes">&lt;meta</xsl:text>
342 <xsl:apply-templates select="@*" mode="attrs" />
343 <xsl:text disable-output-escaping="yes">/&gt;</xsl:text>
344 </xsl:template>
345 `<copy attributes`>
346 `<close xslt script`>
347 </set>
348 <xslt name="." xml="." xsl="meta" />
349 </script>
350 >>>
351
352
353 \<empty html element script\><<<
354 <script element="area" >
355 <set name="area" >
356 `<open xslt script`>
357 <xsl:template match="area" >
358 <xsl:text disable-output-escaping="yes">&lt;area</xsl:text>
359 <xsl:apply-templates select="@*" mode="attrs" />
360 <xsl:text disable-output-escaping="yes">/&gt;</xsl:text>
361 </xsl:template>
362 `<copy attributes`>
363 `<close xslt script`>
364 </set>
365 <xslt name="." xml="." xsl="area" />
366 </script>
367 >>>
368
369
370
371
372 \<empty html element script\><<<
373 <script element="base" >
374 <set name="base" >
375 `<open xslt script`>
376 <xsl:template match="base" >
377 <xsl:text disable-output-escaping="yes">&lt;base</xsl:text>
378 <xsl:apply-templates select="@*" mode="attrs" />
379 <xsl:text disable-output-escaping="yes">/&gt;</xsl:text>
380 </xsl:template>
381 `<copy attributes`>
382 `<close xslt script`>
383 </set>
384 <xslt name="." xml="." xsl="base" />
385 </script>
386 >>>
387
388
389
390
391 \<empty html element script\><<<
392 <script element="basefont" >
393 <set name="basefont" >
394 `<open xslt script`>
395 <xsl:template match="basefont" >
396 <xsl:text disable-output-escaping="yes">&lt;basefont</xsl:text>
397 <xsl:apply-templates select="@*" mode="attrs" />
398 <xsl:text disable-output-escaping="yes">/&gt;</xsl:text>
399 </xsl:template>
400 `<copy attributes`>
401 `<close xslt script`>
402 </set>
403 <xslt name="." xml="." xsl="basefont" />
404 </script>
405 >>>
406
407
408
409
410 \<empty html element script\><<<
411 <script element="br" >
412 <set name="br" >
413 `<open xslt script`>
414 <xsl:template match="br" >
415 <xsl:text disable-output-escaping="yes">&lt;br</xsl:text>
416 <xsl:apply-templates select="@*" mode="attrs" />
417 <xsl:text disable-output-escaping="yes">/&gt;</xsl:text>
418 </xsl:template>
419 `<copy attributes`>
420 `<close xslt script`>
421 </set>
422 <xslt name="." xml="." xsl="br" />
423 </script>
424 >>>
425
426
427
428
429 \<empty html element script\><<<
430 <script element="col" >
431 <set name="col" >
432 `<open xslt script`>
433 <xsl:template match="col" >
434 <xsl:text disable-output-escaping="yes">&lt;col</xsl:text>
435 <xsl:apply-templates select="@*" mode="attrs" />
436 <xsl:text disable-output-escaping="yes">/&gt;</xsl:text>
437 </xsl:template>
438 `<copy attributes`>
439 `<close xslt script`>
440 </set>
441 <xslt name="." xml="." xsl="col" />
442 </script>
443 >>>
444
445
446
447
448 \<empty html element script\><<<
449 <script element="frame" >
450 <set name="frame" >
451 `<open xslt script`>
452 <xsl:template match="frame" >
453 <xsl:text disable-output-escaping="yes">&lt;frame</xsl:text>
454 <xsl:apply-templates select="@*" mode="attrs" />
455 <xsl:text disable-output-escaping="yes">/&gt;</xsl:text>
456 </xsl:template>
457 `<copy attributes`>
458 `<close xslt script`>
459 </set>
460 <xslt name="." xml="." xsl="frame" />
461 </script>
462 >>>
463
464
465
466
467 \<empty html element script\><<<
468 <script element="hr" >
469 <set name="hr" >
470 `<open xslt script`>
471 <xsl:template match="hr" >
472 <xsl:text disable-output-escaping="yes">&lt;hr</xsl:text>
473 <xsl:apply-templates select="@*" mode="attrs" />
474 <xsl:text disable-output-escaping="yes">/&gt;</xsl:text>
475 </xsl:template>
476 `<copy attributes`>
477 `<close xslt script`>
478 </set>
479 <xslt name="." xml="." xsl="hr" />
480 </script>
481 >>>
482
483
484
485
486 \<empty html element script\><<<
487 <script element="img" >
488 <set name="img" >
489 `<open xslt script`>
490 <xsl:template match="img" >
491 <xsl:text disable-output-escaping="yes">&lt;img</xsl:text>
492 <xsl:apply-templates select="@*" mode="attrs" />
493 <xsl:text disable-output-escaping="yes">/&gt;</xsl:text>
494 </xsl:template>
495 `<copy attributes`>
496 `<close xslt script`>
497 </set>
498 <xslt name="." xml="." xsl="img" />
499 </script>
500 >>>
501
502
503
504
505 \<empty html element script\><<<
506 <script element="input" >
507 <set name="input" >
508 `<open xslt script`>
509 <xsl:template match="input" >
510 <xsl:text disable-output-escaping="yes">&lt;input</xsl:text>
511 <xsl:apply-templates select="@*" mode="attrs" />
512 <xsl:text disable-output-escaping="yes">/&gt;</xsl:text>
513 </xsl:template>
514 `<copy attributes`>
515 `<close xslt script`>
516 </set>
517 <xslt name="." xml="." xsl="input" />
518 </script>
519 >>>
520
521
522
523
524 \<empty html element script\><<<
525 <script element="isindex" >
526 <set name="isindex" >
527 `<open xslt script`>
528 <xsl:template match="isindex" >
529 <xsl:text disable-output-escaping="yes">&lt;isindex</xsl:text>
530 <xsl:apply-templates select="@*" mode="attrs" />
531 <xsl:text disable-output-escaping="yes">/&gt;</xsl:text>
532 </xsl:template>
533 `<copy attributes`>
534 `<close xslt script`>
535 </set>
536 <xslt name="." xml="." xsl="isindex" />
537 </script>
538 >>>
539
540
541
542
543 \<empty html element script\><<<
544 <script element="link" >
545 <set name="link" >
546 `<open xslt script`>
547 <xsl:template match="link" >
548 <xsl:text disable-output-escaping="yes">&lt;link</xsl:text>
549 <xsl:apply-templates select="@*" mode="attrs" />
550 <xsl:text disable-output-escaping="yes">/&gt;</xsl:text>
551 </xsl:template>
552 `<copy attributes`>
553 `<close xslt script`>
554 </set>
555 <xslt name="." xml="." xsl="link" />
556 </script>
557 >>>
558
559
560
561
562 \<empty html element script\><<<
563 <script element="param" >
564 <set name="param" >
565 `<open xslt script`>
566 <xsl:template match="param" >
567 <xsl:text disable-output-escaping="yes">&lt;param</xsl:text>
568 <xsl:apply-templates select="@*" mode="attrs" />
569 <xsl:text disable-output-escaping="yes">/&gt;</xsl:text>
570 </xsl:template>
571 `<copy attributes`>
572 `<close xslt script`>
573 </set>
574 <xslt name="." xml="." xsl="param" />
575 </script>
576 >>>
577
578
579
580
581
582
583
584
585
586
587 \<copy attributes\><<<
588 <xsl:template match="@*" mode="attrs" >
589 <xsl:text> </xsl:text>
590 <xsl:value-of select="name()" />
591 <xsl:text>="</xsl:text>
592 <xsl:value-of select="." />
593 <xsl:text>"</xsl:text>
594 </xsl:template>
595 >>>
596
597
598
599
600 %%%%%%%%%%%%%%%%%%
601 \section{Shared}
602 %%%%%%%%%%%%%%%%%%
603
604
605
606 \<open xslt script\><<<
607 <![CDATA[
608 <xsl:stylesheet version="1.0"
609 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
610 >
611 <xsl:output omit-xml-declaration = "yes" method="xml" />
612 >>>
613
614 \<close xslt script\><<<
615 <xsl:template match="*|@*|text()|comment()" >
616 <xsl:copy>
617 <xsl:apply-templates select="*|@*|text()|comment()" />
618 </xsl:copy>
619 </xsl:template>
620 </xsl:stylesheet>
621 ]]>
622 >>>
623
624
625
626
627 \ifdojava
628 \AtEndDocument{\Needs{%
629 "pushd \XTPIPES || exit 1
630 ;
631 jar cf tex4ht.jar *
632 ;
633 popd
634 ;
635 mv tex4ht.jar \TEXMFTEXivBIN
636 ;
637 if [ ! -d \TEXMFTEXivXTPIPES\space]; then exit 1; fi
638 "}}
639 \fi
640
641 \end{document}