1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
|
-*- mode: org -*-
#+TITLE: sisu xml including odf
#+DESCRIPTION: documents - structuring, various output representations & search
#+FILETAGS: :sisu:xml:
#+AUTHOR: Ralph Amissah
#+EMAIL: [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]]
#+COPYRIGHT: Copyright (C) 2015 - 2021 Ralph Amissah
#+LANGUAGE: en
#+STARTUP: content hideblocks hidestars noindent entitiespretty
#+OPTIONS: H:3 num:nil toc:t \n:nil @:t ::t |:t ^:nil _:nil -:t f:t *:t <:t
#+PROPERTY: header-args :exports code
#+PROPERTY: header-args+ :noweb yes
#+PROPERTY: header-args+ :eval no
#+PROPERTY: header-args+ :results no
#+PROPERTY: header-args+ :cache no
#+PROPERTY: header-args+ :padline no
* xml native
** xml_sax.rb
#+BEGIN_SRC ruby :tangle "../lib/sisu/xml_sax.rb"
# <<sisu_document_header>>
module SiSU_XML_SAX
require_relative 'se_hub_particulars' # se_hub_particulars.rb
include SiSU_Particulars
require_relative 'se' # se.rb
include SiSU_Env
require_relative 'xml_shared' # xml_shared.rb
include SiSU_XML_Munge
require_relative 'xml_format' # xml_format.rb
include SiSU_XML_Format
require_relative 'xml_persist' # xml_persist.rb
require_relative 'rexml' # rexml.rb
include SiSU_Rexml
require_relative 'shared_metadata' # shared_metadata.rb
@@alt_id_count=0
@@tablefoot=''
class Source
def initialize(opt)
@opt=opt
@particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt)
end
def read
begin
@env, @md, @ao_arr=
@particulars.env,@particulars.md,@particulars.ao_array
unless @opt.act[:quiet][:set]==:on
tool=if (@opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on)
@env.program.web_browser \
+ ' file://' \
+ @md.file.output_path.xml_sax.dir + '/' \
+ @md.file.base_filename.xml_sax + "\n\t" \
+ @env.program.xml_viewer \
+ ' file://' \
+ @md.file.output_path.xml_sax.dir + '/' \
+ @md.file.base_filename.xml_sax
elsif @opt.act[:verbose][:set]==:on
@env.program.web_browser \
+ ' file://' \
+ @md.file.output_path.xml_sax.dir + '/' \
+ @md.file.base_filename.xml_sax
else "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}"
end
(@opt.act[:verbose][:set]==:on \
|| @opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on) \
? SiSU_Screen::Ansi.new(
@opt.act[:color_state][:set],
'XML SAX',
tool
).green_hi_blue
: SiSU_Screen::Ansi.new(
@opt.act[:color_state][:set],
'XML SAX',
tool
).green_title_hi
if (@opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on)
SiSU_Screen::Ansi.new(
@opt.act[:color_state][:set],
@opt.fns,
'file://' \
+ @md.file.output_path.xml_sax.dir + '/' \
+ @md.file.base_filename.xml_sax
).flow
end
end
SiSU_XML_SAX::Source::Songsheet.new(@particulars).song
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
end
ensure
#file closed in songsheet
SiSU_Env::CreateSite.new(@opt).cp_css
Dir.chdir(@opt.f_pth[:pth])
end
end
private
class Songsheet
def initialize(particulars)
@env, @md, @ao_arr, @particulars=
particulars.env,particulars.md,particulars.ao_array,particulars
@file=SiSU_Env::FileOp.new(@md)
end
def song
begin
SiSU_XML_SAX::Source::Scroll.new(@particulars).songsheet
if (@md.opt.act[:verbose][:set]==:on \
|| @md.opt.act[:verbose_plus][:set]==:on \
|| @md.opt.act[:maintenance][:set]==:on)
SiSU_XML_SAX::Source::Tidy.new(@md,@file.place_file.xml_sax.dir).xml # test wellformedness, comment out when not in use
end
SiSU_Rexml::Rexml.new(@md,@file.place_file.xml_sax.dir).xml if @md.opt.act[:maintenance][:set]==:on # test rexml parsing, comment out when not in use #debug
rescue
SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
__LINE__.to_s + ':' + __FILE__
end
ensure
end
end
end
class Scroll
require_relative 'txt_shared' # txt_shared.rb
include SiSU_TextUtils
require_relative 'css' # css.rb
require_relative 'xhtml_shared' # decide use, whether xml rather than xhtml
def initialize(particulars)
@env, @md, @ao_arr=
particulars.env,particulars.md,particulars.ao_array
@trans=SiSU_XML_Munge::Trans.new(@md)
@sys=SiSU_Env::SystemCall.new
@per=SiSU_XML_Persist::Persist.new
end
def songsheet
begin
pre
@data=markup(@ao_arr)
post
publish
ensure
SiSU_XML_Persist::Persist.new.persist_init
end
end
protected
def embedded_endnotes(dob='')
dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/,
'<endnote><number>\1</number><note>\2</note></endnote> ').
gsub(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/,
'<endnote><symbol>\1</symbol><note>\2</note></endnote> ').
gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/,
'<endnote><symbol>\1</symbol><note>\2</note></endnote> ')
end
def extract_endnotes(dob='')
notes=dob.obj.scan(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})([\d*+]+\s+.+?)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/)
notes.flatten.each do |e|
s=e.to_s
util=SiSU_TextUtils::Wrap.new(s,70)
wrap=util.line_wrap
wrap=wrap.gsub(/^(\d+)\s+(.+?)\s*\Z/m, <<WOK
#{Ax[:tab]*1}<endnote notenumber="\\1">
#{Ax[:tab]*2}<number>\\1</number>
#{Ax[:tab]*2}<note>
#{Ax[:tab]*3}\\2
#{Ax[:tab]*2}</note>
#{Ax[:tab]*1}</endnote>
WOK
).
gsub(/^([*+]\d+)\s+(.+?)\s*\Z/m, <<WOK
#{Ax[:tab]*1}<endnote symbol="\\1">
#{Ax[:tab]*2}<symbol>\\1</symbol>
#{Ax[:tab]*2}<note>
#{Ax[:tab]*3}\\2
#{Ax[:tab]*2}</note>
#{Ax[:tab]*1}</endnote>
WOK
).
gsub(/^([*+]+)\s+(.+?)\s*\Z/m, <<WOK
#{Ax[:tab]*1}<endnote symbol="\\1.length">
#{Ax[:tab]*2}<symbol>\\1</symbol>
#{Ax[:tab]*2}<note>
#{Ax[:tab]*3}\\2
#{Ax[:tab]*2}</note>
#{Ax[:tab]*1}</endnote>
WOK
)
@endnotes << wrap
end
end
def xml_head
metadata=SiSU_Metadata::Summary.new(@md).xml_sax.metadata
@per.head << metadata
end
def xml_sc(md='')
sc=if @md.sc_info
<<WOK
<source_control>
<meta>filename:</meta>
<sc class="sourcefile">
#{@md.sc_filename}
</sc><br />
<meta>version number:</meta>
<sc class="number">
#{@md.sc_number}
</sc><br />
<meta>version date:</meta>
<sc class="date">
#{@md.sc_date}
</sc><br />
</source_control>
WOK
else ''
end
@per.sc=sc
end
def xml_structure(dob,type='norm')
if dob.is==:heading
lv=dob.ln
dob.ln + 2
else lv=nil
end
extract_endnotes(dob)
dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>'). #footnote/endnote clean
gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean
#if defined? dob.obj
#t_ograph="#{dob.obj}"
util=SiSU_TextUtils::Wrap.new(dob.obj,70)
wrapped=util.line_wrap
#end
@per.body << if defined? dob.ocn; %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
else "#{Ax[:tab]*0}<object>"
end
@per.body << "#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>" if defined? dob.ocn
@per.body << if lv; %{#{Ax[:tab]*1}<text class="h#{lv}">\n#{Ax[:tab]*2}#{wrapped}\n#{Ax[:tab]*1}</text>}
else %{#{Ax[:tab]*1}<text class="#{type}">\n#{Ax[:tab]*2}#{wrapped}\n#{Ax[:tab]*1}</text>} # main text, contents, body KEEP
end
@per.body << @endnotes if @endnotes
##@per.body << "#{Ax[:tab]*1}<text>#{dob[@regx,2]}</text>" if dob[@regx,2] # old unwrapped main text, contents, body KEEP
@per.body << "#{Ax[:tab]*0}</object>"
@endnotes=[]
end
def block_structure(dob='')
extract_endnotes(dob)
dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>'). #footnote/endnote clean
gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean
dob=@trans.markup_block(dob)
dob.obj=dob.obj.strip
@per.body << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
@per.body << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
@per.body << %{#{Ax[:tab]*1}<text class="block">#{Ax[:tab]*1}}
@per.body << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
@per.body << %{#{Ax[:tab]*1}</text>}
@per.body << "#{Ax[:tab]*0}</object>"
@per.body << @endnotes if @endnotes
@endnotes=[]
end
def group_structure(dob='')
extract_endnotes(dob)
dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>'). #footnote/endnote clean
gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean
dob=@trans.markup_group(dob)
dob.obj=dob.obj.strip
@per.body << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
@per.body << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
@per.body << %{#{Ax[:tab]*1}<text class="group">#{Ax[:tab]*1}}
@per.body << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
@per.body << %{#{Ax[:tab]*1}</text>}
@per.body << "#{Ax[:tab]*0}</object>"
@per.body << @endnotes if @endnotes
@endnotes=[]
end
def poem_structure(dob='')
dob=@trans.markup_group(dob)
#dob.obj.gsub(/\s\s/,'  ')
dob.obj=dob.obj.strip
@per.body << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
@per.body << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
@per.body << %{#{Ax[:tab]*1}<text class="verse">#{Ax[:tab]*1}}
@per.body << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
@per.body << %{#{Ax[:tab]*1}</text>}
@per.body << %{#{Ax[:tab]*0}</object>}
end
def code_structure(dob='')
dob=@trans.markup_group(dob)
dob.obj=dob.obj.gsub(/\s\s/,'  ').strip
@per.body << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
@per.body << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
@per.body << %{#{Ax[:tab]*1}<text class="code">#{Ax[:tab]*1}}
@per.body << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
@per.body << %{#{Ax[:tab]*1}</text>}
@per.body << "#{Ax[:tab]*0}</object>"
end
def table_structure(dob)
table=SiSU_XHTML_Shared::TableXHTML.new(dob)
@per.body << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
@per.body << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
@per.body << %{#{Ax[:tab]*1}<text class="table">#{Ax[:tab]*1}}
@per.body << %{#{Ax[:tab]*2}#{table.table.obj}}
@per.body << %{#{Ax[:tab]*1}</text>}
#@per.body << %{#{tab*1}</text>}
@per.body << "#{Ax[:tab]*0}</object>"
#@per.body << %{#{Ax[:tab]*0}<object id="#{ocn}">}
#@per.body << %{#{Ax[:tab]*1}#{table}\n#{Ax[:tab]*1}} # unless lv # main text, contents, body KEEP
#@per.body << "#{Ax[:tab]*0}</object>"
#@endnotes=[]
end
def markup(data)
xml_sc(@md)
@endnotes,@level,@cont,@copen,@xml_contents_close=[],[],[],[],[]
@rcdc=false
xml_head
(0..7).each { |x| @cont[x]=@level[x]=false }
(4..7).each { |x| @xml_contents_close[x]='' }
data.each do |dob|
@trans.char_enc.utf8(dob) if @sys.locale =~/utf-?8/i #% utf8
dob=@trans.markup(dob)
if @rcdc==false \
and (dob.is ==:meta \
and dob.obj =~/Document Information/)
@rcdc=true
end
if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/
if defined? dob.ocn #look to move to format section
ocn=((dob.ocn.to_s =~/\d+/) ? dob.ocn : nil)
@p_num=SiSU_XML_Format::ParagraphNumber.new(@md,ocn)
end
if not @rcdc
if defined? dob.ocn \
and dob.ocn.to_s =~/\d+/
x=SiSU_XML_Format::FormatSeg.new(@md,dob)
if dob.is==:heading
xml_structure(dob)
dob.obj=case dob.ln
when 1 then x.heading_body1
when 2 then x.heading_body2
when 3 then x.heading_body3
when 4 then x.heading_body4
when 5 then x.heading_body5
when 6 then x.heading_body6
when 7 then x.heading_body7
end
else
if dob.is==:verse
poem_structure(dob)
elsif dob.is==:group
group_structure(dob)
elsif dob.is==:block
block_structure(dob)
elsif dob.is==:code
code_structure(dob)
elsif dob.is==:table # FIX, check css, will need to modify
table_structure(dob)
elsif dob.is ==:para \
and dob.indent.to_s =~/[1-9]/ \
and dob.bullet_==true
xml_structure(dob,"indent_bullet#{dob.indent}")
elsif dob.is ==:para \
and dob.indent.to_s =~/[1-9]/ \
and dob.indent == dob.hang
xml_structure(dob,"indent#{dob.indent}")
elsif dob.is ==:para \
and dob.hang.to_s =~/[0-9]/ \
and dob.indent != dob.hang
xml_structure(dob,"hang#{dob.hang.to_s}_indent#{dob.indent.to_s}")
else xml_structure(dob)
end
end
elsif dob.obj =~/(#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/
elsif dob.obj =~/MetaData/
txt_obj={ txt: '<br /><a name="metadata">MetaData</a>' }
format_scroll=FormatScroll.new(@md,txt_obj)
dob.obj=format_scroll.bold_para
elsif dob.obj =~/(Owner Details)/
# txt_obj={ txt: '<br /><a name="owner.details">Owner Details</a>' }
# format_scroll=FormatScroll.new(@md,txt_obj)
# @per.owner_details=format_scroll.bold_para
dob.obj=''
end
if dob.obj =~/<a name="n\d+">/ \
and dob.obj =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/ # -endnote
dob.obj=''
end
if dob.obj =~/.*<:#>.*$/ #investigate removal
dob.obj=if dob.obj =~ /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/
txt_obj={ txt: dob }
format_text=FormatTextObject.new(@md,txt_obj)
format_text.scr_inden_ocn_e_no_paranum
end
end
else #
end
dob.obj=dob.obj.gsub(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if dob.obj
end
end
7.downto(4) do |x|
y=x - 1; v=x - 3
@per.body << "#{Ax[:tab]*5}</content>\n#{Ax[:tab]*y}</contents#{v}>" if @level[x]==true
end
3.downto(1) do |x|
y=x - 1
@per.body << "#{Ax[:tab]*y}</heading#{x}>" if @level[x]==true
end
#7.downto(1) { |x| y=x - 1; @per.body << "#{Ax[:tab]*y}</level #{x}>" if @level[x]==true }
end
def pre
rdf=SiSU_XML_Tags::RDF.new(@md)
@per.head,@per.body=[],[]
stylesheet=SiSU_Style::CSS_HeadInfo.new(@md,'xml_sax').stylesheet
encoding=if @sys.locale =~/utf-?8/i then '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'
else '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>'
end
@per.open =<<WOK
#{encoding}
#{stylesheet.css_head_xml}
#{rdf.comment_xml}
<document>
WOK
@per.head << '<head>'
@per.body << '<body>'
end
def post
@per.head << @per.sc
@per.head << '</head>'
@per.body << '</body>'
@per.close = '</document>'
end
def publish
content=[]
content << @per.open << @per.head << @per.body #<< @per.metadata
#content << @per.owner_details if @md.stmp =~/\w\w/
content << @per.tail << @per.close
content=content.flatten.compact
Output.new(content,@md).xml
@@xml={}
end
end
class Output
def initialize(data,md)
@data,@md=data,md
@file=SiSU_Env::FileOp.new(@md)
end
def xml
SiSU_Env::FileOp.new(@md).mkdir
filename_xml=@file.write_file.xml_sax
@data.each do |str|
str=str.gsub(/\A\s+\Z/m,'')
filename_xml.puts str unless str.empty?
end
filename_xml.close
end
end
class Tidy
def initialize(md,file)
@md,@file=md,file
@prog=SiSU_Env::InfoProgram.new
end
def xml
if @prog.tidy !=false #note values can be other than true
if (@md.opt.act[:verbose_plus][:set]==:on \
|| @md.opt.act[:maintenance][:set]==:on)
unless @md.opt.act[:quiet][:set]==:on
SiSU_Screen::Ansi.new(
@md.opt.act[:color_state][:set],
'invert',
'Using XML Tidy',
'check document structure'
).colorize
tell=SiSU_Screen::Ansi.new(
@md.opt.act[:color_state][:set],
'invert',
'',
''
)
tell.grey_open
end
tidyfile='/dev/null' #don't want one or screen output, check for alternative flags
tidy=SiSU_Env::SystemCall.new(@file,tidyfile)
tidy.well_formed?
tell.p_off unless @md.opt.act[:quiet][:set]==:on
end
end
end
end
end
end
__END__
#+END_SRC
** xml_dom.rb
#+BEGIN_SRC ruby :tangle "../lib/sisu/xml_dom.rb"
# <<sisu_document_header>>
module SiSU_XML_DOM
require_relative 'se_hub_particulars' # se_hub_particulars.rb
include SiSU_Particulars
require_relative 'se' # se.rb
include SiSU_Env
require_relative 'ao' # ao.rb
require_relative 'xml_shared' # xml_shared.rb
include SiSU_XML_Munge
require_relative 'xml_format' # xml_format.rb
include SiSU_XML_Format
require_relative 'xml_persist' # xml_persist.rb
require_relative 'rexml' # rexml.rb
include SiSU_Rexml
require_relative 'shared_metadata' # shared_metadata.rb
@@alt_id_count=0
@@tablefoot=''
class Source
def initialize(opt)
@opt=opt
@particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt)
end
def read
begin
@env, @md, @ao_arr=
@particulars.env,@particulars.md,@particulars.ao_array
unless @opt.act[:quiet][:set]==:on
tool=if (@opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on)
@env.program.web_browser \
+ ' file://' \
+ @md.file.output_path.xml_dom.dir + '/' \
+ @md.file.base_filename.xml_dom + "\n\t" \
+ @env.program.xml_viewer \
+ ' file://' \
+ @md.file.output_path.xml_dom.dir + '/' \
+ @md.file.base_filename.xml_dom
elsif @opt.act[:verbose][:set]==:on
@env.program.web_browser \
+ ' file://' \
+ @md.file.output_path.xml_dom.dir + '/' \
+ @md.file.base_filename.xml_dom
else "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}"
end
(@opt.act[:verbose][:set]==:on \
|| @opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on) \
? SiSU_Screen::Ansi.new(
@opt.act[:color_state][:set],
'XML DOM',
tool
).green_hi_blue
: SiSU_Screen::Ansi.new(
@opt.act[:color_state][:set],
'XML DOM',
tool
).green_title_hi
if (@opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on)
SiSU_Screen::Ansi.new(
@opt.act[:color_state][:set],
@opt.fns,
'file://' \
+ @md.file.output_path.xml_dom.dir + '/' \
+ @md.file.base_filename.xml_dom
).flow
end
end
SiSU_XML_DOM::Source::Songsheet.new(@particulars).songsheet
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
end
ensure
SiSU_Env::CreateSite.new(@opt).cp_css
Dir.chdir(@opt.f_pth[:pth])
end
end
private
class Songsheet
def initialize(particulars)
@env, @md, @ao_arr, @particulars=
particulars.env,particulars.md,particulars.ao_array,particulars
@file=SiSU_Env::FileOp.new(@md)
end
def songsheet
begin
SiSU_XML_DOM::Source::Scroll.new(@particulars).songsheet
if (@md.opt.act[:verbose][:set]==:on \
|| @md.opt.act[:verbose_plus][:set]==:on \
|| @md.opt.act[:maintenance][:set]==:on)
SiSU_XML_DOM::Source::Tidy.new(@md,@file.place_file.xml_dom.dir).xml # test wellformedness, comment out when not in use
end
SiSU_Rexml::Rexml.new(@md,@file.place_file.xml_dom.dir).xml if @md.opt.act[:maintenance][:set]==:on # test rexml parsing, comment out when not in use #debug
rescue
SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
__LINE__.to_s + ':' + __FILE__
end
ensure
end
end
end
class Scroll
require_relative 'txt_shared' # txt_shared.rb
include SiSU_TextUtils
require_relative 'xhtml_shared' # decide use, whether xml rather than xhtml
def initialize(particulars)
@env, @md, @ao_arr=
particulars.env,particulars.md,particulars.ao_array
@trans=SiSU_XML_Munge::Trans.new(@md)
@sys=SiSU_Env::SystemCall.new
@per=SiSU_XML_Persist::Persist.new
end
def songsheet
begin
pre
@data=markup(@ao_arr)
post
publish
ensure
SiSU_XML_Persist::Persist.new.persist_init
end
end
protected
def xml_markup(dob='')
dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/,
'<endnote><number>\1</number><note>\2</note></endnote> ').
gsub(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/,
'<endnote><symbol>\1</symbol><note>\2</note></endnote> ').
gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/,
'<endnote><symbol>\1</symbol><note>\2</note></endnote> ')
end
def xml_head
metadata=SiSU_Metadata::Summary.new(@md).xml_dom.metadata
@per.head << metadata
end
def xml_sc(md='')
sc=if @md.sc_info
<<WOK
<source_control>
<meta>filename:</meta>
<sc class="sourcefile">
#{@md.sc_filename}
</sc><br />
<meta>version number:</meta>
<sc class="number">
#{@md.sc_number}
</sc><br />
<meta>version date:</meta>
<sc class="date">
#{@md.sc_date}
</sc><br />
</source_control>
WOK
else ''
end
@per.sc=sc
end
def xml_element(dob,xml_el='',xml_content='',type='norm')
n=n1=n2=n3=0
if dob.is==:heading
lv=dob.ln
n=dob.ln
n1=dob.ln
n2=dob.ln + 2
n3=dob.ln + 3
else lv=nil
end
tag=if defined? dob.name and dob.name=~/\S+/
"\n#{Ax[:tab]*n3}<nametag>#{dob.name}</nametag>"
else ''
end
xml_el ||=''
@per.body <<<<WOK
#{Ax[:tab]*n}#{xml_el}
#{Ax[:tab]*n1}<heading>
#{Ax[:tab]*n2}<object id="#{dob.ocn}">
#{Ax[:tab]*n3}<ocn>#{dob.ocn}</ocn>#{tag}
#{Ax[:tab]*n3}<text class="#{type}">#{dob.obj}</text>
#{Ax[:tab]*n2}</object>
#{Ax[:tab]*n1}</heading>#{xml_content}
WOK
if lv==4
@copen[1]=true
@copen[2]=@copen[3]=@copen[4]=false
elsif lv==5
@copen[2]=true
@copen[3]=@copen[4]=false
elsif lv==6
@copen[3]=true
@copen[4]=false
elsif lv==7
@copen[4]=true
end
end
def xml_structure(dob,type='norm')
n=n1=n2=n3=0
if dob.is==:heading
lv=dob.ln
n=dob.ln - 1
n1=dob.ln
n2=dob.ln + 1
n3=dob.ln + 2
dob.ln - 3
else lv=nil
end
case lv
when 1..3
xml_el="<heading#{lv}>"
3.downto(lv) do |x|
y=x - 1
if @cont[1] \
or @cont[2] \
or @cont[3]
@per.body << "#{Ax[:tab]*5}</content>"
end
@cont[1]=false if @cont[1]
@cont[2]=false if @cont[2]
@cont[3]=false if @cont[3]
####### attempt to close contents
if @copen[4] # 4~
[4,3,2,1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
@copen[1]=@copen[2]=@copen[3]=@copen[4]=false
elsif @copen[3] # 3~
[3,2,1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
@copen[1]=@copen[2]=@copen[3]=false
elsif @copen[2] # 2~
[2,1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
@copen[1]=@copen[2]=@copen[3]=false
elsif @copen[1] # 1~
[1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
@copen[1]=@copen[2]=@copen[3]=false
end
@per.body << "#{Ax[:tab]*y}</heading#{x}>" if @level[x]
@level[x]=false
end
when 4..7
7.downto(lv) do |x|
if @level[x]==true
@xml_contents_close[x]=''
end
end
cv=lv - 3
xml_el="<contents#{cv}>"
xml_content="\n#{Ax[:tab]*5}<content>"
case lv
when 4
@per.body << "#{Ax[:tab]*5}</content>" if @cont[1]
if @copen[4]==true # 4~
[4,3,2,1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
elsif @copen[3]==true # 3~
[3,2,1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
elsif @copen[2]==true # 2~
[2,1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
elsif @copen[1]==true # 1~
[1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
end
@cont[1]=true
when 5
if @cont[3] \
or @cont[2] \
or @cont[1]
@per.body << "#{Ax[:tab]*5}</content>"
end
if @copen[4]==true #4~
[4,3,2].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
elsif @copen[3]==true #3~
[3,2].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
elsif @copen[2]==true #2~
[2].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
end
@cont[2]=true
when 6
if @cont[4] \
or @cont[3] \
or @cont[2] \
or @cont[1]
@per.body << "#{Ax[:tab]*5}</content>"
end
if @copen[4] #4~
[4,3].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
elsif @copen[3] #3~
[3].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
end
@cont[3]=true
when 7
if @cont[4] \
or @cont[3] \
or @cont[2] \
or @cont[1]
@per.body << "#{Ax[:tab]*5}</content>"
end
if @copen[4] #4~
[4].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
end
@cont[4]=true
end
end
xml_el ||=''
xml_element(dob,xml_el,xml_content,type)
if lv
@level[lv]=true
((lv+1)..7).each { |x| @level[x]=false }
end
end
def add_to_body(dob,type='norm')
if defined? dob.obj # main text, contents, body KEEP
if defined? dob.ocn \
and dob.ocn
@per.body << %{#{Ax[:tab]*6}<object id="#{dob.ocn}">}
@per.body << %{#{Ax[:tab]*7}<ocn>#{dob.ocn}</ocn>} if defined? dob.ocn
end
#@per.body << %{#{Ax[:tab]*7}<text class="#{type}">#{dob.obj}</text>}
#@per.body << %{#{Ax[:tab]*7}<text class="#{dob.is}">#{Ax[:tab]*1}}
@per.body << %{#{Ax[:tab]*7}<text class="#{type}">#{Ax[:tab]*1}}
@per.body << %{#{Ax[:tab]*8}#{dob.obj}#{Ax[:tab]*1}}
@per.body << %{#{Ax[:tab]*7}</text>}
@per.body << %{#{Ax[:tab]*6}</object>}
end
end
def block_structure(dob)
dob=@trans.markup_block(dob) #decide check & FIX
dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m,
'<endnote><number>\1</number><note>\2</note></endnote> ').strip
dob
end
def group_structure(dob)
dob=@trans.markup_group(dob) #decide check & FIX
dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m,
'<endnote><number>\1</number><note>\2</note></endnote> ').strip
dob
end
def poem_structure(dob)
dob=@trans.markup_group(dob) #decide check & FIX
dob.obj=dob.obj.strip
dob
end
def code_structure(dob)
dob=@trans.markup_group(dob) #decide check & FIX
dob.obj=dob.obj.gsub(/\s\s/,'  ').strip
dob
end
def table_structure(dob) #tables
SiSU_XHTML_Shared::TableXHTML.new(dob)
end
def markup(data)
xml_sc(@md)
@level,@cont,@copen,@xml_contents_close=[],[],[],[]
@rcdc=false
type='norm'
(0..7).each { |x| @cont[x]=@level[x]=false }
(4..7).each { |x| @xml_contents_close[x]='' }
xml_head
data.each do |dob|
@trans.char_enc.utf8(dob) if @sys.locale =~/utf-?8/i #% utf8
dob=@trans.markup(dob)
if @rcdc==false \
and (dob.is ==:meta \
and dob.obj =~/Document Information/)
@rcdc=true
end
if dob !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/
@p_num=SiSU_XML_Format::ParagraphNumber.new(@md,dob.ocn) if defined? dob.ocn
if not @rcdc
if defined? dob.ocn \
and dob.ocn.to_s =~/\d+/
format_scroll=SiSU_XML_Format::FormatScroll.new(@md,dob) if dob.is==:para and dob.indent ##FIX
x=SiSU_XML_Format::FormatSeg.new(@md,dob)
if dob.is==:heading
if dob.ln==0
type="heading_section_#{dob.ln.to_s}"
xml_markup(dob)
xml_structure(dob,type)
dob.obj=x.heading_body0
elsif dob.ln==1
type="heading_section_#{dob.ln.to_s}"
xml_markup(dob)
xml_structure(dob,type)
dob.obj=x.heading_body1
elsif dob.ln==2
type="heading_section_#{dob.ln.to_s}"
xml_markup(dob)
xml_structure(dob,type)
dob.obj=x.heading_body2
elsif dob.ln==3
type="heading_section_#{dob.ln.to_s}"
xml_markup(dob)
xml_structure(dob,type)
dob.obj=x.heading_body3
elsif dob.ln==4
type="heading_content_#{dob.lv}"
xml_markup(dob)
xml_structure(dob,type)
dob.obj=x.heading_body4
elsif dob.ln==5
type="heading_content_#{dob.lv}"
xml_markup(dob)
xml_structure(dob,type)
dob.obj=x.heading_body5
elsif dob.ln==6
type="heading_content_#{dob.lv}"
xml_structure(dob,type)
dob.obj=x.heading_body6
elsif dob.ln==7
type="heading_content_#{dob.lv}"
xml_structure(dob,type)
dob.obj=x.heading_body7
end
else
dob.ocn
if dob.is==:verse
type='verse'
poem_structure(dob) #redo
elsif dob.is==:group
type='group'
group_structure(dob) #redo
elsif dob.is==:block
type='block'
block_structure(dob) #redo
elsif dob.is==:code
type='code'
code_structure(dob) #redo
elsif dob.is==:table # tables come as single block #work area 2005w13
type='table'
table_structure(dob)
elsif dob.is==:para \
and dob.indent.to_s =~/[1-9]/ \
and dob.bullet_
type="indent_bullet#{dob.indent.to_s}"
xml_markup(dob)
elsif dob.is==:para \
and dob.indent.to_s =~/[1-9]/ \
and dob.indent == dob.hang
type="indent#{dob.indent.to_s}"
xml_markup(dob)
elsif dob.is==:para \
and dob.hang.to_s =~/[0-9]/ \
and dob.indent != dob.hang
type="hang#{dob.hang.to_s}_indent#{dob.indent.to_s}"
xml_markup(dob)
else
type='norm'
xml_markup(dob)
end
add_to_body(dob,type)
end
elsif dob.obj =~/(#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/
elsif dob.obj =~/(MetaData)/
txt_obj={ txt: '<br /><a name="metadata">MetaData</a>' }
format_scroll=FormatScroll.new(@md,txt_obj)
dob.obj=format_scroll.bold_para
elsif dob.obj =~/(Owner Details)/
dob.obj=''
end
if dob.obj =~/<a name="n\d+">/ \
and dob.obj =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/ # -endnote
dob.obj=''
end
if dob.obj =~/.*<:#>.*$/
dob.obj=if dob.obj =~ /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/
txt_obj={ txt: dob.obj }
format_text=FormatTextObject.new(@md,txt_obj)
format_text.scr_inden_ocn_e_no_paranum
end
end
else #
end
dob.obj=dob.obj.gsub(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if dob.obj
end
end
@content_flag=true
7.downto(4) do |x|
y=x - 1; v=x - 3
if @level[x]==true #2004w36 bug fix? watch/test previous logic broke on free.for.all @coontent_flag introduced
if @content_flag==true
@per.body << "#{Ax[:tab]*5}</content>\n#{Ax[:tab]*y}</contents#{v}>"
@content_flag=false
else
@per.body << "\n#{Ax[:tab]*y}</contents#{v}>"
end
end
end
3.downto(1) do |x|
y=x - 1
@per.body << "#{Ax[:tab]*y}</heading#{x}>" if @level[x]==true
end
end
def pre
rdf=SiSU_XML_Tags::RDF.new(@md)
stylesheet=SiSU_Style::CSS_HeadInfo.new(@md,'xml_dom').stylesheet
encoding=if @sys.locale =~/utf-?8/i then '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'
else '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>'
end
@per.open =<<WOK
#{encoding}
#{stylesheet.css_head_xml}
#{rdf.comment_xml}
<document>
WOK
@per.head << '<head>'
@per.body << '<body>'
end
def post
@per.head << @per.sc
@per.head << '</head>'
@per.body << '</body>'
@per.close << '</document>'
end
def publish
content=[]
content << @per.open << @per.head << @per.body # << @per.metadata
content << @per.tail << @per.close
content=content.flatten.compact
Output.new(content,@md).xml
@per.head,@per.body,@per.tail=[],[],[] # check whether should be nil
end
end
class Output
include SiSU_Param
def initialize(data,md)
@data,@md=data,md
@file=SiSU_Env::FileOp.new(@md)
end
def xml
SiSU_Env::FileOp.new(@md).mkdir
filename_xml=@file.write_file.xml_dom
@data.each do |str|
str=str.gsub(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'')
filename_xml.puts str unless str.empty?
end
filename_xml.close
end
end
class Tidy
def initialize(md,file)
@md,@file=md,file
@prog=SiSU_Env::InfoProgram.new
end
def xml
if @prog.tidy !=false
if (@md.opt.act[:verbose_plus][:set]==:on \
|| @md.opt.act[:maintenance][:set]==:on)
unless @md.opt.act[:quiet][:set]==:on
SiSU_Screen::Ansi.new(
@md.opt.act[:color_state][:set],
'invert',
'Using XML Tidy',
'check document structure'
).colorize
tell=SiSU_Screen::Ansi.new(
@md.opt.act[:color_state][:set],
'invert',
'',
''
)
tell.grey_open
end
tidyfile='/dev/null' #don't want one or screen output, check for alternative flags
tidy=SiSU_Env::SystemCall.new(@file,tidyfile)
tidy.well_formed?
tell.p_off unless @md.opt.act[:quiet][:set]==:on
end
end
end
end
end
end
__END__
,** Notes: tidy -xml dom.xml >> index.tidy
#+END_SRC
#+END_SRC
* xml shared
** xml_shared.rb
#+BEGIN_SRC ruby :tangle "../lib/sisu/xml_shared.rb"
# <<sisu_document_header>>
module SiSU_XML_Munge
require_relative 'xml_parts' # xml_parts.rb
class Trans
include SiSU_Parts_XML
def initialize(md)
@md=md
@sys=SiSU_Env::SystemCall.new
@dir=SiSU_Env::InfoEnv.new(@md.fns)
if @md.sem_tag
@ab ||=semantic_tags.default
end
end
def semantic_tags
def default
{
pub: 'publication',
conv: 'convention',
vol: 'volume',
pg: 'page',
cty: 'city',
org: 'organization',
uni: 'university',
dept: 'department',
fac: 'faculty',
inst: 'institute',
co: 'company',
com: 'company',
dt: 'date',
y: 'year',
m: 'month',
d: 'day',
ti: 'title',
au: 'author',
ed: 'editor', #editor?
v: 'version', #edition
n: 'name',
fn: 'firstname',
mn: 'middlename',
ln: 'lastname',
in: 'initials',
qt: 'quote',
ct: 'cite',
ref: 'reference',
ab: 'abreviation',
def: 'define',
desc: 'description',
trans: 'translate',
}
end
self
end
def char_enc #character encode
def utf8(dob='')
if @sys.locale =~/utf-?8/i # instead ucs for utf8 # String#encode Iñtërnâtiônàlizætiøn
str=if defined? dob.obj then dob.obj
elsif dob.is_a?(String) then dob
end
if str
#¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûü
#¢£¥§©ª«®°±²³µ¶¹º»¼½¾×÷
str=str.gsub(/</um,'<'). # '<' # <
gsub(/>/um,'>'). # '>' # >
gsub(/¢/um,'¢'). # '¢' # ¢
gsub(/£/um,'£'). # '£' # £
gsub(/¥/um,'¥'). # '¥' # ¥
gsub(/§/um,'§'). # '§' # §
gsub(/©/um,'©'). # '©' # ©
gsub(/ª/um,'ª'). # 'ª' # ª
gsub(/«/um,'«'). # '«' # «
gsub(/®/um,'®'). # '®' # ®
gsub(/°/um,'°'). # '°' # °
gsub(/±/um,'±'). # '±' # ±
gsub(/²/um,'²'). # '²' # ²
gsub(/³/um,'³'). # '³' # ³
gsub(/µ/um,'µ'). # 'µ' # µ
gsub(/¶/um,'¶'). # '¶' # ¶
gsub(/¹/um,'¹'). # '¹' # ¹
gsub(/º/um,'º'). # 'º' # º
gsub(/»/um,'»'). # '»' # »
gsub(/¼/um,'¼'). # '¼' # ¼
gsub(/½/um,'½'). # '½' # ½
gsub(/¾/um,'¾'). # '¾' # ¾
gsub(/×/um,'×'). # '×' # ×
gsub(/÷/um,'÷'). # '÷' # ÷
gsub(/¿/um,'¿'). # '¿' # ¿
gsub(/À/um,'À'). # 'À' # À
gsub(/Á/um,'Á'). # 'Á' # Á
gsub(/Â/um,'Â'). # 'Â' # Â
gsub(/Ã/um,'Ã'). # 'Ã' # Ã
gsub(/Ä/um,'Ä'). # 'Ä' # Ä
gsub(/Å/um,'Å'). # 'Å' # Å
gsub(/Æ/um,'Æ'). # 'Æ' # Æ
gsub(/Ç/um,'Ç'). # 'Ç' # Ç
gsub(/È/um,'È'). # 'È' # È
gsub(/É/um,'É'). # 'É' # É
gsub(/Ê/um,'Ê'). # 'Ê' # Ê
gsub(/Ë/um,'Ë'). # 'Ë' # Ë
gsub(/Ì/um,'Ì'). # 'Ì' # Ì
gsub(/Í/um,'Í'). # 'Í' # Í
gsub(/Î/um,'Î'). # 'Î' # Î
gsub(/Ï/um,'Ï'). # 'Ï' # Ï
gsub(/Ð/um,'Ð'). # 'Ð' # Ð
gsub(/Ñ/um,'Ñ'). # 'Ñ' # Ñ
gsub(/Ò/um,'Ò'). # 'Ò' # Ò
gsub(/Ó/um,'Ó'). # 'Ó' # Ó
gsub(/Ô/um,'Ô'). # 'Ô' # Ô
gsub(/Õ/um,'Õ'). # 'Õ' # Õ
gsub(/Ö/um,'Ö'). # 'Ö' # Ö
gsub(/Ø/um,'Ø'). # 'Ø' # Ø
gsub(/Ù/um,'Ù'). # 'Ù' # Ù
gsub(/Ú/um,'Ú'). # 'Ú' # Ú
gsub(/Û/um,'Û'). # 'Û' # Û
gsub(/Ü/um,'Ü'). # 'Ü' # Ü
gsub(/Ý/um,'Ý'). # 'Ý' # Ý
gsub(/Þ/um,'Þ'). # 'Þ' # Þ
gsub(/ß/um,'ß'). # 'ß' # ß
gsub(/à/um,'à'). # 'à' # à
gsub(/á/um,'á'). # 'á' # á
gsub(/â/um,'â'). # 'â' # â
gsub(/ã/um,'ã'). # 'ã' # ã
gsub(/ä/um,'ä'). # 'ä' # ä
gsub(/å/um,'å'). # 'å' # å
gsub(/æ/um,'æ'). # 'æ' # æ
gsub(/ç/um,'ç'). # 'ç' # ç
gsub(/è/um,'è'). # 'è' # è
gsub(/é/um,'é'). # '´' # é
gsub(/ê/um,'ê'). # 'ˆ' # ê
gsub(/ë/um,'ë'). # 'ë' # ë
gsub(/ì/um,'ì'). # 'ì' # ì
gsub(/í/um,'í'). # '´' # í
gsub(/î/um,'î'). # 'î' # î
gsub(/ï/um,'ï'). # 'ï' # ï
gsub(/ð/um,'ð'). # 'ð' # ð
gsub(/ñ/um,'ñ'). # 'ñ' # ñ
gsub(/ò/um,'ò'). # 'ò' # ò
gsub(/ó/um,'ó'). # 'ó' # ó
gsub(/ô/um,'ô'). # 'ô' # ô
gsub(/õ/um,'õ'). # 'õ' # õ
gsub(/ö/um,'ö'). # 'ö' # ö
gsub(/ø/um,'ø'). # 'ø' # ø
gsub(/ù/um,'ú'). # 'ù' # ú
gsub(/ú/um,'û'). # 'ú' # û
gsub(/û/um,'ü'). # 'û' # ü
gsub(/ü/um,'ý'). # 'ü' # ý
gsub(/þ/um,'þ'). # 'þ' # þ
gsub(/ÿ/um,'ÿ'). # 'ÿ' # ÿ
gsub(/‘/um,'‘'). # '‘' # ‘
gsub(/’/um,'’'). # '’' # ’
gsub(/“/um,'“'). # “ # “
gsub(/”/um,'”'). # ” # ”
gsub(/–/um,'–'). # – # –
gsub(/—/um,'—'). # — # —
gsub(/∝/um,'∝'). # ∝ # ∝
gsub(/∞/um,'∞'). # ∞ # ∞
gsub(/™/um,'™'). # ™ # ™
gsub(/✠/um,'✠'). # ✗ # ✠
gsub(/ /um,' '). # space identify
gsub(/ /um,' ') # space identify
end
dob=if defined? dob.obj
dob.obj=str
dob
elsif dob.is_a?(String)
str
end
dob
end
end
def html(dob='')
if @sys.locale =~/utf-?8/i # instead ucs for utf8 # String#encode Iñtërnâtiônàlizætiøn
dob.obj=dob.obj.gsub(/ /u,' '). # space identify
gsub(/ /u,' ') # space identify
end
end
self
end
def tidywords(wordlist)
wordlist_new=[]
wordlist.each do |x|
#imperfect solution will not catch all possible cases
x=x.gsub(/&/,'&') unless x =~/&\S+;/
x=x.gsub(/&([A-Z])/,'&\1')
wordlist_new << x
end
wordlist_new
end
def markup(dob='')
wordlist=dob.obj.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17
dob.obj=tidywords(wordlist).join(' ').strip
unless dob.is==:table
dob.obj=dob.obj.gsub(/#{Mx[:br_line]}/u,'<br />').
gsub(/#{Mx[:br_paragraph]}/u,'<br />').
gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />')
end
dob.obj=dob.obj.gsub(/#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}/,'').
gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;').
gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;').
gsub(/(^|#{Mx[:gl_c]}|\s+)<\s+/,'\1< ').gsub(/\s+>(\s+|$)/,' >\1').
#gsub(/#{Mx[:fa_emphasis_o]}(.+?)#{Mx[:fa_emphasis_c]}/,'<em>\1</em>'). #reinstate
gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/m,'<b>\1</b>').
gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/m,'<i>\1</i>').
gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>').
gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>').
gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>').
gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>').
gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>').
gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>').
gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>').
gsub(/<:pb>\s*/,''). #Fix
gsub(/<+[-~]#>+/,'')
if dob.is !=:code
#embeds a red-bullet image -->
dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>').
gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>').
gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>').
gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>')
dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') unless dob.is==:table
dob.obj=dob.obj.gsub(/#{Mx[:br_page]}\s*/,'').
gsub(/#{Mx[:br_page_new]}\s*/,'').
gsub(/#{Mx[:br_page_line]}\s*/,'').
gsub(/#{Mx[:pa_non_object_no_heading]}|#{Mx[:pa_non_object_dummy_heading]}/,'').
gsub(/<[-~]#>/,'').
gsub(/href="#{Xx[:segment]}/m,'href="').
gsub(/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{Mx[:rel_c]}]+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\.\.\/\S+?)#{Mx[:rel_c]}/,
'<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:href="\2">\1</link>').
gsub(/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{Mx[:rel_c]}]+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}:(\S+?)#{Mx[:rel_c]}/,
'<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:href="../\2">\1</link>').
gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]}/,
'<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:href="#\2">\1</link>').
gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))[ ]+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
%{<image xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:actuate="onLoad" xl:show="embed" xl:href="#{@md.file.output_path.xml.rel_image}/\\1" width="\\2" height="\\3" />[\\1] \\4}).
gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))([ ]+[^}]+)?#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
%{<image xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:actuate="onLoad" xl:show="embed" xl:href="#{@md.file.output_path.xml.rel_image}/\\1"/>\\1}).
gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))[ ]+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}image/,
%{<image xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:actuate="onLoad" xl:show="embed" xl:href="#{@md.file.output_path.xml.rel_image}/\\1" width="\\2" height="\\3" />[\\1] \\4}).
gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))([ ]+[^}]+)?#{Mx[:lnk_c]}image/,
%{<image xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:actuate="onLoad" xl:show="embed" xl:href="#{@md.file.output_path.xml.rel_image}/\\1"/>\\1}).
gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
'<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:href="\2">\1</link>'). #watch, compare html_tune
gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
%{#{the_url_decoration.xml_open}<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:href="\\1">\\1</link>#{the_url_decoration.xml_close}}).
gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
'<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:href="\1">\1</link>') #escaped urls not linked, deal with later
else
dob.obj=dob.obj.gsub(/</m,'<').gsub(/>/m,'>')
end
if dob.of==:block
dob.obj=dob.obj.gsub(/#{Mx[:gl_bullet]}/,'● ')
end
dob.obj=dob.obj.gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,
%{#{the_url_decoration.xml_open}\\1#{the_url_decoration.xml_close}}).
gsub(/#{Dx[:url_o]}/,"#{Dx[:url_o_xml]}").
gsub(/#{Dx[:url_c]}/,"#{Dx[:url_c_xml]}").
gsub(/ |#{Mx[:nbsp]}/m,' ').
gsub(/;&([^#]|(?:[^gl][^t]|[^a][^m][^p]|[^n][^b][^s][^p])[^;])/,';&\1') # pattern not to match
dob
end
def markup_light(dob='')
dob.obj=dob.obj.gsub(/\/\{(.+?)\}\//,'<i>\1</i>').
gsub(/[*!]\{(.+?)\}[*!]/,'<b>\1</b>').
gsub(/_\{(.+?)\}_/,'<u>\1</u>').
gsub(/-\{(.+?)\}-/,'<del>\1</del>').
gsub(/<br(\s*\/)?>/,'<br />').
gsub(/<:pb>\s*/,'').
gsub(/<[-~]#>/,'').
gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& '). #sort
gsub(/&([^;]{1,5})/,'&\1'). #sort, rough estimate, revisit #WATCH found in node not sax
gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif))[ ]+.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,
"<image.path>#{@md.file.output_path.xml.rel_image}\/\\1</image.path>").
gsub(/ |#{Mx[:nbsp]}/,' ').
gsub(/;&([^#]|(?:[^gl][^t]|[^a][^m][^p]|[^n][^b][^s][^p])[^;])/,';&\1') # pattern not to match
wordlist=dob.obj.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17
dob.obj=tidywords(wordlist).join(' ').strip
dob
end
def clean(str)
str=str.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;').
gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;')
end
def markup_fictionbook(str='',is='')
str=str.gsub(/#{Mx[:en_a_o]}([\d+*]+).+?#{Mx[:en_a_c]}/m,'<a xl:href="#footnote\1" type="note">[\1]</a>').
gsub(/&/,'&'). #sort
gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;').
gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& '). #sort
gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;')
str=str.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') unless is==:table
str=str.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>').
gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>').
gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>').
gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>').
gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>').
gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>').
gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>').
gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>').
gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>'). # tt, kbd
gsub(/#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)).+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/m,'<image xl:href="#\1" />').
gsub(/#{Mx[:url_o]}(.+?)#{Mx[:url_c]}/,"#{Dx[:url_o]}\\1#{Dx[:url_c]}").
gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'<a name="\1"></a>').
gsub(/#{Mx[:gl_bullet]}/m,'● '). # not available
gsub(/#{Mx[:nbsp]}/,' '). # not available
gsub(/<(p|br)>/,'<\1 />')
clean(str)
end
def markup_docbook(dob='') # work on, initially a copy of fictionbook!
if dob.is !=:code
dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s*(.+?)#{Mx[:en_a_c]}/m,'<footnote><para><!-- fn\1 -->\2</para></footnote>').
gsub(/\\\\/,'</para><para>').
gsub(/&/,'&'). #sort
gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;').
gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& '). #sort
gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;')
dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') unless dob.is==:table
dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>').
gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>').
gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>').
gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>').
gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>').
gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>').
gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>').
gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>').
gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>'). # tt, kbd
gsub(/#{Mx[:lnk_o]}\s*(\S+?)\.(png|jpg|gif).+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/m,
%{#{Xx[:split]}:spaces0:<figure id="fig-\\1">\n:spaces1:<title></title>\n:spaces1:<graphic fileref="../../_sisu/image/\\1.\\2" align="center" width="50%"></graphic>\n:spaces0:</figure>#{Xx[:split]}}). # common image location, else use ./images
gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(.+?)#{Mx[:url_c]}/,
'<ulink url="\2">\1</ulink>').
gsub(/#{Mx[:url_o]}(.+?)#{Mx[:url_c]}/,
'<ulink url="\1">\1</ulink>').
gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'<a name="\1"></a>').
gsub(/#{Mx[:gl_bullet]}/m,'● '). # not available
gsub(/#{Mx[:nbsp]}/,' '). # not available
gsub(/<(p|br)>/,'<\1 />')
dob.obj=clean(dob.obj)
elsif dob.is == :code
dob.obj=dob.obj.gsub(/&/m,'&'). #sort
gsub(/</,'<').gsub(/>/,'>')
else # p dob.is ??
end
dob
end
def markup_group(dob='')
dob.obj=dob.obj.gsub(/</,'<').gsub(/>/,'>').
gsub(/<:?br(?:\s+\/)?>/,'<br />').
gsub(/<(link xmlns:xl=".+?")>/,'<\1>').
gsub(/<(\/link)>/,'<\1>').
gsub(/<(\/?en)>/,'<\1>')
dob
end
def markup_block(dob='')
dob.obj=dob.obj.gsub(/</,'<').gsub(/>/,'>').
gsub(/<:?br(?:\s+\/)?>/,'<br />').
gsub(/<(link xmlns:xl=".+?")>/,'<\1>').
gsub(/<(\/link)>/,'<\1>').
gsub(/<(\/?en)>/,'<\1>')
dob
end
def xml_sem_block_paired(matched) # colon depth: many, recurs
matched=matched.gsub(/\b(au):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:au]} depth="many">\\2</sem:#{@ab[:au]}>}).
gsub(/\b(vol):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:vol]} depth="many">\\2</sem:#{@ab[:vol]}>}).
gsub(/\b(pub):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:pub]} depth="many">\\2</sem:#{@ab[:pub]}>}).
gsub(/\b(ref):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:ref]} depth="many">\\2</sem:#{@ab[:ref]}>}).
gsub(/\b(desc):\{(.+?)\}:\1\b/m,%{<sem:#{@ab[:desc]} depth="many">\\2</sem:#{@ab[:desc]}>}).
gsub(/\b(conv):\{(.+?)\}:\1\b/m,%{<sem:#{@ab[:conv]} depth="many">\\2</sem:#{@ab[:conv]}>}).
gsub(/\b(ct):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:ct]} depth="many">\\2</sem:#{@ab[:ct]}>}).
gsub(/\b(cty):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:cty]} depth="many">\\2</sem:#{@ab[:cty]}>}).
gsub(/\b(org):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:org]} depth="many">\\2</sem:#{@ab[:org]}>}).
gsub(/\b(dt):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:dt]} depth="many">\\2</sem:#{@ab[:dt]}>}).
gsub(/\b(n):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:n]} depth="many">\\2</sem:#{@ab[:n]}>}).
gsub(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m,'<sem:\1 depth="many">\2</sem:\1>')
end
def xml_semantic_tags(dob)
if @md.sem_tag
dob.obj.gsub!(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m) {|c| xml_sem_block_paired(c) }
dob.obj.gsub!(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m) {|c| xml_sem_block_paired(c) }
dob.obj.gsub!(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m) {|c| xml_sem_block_paired(c) }
dob.obj=dob.obj.gsub(/:\{(.+?)\}:au\b/m, %{<sem:#{@ab[:au]} depth="one">\\1</sem:#{@ab[:au]}>}).
gsub(/:\{(.+?)\}:n\b/m, %{<sem:#{@ab[:n]} depth="one">\\1</sem:#{@ab[:n]}>}).
gsub(/:\{(.+?)\}:ti\b/m, %{<sem:#{@ab[:ti]} depth="one">\\1</sem:#{@ab[:ti]}>}).
gsub(/:\{(.+?)\}:ref\b/m, %{<sem:#{@ab[:ref]} depth="one">\\1</sem:#{@ab[:ref]}>}).
gsub(/:\{(.+?)\}:desc\b/m, %{<sem:#{@ab[:desc]} depth="one">\\1</sem:#{@ab[:desc]}>}).
gsub(/:\{(.+?)\}:cty\b/m, %{<sem:#{@ab[:cty]} depth="one">\\1</sem:#{@ab[:cty]}>}).
gsub(/:\{(.+?)\}:org\b/m, %{<sem:#{@ab[:org]} depth="one">\\1</sem:#{@ab[:org]}>}).
gsub(/:\{(.+?)\}:([a-z]+(?:[_:.][a-z]+)*)/m,'<sem:\2 depth="one">\1</sem:\2>').
gsub(/;\{([^}]+(?![;]))\};ti\b/m, %{<sem:#{@ab[:ti]} depth="zero">\\1</sem:#{@ab[:ti]}>}).
gsub(/;\{([^}]+(?![;]))\};qt\b/m, %{<sem:#{@ab[:qt]} depth="zero">\\1</sem:#{@ab[:qt]}>}).
gsub(/;\{([^}]+(?![;]))\};ref\b/m, %{<sem:#{@ab[:ref]} depth="zero">\\1</sem:#{@ab[:ref]}>}).
gsub(/;\{([^}]+(?![;]))\};ed\b/m, %{<sem:#{@ab[:ed]} depth="zero">\\1</sem:#{@ab[:ed]}>}).
gsub(/;\{([^}]+(?![;]))\};v\b/m, %{<sem:#{@ab[:v]} depth="zero">\\1</sem:#{@ab[:v]}>}).
gsub(/;\{([^}]+(?![;]))\};desc\b/m, %{<sem:#{@ab[:desc]} depth="zero">\\1</sem:#{@ab[:desc]}>}).
gsub(/;\{([^}]+(?![;]))\};def\b/m, %{<sem:#{@ab[:def]} depth="zero">\\1</sem:#{@ab[:def]}>}).
gsub(/;\{([^}]+(?![;]))\};trans\b/m, %{<sem:#{@ab[:trans]} depth="zero">\\1</sem:#{@ab[:trans]}>}).
gsub(/;\{([^}]+(?![;]))\};y\b/m, %{<sem:#{@ab[:y]} depth="zero">\\1</sem:#{@ab[:y]}>}).
gsub(/;\{([^}]+(?![;]))\};ab\b/m, %{<sem:#{@ab[:ab]} depth="zero">\\1</sem:#{@ab[:ab]}>}).
gsub(/;\{([^}]+(?![;]))\};pg\b/m, %{<sem:#{@ab[:pg]} depth="zero">\\1</sem:#{@ab[:pg]}>}).
gsub(/;\{([^}]+(?![;]))\};fn?\b/m, %{<sem:#{@ab[:fn]} depth="zero">\\1</sem:#{@ab[:fn]}>}).
gsub(/;\{([^}]+(?![;]))\};mn?\b/m, %{<sem:#{@ab[:mn]} depth="zero">\\1</sem:#{@ab[:mn]}>}).
gsub(/;\{([^}]+(?![;]))\};ln?\b/m, %{<sem:#{@ab[:ln]} depth="zero">\\1</sem:#{@ab[:ln]}>}).
gsub(/;\{([^}]+(?![;]))\};in\b/m, %{<sem:#{@ab[:in]} depth="zero">\\1</sem:#{@ab[:in]}>}).
gsub(/;\{([^}]+(?![;]))\};uni\b/m, %{<sem:#{@ab[:uni]} depth="zero">\\1</sem:#{@ab[:uni]}>}).
gsub(/;\{([^}]+(?![;]))\};fac\b/m, %{<sem:#{@ab[:fac]} depth="zero">\\1</sem:#{@ab[:fac]}>}).
gsub(/;\{([^}]+(?![;]))\};inst\b/m, %{<sem:#{@ab[:inst]} depth="zero">\\1</sem:#{@ab[:inst]}>}).
gsub(/;\{([^}]+(?![;]))\};dept\b/m, %{<sem:#{@ab[:dpt]} depth="zero">\\1</sem:#{@ab[:dept]}>}).
gsub(/;\{([^}]+(?![;]))\};org\b/m, %{<sem:#{@ab[:org]} depth="zero">\\1</sem:#{@ab[:org]}>}).
gsub(/;\{([^}]+(?![;]))\};com?\b/m, %{<sem:#{@ab[:com]} depth="zero">\\1</sem:#{@ab[:com]}>}).
gsub(/;\{([^}]+(?![;]))\};cty\b/m, %{<sem:#{@ab[:cty]} depth="zero">\\1</sem:#{@ab[:cty]}>}).
gsub(/;\{([^}]+(?![;]))\};([a-z]+(?:[_:.][a-z]+)*)/m,'<sem:\2 depth="zero">\1</sem:\2>')
end
dob
end
end
end
module SiSU_XML_Tags #Format
require_relative 'dp' # dp.rb
include SiSU_Param
class RDF
include SiSU_Parts_XML
def initialize(md='',seg_name=[],tracker=0)
@full_title=@subtitle=@author=@subject=@description=@publisher=@contributor=@date=@date_created=@date_issued=@date_available=@date_valid=@date_modified=@type=@format=@identifier=@source=@language=@relation=@coverage=@rights=@copyright=@owner=@keywords=''
@md=md
@rdfurl=%{ rdf:about="http://www.jus.uio.no/lm/toc"\n}
if defined? @md.title.full \
and @md.title.full # DublinCore 1 - title
@rdf_title=%{ dc.title="#{seg_name}#{@md.title.full}"\n}
@full_title=%{ <meta name="dc.title" content="#{@md.title.full}" />\n}
end
if defined? @md.creator.author \
and @md.creator.author=~/\S+/ # DublinCore 2 - creator/author (author)
@rdf_author=%{ dc.author="#{@md.creator.author}"\n}
content=meta_content_clean(@md.creator.author)
@author=%{ <meta name="dc.author" content="#{content}" />\n}
end
if defined? @md.publisher \
and @md.publisher # DublinCore 5 - publisher (current copy published by)
@rdf_publisher=%{ dc.publisher="#{@md.publisher}"\n}
content=meta_content_clean(@md.publisher)
@publisher=%{ <meta name="dc.publisher" content="#{content}" />\n}
end
if defined? @md.creator.contributor \
and @md.creator.contributor=~/\S+/ # DublinCore 6 - contributor
@rdf_contributor=%{ dc.contributor="#{@md.creator.contributor}"\n}
content=meta_content_clean(@md.creator.contributor)
@contributor=%{ <meta name="dc.contributor" content="#{content}" />\n}
end
if defined? @md.date.published \
and @md.date.published=~/\S+/ # DublinCore 7 - date year-mm-dd
@rdf_date=%{ dc.date="#{@md.date.published}"\n}
@date=%{ <meta name="dc.date" content="#{@md.date.published}" #{@md.date_scheme} />\n} # fix @md.date_scheme
end
if defined? @md.date.created \
and @md.date.created=~/\S+/ # DublinCore 7 - date.created year-mm-dd
@rdf_date_created=%{ dc.date.created="#{@md.date.created}"\n}
@date_created=%{ <meta name="dc.date.created" content="#{@md.date.created}" #{@md.date_scheme} />\n}
end
if defined? @md.date.issued \
and @md.date.issued=~/\S+/ # DublinCore 7 - date.issued year-mm-dd
@rdf_date_issued=%{ dc.date.issued="#{@md.date.issued}"\n}
@date_issued=%{ <meta name="dc.date.issued" content="#{@md.date.issued}" #{@md.date_scheme} />\n}
end
if defined? @md.date.available \
and @md.date.available=~/\S+/ # DublinCore 7 - date.available year-mm-dd
@rdf_date_available=%{ dc.date.available="#{@md.date.available}"\n}
@date_available=%{ <meta name="dc.date.available" content="#{@md.date.available}" #{@md.date_scheme} />\n}
end
if defined? @md.date.valid \
and @md.date.valid=~/\S+/ # DublinCore 7 - date.valid year-mm-dd
@rdf_date_valid=%{ dc.date.valid="#{@md.date.valid}"\n}
@date_valid=%{ <meta name="dc.date.valid" content="#{@md.date.valid}" #{@md.date_scheme} />\n}
end
if defined? @md.date.modified \
and @md.date.modified=~/\S+/ # DublinCore 7 - date.modified year-mm-dd
@rdf_date_modified=%{ dc.date.modified="#{@md.date.modified}"\n}
@date_modified=%{ <meta name="dc.date.modified" content="#{@md.date.modified}" #{@md.date_scheme} />\n}
end
if defined? @md.rights.all \
and @md.rights.all # DublinCore 15 - rights
@rdf_rights=%{ dc.rights="#{@md.rights.all}"\n}
content=meta_content_clean(@md.rights.all)
@rights=%{ <meta name="dc.rights" content="#{content}" />\n}
end
if defined? @md.classify.subject \
and @md.classify.subject=~/\S+/ # DublinCore 3 - subject (us library of congress, eric or udc, or schema???)
@rdf_subject=%{ dc.subject="#{@md.classify.subject}"\n}
content=meta_content_clean(@md.classify.subject)
@subject=%{ <meta name="dc.subject" content="#{content}" />\n}
end
if defined? @md.notes.description \
and @md.notes.description=~/\S+/ # DublinCore 4 - description
@rdf_description=%{ dc.description="#{@md.notes.description}"\n}
content=meta_content_clean(@md.notes.description)
@description=%{ <meta name="dc.description" content="#{content}" />\n}
end
if defined? @md.notes.coverage \
and @md.notes.coverage=~/\S+/ # DublinCore 14 - coverage
@rdf_coverage=%{ dc.coverage="#{@md.notes.coverage}"\n}
content=meta_content_clean(@md.notes.coverage)
@coverage=%{ <meta name="dc.coverage" content="#{content}" />\n}
end
if defined? @md.notes.relation \
and @md.notes.relation=~/\S+/ # DublinCore 13 - relation
@rdf_relation=%{ dc.relation="#{@md.notes.relation}"\n}
content=meta_content_clean(@md.notes.relation)
@relation=%{ <meta name="dc.relation" content="#{content}" />\n}
end
if defined? @md.notes.type \
and @md.notes.type # DublinCore 8 - type (genre eg. report, convention etc)
@rdf_type=%{ dc.type="#{@md.notes.type}"\n}
content=meta_content_clean(@md.notes.type)
@type=%{ <meta name="dc.type" content="#{content}" />\n}
end
if defined? @md.notes.format \
and @md.notes.format=~/\S+/ # DublinCore 9 - format (use your mime type)
@rdf_format=%{ dc.format="#{@md.notes.format}"\n}
content=meta_content_clean(@md.notes.format)
@format=%{ <meta name="dc.format" content="#{content}" />\n}
end
#if defined? @md.identifier.sisupod \
#and @md.identifier.sisupod=~/\S+/ # DublinCore 10 - identifier (your identifier, could use urn which is free)
# @rdf_identifier=%{ dc.identifier="#{@md.identifier.sisupod}"\n}
# content=meta_content_clean(@md.identifier.sisupod)
# @identifier=%{ <meta name="dc.identifier" content="#{content}" />\n}
#end
if defined? @md.original.source \
and @md.original.source=~/\S+/ # DublinCore 11 - source (document source)
@rdf_source=%{ dc.source="#{@md.original.source}"\n}
content=meta_content_clean(@md.original.source)
@source=%{ <meta name="dc.source" content="#{content}" />\n}
end
if defined? @md.title.language \
and @md.title.language=~/\S+/ # DublinCore 12 - language (English)
@rdf_language=%{ dc.language="#{@md.title.language}"\n}
@language=%{ <meta name="dc.language" content="#{@md.title.language}" />\n}
end
if defined? @md.original.language \
and @md.original.language=~/\S+/
@rdf_language_original=%{ dc.language="#{@md.original.language}"\n}
@language_original=%{ <meta name="dc.language" content="#{@md.original.language}" />\n}
end
content=meta_content_clean(@md.keywords)
@keywords=%{ <meta name="keywords" content="#{content}" />\n} if @md.keywords
end
def meta_content_clean(content='')
content=if not content.nil?
content=content.tr('"',"'").
gsub(/&/,'&')
else content
end
end
def rdfseg #segHead
rdftoc
end
def comment_xml(extra='')
generator="Generated by: #{@md.project_details.project} #{@md.project_details.version} of #{@md.project_details.date_stamp} (#{@md.project_details.date})" if @md.project_details.version
lastdone="Last Generated on: #{Time.now}"
rubyv="Ruby version: #{@md.ruby_version}"
sc=if @md.sc_info
"Source file: #{@md.sc_filename} version: #{@md.sc_number} of: #{@md.sc_date}"
else ''
end
if extra.empty?
<<WOK
<!-- Document processing information:
,* #{generator}
,* #{rubyv}
,* #{sc}
,* #{lastdone}
,* SiSU http://www.jus.uio.no/sisu
-->
WOK
else
<<WOK
<!-- Document processing information:
,* #{extra}
,* #{generator}
,* #{rubyv}
,* #{sc}
,* #{lastdone}
,* SiSU http://www.jus.uio.no/sisu
-->
WOK
end
end
def comment_xml_sax
desc='SiSU XML, SAX type representation'
comment_xml(desc)
end
def comment_xml_node
desc='SiSU XML, Node type representation'
comment_xml(desc)
end
def comment_xml_dom
desc='SiSU XML, DOM type representation'
comment_xml(desc)
end
def metatag_html #values strung together, because some empty, and resulting output (line breaks) is much better
<<WOK
#{@full_title}#{@subtitle}#{@author}#{@subject}#{@description}#{@publisher}#{@contributor}#{@date}#{@date_created}#{@date_issued}#{@date_available}#{@date_valid}#{@date_modified}#{@type}#{@format}#{@identifier}#{@source}#{@language}#{@relation}#{@coverage}#{@rights}#{@copyright}#{@owner}
#{SiSU_Proj_XML::Bits.new.txt_generator}
#{the_png.ico}
WOK
end
end
end
module SiSU_Tables
require_relative 'xml_tables' # xml_tables.rb
end
__END__
#+END_SRC
** xml_tables.rb
#+BEGIN_SRC ruby :tangle "../lib/sisu/xml_tables.rb"
# <<sisu_document_header>>
module SiSU_Tables
class Table #_xml
@@tablehead=0
@@tablefoot=[] #watch #bug??? #check was @@tablefoot
def initialize(one,ocn='')
@one,@parablock,@ocn=one,one,ocn
end
def table_split #% used but, no longer operational, revisit
@new_content=[]
@one.split(/\n/).each do |parablock|
table=TableXML.new("#{parablock}\n")
@new_content << table.table
end
@new_content.join
end
end
class TableXML <Table
@@tablehead=0
@@tablefoot=[]
def initialize(one,ocn='')
@one,@parablock,@ocn=one,one,ocn
end
def table
m=@parablock[/<!f(.+?)!>/,1]
@@tablefoot << m if m
@parablock=@parablock.gsub(/<!f.+?!>/,'')
@@tablehead=1 if @parablock =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}/u
if @parablock =~/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}/u
@parablock=@parablock.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+?#{Mx[:tc_p]}~(\d+);\w\d+;\w\d+#{Mx[:gr_c]}/u,
%{\n<ocn>#{@ocn}</ocn><table summary="normal text css" width="100%" border="0" bgcolor="white" cellpadding="2" align="center">})
end
if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/
tablefoot=[]
@@tablefoot.each {|x| tablefoot << ''}
@@tablefoot=[]
end
if @@tablehead==1
if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u
@parablock=@parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,
%{<tr>
<td width="\\1%" valign="top"><b>}).
gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,
%{</b></td><td width="\\1%" valign="top"><b>}).
gsub(/#{Mx[:tc_c]}/,"</b>\n</td>\n</tr>")
@@tablehead=0
end
@parablock
else
@parablock=@parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,
%{<tr>
<td width="\\1%" valign="top">}).
gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,
%{
</td>
<td width="\\1%" valign="top">}).
gsub(/#{Mx[:tc_c]}/,"\n</td>\n</tr>\n")
end
@parablock
end
end
class TableXMLdocbook
@@tablehead=0
@@tablefoot=[] #watch
def initialize(table,id='')
@table_obj,@id=table,id
end
def spaces
Ax[:spaces]
end
def table
table_obj=@table_obj
if table_obj.obj !~/^<table\s/m
table_obj=table_rows_and_columns_array(table_obj)
else p __LINE__; p caller
end
table_obj
end
def table_rows_and_columns_array(table_obj) # provides basic (x)html table
table_rows,nr=[],0
table_obj.obj.split(Mx[:tc_c]).each do |table_row|
table_row_with_columns=table_row.split(Mx[:tc_p])
trc,nc=[],0
table_row_with_columns.each do |c|
c=c.gsub(/^(?:~| )$/,''). # tilde / empty cell
gsub(/ /,' ').
gsub(/<:br>/,'<br />')
trc <<= if table_obj.head_ and nr==0
%{#{spaces*6}<entry>#{c}</entry>\n}
else %{#{spaces*6}<entry>#{c}</entry>\n}
end
nc+=1
end
trc=(trc.is_a?(Array)) ? trc.flatten.join : trc
trc = if table_obj.head_ and nr==0
"#{spaces*4}<thead>\n#{spaces*5}<row>\n#{trc}#{spaces*5}</row>\n#{spaces*4}</thead>\n#{spaces*4}<tbody>\n"
else
"#{spaces*5}<row>\n#{trc}#{spaces*5}</row>\n"
end
nr+=1
table_rows << trc
end
tbody_close=if table_obj.head_
"#{spaces*4}</tbody>"
else ''
end
table_rows=table_rows.flatten.join
# include table_id <table id=''>
table_obj.obj=%{#{spaces*3}<para #{@id}>
#{spaces*4}<table>
#{spaces*4}<tgroup cols="#{table_obj.cols}" align="char">
#{table_rows}#{tbody_close}
#{spaces*4}</tgroup>
#{spaces*4}</table>
#{spaces*3}</para>}
table_obj
end
end
class TableXMLexp <Table
@@tablehead=0
@@tablefoot=[]
def initialize(one)
@one,@parablock=one,one
end
def table_close
'</td></tr>
</table>'
end
def margin_numless
'</td><td width="4%" align="right" valign="top">'
end
def table_head(inf)
%{<table summary="normal text css" width="100%" border="0" bgcolor="white" cellpadding="2" align="center">
<tr>
<td valign="top" align="justify">
<a name="#{inf}"></a>
</td>
<td>
<table summary="normal text css" width="100%" border="0" bgcolor="white" cellpadding="2" align="center">}
end
def table_end(tablefoot='')
%{</table>#{the_margin_numless}#{the_margin_numless} #{the_table_close}
#{tablefoot}}
end
def table_row(inf,h=false)
bold=h ? '<b>' : ''
%{
<tr>
<td width="#{inf}%" valign="top">#{bold}}
end
def table_cell(inf,h=false)
if h; %{</b></td><td width="#{inf}%" valign="top"><b>}
else %{</td><td width="#{inf}%" valign="top">}
end
end
def table_row_close(h=false)
bold_close=h ? '<b>' : ''
"#{bold_close}</td></tr>"
end
def table
m=@parablock[/<!f(.+?)!>/,1]
@@tablefoot << m if m
@parablock=@parablock.gsub(/<!f.+?!>/,'')
@@tablehead=1 if @parablock =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}/u
if @parablock =~/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+?#{Mx[:tc_p]}~(\d+);\w\d+;\w\d+#{Mx[:gr_c]}/u
@parablock=table_head($1)
end
if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/
tablefoot=[]
@@tablefoot.each {|x| tablefoot << ''}
@@tablefoot=[]
if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/
@parablock=table_end
end
end
if @@tablehead==1
if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u
if @parablock =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u
@parablock=@parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1,true))
end
if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u
@parablock=@parablock.gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1,true))
end
if @parablock =~/#{Mx[:tc_c]}/
@parablock=@parablock.gsub(/#{Mx[:tc_c]}/,table_row_close(true))
end
@@tablehead=0
end
@parablock
else
if @parablock =~/^#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u
@parablock=@parablock.gsub(/^#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1))
end
if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u
@parablock=@parablock.gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1))
end
if @parablock =~/#{Mx[:tc_c]}/
@parablock=@parablock.gsub(/#{Mx[:tc_c]}/,table_row_close)
end
@parablock
end
@parablock
end
end
end
__END__
#+END_SRC
** xml_format.rb
#+BEGIN_SRC ruby :tangle "../lib/sisu/xml_format.rb"
# <<sisu_document_header>>
module SiSU_XML_Format
require_relative 'dp' # dp.rb
require_relative 'xml_parts' # xml_parts.rb
include SiSU_Param
class ParagraphNumber
def initialize(md,paranum)
@md=md
@paranum=(paranum ? (/(\d+)/m.match(paranum)[1]) : nil)
end
def display
p_num_display=if @paranum
@paranum.gsub(/(\d+)/,
'<font size="1" color="#777777">' +
' \1</font>')
else ''
end
p_num_display
end
def name
p_num_name=@paranum.gsub(/(\d+)/,'<a name="\1"></a>')
p_num_name
end
def goto
p_num_goto=@paranum.gsub(/(\d+)/,'<a href="#\1">')
p_num_goto
end
end
class HeadInformation
include SiSU_Parts_XML
def initialize #dc rdf
@full_title=@subtitle=@author=@subject=@description=@publisher=@contributor=@date=@type=@format=@identifier=@source=@language=@relation=@coverage=@rights=@copyright=@owner=@keywords=''
@md=@@md
# DublinCore 1 - title
@rdfurl=%{ rdf:about="http://www.jus.uio.no/lm/toc"\n}
if defined? @md.title.full \
and @md.title.full # DublinCore 1 - title
@rdf_title=%{ dc.title="#{seg_name}#{@md.title.full}"\n}
@full_title=%{<meta name="dc.title" content="#{seg_name}#{@md.title.full}" />\n}
end
if defined? @md.creator.author \
and @md.creator.author # DublinCore 2 - creator/author (author)
@rdf_author=%{ dc.author="#{@md.creator.author}"\n}
@author=%{<meta name="dc.author" content="#{@md.creator.author}" />\n}
end
if defined? @md.classify.subject \
and @md.classify.subject=~/\S+/ # DublinCore 3 - subject (us library of congress, eric or udc, or schema???)
@rdf_subject=%{ dc.subject="#{@md.classify.subject}"\n}
@subject=%{<meta name="dc.subject" content="#{@md.classify.subject}" />\n}
end
if defined? @md.notes.description \
and @md.notes.description=~/\S+/ # DublinCore 4 - description
@rdf_description=%{ dc.description="#{@md.notes.description}"\n}
@description=%{<meta name="dc.description" content="#{@md.notes.description}" />\n}
end
if defined? @md.publisher \
and @md.publisher=~/\S+/ # DublinCore 5 - publisher (current copy published by)
@rdf_publisher=%{ dc.publisher="#{@md.publisher}"\n}
@publisher=%{<meta name="dc.publisher" content="#{@md.publisher}" />\n}
end
if defined? @md.creator.contributor \
and @md.creator.contributor=~/\S+/ # DublinCore 6 - contributor
@rdf_contributor=%{ dc.contributor="#{@md.creator.contributor}"\n}
@contributor=%{<meta name="dc.contributor" content="#{@md.creator.contributor}" />\n}
end
if defined? @md.date.published \
and @md.date.published # DublinCore 7 - date year-mm-dd
@rdf_date=%{ dc.date="#{@md.date.published}"\n}
@date=%{<meta name="dc.date" content="#{@md.date.published}" #{@md.date_scheme} />\n}
end
if defined? @md.date.created \
and @md.date.created # DublinCore 7 - date.created year-mm-dd
@rdf_date_created=%{ dc.date.created="#{@md.date.created}"\n}
@date_created=%{<meta name="dc.date.created" content="#{@md.date.created}" #{@md.date_created_scheme} />\n}
end
if defined? @md.date.issued \
and @md.date.issued # DublinCore 7 - date.issued year-mm-dd
@rdf_date_issued=%{ dc.date.issued="#{@md.date.issued}"\n}
@date_issued=%{<meta name="dc.date.issued" content="#{@md.date.issued}" #{@md.date_issued_scheme} />\n}
end
if defined? @md.date.available \
and @md.date.available # DublinCore 7 - date.available year-mm-dd
@rdf_date_available=%{ dc.date.available="#{@md.date.available}"\n}
@date_available=%{<meta name="dc.date.available" content="#{@md.date.available}" #{@md.date_available_scheme} />\n}
end
if defined? @md.date.valid \
and @md.date.valid # DublinCore 7 - date.valid year-mm-dd
@rdf_date_valid=%{ dc.date.valid="#{@md.date.valid}"\n}
@date_valid=%{<meta name="dc.date.valid" content="#{@md.date.valid}" #{@md.date_valid_scheme} />\n}
end
if defined? @md.date.modified \
and @md.date.modified # DublinCore 7 - date.modified year-mm-dd
@rdf_date_modified=%{ dc.date.modified="#{@md.date.modified}"\n}
@date_modified=%{<meta name="dc.date.modified" content="#{@md.date.modified}" #{@md.date_modified_scheme} />\n}
end
if defined? @md.notes.coverage \
and @md.notes.coverage=~/\S+/ # DublinCore 14 - coverage
@rdf_coverage=%{ dc.coverage="#{@md.notes.coverage}"\n}
@coverage=%{<meta name="dc.coverage" content="#{@md.notes.coverage}" />\n}
end
if defined? @md.notes.relation \
and @md.notes.relation=~/\S+/ # DublinCore 13 - relation
@rdf_relation=%{ dc.relation="#{@md.notes.relation}"\n}
@relation=%{<meta name="dc.relation" content="#{@md.notes.relation}" />\n}
end
if defined? @md.notes.type \
and @md.notes.type # DublinCore 8 - type (genre eg. report, convention etc)
@rdf_type=%{ dc.type="#{@md.notes.type}"\n}
@type=%{<meta name="dc.type" content="#{@md.notes.type}" />\n}
end
if defined? @md.notes.format \
and @md.notes.format=~/\S+/ # DublinCore 9 - format (use your mime type)
@rdf_format=%{ dc.format="#{@md.notes.format}"\n}
@format=%{<meta name="dc.format" content="#{@md.notes.format}" />\n}
end
#if defined? @md.identifier.sisupod \
#and @md.identifier.sisupod=~/\S+/ # DublinCore 10 - identifier (your identifier, could use urn which is free)
# @rdf_identifier=%{ dc.identifier="#{@md.identifier.sisupod}"\n}
# @identifier=%{<meta name="dc.identifier" content="#{@md.identifier.sisupod}" />\n}
#end
if defined? @md.original.source \
and @md.original.source=~/\S+/ # DublinCore 11 - source (document source)
@rdf_source=%{ dc.source="#{@md.original.source}"\n}
@source=%{<meta name="dc.source" content="#{@md.source}" />\n}
end
if defined? @md.original.language \
and @md.original.language=~/\S+/ # DublinCore 12 - language (English)
@rdf_language=%{ dc.language="#{@md.original.title}"\n}
@language=%{<meta name="dc.language" content="#{@md.language[:name]}" />\n}
end
if defined? @md.rights.all \
and @md.rights.all=~/\S+/ # DublinCore 15 - rights
rights=meta_content_clean(@md.rights.all)
copyright=meta_content_clean(@md.rights.copyright.all)
@rdf_rights=%{ dc.rights="#{rights}"\n}
@rights=%{<meta name="dc.rights" content="#{rights}" />\n}
end
@copyright=%{<meta name="copyright" content="#{copyright}" />\n} \
if @md.rights.copyright.all # possibly redundant see dc.rights
@owner=%{<meta name="owner" content="#{@md.owner}" />\n} if @md.owner
@keywords=%{<meta name="keywords" content="#{@md.keywords}" />\n} if @md.keywords
@index='index'
end
def meta_content_clean(content='')
content=if not content.nil?
content=content.tr('"',"'").
gsub(/&/,'&')
content=SiSU_XML_Munge::Trans.new(@md).char_enc.utf8(content)
else content
end
end
def table_close
'</font> </td></tr></table>'
end
def toc_head
<<WOK
<html>
<head>
<title>#{@md.html_title}</title>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<rdf:Description
#{@rdfurl}
#{@rdf_title}
#{@rdf_subtitle}
#{@rdf_author}
#{@rdf_subject}
#{@rdf_description}
#{@rdf_publisher}
#{@rdf_contributor}
#{@rdf_date}
#{@rdf_date_created}
#{@rdf_date_issued}
#{@rdf_date_available}
#{@rdf_date_valid}
#{@rdf_date_modified}
#{@rdf_type}
#{@rdf_format}
#{@rdf_identifier}
#{@rdf_source}
#{@rdf_language}
#{@rdf_relation}
#{@rdf_coverage}
#{@rdf_rights}
/>
</rdf:RDF>
#{@full_title}
#{@author}
#{@subject}
#{@description}
#{@publisher}
#{@contributor}
#{@date}
#{@date_created}
#{@date_issued}
#{@date_available}
#{@date_valid}
#{@date_modified}
#{@type}
#{@format}
#{@identifier}
#{@source}
#{@language}
#{@relation}
#{@coverage}
#{@rights}
#{@copyright}
#{@owner}
#{@png.ico}
#{@txt.generator}
#{@js.head}
\n</head>
#{@color.body}
#{@font.css_table_file}
<a name="top"></a>
<a name="up"></a>
<a name="start"></a>
#{@js.top}
WOK
end
end
class FormatTextObject
include SiSU_Parts_XML
attr_accessor :md,:txt,:format,:paranum,:p_num,:para_id,:headname,:font
def initialize(md,dob)
@md,@dob=md,dob
if @dob[:ocn]=~/\d+/
@paranum=/(\d+)/m.match(@dob[:ocn])[1]
@headname=''
@headname=%{<a name="h#{dob.name}"></a>} if defined? dob.name
@p_num=SiSU_XML_Format::ParagraphNumber.new(@md,dob.ocn)
end
rgx=/^[1-6-]~{1,2}/ #watch
@lnk_url=@lnk_url.gsub(rgx,'') if @lnk_url =~rgx
rgx=/~\{\d+\s+(.+?)\}~/
@lnk_url=@lnk_url.gsub(rgx,'\1') if @lnk_url =~rgx
end
def scr_endnote_body
"<endnote>#{@txt}</endnote> "
end
end
class FormatScroll < FormatTextObject
def initialize(md,dob)
super(md,dob)
end
def heading_body
%{<p class="norm">#{@p_num.name}#{@headname}#{@dob.obj} </p>} +
%{<p class="paranum"><font size="1" color="#777777"> #{@dob.ocn}</font></p>\n}
end
def heading_body0
%{<h1 class="norm">#{@p_num.name}#{@headname}#{@dob.obj}</h1>} +
%{<p class="paranum"><font size="1" color="#777777"> #{@dob.ocn}</font></p>\n}
end
def heading_body1
%{<h2 class="norm">#{@p_num.name}#{@headname}#{@dob.obj}</h2>} +
%{<p class="paranum"><font size="1" color="#777777"> #{@dob.ocn}</font></p>\n}
end
def heading_body2
%{<h3 class="norm">#{@p_num.name}#{@headname}#{@dob.obj}</h3>} +
%{<p class="paranum"><font size="1" color="#777777"> #{@dob.ocn}</font></p>\n}
end
def heading_body3
%{<h4 class="norm">#{@p_num.name}#{@headname}#{@dob.obj}</h4>} +
%{<p class="paranum"><font size="1" color="#777777"> #{@dob.ocn}</font></p>\n}
end
def heading_body4
%{<h5 class="norm">#{@p_num.name}#{@headname}#{@dob.obj}</h5>} +
%{<p class="paranum"><font size="1" color="#777777"> #{@dob.ocn}</font></p>\n}
end
def heading_body5
%{<h6 class="norm">#{@p_num.name}#{@headname}#{@dob.obj}</h6>} +
%{<p class="paranum"><font size="1" color="#777777"> #{@dob.ocn}</font></p>\n}
end
def heading_body6
%{<h7 class="norm">#{@p_num.name}#{@headname}#{@dob.obj}</h7>} +
%{<p class="paranum"><font size="1" color="#777777"> #{@dob.ocn}</font></p>\n}
end
end
class ParagraphNumber
def initialize(md,ocn)
@md,@ocn=md,ocn.to_s
@ocn ||=''
end
def ocn_display
@make=SiSU_Env::ProcessingSettings.new(@md)
if @make.build.ocn?
ocn_class='ocn'
if @ocn.to_i==0
@ocn.gsub(/^(\d+|)$/,
%{<label class="#{ocn_class}"><a name="#{@ocn}"> </a></label>})
else
@ocn.gsub(/^(\d+|)$/,
%{<label class="#{ocn_class}"><a name="#{@ocn}">\\1</a></label>})
end
else
ocn_class='ocn_off'
@ocn.gsub(/^(\d+|)$/,
%{<label class="#{ocn_class}"> </label>})
end
end
def name
%{<a name="#{@ocn}"></a>}
end
def id #w3c? "tidy" complains about numbers as identifiers ! annoying
%{id="o#{@ocn}"}
end
def goto
%{<a href="##{@ocn}">}
end
end
class HeadInformation
include SiSU_Parts_XML
attr_reader :md,:sfx,:pdf,:rdf,:vz
def initialize(md)
@md=md
@rdf=SiSU_XML_Tags::RDF.new(md)
# DublinCore 1 - title
@stylesheet=SiSU_Style::CSS_HeadInfo.new(md).stylesheet
@seg_name_html=(SiSU_HTML::Source::Seg.new.seg_name_html || [])
@seg_name_html_tracker=(SiSU_HTML::Source::Seg.new.seg_name_html_tracker || [])
@index='index'
@metalink='#metadata'
@tocband_scroll,@tocband_segtoc=nil,nil
end
def doc_type
%{<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">\n}
end
def table_close
%{ </font>
#{the_table_close}}
end
def html_close #moved
%{</body>
</html>}
end
end
class XML
end
class FormatTextObject
include SiSU_Parts_XML
attr_accessor :md,:dob,:txt,:ocn,:format,:table,:link,:linkname,:paranum,:p_num,:headname,:banner,:url
def initialize(md,t_o)
@md,@t_o=md,t_o
if t_o.is_a?(Hash)
@txt =t_o[:txt] || nil
@ocn =t_o[:ocn] || nil
@ocn_display =t_o[:ocn_display] || nil
@headname =t_o[:headname] || nil
@trailer =t_o[:trailer] || nil
@endnote_part_a =t_o[:endnote_part_a] || nil
@endnote_part_b =t_o[:endnote_part_b] || nil
@lnk_url =t_o[:lnk_url] || nil
@lnk_txt =t_o[:lnk_txt] || nil
@format =t_o[:format] || nil
@target =t_o[:target] || nil #occasionally passed but not used
elsif t_o.class.inspect =~/Object/
@txt=if defined? t_o.obj; t_o.obj
else nil
end
@ocn=if defined? t_o.ocn; t_o.ocn.to_s
else nil
end
@headname=if t_o.is==:heading and defined? t_o.name; t_o.name
else nil
end
else
if @md.opt.act[:maintenance][:set]==:on
p __FILE__ << ':' << __LINE__.to_s
p t_o.class
p caller
end
end
if defined? @t_o.ocn
ocn=((@t_o.ocn.to_s =~/\d+/) ? @t_o.ocn : nil)
@p_num=ParagraphNumber.new(@md,ocn)
end
if @format and not @format.empty?
if @format=~/^\d:(\S+)/ #need more reliable marker #if @format =~ /#{Rx[:lv]}/
headname=$1 #format[/\d~(\S+)/m,1]
@headname=if headname =~/^[a-zA-Z]/; %{<a name="#{headname}" id="#{headname}"></a>} #consider: h_#{headname}
else %{<a name="h#{headname}" id="h#{headname}"></a>}
end
end
end
@dob=t_o if defined? t_o.is
end
def endnote_body
%{
<p class="endnote">
#{@txt}
</p>
}
end
def endnote_body_indent
%{
<p class="endnote_indent">
#{@txt}
</p>
}
end
def no_paranum
%{
<div class="substance">
<label class="ocn"> </label>
<p class="norm">
#{@txt}
</p>
</div>
}
end
def para_form_css(tag,attrib) # regular paragraphs shaped here
ul=ulc=''
ul,ulc="<ul>\n ","\n </ul>" if @tag =~/li/
%{
<div class="substance">
#{@p_num.ocn_display}
#{ul}<#{tag} class="#{attrib}" #{@p_num.id}>
#{@txt}
</#{tag}>#{ulc}
</div>
}
end
def para
para_form_css('p','norm')
end
def code
para_form_css('p','code')
end
def center
para_form_css('p','center')
end
def bold
para_form_css('p','bold')
end
def bullet
para_form_css('li','bullet')
end
def format(tag,attrib)
para_form_css(tag,attrib)
end
def heading_normal(tag,attrib)
%{
<div class="substance">
#{@p_num.ocn_display}
<#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name}
#{@headname}#{@txt}
</#{tag}>
</div>
}
end
def heading_body
heading_normal('p','norm')
end
def heading_body0
heading_normal('h1','norm')
end
def heading_body1
heading_normal('h1','norm')
end
def heading_body2
heading_normal('h2','norm')
end
def heading_body3
heading_normal('h3','norm')
end
def heading_body4
heading_normal('h4','norm')
end
def heading_body5
heading_normal('h5','norm')
end
def heading_body6
heading_normal('h6','norm')
end
def heading_body7
heading_normal('h7','norm')
end
def title_header(tag,attrib)
%{
<div class="content">
<#{tag} class="#{attrib}">
#{@txt}
</#{tag}>
</div>
}
end
def title_header1
title_header('h1','tiny')
end
def title_header2
title_header('h2','tiny')
end
def title_header3
title_header('h3','tiny')
end
def title_header4
''
end
def title_header4_old
%{
<div class="substance">
<label class="ocn"> </label>
<h4 class="banner">
#{@txt}
</h4>
</div>
}
end
def dl #check :trailer
"<dl><b>#{@txt}</b> #{@trailer}</dl>"
end
def table_css_end #<!TZ!>
'</table>
</p>
</div>'
end
def gsub_body
#fix
@txt=case @txt
when /^\s*\((i+|iv|v|vi+|ix|x|xi+)\)/
@txt.gsub(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'<b>(\1)</b>').
gsub(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1<b>(\2)</b>')
when /^\s*\(?(\d|[a-z])+\)/
@txt.gsub(/^\((\d+|[a-z])+\)/,'<b>(\1)</b>').
gsub(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((\d+|[a-z])+\)/,'\1<b>(\2)</b>')
when /^\s*\d{1,3}\.\s/
@txt.gsub(/^\s*(\d+\.)/,'<b>\1</b>')
when /^\s*[A-Z]\.\s/
@txt.gsub(/^\s*([A-Z]\.)/,'<b>\1</b>')
else @txt
end
end
def bold_para
%{#{the_margin.txt_0}
<p class="bold">
#{@txt}
</p>
#{the_margin.num_css}
#{the_table_close}}
end
def bold_header
@txt=@txt.gsub(/[1-9]~(\S+)/,'<a name="\1"></a>').
gsub(/[1-9]~/,'')
%{<p class="bold">
#{@txt}
</p>
#{the_margin.num_css}
#{the_table_close}}
end
def toc_head_copy_at
%{<p class="center">#{@txt}</p>\n}
end
def center
%{<p class="center">#{@txt}</p>\n}
end
def bold
%{<p class="bold">#{@txt}</p>\n}
end
def center_bold
%{<p class="centerbold">#{@txt}</p>\n}
end
end
class FormatScroll < FormatTextObject
include SiSU_Parts_XML
def initialize(md,txt)
super(md,txt)
end
end
class FormatSeg < FormatTextObject
def initialize(md,txt)
super(md,txt)
end
def navigation_toc_lev1_advert
%{#{@banner.home_button}\n
<center>
#{@txt}
#{@two}
</a></center><p />}
end
def navigation_toc_lev1
%{#{@banner.nav_toc}}
end
def navigation_toc_lev2 #change bold use css
%{<p />
<table summary="navigation segment level 2">
<tr><td width ="20">
</td>
<td>
<font size="3" #{the_font.set_face}>
<b>#{@txt}</b>
</font>
</p>
#{the_table_close}}
end
def navigation_toc_lev3 #change bold use css
%{<p />
<table summary="navigation segment level 3">
<tr><td width ="20">
</td>
<td>
<font size="3" #{the_font.set_face}>
<b>#{@txt}</b>
</font>
</p>
#{the_table_close}}
end
def navigation_toc_lev4
%{<table summary="navigation segment level 4">
<tr><td width ="80">
</td>
<td>
<p>
#{@txt}
</p>
#{the_table_close}}
end
def navigation_toc_lev5
end
def navigation_toc_lev6
end
def endnote_seg_body(fn='') #FIX #url construction keep within single line... BUG WATCH 200408
fn='doc' if fn.empty? #you may wish to reconsider, sends to 'doc' where no segment info # Sfx[:html] or Sfx[:xhtml] ?
%{
<p class="endnote">
#{@endnote_part_a}#{fn}#{@md.lang_code_insert}#{Sfx[:html]}#{@endnote_part_b}
</p>
}
end
def subtoc_lev(tag,attrib)
txt=if @txt \
and @txt =~/<\/?i>|<a\s+name="\S+?">/mi
@txt.gsub(/<\/?i>|<a\s+name="\S+?">/mi,'') #removes name markers from subtoc, go directly to substantive text
else @txt
end
note=''
if txt =~/(#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}\s*)/m
note=$1
note=note.gsub(/[\n\s]+/m,' ')
txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ').
gsub(/<a[\n\s]+name="-\d+"[\n\s]+href="#_\d+"> <sup>\d+<\/sup> /m,'')
end
%{<#{tag} class="#{attrib}">
<a href="##{@ocn}"><i>#{txt}</i></a> #{note}
</#{tag}>}
end
def subtoc_lev5
subtoc_lev('h5','subtoc') if @txt
end
def subtoc_lev6
subtoc_lev('h6','subtoc') if @txt
end
def subtoc_lev7
subtoc_lev('h7','subtoc') if @txt
end
#% para sisu
def header_sub(tag,attrib)
@txt=@txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ')
%{
<div class="substance">
#{@p_num.ocn_display}
<#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} #{@headname}
#{@txt}
</#{tag}>
</div>
}
end
def header4
%{
<div class="substance">
#{@p_num.ocn_display}
<h1 class="norm" #{@p_num.id}>#{@p_num.name}
#{@t_o[:format]}
#{@txt}
</h1>
</div>
}
end
def header5
header_sub('p','bold')
end
def header6
header_sub('p','bold')
end
def header7
header_sub('p','bold')
end
def navigation_header4
%{<table summary="navigation segment header 4" width=100% bgcolor="#08163f" border="0">
<tr><td align="center">
<p class="bold">
#{@txt}
</p>
#{the_table_close}}
end
def navigation_header5
%{<p class="bold">
#{@txt}
</p>}
end
def navigation_header6
%{<p class="bold">
#{@txt}
</p>}
end
def navigation_header7
%{<p class="bold">
#{@txt}
</p>}
end
def navigation_center
"<center>#{@txt}</center>"
end
end
class FormatToc < FormatTextObject
def initialize(md,txt)
super(md,txt)
end
def links_guide
%{ <li class="doc">
<a href="#{@lnk_url}" target="_top">
#{@lnk_txt}
</a>
</li>
}
end
def lev(tag,attrib)
if @txt
%{<#{tag} class="#{attrib}">
#{@txt}
</#{tag}>
}
else ''
end
end
def lev1
lev('h1','toc')
end
def lev2
lev('h2','toc')
end
def lev3
lev('h3','toc')
end
def lev4
lev('h4','toc')
end
def lev5
lev('h5','toc')
end
def lev6
lev('h6','toc')
end
def lev7
lev('h7','toc')
#lev('b','toc')
end
def lev0 #docinfo
lev('h0','toc')
end
def mini_lev1
lev('h1','minitoc')
end
def mini_lev2
lev('h2','minitoc')
end
def mini_lev3
lev('h3','minitoc')
end
def mini_lev4
lev('h4','minitoc')
end
def mini_lev5
lev('h5','minitoc')
end
def mini_lev6
lev('h6','minitoc')
end
def mini_lev7
lev('h7','minitoc')
end
def mini_lev0 #docinfo
lev('h0','minitoc')
end
def mini_tail
%{
<h4 class="minitoc">
<a href="sisu_manifest.html">Manifest (alternative outputs)</a>
</h4>
}
end
def mini_concord_tail
%{
<h4 class="minitoc">
<a href="concordance.html">Concordance (wordlist)</a>
</h4>
<h4 class="minitoc">
<a href="sisu_manifest.html">Manifest (alternative outputs)</a>
</h4>
}
end
end
class XML
end
end
__END__
,** Notes: tidy -xml index.xml >> index.tidy
#+END_SRC
** xml_md_oai_pmh_dc.rb
#+BEGIN_SRC ruby :tangle "../lib/sisu/xml_md_oai_pmh_dc.rb"
# <<sisu_document_header>>
module SiSU_XML_Metadata
require_relative 'se' # se.rb
include SiSU_Env
require_relative 'dp' # dp.rb
include SiSU_Param
class OAI_PMH
def initialize(opt)
@md=SiSU_Param::Parameters.new(opt).get
@oai_pmh=[]
end
def read
output
end
def pre
<<WOK
<?xml version="1.0" encoding="UTF-8"?>
<oai_dc:dc
xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/
http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
WOK
end
def body
if defined? @md.title.full \
and @md.title.full=~/\S+/ # DublinCore 1 - title
@oai_pmh << %{ <dc:title xml:lang="en">#{@md.title.full}</dc:title>\n}
end
if defined? @md.creator.author \
and @md.creator.author=~/\S+/ # DublinCore 2 - creator/author (author)
txt=meta_content_clean(@md.creator.author)
@oai_pmh << %{ <dc:author>#{txt}</dc:author>\n}
end
if defined? @md.classify.subject \
and @md.classify.subject=~/\S+/ # DublinCore 3 - subject (us library of congress, eric or udc, or schema???)
txt=meta_content_clean(@md.classify.subject)
@oai_pmh << %{ <dc:subject>#{txt}</dc:subject>\n}
end
if defined? @md.classify.keywords \
and @md.classify.keywords=~/\S+/
txt=meta_content_clean(@md.classify.keywords)
@oai_pmh << %{ <dc:keywords>#{txt}</dc:keywords>\n}
end
if @md.publisher # DublinCore 5 - publisher (current copy published by)
txt=meta_content_clean(@md.publisher)
@oai_pmh << %{ <dc:publisher>#{txt}</dc:publisher>\n}
end
if defined? @md.creator.contributor \
and @md.creator.contributor=~/\S+/ # DublinCore 6 - contributor
txt=meta_content_clean(@md.creator.contributor)
@oai_pmh << %{ <dc:contributor>#{txt}</dc:contributor>\n}
end
if defined? @md.date.published \
and @md.date.published=~/\S+/ # DublinCore 7 - date year-mm-dd
@oai_pmh << %{ <dc:date>#{@md.date.published}</dc:date>\n}
end
if defined? @md.date.created \
and @md.date.created=~/\S+/ # DublinCore 7 - date.created
@oai_pmh << %{ <dc:date_created>#{@md.date.created}</dc:date_created>\n}
end
if defined? @md.date.issued \
and @md.date.issued=~/\S+/ # DublinCore 7 - date.issued
@oai_pmh << %{ <dc:date_issued>#{@md.date.issued}</dc:date_issued>\n}
end
if defined? @md.date.available \
and @md.date.available=~/\S+/ # DublinCore 7 - date.available
@oai_pmh << %{ <dc:date_available>#{@md.date.available}</dc:date_available>\n}
end
if defined? @md.date.valid \
and @md.date.valid=~/\S+/ # DublinCore 7 - date.valid
@oai_pmh << %{ <dc:date_valid>#{@md.date.valid}</dc:date_valid>\n}
end
if defined? @md.date.modified \
and @md.date.modified=~/\S+/ # DublinCore 7 - date.modified
@oai_pmh << %{ <dc:date_modified>#{@md.date.modified}</dc:date_modified>\n}
end
if defined? @md.notes.description \
and @md.notes.description=~/\S+/ # DublinCore 4 - description
txt=meta_content_clean(@md.notes.description)
@oai_pmh << %{ <dc:description>#{txt}</dc:description>\n}
end
if defined? @md.notes.coverage \
and @md.notes.coverage=~/\S+/ # DublinCore 14 - coverage
txt=meta_content_clean(@md.notes.coverage)
@oai_pmh << %{ <dc:coverage>#{txt}</dc:coverage>\n}
end
if defined? @md.notes.relation \
and @md.notes.relation=~/\S+/ # DublinCore 13 - relation
txt=meta_content_clean(@md.notes.relation)
@oai_pmh << %{ <dc:relation>#{txt}</dc:relation>\n}
end
if defined? @md.notes.type \
and @md.notes.type=~/\S+/ # DublinCore 8 - type
txt=meta_content_clean(@md.notes.type)
@oai_pmh << %{ <dc:type>#{txt}</dc:type>\n}
end
if defined? @md.notes.format \
and @md.notes.format=~/\S+/ # DublinCore 9 - format
txt=meta_content_clean(@md.notes.format)
@oai_pmh << %{ <dc:format>#{txt}</dc:format>\n}
end
#if defined? @md.identifier.sisupod \
#and @md.identifier.sisupod=~/\S+/ # DublinCore 10 - identifier
# txt=meta_content_clean(@md.identifier.sisupod)
# @oai_pmh << %{ <dc:identifier>#{txt}</dc:identifier>\n}
#end
if defined? @md.original.source \
and @md.original.source=~/\S+/ # DublinCore 11 - source
txt=meta_content_clean(@md.original.source)
@oai_pmh << %{ <dc:source>#{txt}</dc:source>\n}
end
if defined? @md.title.language \
and @md.title.language=~/\S+/ # DublinCore 12 - language (English)
@oai_pmh << %{ <dc:language>#{@md.title.language}</dc:language>\n}
end
if defined? @md.original.language \
and @md.original.language=~/\S+/
@oai_pmh << %{ <dc:language>#{@md.original.language}</dc:language>\n}
end
if defined? @md.rights.all \
and @md.rights.all=~/\S+/ # DublinCore 15 - rights
txt=meta_content_clean(@md.rights.all)
@oai_pmh << %{ <dc:rights>#{txt}</dc:rights>\n}
end
@oai_pmh
end
def meta_content_clean(content='')
unless content.nil?
content=content.tr('"',"'")
end
content
end
def post
'</oai_dc:dc>'
end
def output
SiSU_Env::FileOp.new(@md).mkdir
oai_pmh=SiSU_Env::FileOp.new(@md,@md.fn[:oai_pmh]).mkfile #implement in param
oai_pmh << pre
body.each do |x|
oai_pmh << x
end
oai_pmh << post
end
end
end
__END__
http://www.openarchives.org/pmh/
http://www.openarchives.org/OAI/2.0/openarchivesprotocol.htm#dublincore
http://es.dublincore.org/documents/usageguide/elements.shtml
http://dublincore.org/documents/dces/
see also http://dublincore.org/documents/dcmes-xml/
#http://www.openarchives.org/OAI/2.0/openarchivesprotocol.htm#dublincore
#sample implementation, e.g. 2
<?xml version="1.0" encoding="UTF-8"?>
<oai_dc:dc
xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/
http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
<dc:title xml:lang="en">Grassmann's space analysis</dc:title>
<dc:author>Hyde, E. W. (Edward Wyllys)</dc:author>
<dc:subject>LCSH:Ausdehnungslehre; LCCN QA205.H99</dc:subject>
<dc:publisher>J. Wiley & Sons</dc:publisher>
<dc:date>Created: 1906; Available: 1991</dc:date>
<dc:type>text</dc:type>
<dc:identifier>http://resolver.library.cornell.edu/math/1796949
</dc:identifier>
<dc:language>english</dc:language>
<dc:rights xml:lang="en">Public Domain</dc:rights>
</oai_dc:dc>
#+END_SRC
** xml_parts.rb
#+BEGIN_SRC ruby :tangle "../lib/sisu/xml_parts.rb"
# <<sisu_document_header>>
module SiSU_Parts_XML
require_relative 'generic_parts' # generic_parts.rb
include SiSU_Parts_Generic
def the_line_break
'<br />'
end
def the_table_close
'</td></tr>
</table>'
end
def the_url_decoration
def xml_open #'<'
Dx[:url_o]
end
def xml_close #'>'
Dx[:url_c]
end
def txt_open
'<'
end
def txt_close
'>'
end
self
end
def the_color
def white
'#ffffff'
end
def black
'#000000'
end
def grey_pale
'#eeeeee'
end
def grey_medium
'#cccccc'
end
def grey
'#999999'
end
def blue_ink
'#003399'
end
def blue_tinge
'#e3ecef'
end
def yellow_light
'#fff3b6'
end
def table1
'ffffcc'
end
def table2
'c0d0f0'
end
def band1
%{"#{white}"}
end
def band2
%{"#{white}"}
end
self
end
def the_png
def _url_path_image_base #used for html image display
"#{Xx[:html_relative2]}_sisu/image"
end
def ico
%{ <link rel="shortcut icon" href="../_sisu/image/#{the_icon.i_ico}" />}
end
def png_home
%{<img border="0" src="#{_url_path_image_base}/#{the_icon.home_button}" alt="#{the_text.home} -->" />}
end
def png_home_button
rel=@dir.path_rel_links.html_scroll_2
%{<img border="0" src="#{rel}/#{the_icon.home_button}" alt="#{the_text.home} -->" />}
end
self
end
def the_font
def set_fonts
'verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman'
#'verdana, arial, georgia, tahoma, sans-serif, helvetica, "times new roman", times, roman'
end
def set_face
%{face="#{set_fonts}"}
end
#def set_color
# 'color="#000000"'
#end
#def set_size_endnote
# 'size="3"'
#end
#def set_small
# 'size="3"'
#end
#def set_tiny
# 'size="2"'
#end
#def paragraph_font_tiny
# %{<font #{set_tiny} #{set_face}>}
#end
#def paragraph_font_small
# %{<font #{set_small} #{set_face}>}
#end
self
end
def the_banner
def home_button_only
%{<a href="#{url.site}/">
#{the_png.png_home_button}
</a>}
end
def banner_band
%{<table summary="home button" width="100%" border="0" cellpadding="3" align="center">
<tr><td align="left" valign="middle">
<a href="#{url.site}/" target="_top">
#{the_png.png_home}
</a>
</td>
<td width="90%">
#{the_table_close}}
end
self
end
end
module SiSU_Proj_XML
require_relative 'html_parts' # html_parts.rb
require_relative 'se' # se.rb
include SiSU_Env
class Bits < SiSU_Proj_HTML::Bits
end
end
__END__
#+END_SRC
** xml_persist.rb
#+BEGIN_SRC ruby :tangle "../lib/sisu/xml_persist.rb"
# <<sisu_document_header>>
module SiSU_XML_Persist
class Persist
@@persist=nil
attr_accessor :head,:toc,:body,:tail,:open,:close,:sc,:endnotes,:book_idx,:metadata
#attr_accessor :head,:body,:tail,:open,:close,:sc
#@@odf={ body: [], head: [], toc: [], metadata: [], tail: [], book_idx: [], endnotes: [] }
def initialize(args=nil)
@@persist=args=(args ? args : (@@persist || persist_init_hash_values))
@head=args[:head]
@toc=args[:toc]
@body=args[:body]
@tail=args[:tail]
@open=args[:open]
@close=args[:close]
@sc=args[:sc]
@endnotes=args[:endnotes]
@book_idx=args[:book_idx]
@metadata=args[:metadata]
end
def head
@head
end
def toc
@toc
end
def body
@body
end
def tail
@tail
end
def open
@open
end
def close
@close
end
def sc
@sc
end
def endnotes
@endnotes
end
def book_idx
@book_idx
end
def metadata
@metadata
end
def persist_init_hash_values
{
head: [],
toc: [],
body: [],
tail: [],
open: [],
close: [],
sc: [],
endnotes: [],
book_idx: [],
metadata: [],
}
end
def persist_init
@@persist=nil
Persist.new(persist_init_hash_values)
end
end
end
__END__
#+END_SRC
** xml_scaffold_structure_collapsed.rb
#+BEGIN_SRC ruby :tangle "../lib/sisu/xml_scaffold_structure_collapsed.rb"
# <<sisu_document_header>>
module SiSU_XML_Scaffold_Structure_Collapse
require_relative 'se_hub_particulars' # se_hub_particulars.rb
include SiSU_Particulars
require_relative 'ao' # ao.rb
require_relative 'se' # se.rb
include SiSU_Env
class Source
def initialize(opt)
@opt=opt
@particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt)
end
def spaces
Ax[:spaces]
end
def read
begin
@md,@ao_array=@particulars.md,@particulars.ao_array
SiSU_XML_Scaffold_Structure_Collapse::Source::Scroll.new(@ao_array,@md).songsheet
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
end
ensure
end
end
private
class Scroll <Source
def initialize(data='',md='')
@data,@md=data,md
end
def songsheet
@t='sisu'
data=@data
if @md.opt.act[:verbose_plus][:set]==:on
structure_collapsed(data)
end
structure_build_collapsed(data)
end
def tags
# collapsed -->
def collapsed
[ '0',
'1',
'2',
'3',
'4',
'5',
'6'
]
end
def docbook
end
def fictionbook
end
self
end
def output(o,lev=nil,comment='')
puts lev == (0..6) \
? "#{spaces*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}"
: "<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}"
end
def structure_collapsed(data)
puts "\ncollapsed structure, heading outline --->\n\n"
data.each_with_index do |o,i|
if (o.is ==:heading || o.is ==:heading_insert)
output(o,o.lc)
end
end
end
def structure_build_collapsed(data)
@s=tags.collapsed
puts "\nXML [#{@t} type] structure outline --->\n\n"
h=[0,false,false,false]
puts "<#{@s[0]}>"
data.each_with_index do |o,i|
if (o.is ==:heading || o.is ==:heading_insert)
lev=o.lc
structure_build_tag_close(lev,h)
puts "#{spaces*lev}<#{@s[lev]}>\n#{spaces*lev} [#{o.ocn}] #{lev} {#{o.node}}"
h[0]=lev
end
end
structure_build_tag_close(0,h)
end
def structure_build_tag_close(lev,h)
case h[0]
when 1
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1)
puts "</#{@s[0]}>" if (lev==0)
when 2
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2)
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1)
puts "</#{@s[0]}>" if (lev==0)
when 3
puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3)
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2)
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1)
puts "</#{@s[0]}>" if (lev==0)
when 4
puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4)
puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3)
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2)
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1)
puts "</#{@s[0]}>" if (lev==0)
when 5
puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5)
puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4)
puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3)
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2)
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1)
puts "</#{@s[0]}>" if (lev==0)
when 6
puts "#{spaces*6}</#{@s[6]}>" if (lev <= 6)
puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5)
puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4)
puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3)
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2)
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1)
puts "</#{@s[0]}>" if (lev==0)
end
end
end
end
end
__END__
@s=['0',
'A',
'B',
'C',
'1',
'2',
'3'
]
#@t='docbook' #@t='fictionbook'
#@s=['book', #@s=['body',
# 'part', # 'section',
# 'subpart N/A', # 'section',
# 'sub-subpart N/A', # 'section',
# 'chapter', # 'section',
# 'sect1', # 'section',
# 'sect2' # 'section'
#] #]
#+END_SRC
** xml_scaffold_structure_sisu.rb
#+BEGIN_SRC ruby :tangle "../lib/sisu/xml_scaffold_structure_sisu.rb"
# <<sisu_document_header>>
module SiSU_XML_Scaffold_Structure_Sisu
require_relative 'se_hub_particulars' # se_hub_particulars.rb
include SiSU_Particulars
require_relative 'ao' # ao.rb
require_relative 'se' # se.rb
include SiSU_Env
class Source
def initialize(opt)
@opt=opt
@particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt)
end
def spaces
Ax[:spaces]
end
def read
begin
@md,@ao_array=@particulars.md,@particulars.ao_array
SiSU_XML_Scaffold_Structure_Sisu::Source::Scroll.new(@ao_array,@md).songsheet
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
end
ensure
end
end
private
class Scroll <Source
def initialize(data='',md='')
@data,@md=data,md
end
def songsheet
@t='sisu'
data=@data
if @md.opt.act[:verbose_plus][:set]==:on
structure_sisu_simple(data)
end
structure_build_sisu(data)
end
def tags
def sisu
[ '0',
'A',
'B',
'C',
'1',
'2',
'3'
]
end
self
end
def structure_sisu_simple(data)
puts "\nsisu structure, heading outline --->\n\n"
data.each_with_index do |o,i|
if (o.is ==:heading || o.is ==:heading_insert)
puts "#{spaces*o.ln}<#{tags.sisu[o.ln]}>[#{o.ocn}] #{o.ln} #{o.obj}</#{tags.sisu[o.ln]}>"
end
end
end
def output(o,lev=nil,comment='')
puts lev == (0..6) \
? "#{spaces*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}"
: "<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}"
end
def structure_build_sisu(data)
@s=tags.sisu
puts "\nXML [#{@t} type] structure outline --->\n\n"
h=[0,false,false,false]
puts "<#{@s[0]}>"
data.each_with_index do |o,i|
if (o.is ==:heading || o.is ==:heading_insert)
structure_build_tag_close(o.ln,h)
puts "#{spaces*o.ln}<#{@s[o.ln]}>\n#{spaces*o.ln} [#{o.ocn}] #{o.ln} {#{o.node}}"
case o.ln
when 1
h=[o.ln,true,false,false]
when 2
h=[o.ln,true,true,false]
when 3
h=[o.ln,true,true,true]
when 4..6
h[0]=o.ln
end
end
end
structure_build_tag_close(0,h)
end
def structure_build_tag_close(lev,h)
case h[0]
when 1
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1]
puts "</#{@s[0]}>" if (lev==0)
when 2
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2]
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1]
puts "</#{@s[0]}>" if (lev==0)
when 3
puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) && h[3]
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2]
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1]
puts "</#{@s[0]}>" if (lev==0)
when 4
puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4)
puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) && h[3]
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2]
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1]
puts "</#{@s[0]}>" if (lev==0)
when 5
puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5)
puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4)
puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) && h[3]
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2]
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1]
puts "</#{@s[0]}>" if (lev==0)
when 6
puts "#{spaces*6}</#{@s[6]}>" if (lev <= 6)
puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5)
puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4)
puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) && h[3]
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2]
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1]
puts "</#{@s[0]}>" if (lev==0)
end
end
end
end
end
__END__
@s=['0',
'A',
'B',
'C',
'1',
'2',
'3'
]
#@t='docbook' #@t='fictionbook'
#@s=['book', #@s=['body',
# 'part', # 'section',
# 'subpart N/A', # 'section',
# 'sub-subpart N/A', # 'section',
# 'chapter', # 'section',
# 'sect1', # 'section',
# 'sect2' # 'section'
#] #]
#+END_SRC
* odf
** xml_odf_odt.rb
#+BEGIN_SRC ruby :tangle "../lib/sisu/xml_odf_odt.rb"
# <<sisu_document_header>>
module SiSU_XML_ODF_ODT
require_relative 'se_hub_particulars' # se_hub_particulars.rb
include SiSU_Particulars
require_relative 'ao' # ao.rb
require_relative 'se' # se.rb
include SiSU_Env
require_relative 'xml_parts' # xml_parts.rb
require_relative 'xml_odf_odt_format' # xml_odf_odt_format.rb
include SiSU_XML_ODF_ODT_Format
require_relative 'shared_metadata' # shared_metadata.rb
require_relative 'txt_shared' # txt_shared.rb
require_relative 'xml_shared' # xml_shared.rb
include SiSU_XML_Munge
require_relative 'xml_persist' # xml_persist.rb
@@alt_id_count,@@alt_id_count=0,0
class Source
begin
require 'zlib'
require 'find'
rescue LoadError
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
error('zlib or find NOT FOUND (LoadError)')
end
def initialize(opt)
@opt=opt
@particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt)
@@endnotes_para=[]
end
def read
begin
@md,@env,@ao_array=@particulars.md,@particulars.env,@particulars.ao_array
unless @opt.act[:quiet][:set]==:on
tool=(@opt.act[:verbose][:set]==:on \
|| @opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on) \
? "#{@env.program.odf_viewer} file://#{@md.file.output_path.odt.dir}/#{@md.file.base_filename.odt}"
: "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}"
(@opt.act[:verbose][:set]==:on \
|| @opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on) \
? SiSU_Screen::Ansi.new(
@opt.act[:color_state][:set],
'Opendocument (ODF:ODT)',
tool
).green_hi_blue
: SiSU_Screen::Ansi.new(
@opt.act[:color_state][:set],
'Opendocument (ODF:ODT)',
tool
).green_title_hi
if (@opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on)
SiSU_Screen::Ansi.new(
@opt.act[:color_state][:set],
@opt.fns,
'file://' \
+ @md.file.output_path.odt.dir + '/' \
+ @md.file.base_filename.odt
).flow
end
end
SiSU_XML_ODF_ODT::Source::Scroll.new(@particulars).songsheet
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
end
ensure
Dir.chdir(@opt.f_pth[:pth])
end
end
private
class Scroll <Source
require_relative 'txt_shared' # txt_shared.rb
include SiSU_Parts_XML
@@img_count=0
@@docstart=true
@@fns=nil
def initialize(particulars)
@md,@env,@ao_array=particulars.md,particulars.env,particulars.ao_array
@make=SiSU_Env::ProcessingSettings.new(@md)
@tab="\t"
@br=(@md.opt.act[:maintenance][:set]==:on) \
? '' : ''
end
def songsheet
begin
@per=SiSU_XML_Persist::Persist.new
pre
@data=markup(@ao_array)
publish
ensure
SiSU_XML_Persist::Persist.new.persist_init
unless (@md.opt.act[:verbose_plus][:set]==:on \
|| @md.opt.act[:maintenance][:set]==:on)
if @env.processing_path.odt =~/od[ft]/
#p "rm -r #{@env.processing_path.odt}" if @md.opt.selections.str =~/v/
FileUtils::rm_r(@env.processing_path.odf_pth)
#system("rm -r #{@env.processing_path.odt}")
end
end
end
end
def break_line
(@md.opt.act[:maintenance][:set]==:on) \
? "\n" : ''
end
# Used for extraction of endnotes from paragraphs
def extract_endnotes(dob='')
notes=dob.obj.scan(/#{Mx[:en_a_o]}(\d+\s+.+?)#{Mx[:en_a_c]}/)[1] #FIX
@n=[]
notes.each do |n| #high cost to deal with <br> appropriately within odf, consider
n=n.dup.to_s
if n =~/#{Mx[:br_line]}/
fix=n.split(/#{Mx[:br_line]}/) #watch #added
fix.each do |x|
if x =~/\S+/ then @n << x
end
end
else @n << n
end
end
end
def odf_book_idx
if @md.book_idx
idx_arr=[]
idx_raw=SiSU_Particulars::CombinedSingleton.
instance.get_idx_raw(@md.opt).raw_idx
idx_raw.each do |x|
x=if x.is_a?(String)
SiSU_XML_ODF_ODT_Format::FormatBookIndex.new(x).
book_idx_bookmark
else nil
end
idx_arr << x.strip if x.is_a?(String)
end
@per.book_idx=idx_arr.join
end
end
def odf_metadata
@per.metadata=SiSU_Metadata::Summary.new(@md).
odf.metadata
end
def odf_tail
manifest="#{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}"
@per.tail << %{<text:p text:style-name="P_normal">Available document outputs: <br /> <<text:a xl:type="simple" xl:href="#{manifest}">#{manifest}</text:a>></text:p>}
@per.tail << %{\n<text:p text:style-name="P_normal">SiSU: <<text:a xl:type="simple" xl:href="http://www.jus.uio.no/lm">www.jus.uio.no/sisu</text:a>> and <<text:a xl:type="simple" xl:href="http://www.sisudoc.org">www.sisudoc.org</text:a>></text:p>}
@per.tail << "\n</office:text></office:body></office:document-content>"
end
def set_bookmark_tag(dob)
SiSU_XML_ODF_ODT_Format::Tags.new.set_bookmark_tag(dob)
end
def heading(dob,p_num)
dob=footnote(dob)
m=/#{$1}/
breakpage=''
if @md.fns \
and @md.fns != '' \
and @md.fns !=@@fns
@@docstart=true
@@fns=@md.fns
end
unless @@docstart
breakpage=if (@md.pagenew || @md.pagebreak) \
and (@md.pagenew.to_s =~m \
or @md.pagebreak.to_s =~m)
'<text:p text:style-name="P_normal_page_new"> </text:p>'
elsif @md.pageline \
and @md.pageline =~m #fix
else ''
end
end
@@docstart=false
if dob.use_ != :dummy
dob.tmp=dob.obj
dob.obj=%{#{breakpage}<text:h text:style-name="H_#{dob.ln}" text:outline-level="#{dob.ln}">} \
+ %{#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}</text:h>}
else dob.tmp,dob.obj='',''
end
dob
end
def toc(dob,p_num)
hardspace=(dob.lv =~/[A-D]/i) \
? '<text:p text:style-name="Standard"/>'
: ''
toc_heading=dob.ocn \
? (%{<text:bookmark-ref text:reference-format="text" text:ref-name="#{dob.ocn}">} \
+ %{#{dob.tmp}</text:bookmark-ref>})
: dob.tmp
dob.obj=%{<text:h text:style-name="H_#{dob.ln}" text:outline-level="#{dob.ln}">} \
+ %{#{toc_heading}</text:h>#{hardspace}}
dob
end
def image_src(i)
if @md.fns =~/\.ss[tm]$/ \
and FileTest.file?("#{@env.path.image_source_include(@md)}/#{i}") #review
@env.path.image_source_include(@md)
elsif @md.opt.f_pth[:pth] =~/\/\S+?\/sisupod\/\S+?\/sisupod\/doc/
pt=/(\/\S+?\/sisupod\/\S+?\/sisupod)\/doc/.match(@md.opt.f_pth[:pth])[1]
img_src=pt + '/image'
if FileTest.file?("#{img_src}/#{i}")
img_src
else
SiSU_Screen::Ansi.new(
@md.opt.act[:color_state][:set],
"ERROR - image:",
%{"#{i}" missing},
"search locations: #{@env.path.image_source_include_local}," \
+ "#{@env.path.image_source_include_remote} and" \
+ "#{@env.path.image_source_include}"
).error2 unless @md.opt.act[:quiet][:set]==:on
nil
end
elsif @md.fns =~/\.ss[tm]$/ \
and FileTest.file?("#{@env.path.image_source_include_local}/#{i}") #review
@env.path.image_source_include_local
elsif @md.fns =~/\.ss[tm]$/ \
and FileTest.file?("#{@env.path.image_source_sisu_includes(@md)}/#{i}")
@env.path.image_source_sisu_includes(@md)
elsif @md.fns =~/\.-ss[tm]$/ \
and FileTest.file?("#{@env.path.image_source_include_remote}/#{i}")
@env.path.image_source_include_remote
else
SiSU_Screen::Ansi.new(
@md.opt.act[:color_state][:set],
"ERROR - image:",
%{"#{i}" missing},
"search locations: " \
+ @env.path.image_source_include_local + ',' \
+ @env.path.image_source_include_remote + 'and' \
+ @env.path.image_source_include \
+ @md.opt.sisu_data_dir?
).error2 unless @md.opt.act[:quiet][:set]==:on
nil
end
end
def image_odf(img)
# copy image to od image directory (unless exists)
# divide pixel dimension by 37.79485 and retain 3 decimal places
m=img[1]
i=/^(\S+?\.(?:png|jpg|gif))/.match(m).captures.join \
if m =~/^(\S+?\.(?:png|jpg|gif))/
c=/^\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"/.match(m).captures.join \
if m =~/^\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"/
w,h=/\s(\d+)x(\d+)/.match(m).captures if m =~/\s\d+x\d+/
w=(w.to_i/37.79485).to_s
h=(h.to_i/37.79485).to_s
h=/([0-9]+\.\d{0,3})/.match(h).captures.join
w=/([0-9]+\.\d{0,3})/.match(w).captures.join
image_source=image_src(i)
if image_source
if FileTest.file?("#{image_source}/#{i}")
FileUtils::cp(
"#{image_source}/#{i}",
"#{@env.processing_path.odt}/Pictures/#{i}"
)
else STDERR.puts %{\t*WARN* did not find image - "#{image_source}/#{i}" [#{__FILE__}:#{__LINE__}]}
end
end
img=if i.to_s =~/jpg|png|gif/ \
and h.to_s =~/\d/ \
and w.to_s =~/\d/
@@img_count +=1
%{<draw:frame draw:style-name="fr1" draw:name="graphics#{@@img_count}" text:anchor-type="as-char" svg:width="#{w}cm" svg:height="#{h}cm" draw:z-index="2"><draw:image xl:href="Pictures/#{i}" xl:type="simple" xl:show="embed" xl:actuate="onLoad"/></draw:frame>#{c}} #anchor-type: as-char or paragraph or char or ...
else %{<text:p text:style-name="P_normal">[image omitted]</text:p>}
end
end
def image(dob)
m=if dob.obj =~/#{Mx[:lnk_o]}[ ]*(.+?)[ ]*#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/
dob.obj.scan(/(#{Mx[:lnk_o]}[ ]*(.+?)[ ]*#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]})/)
elsif dob.obj =~/#{Mx[:lnk_o]}[ ]*(.+?)[ ]*#{Mx[:lnk_c]}image/
dob.obj.scan(/(#{Mx[:lnk_o]}[ ]*(.+?)[ ]*#{Mx[:lnk_c]}(image))/)
else nil
end
if m then m.each do |i|
cont,url=i[1],i[2]
cont=cont.gsub(/([)(\]\[])/,"\\\\\\1").
gsub(/([+?])/,"\\\\\\1") # incorrect handling of +
url=url.gsub(/([+?])/,"\\\\\\1")
dob.obj=dob.obj.sub(/#{Mx[:lnk_o]}[ ]*#{cont}[ ]*#{Mx[:lnk_c]}image/m,image_odf(i)).
sub(/#{Mx[:lnk_o]}[ ]*#{cont}[ ]*#{Mx[:lnk_c]}#{Mx[:url_o]}#{url}#{Mx[:url_c]}/m,image_odf(i)).
sub(/\\([)(\]\[?])/,'\1') #clumsy fix
end
m=nil
end
dob
end
def text_link_odf(txt,url,trail)
txt=txt.gsub(/(\\\+)/,'+') #this is convoluted, and risky :-(
url=url.gsub(/(\\\+)/,'+') #this is convoluted, and risky :-(
map_nametags=SiSU_Particulars::CombinedSingleton.
instance.get_map_nametags(@md).nametags_map
t=case url
when /^https?:/
%{<text:a xl:type="simple" xl:href="#{url}">#{txt.strip}</text:a>#{trail}}
when /^:/ # site same document collection html link
url=url.gsub(/^:/,"#{@env.url.root}/")
%{<text:a xl:type="simple" xl:href="#{url}">#{txt.strip}</text:a>#{trail}}
when /^\.\.\// # site same document collection html link
url=url.gsub(/^\.\.\//,"#{@env.url.root}/")
%{<text:a xl:type="simple" xl:href="#{url}">#{txt.strip}</text:a>#{trail}}
else # document internal link
if map_nametags[url] \
and map_nametags[url][:segname]
else p "NOT FOUND name_tags: #{url}"
end
t=map_nametags[url] \
&& map_nametags[url][:segname] \
? (%{<text:a xl:type="simple" xl:href="#{@env.url.root}/#{@md.fnb}/#{map_nametags[url][:segname]}#{Sfx[:html]}##{url}">} \
+ %{#{txt.strip}</text:a>#{trail}})
: %{#{txt.strip}#{trail}}
end
t
end
def text_link_odf_bookmark(txt,url,trail)
SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map
%{<text:bookmark-ref text:reference-format="text" text:ref-name="#{url}">#{txt.strip}</text:bookmark-ref>#{trail}}
end
def text_link(dob)
m=dob.obj.scan(/(#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]})/) #sort
if m
m.each do |i|
txt,url,trail=i[1],i[2]
txt=txt.gsub(/([)(\]\[])/,"\\\\\\1").
gsub(/([+?*])/,"\\\\\\1") # problems with +
url=url.gsub(/([+?])/,"\\\\\\1") # problems with +
dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}[ ]*#{txt}#{Mx[:lnk_c]}#{Mx[:url_o]}#{url}#{Mx[:url_c]}/m,
text_link_odf(txt,url,trail)). #make sure trailing ']' are not caught in url
gsub(/\\([)(\]\[?])/,'\1') #clumsy fix
end
m=nil
end
dob
end
def text_link_relative(dob)
m=dob.obj.scan(/(#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]})/) #sort
if m
m.each do |i|
txt,url,trail=i[1],i[2]
txt=txt.gsub(/([)(\]\[])/,"\\\\\\1").
gsub(/([+?*])/,"\\\\\\1") # problems with +
url=url.gsub(/([+?])/,"\\\\\\1") # problems with +
dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}[ ]*#{txt}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{url}#{Mx[:rel_c]}/m,
text_link_odf_bookmark(txt,url,trail)). #make sure trailing ']' are not caught in url
gsub(/\\([)(\]\[?])/,'\1') #clumsy fix
end
m=nil
end
dob
end
def text_link_relative_(dob)
m=dob.obj.scan(/(#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]})/) #sort
if m
m.each do |i|
txt,url,trail=i[1],i[2]
txt=txt.gsub(/([)(\]\[])/,"\\\\\\1")
dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}[ ]*#{txt}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{url}#{Mx[:rel_c]}/m,
text_link_odf(txt,url,trail)). #make sure trailing ']' are not caught in url
gsub(/\\([)(\]\[?])/,'\1') #clumsy fix
end
m=nil
end
dob
end
def normal(dob,p_num) #P1 - P3
dob=footnote(dob)
dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
'<text:a xl:type="simple" xl:href="\1">\1</text:a>'). #http ftp matches escaped, no decoration
gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,
%{#{the_url_decoration.xml_open}<text:a xl:type="simple" xl:href="mailto:\\1">\\1</text:a>#{the_url_decoration.xml_close}}).
gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
%{#{the_url_decoration.xml_open}<text:a xl:type="simple" xl:href="\\1">\\1</text:a>#{the_url_decoration.xml_close}}) #http ftp matches with decoration
dob.obj= if dob.is==:para \
and dob.indent.to_s =~/[0-9]/ \
and dob.indent == dob.hang
%{<text:p text:style-name="P_indent_#{dob.indent}">#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}</text:p>}
elsif dob.is==:para \
and dob.hang.to_s =~/[0-9]/ \
and dob.indent != dob.hang
%{<text:p text:style-name="P_h#{dob.hang}_i#{dob.indent}">#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}</text:p>}
else %{<text:p text:style-name="P_normal">#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}</text:p>}
end
dob
end
def fontface(dob)
end
def footnote_urls(str)
str=str.gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
%{#{the_url_decoration.xml_open}<text:a xl:type="simple" xl:href="\\1">\\1</text:a>#{the_url_decoration.xml_close}})
str=text_link(str) if str =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/
str=text_link_relative(str) if str =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/
str
end
def footnote(t_o)
str=if defined? t_o.obj then t_o.obj
elsif t_o.is_a?(String) then t_o
end
if str
@astx||=10000
@astxs||=20000
if str =~/#{Mx[:en_a_o]}\d+\s+/
str=str.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/,
'<text:note text:id="ftn\1" text:note-class="footnote"><text:note-citation>\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>')
end
if str =~/#{Mx[:en_a_o]}([*]+)\s+/
a=$1.gsub(/([*])/,"\\\\\\1")
str=str.gsub(/#{Mx[:en_a_o]}([*]+)\s+(.+?)#{Mx[:en_a_c]}/,
%{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \\2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>})
@astxs+=1
end
if str=~/#{Mx[:en_a_o]}[*+]+\s/
asterisk=str.scan(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/)
asterisk.each do |x|
a=x[0].gsub(/([*+])/,"\\\\\\1")
str=group_clean(str)
str=footnote_urls(str)
str=str.gsub(/#{Mx[:en_a_o]}(#{a})\s+(.+?)#{Mx[:en_a_c]}/,
%{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \\2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>})
@astx+=1
end
end
if str=~/#{Mx[:en_b_o]}[*+]\d+\s/
asterisk=str.scan(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/)
asterisk.each do |x|
a=x[0].gsub(/([*+])/,"\\\\\\1")
str=group_clean(str)
str=footnote_urls(str)
str=str.gsub(/#{Mx[:en_b_o]}(#{a})\s+(.+?)#{Mx[:en_b_c]}/,
%{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \\2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>})
@astx+=1
end
end
end
if defined? t_o.obj then t_o.obj=str
elsif t_o.is_a?(String) then t_o=str
end
t_o
end
def group_clean(str)
str=str.gsub(/&nbsp;| |#{Mx[:nbsp]}/,' ').
gsub(/</,'<').gsub(/>/,'>').
gsub(/<(text:span text:style-name="Span_\S+?"|\/text:span)>/,'<\1>'). #works, not ideal
gsub(/#{Mx[:br_line]}/,'<br />').
gsub(/<br(?:\s+\/)?>/,'<br />')
end
def poem(dob,p_num) #P4 #same as group
parray=[]
dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each_with_index do |parablock,i|
set_ref=(i==0) ? "#{p_num[:set_ref]}#{set_bookmark_tag(dob)}" : ''
parablock=group_clean(parablock)
parablock=footnote(parablock)
parray << %{<text:p text:style-name="P_group">#{set_ref}#{parablock}</text:p>} if parablock =~/\S+/
end
dob.obj=parray.join \
+ %{<text:p text:style-name="P_group">#{p_num[:display]}</text:p>} \
+ '<text:p text:style-name="Standard"/>'
dob
end
def group(dob,p_num) #P4 #same as verse
parray=[]
dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
'<text:a xl:type="simple" xl:href="\1">\1</text:a>'). #http ftp matches escaped, no decoration
gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,
%{#{the_url_decoration.xml_open}<text:a xl:type="simple" xl:href="mailto:\\1">\\1</text:a>#{the_url_decoration.xml_close}}).
gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
%{#{the_url_decoration.xml_open}<text:a xl:type="simple" xl:href="\\1">\\1</text:a>#{the_url_decoration.xml_close}}) #http ftp matches with decoration
dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each_with_index do |parablock,i|
set_ref=(i==0) ? "#{p_num[:set_ref]}#{set_bookmark_tag(dob)}" : ''
parablock=group_clean(parablock)
parablock=parablock.gsub(/<text:a xl:type="simple" xl:href="(.+?)">/m,
'<text:a xl:type="simple" xl:href="\1">').
gsub(/<(\/text:a)>/,'<\1>').
gsub(/<(text:note text:id=.+?)>/,'<\1>').
gsub(/<(text:p text:style-name="Footnote")>/,'<\1>').
gsub(/<(\/?text:(?:note-citation|note-body|note|p))>/,'<\1>')
parablock=footnote(parablock)
parray << %{<text:p text:style-name="P_group">#{set_ref}#{parablock}</text:p>} if parablock =~/\S+/
end
dob.obj=parray.join \
+ %{<text:p text:style-name="P_group">#{p_num[:display]}</text:p>} \
+ '<text:p text:style-name="Standard"/>'
dob
end
def block(dob,p_num) #P4 #same as verse
parray=[]
dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
'<text:a xl:type="simple" xl:href="\1">\1</text:a>'). #http ftp matches escaped, no decoration
gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,
%{#{the_url_decoration.xml_open}<text:a xl:type="simple" xl:href="mailto:\\1">\\1</text:a>#{the_url_decoration.xml_close}}).
gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
%{#{the_url_decoration.xml_open}<text:a xl:type="simple" xl:href="\\1">\\1</text:a>#{the_url_decoration.xml_close}}) #http ftp matches with decoration
dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each_with_index do |parablock,i|
set_ref=(i==0) ? "#{p_num[:set_ref]}#{set_bookmark_tag(dob)}" : ''
parablock=group_clean(parablock)
parablock=parablock.gsub(/<text:a xl:type="simple" xl:href="(.+?)">/m,
'<text:a xl:type="simple" xl:href="\1">').
gsub(/<(\/text:a)>/,'<\1>').
gsub(/<(text:note text:id=.+?)>/,'<\1>').
gsub(/<(text:p text:style-name="Footnote")>/,'<\1>').
gsub(/<(\/?text:(?:note-citation|note-body|note|p))>/,'<\1>')
parablock=footnote(parablock)
parray << %{<text:p text:style-name="P_group">#{set_ref}#{parablock}</text:p>} \
if parablock =~/\S+/
end
dob.obj=parray.join \
+ %{<text:p text:style-name="P_group">#{p_num[:display]}</text:p>} \
+ '<text:p text:style-name="Standard"/>'
dob
end
def code(dob,p_num) #P5
if dob.is==:code
dob.obj=dob.obj.gsub(/\s\s/,'  ')
parray=[]
dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each_with_index do |parablock,i|
set_ref=(i==0) ? "#{p_num[:set_ref]}#{set_bookmark_tag(dob)}" : ''
parablock=group_clean(parablock)
parablock=parablock.gsub(/^\s*$/,'<br />').
gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
'<text:a xl:type="simple" xl:href="\1">\1</text:a>') #http ftp matches escaped, no decoration
parray << %{<text:p text:style-name="P_code">#{set_ref}#{parablock}</text:p>} if parablock =~/\S+/
end
dob.obj=parray.join \
+ %{<text:p text:style-name="P_group">#{p_num[:display]}</text:p>} \
+ '<text:p text:style-name="Standard"/>'
end
dob
end
def table(dob,p_num) #
if dob.is ==:table
dob=footnote(dob) #check
table=SiSU_XML_ODF_ODT_Format::Table.new(@md,dob,p_num)
dob=table.table
end
dob
end
def obj_break(dob)
if dob.is ==:break
br=SiSU_XML_ODF_ODT_Format::FormatObjBreak.new(@md,dob)
if dob.obj==Mx[:br_page] \
or dob.obj==Mx[:br_page_new]
dob=br.br_page
elsif dob.obj==Mx[:br_page_line]
dob=br.br_page_line
elsif dob.obj==Mx[:br_obj]
dob=br.obj_sep
end
end
dob
end
def odf_structure(md,dob)
@md,@dob=md,dob
dob=if dob.is !=:code
dob=image(dob) if dob.obj =~/#{Mx[:lnk_o]}[ ]*\S+?\.(?:png|jpg|gif)\s.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/
dob=text_link(dob) if dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/
dob=text_link_relative(dob) if dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/
dob
else dob
end
p_num={ display: '', set_ref: '' }
if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/
if @make.build.odt_ocn?
if defined? dob.ocn \
and dob.ocn.is_a?(Integer)
p_num=SiSU_XML_ODF_ODT_Format::ParagraphNumber.new(@make,dob.ocn).set_bookmark_and_display
end
end
end
if dob.is==:heading
@per.body << heading(dob,p_num).obj << break_line*2
if SiSU_Env::ProcessingSettings.new(md).build.toc?
if dob.lv =~/[A-D1]/i
@per.toc << toc(dob,p_num).obj
end
end
elsif dob.is ==:verse
@per.body << poem(dob,p_num).obj << break_line*2
elsif dob.is==:group
@per.body << group(dob,p_num).obj << break_line*2
elsif dob.is==:block
@per.body << block(dob,p_num).obj << break_line*2
elsif dob.is==:code
@per.body << code(dob,p_num).obj << break_line*2
elsif dob.is==:table #elsif dob.obj =~ /<!Th?¡/u
@per.body << table(dob,p_num).obj << break_line*2
elsif dob.is==:break
@per.body << obj_break(dob).obj << break_line*2
else
@per.body << normal(dob,p_num).obj << break_line*2 # main text, contents, body KEEP
end
@@endnotes_para=[]
end
def tidywords(wordlist)
wordlist
end
def markup(data) # Used for major markup instructions
#safe_characters=/[^a-zA-Z0-9}{\/?,."';:)(><\-_&!@%~#\]\[*=$| \n+`#{Mx[:tc_p]}]/u
dir=SiSU_Env::InfoEnv.new(@md.fns)
dir.path.odt_bld
@data_mod,@endnotes,@level,@cont,@copen,@odf_contents_close=Array.new(6){[]}
@rcdc=false
(0..7).each { |x| @cont[x]=@level[x]=false }
(4..7).each { |x| @odf_contents_close[x]='' }
odf_tail #($1,$2)
bullet=image_src('bullet_09.png')
if bullet
if FileTest.file?("#{bullet}/bullet_09.png")
FileUtils::cp("#{bullet}/bullet_09.png","#{@env.processing_path.odt}/Pictures/.")
else STDERR.puts %{\t*WARN* did not find image - "#{bullet}/bullet_09.png" [#{__FILE__}:#{__LINE__}]}
end
end
odf_book_idx
odf_metadata
data.each do |dob|
#p dob.obj if dob.obj =~safe_characters and @md.opt.selections.str =~/V/ #KEEP
dob.obj='' if dob.obj =~/#{Mx[:lv_o]}\d+:.*?#{Mx[:lv_c]}.+?#{Mx[:pa_non_object_dummy_heading]}/ #fix Mx[:lv_o]
para_array=[]
dob.obj=dob.obj.gsub(/</,'<').gsub(/>/,'>')
word=dob.obj.scan(/\S+|\n/)
if word
word.each do |w| # _ - / # | : ! ^ ~
unless dob.obj =~/^(?:#{Rx[:meta]}|%+ )/m
w=w.gsub(/&#(?:126|152);/,'~'). #126 usual
gsub(/ /,' ')
if w !~/(?:&\S{2,7}?;)+/
w=w.gsub(/&/,'&')
end
if w !~/&\S{1,7}?;(?:&\S{1,7}?;)+/ #imperfect
w=w.gsub(/(&\S{1,7};)+&/,'\1&')
end
end
para_array << w
end
dob.obj=para_array.join(' ')
dob.obj=dob.obj.strip
end
if dob.is==:code #{Mx[:gr_o]}code#{Mx[:gr_c]}/ #fix #code-block: angle brackets special characters #fix
dob.obj=dob.obj.gsub(/(^|[^}])_(?:<|<)/m,'\1<').gsub(/(^|[^}])_(?:>|>)/m,'\1>').
gsub(/(^|[^}])_(?:<|<)/m,'\1<').gsub(/(^|[^}])_(?:>|>)/m,'\1>')
end
if dob.of==:block
dob.obj=dob.obj.gsub(/#{Mx[:gl_bullet]}/,'● ')
end
dob.obj=dob.obj.gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>').
gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>').
gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>').
gsub(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,
'<text:bookmark-start text:name="\1"/><text:bookmark-end text:name="\1"/>'). #check
gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;').
gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;').
gsub(/#{Mx[:mk_o]}[~-]##{Mx[:mk_c]}/,'')
if dob.is==:para \
and dob.bullet_
dob.obj='<draw:frame draw:style-name="gr1" text:anchor-type="as-char" svg:width="0.22cm" svg:height="0.22cm" draw:z-index="2"><draw:image xl:href="Pictures/bullet_09.png" xl:type="simple" xl:show="embed" xl:actuate="onLoad"/></draw:frame> ' +
dob.obj
end
dob.obj=dob.obj.gsub(/#{Mx[:br_line]}/,'<br />').
gsub(/©/,'©'). #too arbitrary
gsub(/.+?<-#>/,''). # remove dummy headings (used by html) #check
gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,
'<text:span text:style-name="Span_bold">\1</text:span>').
gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,
'<text:span text:style-name="Span_italic">\1</text:span>').
gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,
'<text:span text:style-name="Span_underscore">\1</text:span>').
gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,
'<text:span text:style-name="Span_superscript">\1</text:span>').
gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,
'<text:span text:style-name="Span_subscript">\1</text:span>').
gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,
'<text:span text:style-name="Span_monospace">\1</text:span>').
gsub(//u,'-').
gsub(/ /u, ' '). # space identify
gsub(/ /u, ' '). # space identify
gsub(/·/u,'*').
gsub(/[–—]/u,'-'). #— – chk
gsub(/ < /i,'<').
gsub(/\\copy(?:right)?\b/,'©').
gsub(/\\trademark\b|\\tm\b/,'®').
gsub(/\44/,'$'). #$ watch
gsub(/<a href=".+?">(.+?)<\/a>/,'\1').
gsub(/#{Mx[:mk_o]}name#\S+?#{Mx[:mk_c]}/,'') # remove name links
wordlist=dob.obj.scan(/\S+/)
dob.obj=tidywords(wordlist).join(' ').strip
@rcdc=true if @rcdc==false \
and (dob.obj =~/~metadata/ \
or dob.obj =~/#{Mx[:lv_o]}1:meta#{Mx[:lv_x]}\s*Document Information/) #fix Mx[:lv_o]
if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ #check
if defined? dob.ocn and dob.ocn.to_s =~/\d+/
@p_num=SiSU_XML_ODF_ODT_Format::ParagraphNumber.new(@make,dob.ocn)
end
if dob.is ==:heading \
|| dob.is ==:para \
|| dob.is ==:group \
|| dob.is ==:verse \
|| dob.is ==:code \
|| dob.is ==:table \
|| dob.is ==:break
odf_structure(@md,dob)
end
if dob.obj ## Clean Prepared Text
dob.obj=dob.obj.gsub(/<!.+!>/,' ').
gsub(/#{Mx[:tc_o]}.+?#{Mx[:tc_c]}/,' ').
gsub(/<:\S+>/,' ')
end
end
end
end
def pre
table=if @md.flag_tables
x=<<WOK
<style:style style:name="Table1" style:family="table"><style:table-properties style:width="16.999cm" table:align="margins"/></style:style>
<style:style style:name="Table1.A" style:family="table-column"><style:table-column-properties style:column-width="16.999cm" style:rel-column-width="65535*"/></style:style>
<style:style style:name="Table1.B" style:family="table-column"><style:table-column-properties style:column-width="8.499cm" style:rel-column-width="32767*"/></style:style>
<style:style style:name="Table1.C" style:family="table-column"><style:table-column-properties style:column-width="5.666cm" style:rel-column-width="21845*"/></style:style>
<style:style style:name="Table1.D" style:family="table-column"><style:table-column-properties style:column-width="4.349cm" style:rel-column-width="16383*"/></style:style>
<style:style style:name="Table1.E" style:family="table-column"><style:table-column-properties style:column-width="3.399cm" style:rel-column-width="13107*"/></style:style>
<style:style style:name="Table1.F" style:family="table-column"><style:table-column-properties style:column-width="2.833cm" style:rel-column-width="10922*"/></style:style>
<style:style style:name="Table1.G" style:family="table-column"><style:table-column-properties style:column-width="2.428cm" style:rel-column-width="9362*"/></style:style>
<style:style style:name="Table1.H" style:family="table-column"><style:table-column-properties style:column-width="2.124cm" style:rel-column-width="8191*"/></style:style>
<style:style style:name="Table2" style:family="table"><style:table-properties style:width="16.999cm" table:align="margins"/></style:style>
<style:style style:name="Table2.A" style:family="table-column"><style:table-column-properties style:column-width="16.999cm" style:rel-column-width="65535*"/></style:style>
<style:style style:name="Table2.B" style:family="table-column"><style:table-column-properties style:column-width="8.499cm" style:rel-column-width="32767*"/></style:style>
<style:style style:name="Table2.C" style:family="table-column"><style:table-column-properties style:column-width="5.666cm" style:rel-column-width="21845*"/></style:style>
<style:style style:name="Table2.D" style:family="table-column"><style:table-column-properties style:column-width="4.349cm" style:rel-column-width="16383*"/></style:style>
<style:style style:name="Table2.E" style:family="table-column"><style:table-column-properties style:column-width="3.999cm" style:rel-column-width="13107*"/></style:style>
<style:style style:name="Table2.F" style:family="table-column"><style:table-column-properties style:column-width="2.833cm" style:rel-column-width="10922*"/></style:style>
<style:style style:name="Table2.G" style:family="table-column"><style:table-column-properties style:column-width="2.428cm" style:rel-column-width="9362*"/></style:style>
<style:style style:name="Table2.H" style:family="table-column"><style:table-column-properties style:column-width="2.124cm" style:rel-column-width="8191*"/></style:style>
<style:style style:name="Table2.I" style:family="table-column"><style:table-column-properties style:column-width="1.8887cm" style:rel-column-width="7281*"/></style:style>
<style:style style:name="Table2.J" style:family="table-column"><style:table-column-properties style:column-width="1.6999cm" style:rel-column-width="6553*"/></style:style>
<style:style style:name="Table2.K" style:family="table-column"><style:table-column-properties style:column-width="1.5453cm" style:rel-column-width="5957*"/></style:style>
<style:style style:name="Table2.L" style:family="table-column"><style:table-column-properties style:column-width="1.416cm" style:rel-column-width="5461*"/></style:style>
<style:style style:name="Table2.M" style:family="table-column"><style:table-column-properties style:column-width="1.307" style:rel-column-width="5041*"/></style:style>
<style:style style:name="Table2.N" style:family="table-column"><style:table-column-properties style:column-width="1.214cm" style:rel-column-width="4681*"/></style:style>
WOK
x=x.strip
x=x.gsub(/\n+/m,'') unless @md.opt.act[:maintenance][:set]==:on
x
else ''
end
x=<<WOK
<?xml version="1.0" encoding="UTF-8"?>
<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2"><office:scripts/>
<office:font-face-decls><style:font-face style:name="DejaVu Sans Mono" svg:font-family="'DejaVu Sans Mono'" style:font-adornments="Book" style:font-family-generic="modern" style:font-pitch="fixed"/><style:font-face style:name="Inconsolata" svg:font-family="Inconsolata" style:font-adornments="Regular" style:font-pitch="fixed"/><style:font-face style:name="Liberation Mono" svg:font-family="'Liberation Mono'" style:font-adornments="Regular" style:font-family-generic="modern" style:font-pitch="fixed"/><style:font-face style:name="DejaVu Sans" svg:font-family="'DejaVu Sans'" style:font-adornments="ExtraLight" style:font-family-generic="swiss" style:font-pitch="variable"/><style:font-face style:name="Nimbus Sans L" svg:font-family="'Nimbus Sans L'" style:font-pitch="variable"/><style:font-face style:name="Tahoma" svg:font-family="Tahoma, Lucidasans, 'Lucida Sans', 'Arial Unicode MS'" style:font-pitch="variable"/><style:font-face style:name="Nimbus Roman No9 L" svg:font-family="'Nimbus Roman No9 L'" style:font-family-generic="roman" style:font-pitch="variable"/><style:font-face style:name="Bitstream Vera Sans" svg:font-family="'Bitstream Vera Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/></office:font-face-decls>
<office:automatic-styles>
#{table}
<style:style style:name="P_table_cell" style:family="paragraph" style:parent-style-name="Table_Contents"><style:paragraph-properties fo:text-align="justify" style:justify-single-word="false"/></style:style>
</office:automatic-styles>
<office:body>
<office:text text:use-soft-page-breaks="true">
<office:forms form:automatic-focus="false" form:apply-design-mode="false"/>
<text:sequence-decls><text:sequence-decl text:display-outline-level="0" text:name="Illustration"/><text:sequence-decl text:display-outline-level="0" text:name="Table"/><text:sequence-decl text:display-outline-level="0" text:name="Text"/><text:sequence-decl text:display-outline-level="0" text:name="Drawing"/></text:sequence-decls>
WOK
x=x.strip
x=x.gsub(/\n+/m,'') unless @md.opt.act[:maintenance][:set]==:on
@per.head << x
end
def publish
content=[]
br_pg='<text:p text:style-name="P_normal_page_new"> </text:p>'
content <<
@per.head <<
@per.toc <<
br_pg <<
@per.body <<
@per.book_idx <<
br_pg <<
@per.metadata <<
@per.tail
SiSU_XML_ODF_ODT::Source::Output.new(content,@md,@env).odf
@@odf={ head: [], toc: [], body: [], tail: [], book_idx: [], metadata: [] }
end
end
class Output <Source
def initialize(content,md,env)
@content,@md,@env=content,md,env
end
def odf #%odf output
env=SiSU_Env::FileOp.new(@md)
env.mkdir
header=SiSU_XML_ODF_ODT_Format::ODT_Head_1_2.new(@md)
filename="#{@env.processing_path.odt}/manifest.rdf"
od=File.new(filename,'w+')
od << header.manifest_rdf
od.close
filename="#{@env.processing_path.odt}/META-INF/manifest.xml"
od=File.new(filename,'w+')
od << header.meta_inf_manifest_xml(@md)
od.close
filename="#{@env.processing_path.odt}/meta.xml"
od=File.new(filename,'w+')
od << header.meta_xml
od.close
filename="#{@env.processing_path.odt}/settings.xml"
od=File.new(filename,'w+')
od << header.settings_xml
od.close
filename="#{@env.processing_path.odt}/styles.xml"
od=File.new(filename,'w+')
od << header.styles_xml
od.close
filename="#{@env.processing_path.odt}/mimetype"
od=File.new(filename,'w+')
od << header.mimetype
od.close
env.make_path(@env.processing_path.odt)
env.make_path(@md.file.output_path.odt.dir)
filename="#{@env.processing_path.odt}/content.xml"
od=File.new(filename,'w+')
@content.flatten.compact.each do |para| # this is a hack, check change does not alter behavior
od.puts para unless para =~/\A\s*\Z/
end
od.close
opendoc=@md.file.base_filename.odt #watch where output by language
FileUtils::mkdir_p(@md.file.output_path.odt.dir) \
unless FileTest.directory?(@md.file.output_path.odt.dir)
if FileTest.directory?(@env.processing_path.odt) \
and SiSU_Env::SystemCall.new.zip
pwd=Dir.pwd
Dir.chdir(@env.processing_path.odt)
system("
zip -qr #{opendoc} *
")
FileUtils::mv(opendoc, @md.file.place_file.odt.dir)
Dir.chdir(pwd)
else
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark('*EXITED odf* zip program not found') unless SiSU_Env::SystemCall.new.zip
end
end
end
end
end
__END__
#+END_SRC
** xml_odf_odt_format.rb
#+BEGIN_SRC ruby :tangle "../lib/sisu/xml_odf_odt_format.rb"
# <<sisu_document_header>>
module SiSU_XML_ODF_ODT_Format
require_relative 'dp' # dp.rb
include SiSU_Param
class ParagraphNumber
def initialize(make,paranum)
@make=make
@paranum=/(\d+)/m.match(paranum.to_s)[1]
end
def set_ref_and_display
set_ref=@paranum.gsub(/(\d+)/,
' <text:span text:style-name="Span_subscript"><text:reference-mark-start text:name="\1"/><text:reference-mark-end text:name="\1"/></text:span>')
disp=@paranum.gsub(/(\d+)/,
(@make.build.odt_ocn?) \
? %{ <text:span text:style-name="Span_subscript">#{Dx[:ocn_o]}\\1#{Dx[:ocn_c]}</text:span>}
: '')
{ display: disp, set_ref: set_ref }
end
def set_bookmark_and_display
set_ref=@paranum.gsub(/(\d+)/,
' <text:span text:style-name="Span_subscript"><text:bookmark-start text:name="\1"/><text:bookmark-end text:name="\1"/></text:span>')
disp=@paranum.gsub(/(\d+)/,
(@make.build.odt_ocn?) \
? %{ <text:span text:style-name="Span_subscript">#{Dx[:ocn_o]}\\1#{Dx[:ocn_c]}</text:span>}
: '')
{ display: disp, set_ref: set_ref }
end
def name
@paranum.gsub(/(\d+)/,'<a name="\1"></a>')
end
def goto
@paranum.gsub(/(\d+)/,'<a href="#\1">')
end
end
class FormatBookIndex
def initialize(idx_str)
@idx_str=idx_str
end
def book_idx_bookmark
map_nametags=SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map #p map_nametags
rgx_bookmark=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}#?\S+?#{Mx[:rel_c]}/m
while @idx_str =~/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+)#{Mx[:lnk_c]}#{Mx[:rel_o]}#?(\S+?)#{Mx[:rel_c]}/m
link,url=$1,$2
link,url=link.strip,url.strip
@idx_str=@idx_str.gsub(/&/m,"&")
ocn_lnk=if map_nametags[url] \
and map_nametags[url][:ocn]
map_nametags[url][:ocn]
else nil
end
ocn_lnk=(url=~/^\d+$/ ? url : ocn_lnk)
if ocn_lnk and not ocn_lnk.empty?
@idx_str=@idx_str.sub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,
'<text:span text:style-name="Span_bold">\1</text:span>').
sub(rgx_bookmark,
%{<text:bookmark-ref text:reference-format="text" text:ref-name="#{url}">#{link.strip}</text:bookmark-ref>})
else
puts %{name tag: "#{url}" not found}
@idx_str.sub!(rgx_bookmark,"#{link}")
end
end
@idx_str=@idx_str.gsub(/#{Xx[:protect]}/m,'').
sub(/,\s*$/m,'').
gsub(/\n/,'')
@idx_str='<text:p text:style-name="P_normal">' + @idx_str + '</text:p>'
end
end
class Tags
def set_bookmark_tag(dob)
tags=''
if dob.tags.length > 0
dob.tags.each do |tag|
tags +=%{ <text:span text:style-name="Span_subscript"><text:bookmark-start text:name="#{tag}"/><text:bookmark-end text:name="#{tag}"/></text:span>}
end
end
tags
end
end
class FormatTextObject
def initialize(md,t_o)
@md,@t_o=md,t_o
if t_o.is_a?(Hash)
@txt =t_o[:txt] || nil
else
p t_o.class
p caller
end
rgx=/#{Mx[:en_a_o]}\d+\s+(.+?)#{Mx[:en_a_c]}/
@txt=@txt.gsub(rgx,'\1') if @txt =~rgx
end
def scr_endnote_body
"<endnote>#{@txt}</endnote> "
end
def heading_body1
end
def heading_body2
end
def heading_body3
end
def heading_body4
end
def heading_body5
end
def heading_body6
end
def heading_body7
end
end
class Table
@@table_counter=0
@@tablefoot=[] #watch
@@fns=''
def initialize(md,dob,p_num)
@md,@dob,@p_num=md,dob,p_num
@txt=dob.obj
if @md.fns != @@fns
@@table_counter=0
@@fns=@md.fns
end
end
def break_line
(@md.opt.act[:maintenance][:set]==:on) \
? "\n" : ''
end
def table_head_open(count)
type=(@dob.head_) \
? 1
: 2
alpha=case @dob.cols
when 1 then 'A'
when 2 then 'B'
when 3 then 'C'
when 4 then 'D'
when 5 then 'E'
when 6 then 'F'
when 7 then 'G'
when 8 then 'H'
when 9 then 'I'
when 10 then 'J'
when 11 then 'K'
when 12 then 'L'
when 13 then 'M'
when 14 then 'N'
else 'D'
end
tag=SiSU_XML_ODF_ODT_Format::Tags.new.set_bookmark_tag(@dob)
%{<table:table table:name="Table#{count}" table:style-name="Table#{type}">#{@p_num[:set_ref]}#{tag}#{break_line}} +
%{<table:table-column table:style-name="Table#{type}.#{alpha}" table:number-columns-repeated="#{@dob.cols}"/>#{break_line}}
end
def table_close(tablefoot='')
'</table:table>' \
+ %{<text:p text:style-name="P_group">#{@p_num[:display]}</text:p>}
end
def table_tag_cell(str,i)
txt_name_cell=if i==0 \
and @dob.head_
'Table_Heading'
else 'P_table_cell'
end
str=str.gsub(/^~$/,'') # tilde / empty cell
%{<table:table-cell office:value-type="string">#{break_line}} +
%{<text:p text:style-name="#{txt_name_cell}">#{break_line}} +
%{#{str}} +
%{</text:p>#{break_line}} +
%{</table:table-cell>#{break_line}}
end
def table_tag_row(str,i)
%{<table:table-row>#{break_line}} +
%{#{str}} +
%{</table:table-row>#{break_line}}
end
def table_tag_row_dump(str,i)
txt_name_row=if i==0 \
and @dob.head_
'Table_Heading'
else 'P_table_cell'
end
%{<table:table-row>#{break_line}} +
%{<table:table-cell office:value-type="string">#{break_line}} +
%{<text:p text:style-name="#{txt_name_row}">#{break_line}} +
%{#{str}} +
%{</text:p>#{break_line}} +
%{</table:table-cell>#{break_line}} +
%{</table:table-row>#{break_line}}
end
def table_row(row,i)
row='' if row =~/^<!$/
m=row[/<!f(.+?)!>/,1]
@@tablefoot << m if m
row=row.gsub(/<!f.+?!>/,'')
@cells=[]
row.split(/\s*#{Mx[:tc_p]}/).each do |cell|
@cells << table_tag_cell(cell,i)
end
row=@cells.join
row=table_tag_row(row,i)
row
end
def table
@@table_counter+=1
table_head_open(@@table_counter)
@table=[]
@dob.obj.split(/\s*#{Mx[:tc_c]}/).each_with_index do |r,i|
@table << table_row(r,i)
end
@dob.obj= table_head_open(@@table_counter) + @table.join + table_close
@dob
end
end
class ODT_Head_1_2
def initialize(md)
@md=md
@generator="#{@md.project_details.project} #{@md.project_details.version} #{@md.project_details.date_stamp} (#{@md.project_details.date})"
end
def manifest_rdf
x=<<WOK
<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="styles.xml">
<rdf:type rdf:resource="http://docs.oasis-open.org/ns/office/1.2/meta/odf#StylesFile"/>
</rdf:Description>
<rdf:Description rdf:about="">
<ns0:hasPart xmlns:ns0="http://docs.oasis-open.org/ns/office/1.2/meta/pkg#" rdf:resource="styles.xml"/>
</rdf:Description>
<rdf:Description rdf:about="content.xml">
<rdf:type rdf:resource="http://docs.oasis-open.org/ns/office/1.2/meta/odf#ContentFile"/>
</rdf:Description>
<rdf:Description rdf:about="">
<ns0:hasPart xmlns:ns0="http://docs.oasis-open.org/ns/office/1.2/meta/pkg#" rdf:resource="content.xml"/>
</rdf:Description>
<rdf:Description rdf:about="">
<rdf:type rdf:resource="http://docs.oasis-open.org/ns/office/1.2/meta/pkg#Document"/>
</rdf:Description>
</rdf:RDF>
WOK
x=x.strip
x=x.gsub(/\n+/m,'') unless @md.opt.act[:maintenance][:set]==:on
x
end
def meta_inf_manifest_xml(md)
images=[' <manifest:file-entry manifest:media-type="" manifest:full-path="Pictures/bullet_09.png"/>']
if md.ec[:image].length > 0
md.ec[:image].each do |i|
images<<<<WOK
<manifest:file-entry manifest:media-type="" manifest:full-path="Pictures/#{i}"/>
WOK
end
end
images=images.join('')
x=<<WOK
<?xml version="1.0" encoding="UTF-8"?>
<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.2">
<manifest:file-entry manifest:media-type="application/vnd.oasis.opendocument.text" manifest:version="1.2" manifest:full-path="/"/>
<manifest:file-entry manifest:media-type="text/xml" manifest:full-path="styles.xml"/>
<manifest:file-entry manifest:media-type="text/xml" manifest:full-path="content.xml"/>
#{images}
<manifest:file-entry manifest:media-type="text/xml" manifest:full-path="meta.xml"/>
<manifest:file-entry manifest:media-type="application/rdf+xml" manifest:full-path="manifest.rdf"/>
<manifest:file-entry manifest:media-type="image/png" manifest:full-path="Thumbnails/thumbnail.png"/>
<manifest:file-entry manifest:media-type="application/binary" manifest:full-path="layout-cache"/>
<manifest:file-entry manifest:media-type="text/xml" manifest:full-path="settings.xml"/>
<manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/accelerator/current.xml"/>
<manifest:file-entry manifest:media-type="application/vnd.sun.xml.ui.configuration" manifest:full-path="Configurations2/"/>
</manifest:manifest>
WOK
x=x.strip
x=x.gsub(/\n+/m,'') unless @md.opt.act[:maintenance][:set]==:on
x
end
def meta_xml
x=<<WOK
<?xml version="1.0" encoding="UTF-8"?>
<office:document-meta xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:grddl="http://www.w3.org/2003/g/data-view#" office:version="1.2">
<office:meta>
<meta:generator>#{@generator}</meta:generator>
<meta:creation-date>#{@md.generated}</meta:creation-date>
<dc:date>#{@md.generated}</dc:date>
<dc:language>en-US</dc:language>
</office:meta>
</office:document-meta>
WOK
x=x.strip
x=x.gsub(/\n+/m,'') unless @md.opt.act[:maintenance][:set]==:on
x
end
def settings_xml
x=<<WOK
<?xml version="1.0" encoding="UTF-8"?>
<office:document-settings xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" office:version="1.2">
<office:settings>
<config:config-item-set config:name="ooo:view-settings">
<config:config-item config:name="ViewAreaTop" config:type="int">0</config:config-item>
<config:config-item config:name="ViewAreaLeft" config:type="int">0</config:config-item>
<config:config-item config:name="ViewAreaWidth" config:type="int">0</config:config-item>
<config:config-item config:name="ViewAreaHeight" config:type="int">0</config:config-item>
<config:config-item config:name="ShowRedlineChanges" config:type="boolean">true</config:config-item>
<config:config-item config:name="InBrowseMode" config:type="boolean">false</config:config-item>
<config:config-item-map-indexed config:name="Views">
<config:config-item-map-entry>
<config:config-item config:name="ViewId" config:type="string">view2</config:config-item>
<config:config-item config:name="ViewLeft" config:type="int">0</config:config-item>
<config:config-item config:name="ViewTop" config:type="int">0</config:config-item>
<config:config-item config:name="VisibleLeft" config:type="int">0</config:config-item>
<config:config-item config:name="VisibleTop" config:type="int">0</config:config-item>
<config:config-item config:name="VisibleRight" config:type="int">0</config:config-item>
<config:config-item config:name="VisibleBottom" config:type="int">0</config:config-item>
<config:config-item config:name="ZoomType" config:type="short">0</config:config-item>
<config:config-item config:name="ViewLayoutColumns" config:type="short">2</config:config-item>
<config:config-item config:name="ViewLayoutBookMode" config:type="boolean">true</config:config-item>
<config:config-item config:name="ZoomFactor" config:type="short">100</config:config-item>
<config:config-item config:name="IsSelectedFrame" config:type="boolean">false</config:config-item>
</config:config-item-map-entry>
</config:config-item-map-indexed>
</config:config-item-set>
<config:config-item-set config:name="ooo:configuration-settings">
<config:config-item config:name="ChartAutoUpdate" config:type="boolean">true</config:config-item>
<config:config-item config:name="IsLabelDocument" config:type="boolean">false</config:config-item>
<config:config-item config:name="MathBaselineAlignment" config:type="boolean">false</config:config-item>
<config:config-item config:name="OutlineLevelYieldsNumbering" config:type="boolean">true</config:config-item>
<config:config-item config:name="PrintLeftPages" config:type="boolean">true</config:config-item>
<config:config-item config:name="DoNotJustifyLinesWithManualBreak" config:type="boolean">false</config:config-item>
<config:config-item config:name="AlignTabStopPosition" config:type="boolean">true</config:config-item>
<config:config-item config:name="PrintTextPlaceholder" config:type="boolean">false</config:config-item>
<config:config-item config:name="UseOldNumbering" config:type="boolean">false</config:config-item>
<config:config-item config:name="CurrentDatabaseCommand" config:type="string"/>
<config:config-item config:name="ProtectForm" config:type="boolean">false</config:config-item>
<config:config-item config:name="PrintBlackFonts" config:type="boolean">false</config:config-item>
<config:config-item config:name="PrintProspectRTL" config:type="boolean">false</config:config-item>
<config:config-item config:name="SmallCapsPercentage66" config:type="boolean">true</config:config-item>
<config:config-item config:name="PrintControls" config:type="boolean">true</config:config-item>
<config:config-item config:name="CharacterCompressionType" config:type="short">0</config:config-item>
<config:config-item config:name="PrintHiddenText" config:type="boolean">false</config:config-item>
<config:config-item config:name="UseFormerTextWrapping" config:type="boolean">false</config:config-item>
<config:config-item config:name="IsKernAsianPunctuation" config:type="boolean">false</config:config-item>
<config:config-item config:name="PrintProspect" config:type="boolean">false</config:config-item>
<config:config-item config:name="PrintEmptyPages" config:type="boolean">true</config:config-item>
<config:config-item config:name="UseFormerObjectPositioning" config:type="boolean">false</config:config-item>
<config:config-item config:name="ConsiderTextWrapOnObjPos" config:type="boolean">false</config:config-item>
<config:config-item config:name="TableRowKeep" config:type="boolean">false</config:config-item>
<config:config-item config:name="PrintReversed" config:type="boolean">false</config:config-item>
<config:config-item config:name="TabsRelativeToIndent" config:type="boolean">true</config:config-item>
<config:config-item config:name="PrintRightPages" config:type="boolean">true</config:config-item>
<config:config-item config:name="PrintPaperFromSetup" config:type="boolean">false</config:config-item>
<config:config-item config:name="AddFrameOffsets" config:type="boolean">false</config:config-item>
<config:config-item config:name="AddParaSpacingToTableCells" config:type="boolean">true</config:config-item>
<config:config-item config:name="UpdateFromTemplate" config:type="boolean">false</config:config-item>
<config:config-item config:name="AddExternalLeading" config:type="boolean">true</config:config-item>
<config:config-item config:name="PrintSingleJobs" config:type="boolean">false</config:config-item>
<config:config-item config:name="PrinterIndependentLayout" config:type="string">high-resolution</config:config-item>
<config:config-item config:name="LinkUpdateMode" config:type="short">1</config:config-item>
<config:config-item config:name="PrintAnnotationMode" config:type="short">0</config:config-item>
<config:config-item config:name="UseOldPrinterMetrics" config:type="boolean">true</config:config-item>
<config:config-item config:name="RedlineProtectionKey" config:type="base64Binary"/>
<config:config-item config:name="PrinterSetup" config:type="base64Binary"/>
<config:config-item config:name="IgnoreFirstLineIndentInNumbering" config:type="boolean">false</config:config-item>
<config:config-item config:name="CollapseEmptyCellPara" config:type="boolean">true</config:config-item>
<config:config-item config:name="PrinterName" config:type="string"/>
<config:config-item config:name="InvertBorderSpacing" config:type="boolean">false</config:config-item>
<config:config-item config:name="PrintPageBackground" config:type="boolean">true</config:config-item>
<config:config-item config:name="DoNotCaptureDrawObjsOnPage" config:type="boolean">false</config:config-item>
<config:config-item config:name="ApplyUserData" config:type="boolean">true</config:config-item>
<config:config-item config:name="TabAtLeftIndentForParagraphsInList" config:type="boolean">false</config:config-item>
<config:config-item config:name="UnxForceZeroExtLeading" config:type="boolean">true</config:config-item>
<config:config-item config:name="SaveVersionOnClose" config:type="boolean">false</config:config-item>
<config:config-item config:name="PrintFaxName" config:type="string"/>
<config:config-item config:name="AddParaTableSpacing" config:type="boolean">true</config:config-item>
<config:config-item config:name="PrintDrawings" config:type="boolean">true</config:config-item>
<config:config-item config:name="LoadReadonly" config:type="boolean">false</config:config-item>
<config:config-item config:name="PrintGraphics" config:type="boolean">true</config:config-item>
<config:config-item config:name="FieldAutoUpdate" config:type="boolean">true</config:config-item>
<config:config-item config:name="AllowPrintJobCancel" config:type="boolean">true</config:config-item>
<config:config-item config:name="UseFormerLineSpacing" config:type="boolean">false</config:config-item>
<config:config-item config:name="SaveGlobalDocumentLinks" config:type="boolean">false</config:config-item>
<config:config-item config:name="CurrentDatabaseDataSource" config:type="string"/>
<config:config-item config:name="IgnoreTabsAndBlanksForLineCalculation" config:type="boolean">false</config:config-item>
<config:config-item config:name="CurrentDatabaseCommandType" config:type="int">0</config:config-item>
<config:config-item config:name="DoNotResetParaAttrsForNumFont" config:type="boolean">false</config:config-item>
<config:config-item config:name="ClipAsCharacterAnchoredWriterFlyFrames" config:type="boolean">false</config:config-item>
<config:config-item config:name="PrintTables" config:type="boolean">true</config:config-item>
<config:config-item config:name="AddParaTableSpacingAtStart" config:type="boolean">true</config:config-item>
</config:config-item-set>
</office:settings>
</office:document-settings>
WOK
x=x.strip
x=x.gsub(/\n+/m,'') unless @md.opt.act[:maintenance][:set]==:on
x
end
def styles_xml
x=<<WOK
<?xml version="1.0" encoding="UTF-8"?>
<office:document-styles xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2">
<office:font-face-decls>
<style:font-face style:name="DejaVu Sans Mono" svg:font-family="'DejaVu Sans Mono'" style:font-adornments="Book" style:font-family-generic="modern" style:font-pitch="fixed"/>
<style:font-face style:name="Nimbus Sans L" svg:font-family="'Nimbus Sans L'" style:font-pitch="variable"/>
<style:font-face style:name="Tahoma" svg:font-family="Tahoma, Lucidasans, 'Lucida Sans', 'Arial Unicode MS'" style:font-pitch="variable"/>
<style:font-face style:name="Nimbus Roman No9 L" svg:font-family="'Nimbus Roman No9 L'" style:font-family-generic="roman" style:font-pitch="variable"/>
<style:font-face style:name="Bitstream Vera Sans" svg:font-family="'Bitstream Vera Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/>
</office:font-face-decls>
<office:styles>
<style:default-style style:family="graphic">
<style:graphic-properties fo:wrap-option="wrap" draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/>
<style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:writing-mode="lr-tb" style:font-independent-line-spacing="false">
<style:tab-stops/>
</style:paragraph-properties>
<style:text-properties style:use-window-font-color="true" fo:font-size="12pt" fo:language="en" fo:country="US" style:font-size-asian="12pt" style:language-asian="zxx" style:country-asian="none" style:font-size-complex="12pt" style:language-complex="zxx" style:country-complex="none"/>
</style:default-style>
<style:default-style style:family="paragraph">
<style:paragraph-properties fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="1.251cm" style:writing-mode="page"/>
<style:text-properties style:use-window-font-color="true" style:font-name="Nimbus Roman No9 L" fo:font-size="12pt" fo:language="en" fo:country="US" style:font-name-asian="Nimbus Sans L" style:font-size-asian="12pt" style:language-asian="zxx" style:country-asian="none" style:font-name-complex="Nimbus Sans L" style:font-size-complex="12pt" style:language-complex="zxx" style:country-complex="none" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/>
</style:default-style>
<style:default-style style:family="table">
<style:table-properties table:border-model="collapsing"/>
</style:default-style>
<style:default-style style:family="table-row">
<style:table-row-properties fo:keep-together="auto"/>
</style:default-style>
<style:style style:name="Standard" style:family="paragraph" style:class="text"/>
<style:style style:name="Text_body" style:display-name="Text body" style:family="paragraph" style:class="text"><style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.212cm"/></style:style>
<style:style style:name="P_page_break" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:break-before="page"/></style:style>
<style:style style:name="P_normal" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:text-align="justify" style:justify-single-word="false"/></style:style>
<style:style style:name="P_normal_page_new" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:break-after="page"/></style:style>
<style:style style:name="P_indent_0" style:display-name="Paragraph indent 0" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:text-align="justify" style:justify-single-word="false"/></style:style>
<style:style style:name="P_indent_1" style:display-name="Paragraph indent 1" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="1cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>
<style:style style:name="P_indent_2" style:display-name="Paragraph indent 2" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="2cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>
<style:style style:name="P_indent_3" style:display-name="Paragraph indent 3" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="3cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>
<style:style style:name="P_indent_4" style:display-name="Paragraph indent 4" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="4cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>
<style:style style:name="P_indent_5" style:display-name="Paragraph indent 5" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="5cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>
<style:style style:name="P_indent_6" style:display-name="Paragraph indent 6" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="6cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>
<style:style style:name="P_indent_7" style:display-name="Paragraph indent 7" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="7cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>
<style:style style:name="P_indent_8" style:display-name="Paragraph indent 8" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="8cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>
<style:style style:name="P_indent_9" style:display-name="Paragraph indent 9" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="9cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>
<style:style style:name="P_h0_i0" style:display-name="Hang 0 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h0_i1" style:display-name="Hang 0 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="-1cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h0_i2" style:display-name="Hang 0 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="-2cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h0_i3" style:display-name="Hang 0 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="-3cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h0_i4" style:display-name="Hang 0 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="-4cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h0_i5" style:display-name="Hang 0 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="-5cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h0_i6" style:display-name="Hang 0 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="-6cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h0_i7" style:display-name="Hang 0 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="-7cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h0_i8" style:display-name="Hang 0 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="-8cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h0_i9" style:display-name="Hang 0 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="-9cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h1_i0" style:display-name="Hang 1 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="1cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h1_i1" style:display-name="Hang 1 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h1_i2" style:display-name="Hang 1 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="-1cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h1_i3" style:display-name="Hang 1 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="-2cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h1_i4" style:display-name="Hang 1 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="-3cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h1_i5" style:display-name="Hang 1 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="-4cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h1_i6" style:display-name="Hang 1 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="-5cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h1_i7" style:display-name="Hang 1 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="-6cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h1_i8" style:display-name="Hang 1 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="-7cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h1_i9" style:display-name="Hang 1 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="-8cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h2_i0" style:display-name="Hang 2 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="2cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h2_i1" style:display-name="Hang 2 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="1cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h2_i2" style:display-name="Hang 2 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h2_i3" style:display-name="Hang 2 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="-1cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h2_i4" style:display-name="Hang 2 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="-2cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h2_i5" style:display-name="Hang 2 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="-3cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h2_i6" style:display-name="Hang 2 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="-4cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h2_i7" style:display-name="Hang 2 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="-5cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h2_i8" style:display-name="Hang 2 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="-6cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h2_i9" style:display-name="Hang 2 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="-7cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h3_i0" style:display-name="Hang 3 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="3cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h3_i1" style:display-name="Hang 3 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="2cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h3_i2" style:display-name="Hang 3 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="1cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h3_i3" style:display-name="Hang 3 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h3_i4" style:display-name="Hang 3 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="-1cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h3_i5" style:display-name="Hang 3 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="-2cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h3_i6" style:display-name="Hang 3 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="-3cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h3_i7" style:display-name="Hang 3 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="-4cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h3_i8" style:display-name="Hang 3 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="-5cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h3_i9" style:display-name="Hang 3 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="-6cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h4_i0" style:display-name="Hang 4 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="4cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h4_i1" style:display-name="Hang 4 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="3cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h4_i2" style:display-name="Hang 4 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="2cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h4_i3" style:display-name="Hang 4 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="1cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h4_i4" style:display-name="Hang 4 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h4_i5" style:display-name="Hang 4 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="-1cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h4_i6" style:display-name="Hang 4 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="-2cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h4_i7" style:display-name="Hang 4 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="-3cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h4_i8" style:display-name="Hang 4 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="-4cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h4_i9" style:display-name="Hang 4 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="-5cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h5_i0" style:display-name="Hang 5 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="5cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h5_i1" style:display-name="Hang 5 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="4cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h5_i2" style:display-name="Hang 5 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="3cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h5_i3" style:display-name="Hang 5 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="2cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h5_i4" style:display-name="Hang 5 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="1cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h5_i5" style:display-name="Hang 5 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h5_i6" style:display-name="Hang 5 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="-1cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h5_i7" style:display-name="Hang 5 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="-2cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h5_i8" style:display-name="Hang 5 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="-3cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h5_i9" style:display-name="Hang 5 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="-4cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h6_i0" style:display-name="Hang 6 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="6cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h6_i1" style:display-name="Hang 6 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="5cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h6_i2" style:display-name="Hang 6 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="4cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h6_i3" style:display-name="Hang 6 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="3cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h6_i4" style:display-name="Hang 6 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="2cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h6_i5" style:display-name="Hang 6 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="1cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h6_i6" style:display-name="Hang 6 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h6_i7" style:display-name="Hang 6 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="-1cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h6_i8" style:display-name="Hang 6 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="-2cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h6_i9" style:display-name="Hang 6 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="-3cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h7_i0" style:display-name="Hang 7 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="7cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h7_i1" style:display-name="Hang 7 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="6cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h7_i2" style:display-name="Hang 7 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="5cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h7_i3" style:display-name="Hang 7 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="4cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h7_i4" style:display-name="Hang 7 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="3cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h7_i5" style:display-name="Hang 7 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="2cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h7_i6" style:display-name="Hang 7 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="1cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h7_i7" style:display-name="Hang 7 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h7_i8" style:display-name="Hang 7 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="-1cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h7_i9" style:display-name="Hang 7 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="-2cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h8_i0" style:display-name="Hang 8 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="8cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h8_i1" style:display-name="Hang 8 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="7cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h8_i2" style:display-name="Hang 8 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="6cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h8_i3" style:display-name="Hang 8 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="5cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h8_i4" style:display-name="Hang 8 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="4cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h8_i5" style:display-name="Hang 8 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="3cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h8_i6" style:display-name="Hang 8 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="2cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h8_i7" style:display-name="Hang 8 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="1cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h8_i8" style:display-name="Hang 8 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h8_i9" style:display-name="Hang 8 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="-1cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h9_i0" style:display-name="Hang 9 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="9cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h9_i1" style:display-name="Hang 9 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="8cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h9_i2" style:display-name="Hang 9 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="7cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h9_i3" style:display-name="Hang 9 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="6cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h9_i4" style:display-name="Hang 9 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="5cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h9_i5" style:display-name="Hang 9 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="4cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h9_i6" style:display-name="Hang 9 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="3cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h9_i7" style:display-name="Hang 9 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="2cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h9_i8" style:display-name="Hang 9 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="1cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="P_h9_i9" style:display-name="Hang 9 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"><style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0cm"/></style:tab-stops></style:paragraph-properties></style:style>
<style:style style:name="Span_bold" style:family="text"><style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/></style:style>
<style:style style:name="Span_italic" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic"/></style:style>
<style:style style:name="Span_underscore" style:family="text"><style:text-properties style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="font-color"/></style:style>
<style:style style:name="Span_superscript" style:family="text"><style:text-properties style:text-position="super 58%"/></style:style>
<style:style style:name="Span_subscript" style:family="text"><style:text-properties style:text-position="sub 58%"/></style:style>
<style:style style:name="Span_monospace" style:family="text"><style:text-properties style:font-name="DejaVu Sans Mono" fo:font-size="10pt" fo:font-weight="normal" fo:background-color="#e6e6e6"/></style:style>
<style:style style:name="Heading" style:family="paragraph" style:next-style-name="Text_body" style:class="text"> <style:paragraph-properties fo:margin-top="0.423cm" fo:margin-bottom="0.212cm" fo:keep-with-next="always"/><style:text-properties style:font-name="Bitstream Vera Sans" fo:font-size="14pt" style:font-size-asian="14pt" style:font-name-complex="Tahoma" style:font-size-complex="14pt"/></style:style>
<style:style style:name="H_1" style:display-name="Heading 1" style:family="paragraph" style:next-style-name="Text_body" style:default-outline-level="1" style:class="text"><style:text-properties fo:font-size="120%" fo:font-weight="bold" style:font-size-asian="120%" style:font-weight-asian="bold" style:font-size-complex="115%" style:font-weight-complex="bold"/></style:style>
<style:style style:name="H_2" style:display-name="Heading 2" style:family="paragraph" style:next-style-name="Text_body" style:default-outline-level="2" style:class="text"><style:text-properties fo:font-size="115%" fo:font-weight="bold" style:font-size-asian="115%" style:font-weight-asian="bold" style:font-size-complex="115%" style:font-weight-complex="bold"/></style:style>
<style:style style:name="H_3" style:display-name="Heading 3" style:family="paragraph" style:next-style-name="Text_body" style:default-outline-level="3" style:class="text"><style:text-properties fo:font-size="110%" fo:font-weight="bold" style:font-size-asian="110%" style:font-weight-asian="bold" style:font-size-complex="115%" style:font-weight-complex="bold"/></style:style>
<style:style style:name="H_4" style:display-name="Heading 4" style:family="paragraph" style:next-style-name="Text_body" style:default-outline-level="4" style:class="text"><style:text-properties fo:font-size="12pt" fo:font-style="italic" fo:font-weight="bold" style:font-size-asian="12pt" style:font-style-asian="italic" style:font-weight-asian="bold" style:font-size-complex="12pt" style:font-style-complex="italic" style:font-weight-complex="bold"/></style:style>
<style:style style:name="H_5" style:display-name="Heading 5" style:family="paragraph" style:next-style-name="Text_body" style:default-outline-level="5" style:class="text"><style:text-properties fo:font-size="90%" fo:font-style="italic" fo:font-weight="bold" style:font-size-asian="90%" style:font-style-asian="italic" style:font-weight-asian="bold" style:font-size-complex="90%" style:font-style-complex="italic" style:font-weight-complex="bold"/></style:style>
<style:style style:name="H_6" style:display-name="Heading 6" style:family="paragraph" style:next-style-name="Text_body" style:default-outline-level="6" style:class="text"><style:text-properties fo:font-size="80%" fo:font-style="italic" fo:font-weight="bold" style:font-size-asian="80%" style:font-style-asian="italic" style:font-weight-asian="bold" style:font-size-complex="80%" style:font-style-complex="italic" style:font-weight-complex="bold"/></style:style>
<style:style style:name="P_group" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0cm" fo:line-height="100%" fo:text-align="justify" style:justify-single-word="false"/></style:style>
<style:style style:name="P_code" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0cm" fo:line-height="100%" fo:text-align="start" style:justify-single-word="false"/><style:text-properties style:font-name="DejaVu Sans Mono" fo:font-size="9pt" fo:font-weight="normal" fo:background-color="#e6e6e6"/></style:style>
<style:style style:name="Footnote" style:family="paragraph" style:class="extra"><style:paragraph-properties fo:margin-left="0.499cm" fo:margin-right="0cm" fo:text-indent="-0.499cm" style:auto-text-indent="false" text:number-lines="false" text:line-number="0"/> <style:text-properties fo:font-size="10pt" style:font-size-asian="10pt" style:font-size-complex="10pt"/></style:style>
<style:style style:name="Table_Contents" style:display-name="Table Contents" style:family="paragraph" style:parent-style-name="Standard" style:class="extra"><style:paragraph-properties text:number-lines="false" text:line-number="0"/></style:style>
<style:style style:name="Footnote_symbol" style:display-name="Footnote Symbol" style:family="text"/>
<style:style style:name="Footnote_anchor" style:display-name="Footnote Anchor" style:family="text"><style:text-properties style:text-position="super 58%"/></style:style>
<style:style style:name="Internet_link" style:display-name="Internet link" style:family="text"><style:text-properties fo:color="#000080" fo:language="zxx" fo:country="none" style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="font-color" style:language-asian="zxx" style:country-asian="none" style:language-complex="zxx" style:country-complex="none"/></style:style>
<style:style style:name="Graphics" style:family="graphic"><style:graphic-properties text:anchor-type="paragraph" svg:x="0cm" svg:y="0cm" style:wrap="dynamic" style:number-wrapped-paragraphs="no-limit" style:wrap-contour="false" style:vertical-pos="top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph"/></style:style>
<text:outline-style style:name="Outline"><text:outline-level-style text:level="1" style:num-format=""><style:list-level-properties text:min-label-distance="0.381cm"/></text:outline-level-style>
<text:outline-level-style text:level="2" style:num-format=""><style:list-level-properties text:min-label-distance="0.381cm"/></text:outline-level-style>
<text:outline-level-style text:level="3" style:num-format=""><style:list-level-properties text:min-label-distance="0.381cm"/></text:outline-level-style>
<text:outline-level-style text:level="4" style:num-format=""><style:list-level-properties text:min-label-distance="0.381cm"/></text:outline-level-style>
<text:outline-level-style text:level="5" style:num-format=""><style:list-level-properties text:min-label-distance="0.381cm"/></text:outline-level-style>
<text:outline-level-style text:level="6" style:num-format=""><style:list-level-properties text:min-label-distance="0.381cm"/></text:outline-level-style>
<text:outline-level-style text:level="7" style:num-format=""><style:list-level-properties text:min-label-distance="0.381cm"/></text:outline-level-style>
<text:outline-level-style text:level="8" style:num-format=""><style:list-level-properties text:min-label-distance="0.381cm"/></text:outline-level-style>
<text:outline-level-style text:level="9" style:num-format=""><style:list-level-properties text:min-label-distance="0.381cm"/></text:outline-level-style>
<text:outline-level-style text:level="10" style:num-format=""><style:list-level-properties text:min-label-distance="0.381cm"/></text:outline-level-style>
</text:outline-style>
<text:notes-configuration text:note-class="footnote" text:citation-style-name="Footnote_symbol" text:citation-body-style-name="Footnote_anchor" style:num-format="1" text:start-value="0" text:footnotes-position="page" text:start-numbering-at="document"/>
<text:notes-configuration text:note-class="endnote" style:num-format="i" text:start-value="0"/>
<text:linenumbering-configuration text:number-lines="false" text:offset="0.499cm" style:num-format="1" text:number-position="left" text:increment="5"/>
<style:style style:name="fr1" style:family="graphic" style:parent-style-name="Graphics"><style:graphic-properties style:wrap="none" style:horizontal-pos="left" style:horizontal-rel="paragraph" style:mirror="none" fo:clip="rect(0cm 0cm 0cm 0cm)" draw:luminance="0%" draw:contrast="0%" draw:red="0%" draw:green="0%" draw:blue="0%" draw:gamma="100%" draw:color-inversion="false" draw:image-opacity="100%" draw:color-mode="standard"/></style:style>
<style:style style:name="gr1" style:family="graphic"><style:graphic-properties draw:stroke="none" draw:fill="none" draw:textarea-horizontal-align="center" draw:textarea-vertical-align="middle" draw:color-mode="standard" draw:luminance="0%" draw:contrast="0%" draw:gamma="100%" draw:red="0%" draw:green="0%" draw:blue="0%" fo:clip="rect(0cm 0cm 0cm 0cm)" draw:image-opacity="100%" style:mirror="none" style:run-through="background" style:wrap="none" style:vertical-pos="top" style:vertical-rel="baseline" style:horizontal-pos="left" style:horizontal-rel="paragraph" draw:wrap-influence-on-position="once-concurrent" style:flow-with-text="false"/></style:style>
<style:style style:name="gr2" style:family="graphic"><style:graphic-properties draw:stroke="none" draw:fill="none" draw:textarea-horizontal-align="center" draw:textarea-vertical-align="middle" draw:color-mode="standard" draw:luminance="0%" draw:contrast="0%" draw:gamma="100%" draw:red="0%" draw:green="0%" draw:blue="0%" fo:clip="rect(0cm 0cm 0cm 0cm)" draw:image-opacity="100%" style:mirror="none" style:run-through="background" style:wrap="none" style:vertical-pos="middle" style:vertical-rel="baseline" style:horizontal-pos="left" style:horizontal-rel="paragraph" draw:wrap-influence-on-position="once-concurrent" style:flow-with-text="false"/></style:style>
</office:styles>
<office:automatic-styles>
<style:page-layout style:name="Mpm1">
<style:page-layout-properties fo:page-width="20.999cm" fo:page-height="29.699cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm">
<style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="none" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
</style:page-layout-properties>
<style:header-style/>
<style:footer-style/>
</style:page-layout>
</office:automatic-styles>
<office:master-styles>
<style:master-page style:name="Standard" style:page-layout-name="Mpm1"/>
</office:master-styles>
</office:document-styles>
WOK
x=x.strip
x=x.gsub(/\n+/m,'') unless @md.opt.act[:maintenance][:set]==:on
x
end
def mimetype
x=<<WOK
application/vnd.oasis.opendocument.text
WOK
x=x.strip
end
end
class FormatObjBreak
def initialize(md,t_o)
@md,@t_o=md,t_o
end
def br_page
@t_o.obj='<text:p text:style-name="P_page_break"> </text:p>'
@t_o
end
def br_page_line
sep='_'
@t_o.obj=%{<text:p text:style-name="P_normal">#{sep*60}</text:p>}
@t_o
end
def obj_sep #center later
sep='--- '
@t_o.obj=%{<text:p text:style-name="P_normal">#{sep*20}</text:p>}
@t_o
end
end
class XML
end
end
__END__
#+END_SRC
* docbook5rb
#+BEGIN_SRC ruby :tangle "../lib/sisu/xml_docbook5.rb"
# <<sisu_document_header>>
module SiSU_XML_Docbook_Book
require_relative 'se_hub_particulars' # se_hub_particulars.rb
include SiSU_Particulars
require_relative 'ao' # ao.rb
require_relative 'se' # se.rb
include SiSU_Env
require_relative 'txt_shared' # txt_shared.rb
include SiSU_TextUtils
require_relative 'xml_shared' # xml_shared.rb
include SiSU_XML_Munge
require_relative 'shared_metadata' # shared_metadata.rb
class Source
def initialize(opt)
@opt=opt
@particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt)
end
def read
begin
@md,@ao_array=@particulars.md,@particulars.ao_array
@env=@particulars.env
report
SiSU_XML_Docbook_Book::Source::Scroll.new(@ao_array,@md).songsheet
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
end
ensure
#SiSU_Env::CreateSite.new(@opt.selections.str).cp_css
#SiSU_Env::CreateSite.new(@opt.selections.str).cp_base_images
Dir.chdir(@opt.f_pth[:pth])
end
end
private
def report
unless @opt.act[:quiet][:set]==:on
tool=(@opt.act[:verbose][:set]==:on \
|| @opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on) \
? "#{@env.program.docbook_viewer} #{@md.file.output_path.xml_docbook_book.dir}/#{@md.file.base_filename.xml_docbook_book}"
: "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}"
(@opt.act[:verbose][:set]==:on \
|| @opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on) \
? SiSU_Screen::Ansi.new(
@opt.act[:color_state][:set],
'DocBook',
tool
).green_hi_blue
: SiSU_Screen::Ansi.new(
@opt.act[:color_state][:set],
'DocBook',
tool
).green_title_hi
if (@opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on)
SiSU_Screen::Ansi.new(
@opt.act[:color_state][:set],
@opt.fns,
"#{@md.file.output_path.xml_docbook_book.dir}/#{@md.file.base_filename.xml_docbook_book}"
).flow
end
end
end
class Scroll <Source
def initialize(data='',md='')
@data,@md=data,md
@trans=SiSU_XML_Munge::Trans.new(md)
@particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(md.opt)
@env=@particulars.env
@make ||=SiSU_Env::ProcessingSettings.new(md)
end
def songsheet
@t='sisu'
data=@data
if @md.opt.act[:verbose_plus][:set]==:on
structure_collapsed(data)
end
#head
#extract_endnotes
data=markup_text(data)
structure_build_collapsed(data)
document_images if @md.ec[:image] and @md.ec[:image].length > 0
#tail
end
def document_images
img_pth={
src: @md.opt.image_src_path,
dest: @md.env.path.webserv + '/_sisu/image',
}
unless FileTest.directory?(img_pth[:dest])
#mkdir?
end
if FileTest.directory?(img_pth[:dest])
@md.ec[:image].each do |x|
img={
src: "#{img_pth[:src]}/#{x}",
dest: "#{img_pth[:dest]}/#{x}",
}
if FileTest.file?(img[:src])
FileUtils::cp(img[:src],img[:dest])
else p "Not Found: #{img[:src]}/#{x}"
end
end
end
end
def spaces
Ax[:spaces]
end
def tags
# collapsed -->
def collapsed
%w[ 0 1 2 3 4 5 ]
end
def docbook_tag(lc,chlv='')
case lc
when 0 then 'book'
when 1 then lc==chlv ? 'chapter' : 'section'
when 2 then lc==chlv ? 'chapter' : 'section'
when 3 then lc==chlv ? 'chapter' : 'section'
when 4 then 'section'
when 5 then 'section'
when 6 then 'section'
end
end
self
end
def put(line)
#@file_docbook.puts line #look into and use perhaps
puts line if @md.opt.act[:verbose_plus][:set]==:on
end
def head
rdf=SiSU_XML_Tags::RDF.new(@md)
stylesheet=SiSU_Style::CSS_HeadInfo.new(@md,'xml_docbook').stylesheet
<<-WOK
<?xml version="1.0" encoding="utf-8"?>
#{stylesheet.css_head_xml}
#{rdf.comment_xml}
<book xmlns="http://docbook.org/ns/docbook"
xmlns:xl="http://www.w3.org/1999/xlink"
version="5.0">
WOK
end
def markup_text(data)
data.each_with_index do |o,i|
if o.is ==:heading \
|| o.is ==:para \
|| o.of ==:block \
|| o.is ==:open_close_tags
o=@trans.markup_docbook(o) #unless o.obj==nil
end
end
data
end
def tail
tail=<<-WOK
</book>
WOK
put(tail)
end
def output(o,comment='')
puts o.lc == (0..6) \
? "#{spaces*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}"
: "<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}"
end
def structure_collapsed(data)
puts "\ncollapsed structure, heading outline --->\n\n"
data.each_with_index do |o,i|
if (o.is ==:heading || o.is ==:heading_insert)
output(o)
end
end
end
#def chapterlevel
#end
def xml_head
[
'<docinfo>',
SiSU_Metadata::Summary.new(@md).xml_docbook.metadata,
'</docinfo>'
].flatten
end
def code_output(o,ocn,filename_docbook)
filename_docbook.puts o.obj.gsub(/\n?(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\n?/m,"\n")
end
def adjust_output(o,ocn,filename_docbook,splv)
if o.obj =~/#{Xx[:split]}/
outs=o.obj.split(/#{Xx[:split]}/)
outs.each do |out|
if out =~/<figure id=/m
out=out.gsub(/:spaces0:/m,
%{#{spaces*(splv)}#{spaces}}).
gsub(/:spaces1:/m,
%{#{spaces*(splv)}#{spaces*2}})
filename_docbook.puts out
filename_docbook.puts "#{spaces*3}#{ocn}"
else
unless out.empty?
filename_docbook.puts SiSU_TextUtils::Wrap.new(out,80,(splv*2+2),nil).line_wrap
filename_docbook.puts "#{spaces*3}#{ocn}"
end
end
end
else
filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj,80,(splv*2+2),nil,ocn).line_wrap
end
end
def structure_build_collapsed(data)
#output_file=@md.file.output_path.xml_docbook_book.dir + '/' + @md.file.base_filename.xml_docbook_book
file=SiSU_Env::FileOp.new(@md)
filename_docbook=file.write_file.xml_docbook_book
h=0
@chlv=chlv=0
doc_position=:head
filename_docbook.puts head
filename_docbook.puts xml_head
data.each_with_index do |o,i|
if (defined? o.ocn and not o.ocn.nil?)
ocn=(@make.build.ocn?) \
? "<!-- o#{o.ocn} -->"
: ''
id=%{ id="o#{o.ocn}" }
else
ocn,id='',''
end
if (o.is ==:heading || o.is ==:heading_insert)
chlv=(o.lv.to_i == 1) \
? @chlv=o.lc.to_i
: 0
@splv=o.lc
tag_id=o.tags[0] ? %{ id="#{o.tags[0]}" } : ''
if doc_position ==:head
filename_docbook.puts %{#{spaces*o.lc}<title#{id}>}
doc_position=:body_and_tail
else
filename_docbook.puts structure_build_tag_close(o.lc,h)
filename_docbook.puts %{#{spaces*(o.lc)}<#{tags.docbook_tag(o.lc,chlv)}#{tag_id}>
#{spaces*o.lc}<title#{id}>
}
end
adjust_output(o,ocn,filename_docbook,@splv)
filename_docbook.puts %{#{spaces*o.lc}</title>}
h=o.lc
elsif o.of ==:layout \
and o.is ==:open_close_tags
xml_tag=case o.sym
when :quote_open then '<blockquote>'
when :quote_close then '</blockquote>'
else ''
end
unless xml_tag.empty?
filename_docbook.puts "#{spaces*(@splv)}#{xml_tag}"
end
elsif o.of ==:block
if o.is ==:table
filename_docbook.puts SiSU_Tables::TableXMLdocbook.new(o,id).table.obj
elsif o.is ==:code
filename_docbook.puts "#{spaces*(@splv)}<para#{id}>"
filename_docbook.puts "#{spaces*(@splv+1)}<programlisting>"
code_output(o,ocn,filename_docbook)
filename_docbook.puts "#{spaces*(@splv+1)}</programlisting>"
filename_docbook.puts "#{spaces*(@splv)}</para>"
else
filename_docbook.puts "#{spaces*(@splv)}<para#{id}>"
adjust_output(o,ocn,filename_docbook,@splv)
filename_docbook.puts "#{spaces*(@splv)}</para>"
end
elsif o.of ==:para
filename_docbook.puts "#{spaces*(@splv)}<para#{id}>"
adjust_output(o,ocn,filename_docbook,@splv)
filename_docbook.puts "#{spaces*(@splv)}</para>"
end
end
filename_docbook.puts structure_build_tag_close(0,h)
filename_docbook.close
end
def structure_build_tag_close(lc,h)
x=[]
case h
when 0
x << "#{spaces*0}</#{tags.docbook_tag(0)}>" if (lc <= 0)
when 1
x << "#{spaces*1}</#{tags.docbook_tag(1,@chlv)}>" if (lc <= 1)
x << "#{spaces*0}</#{tags.docbook_tag(0)}>" if (lc <= 0)
when 2
x << "#{spaces*2}</#{tags.docbook_tag(2,@chlv)}>" if (lc <= 2)
x << "#{spaces*1}</#{tags.docbook_tag(1,@chlv)}>" if (lc <= 1)
x << "#{spaces*0}</#{tags.docbook_tag(0)}>" if (lc <= 0)
when 3
x << "#{spaces*3}</#{tags.docbook_tag(3,@chlv)}>" if (lc <= 3)
x << "#{spaces*2}</#{tags.docbook_tag(2,@chlv)}>" if (lc <= 2)
x << "#{spaces*1}</#{tags.docbook_tag(1,@chlv)}>" if (lc <= 1)
x << "#{spaces*0}</#{tags.docbook_tag(0)}>" if (lc <= 0)
when 4
x << "#{spaces*4}</#{tags.docbook_tag(4,@chlv)}>" if (lc <= 4)
x << "#{spaces*3}</#{tags.docbook_tag(3,@chlv)}>" if (lc <= 3)
x << "#{spaces*2}</#{tags.docbook_tag(2,@chlv)}>" if (lc <= 2)
x << "#{spaces*1}</#{tags.docbook_tag(1,@chlv)}>" if (lc <= 1)
x << "#{spaces*0}</#{tags.docbook_tag(0)}>" if (lc <= 0)
when 5
x << "#{spaces*5}</#{tags.docbook_tag(5)}>" if (lc <= 5)
x << "#{spaces*4}</#{tags.docbook_tag(4,@chlv)}>" if (lc <= 4)
x << "#{spaces*5}</#{tags.docbook_tag(3,@chlv)}>" if (lc <= 3)
x << "#{spaces*2}</#{tags.docbook_tag(2,@chlv)}>" if (lc <= 2)
x << "#{spaces*1}</#{tags.docbook_tag(1,@chlv)}>" if (lc <= 1)
x << "#{spaces*0}</#{tags.docbook_tag(0)}>" if (lc <= 0)
when 6
x << "#{spaces*6}</#{tags.docbook_tag(6)}>" if (lc <= 6)
x << "#{spaces*5}</#{tags.docbook_tag(5)}>" if (lc <= 5)
x << "#{spaces*4}</#{tags.docbook_tag(4,@chlv)}>" if (lc <= 4)
x << "#{spaces*3}</#{tags.docbook_tag(3,@chlv)}>" if (lc <= 3)
x << "#{spaces*2}</#{tags.docbook_tag(2,@chlv)}>" if (lc <= 2)
x << "#{spaces*1}</#{tags.docbook_tag(1,@chlv)}>" if (lc <= 1)
x << "#{spaces*0}</#{tags.docbook_tag(0)}>" if (lc <= 0)
end
x.join("\n")
end
end
end
end
__END__
#+END_SRC
* fictionbook2.rb
#+BEGIN_SRC ruby :tangle "../lib/sisu/xml_fictionbook2.rb"
# <<sisu_document_header>>
module SiSU_XML_Fictionbook
require_relative 'se_hub_particulars' # se_hub_particulars.rb
include SiSU_Particulars
require_relative 'ao' # ao.rb
require_relative 'se' # se.rb
include SiSU_Env
require_relative 'txt_shared' # txt_shared.rb
include SiSU_TextUtils
require_relative 'xml_shared' # xml_shared.rb
include SiSU_XML_Munge
class Source
def initialize(opt)
@opt=opt
@particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt)
end
def read
begin
@md,@ao_array=@particulars.md,@particulars.ao_array
@env=@particulars.env
report
SiSU_XML_Fictionbook::Source::Scroll.new(@ao_array,@md).songsheet
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
end
ensure
Dir.chdir(@opt.f_pth[:pth])
end
end
private
def report
unless @opt.act[:quiet][:set]==:on
tool=(@opt.act[:verbose][:set]==:on \
|| @opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on) \
? "#{@env.program.fictionbook_viewer} #{@md.file.output_path.xml_fictionbook.dir}/#{@md.file.base_filename.xml_fictionbook}"
: "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}"
(@opt.act[:verbose][:set]==:on \
|| @opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on) \
? SiSU_Screen::Ansi.new(
@opt.act[:color_state][:set],
'Fictionbook',
tool
).green_hi_blue
: SiSU_Screen::Ansi.new(
@opt.act[:color_state][:set],
'Fictionbook',
tool
).green_title_hi
if (@opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on)
SiSU_Screen::Ansi.new(
@opt.act[:color_state][:set],
@opt.fns,
"#{@md.file.output_path.xml_fictionbook.dir}/#{@md.file.base_filename.xml_fictionbook}"
).flow
end
end
end
class Scroll <Source
def initialize(data='',md='')
@data,@md=data,md
@trans=SiSU_XML_Munge::Trans.new(@md)
@particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(md.opt)
@env=@particulars.env
end
def songsheet
@t='sisu'
data=@data
if @md.opt.act[:verbose_plus][:set]==:on
structure_collapsed(data)
end
head
endnotes=extract_endnotes
images_base64=extract_images
data=markup_text(data)
structure_build_collapsed(data,endnotes,images_base64)
end
def spaces
Ax[:spaces]
end
def tags
# collapsed -->
def collapsed
%w[ 0 1 2 3 4 5 ]
end
def fictionbook
[
'section',
'section',
'section',
'section',
'section',
'section',
'section'
]
end
self
end
def put(line)
puts line if @md.opt.act[:verbose_plus][:set]==:on
end
def head
version=SiSU_Env::InfoVersion.instance.get_version
rb_ver=SiSU_Env::InfoVersion.instance.rbversion
date_available=if defined? @md.date.available; "\n <p>#{@md.date.available} Initial version</p>"
else ''
end
date_modified=if defined? @md.date.modified; "\n <p>#{@md.date.modified} Last Modified</p>"
else ''
end
coverpageimage=if defined? @md.make.cover_image[:cover]
%{\n <coverpage><image href="##{@md.make.cover_image[:cover]}" /></coverpage>}
else ''
end
if defined? @md.authors \
and @md.authors.length > 0
authors=[]
@md.authors.each do |author|
authors << ' <author>'
if not author[:others].empty?
authors << %{ <first-name>#{author[:others]}</first-name>}
end
if not author[:the].empty?
authors << %{ <last-name>#{author[:the]}</last-name>}
end
authors << ' </author>'
end
authors=authors.join("\n")
end
<<-WOK
<?xml version="1.0" encoding="UTF-8"?>
<FictionBook xmlns:xl="http://www.w3.org/1999/xlink"
xmlns="http://www.gribuser.ru/xml/fictionbook/2.0">
<description>
<title-info>
<genre match="100">***</genre>
#{authors}
<book-title>#{@md.title.full}</book-title>#{coverpageimage}
<annotation>
</annotation>
<date value="#{@md.date.published}">#{@md.date.published}</date>
</title-info>
<document-info>
<author>
<first-name/>
<last-name/>
<nickname/>
</author>
<program-used>#{version.project} #{version.version} and #{rb_ver}</program-used>
<date value="#{version.date}">#{version.date}</date>
<src-url>#{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}</src-url>
<id></id>
<version>1.0</version>
<history>#{date_available}#{date_modified}
</history>
</document-info>
</description>
<body>
WOK
end
def extract_endnotes #work on
endnotes,endnotes_raw,endnotes_b=[],[],[]
@data.each do |para|
endnotes_raw << para.obj.scan(/#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m)
endnotes_b << para.obj.scan(/#{Mx[:en_b_o]}(.+?)#{Mx[:en_b_c]}/m)
end
endnotes_raw.flatten.each do |en|
en=@trans.markup_fictionbook(en)
endnotes << en.gsub(/([\d+*]+)\s+(.+)/m,
%{<section id="footnote\\1">\n
<title><p>\\1.</p></title>\n
<p>\\2</p>\n
</section>})
end
endnotes_raw=[]
endnotes
end
def extract_images #work on
begin
require 'base64'
rescue LoadError
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
error('base64 NOT FOUND (LoadError)')
end
images_raw,images_base64_fb2=[],[]
images_base64={}
if defined? @md.make.cover_image[:cover]
images_raw << @md.make.cover_image[:cover]
end
@data.each do |para|
images_raw << para.obj.scan(/#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)).+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/m)
end
images_raw.flatten.sort.each do |img|
imgpth=@env.url.images_local + '/' + img
open(imgpth)
if FileTest.file?(imgpth)
images_base64[img]=Base64.encode64(File.read(imgpth))
end
end
images_raw=[]
images_base64.each_key do |k|
imgtype=case k
when /\.jpg/ then 'jpeg'
when /\.png/ then 'png'
when /\.gif/ then 'gif'
else 'jpeg'
end
images_base64_fb2 << %{<binary content-type="image/#{imgtype}" id="#{k}">#{images_base64[k]}
</binary>
}
end
images_base64_fb2.join("\n")
end
def markup_text(data)
data.each_with_index do |o,i|
if o.is ==:heading || o.is ==:para
o.obj=@trans.markup_fictionbook(o.obj,o.is) #unless o.obj==nil
end
end
data
end
def tail(images_base64_fb2)
<<-WOK
</body>
#{images_base64_fb2}
</FictionBook>
WOK
end
def output(o,comment='')
puts o.lc == (0..6) \
? "#{spaces*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}"
: "<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}"
end
def structure_collapsed(data)
puts "\ncollapsed structure, heading outline --->\n\n"
data.each_with_index do |o,i|
if (o.is ==:heading || o.is ==:heading_insert)
output(o)
end
end
end
def endnotes_build(endnotes,filename_fictionbook)
if endnotes.length > 0
filename_fictionbook.puts %{</body><body name="notes">}
endnotes.each do |en|
filename_fictionbook.puts SiSU_TextUtils::Wrap.new(en,80,6).line_wrap
end
end
end
def structure_build_collapsed(data,endnotes,images_base64)
file=SiSU_Env::FileOp.new(@md)
filename_fictionbook=file.write_file.xml_fictionbook
h=0
doc_position=:head
filename_fictionbook.puts head
data.each_with_index do |o,i|
ocn=if @make.build.ocn?
(defined? o.ocn and not o.ocn.nil?) \
? "\n#{Dx[:ocn_o]}#{o.ocn}#{Dx[:ocn_c]}"
: ''
else ''
end
if o.is ==:heading
unless doc_position==:head
filename_fictionbook.puts structure_build_tag_close(o.lc,h)
end
doc_position=:body_and_tail
filename_fictionbook.puts %{#{spaces*o.lc}<#{tags.fictionbook[o.lc]}>
#{spaces*o.lc}<title>
}
filename_fictionbook.puts SiSU_TextUtils::Wrap.new("<p>#{o.obj}#{ocn}</p>",80,(o.lc*2+2)).line_wrap
filename_fictionbook.puts %{#{spaces*o.lc}</title>}
h=o.lc
elsif o.is ==:heading_insert \
and o.obj =~/Endnotes/ \
and o.ln == 1
break
elsif (o.of ==:para or o.of ==:block)
filename_fictionbook.puts SiSU_TextUtils::Wrap.new("<p>#{o.obj}#{ocn}</p>",80,6).line_wrap
end
end
filename_fictionbook.puts structure_build_tag_close(0,h)
endnotes_build(endnotes,filename_fictionbook)
filename_fictionbook.puts tail(images_base64)
filename_fictionbook.close
end
def structure_build_tag_close(lc,h)
x=[]
case h
when 0
x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0)
when 1
x << "#{spaces*1}</#{tags.fictionbook[1]}>" if (lc <= 1)
x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0)
when 2
x << "#{spaces*2}</#{tags.fictionbook[2]}>" if (lc <= 2)
x << "#{spaces*1}</#{tags.fictionbook[1]}>" if (lc <= 1)
x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0)
when 3
x << "#{spaces*3}</#{tags.fictionbook[3]}>" if (lc <= 3)
x << "#{spaces*2}</#{tags.fictionbook[2]}>" if (lc <= 2)
x << "#{spaces*1}</#{tags.fictionbook[1]}>" if (lc <= 1)
x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0)
when 4
x << "#{spaces*4}</#{tags.fictionbook[4]}>" if (lc <= 4)
x << "#{spaces*3}</#{tags.fictionbook[3]}>" if (lc <= 3)
x << "#{spaces*2}</#{tags.fictionbook[2]}>" if (lc <= 2)
x << "#{spaces*1}</#{tags.fictionbook[1]}>" if (lc <= 1)
x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0)
when 5
x << "#{spaces*5}</#{tags.fictionbook[5]}>" if (lc <= 5)
x << "#{spaces*4}</#{tags.fictionbook[4]}>" if (lc <= 4)
x << "#{spaces*3}</#{tags.fictionbook[3]}>" if (lc <= 3)
x << "#{spaces*2}</#{tags.fictionbook[2]}>" if (lc <= 2)
x << "#{spaces*1}</#{tags.fictionbook[1]}>" if (lc <= 1)
x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0)
when 6
x << "#{spaces*6}</#{tags.fictionbook[6]}>" if (lc <= 6)
x << "#{spaces*5}</#{tags.fictionbook[5]}>" if (lc <= 5)
x << "#{spaces*4}</#{tags.fictionbook[4]}>" if (lc <= 4)
x << "#{spaces*3}</#{tags.fictionbook[3]}>" if (lc <= 3)
x << "#{spaces*2}</#{tags.fictionbook[2]}>" if (lc <= 2)
x << "#{spaces*1}</#{tags.fictionbook[1]}>" if (lc <= 1)
x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0)
end
x.join("\n")
end
end
end
end
__END__
#+END_SRC
* document header
#+NAME: sisu_document_header
#+BEGIN_SRC text
encoding: utf-8
- Name: SiSU
- Description: documents, structuring, processing, publishing, search
xml
- Author: Ralph Amissah
<ralph.amissah@gmail.com>
- Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019,
2020, 2021, Ralph Amissah,
All Rights Reserved.
- License: GPL 3 or later:
SiSU, a framework for document structuring, publishing and search
Copyright (C) Ralph Amissah
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
If you have Internet connection, the latest version of the GPL should be
available at these locations:
<http://www.fsf.org/licensing/licenses/gpl.html>
<http://www.gnu.org/licenses/gpl.html>
<http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
- SiSU uses:
- Standard SiSU markup syntax,
- Standard SiSU meta-markup syntax, and the
- Standard SiSU object citation numbering and system
- Homepages:
<http://www.sisudoc.org>
- Git
<https://git.sisudoc.org/projects/>
<https://git.sisudoc.org/projects/?p=software/sisu.git;a=summary>
<https://git.sisudoc.org/projects/?p=markup/sisu-markup-samples.git;a=summary>
#+END_SRC
|