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
|
% \iffalse meta-comment
%
% ekdosis -- Typesetting TEI xml compliant critical editions
% Copyright (C) 2020 Robert Alessi
%
% Please send error reports and suggestions for improvements to Robert
% Alessi <alessi@robertalessi.net>
%
% 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/>.
%
%<*internal>
\iffalse
%</internal>
%<*luapre>
--[[
This file is part of the `ekdosis' package
ekdosis -- Typesetting TEI xml compliant critical editions
Copyright (C) 2020 Robert Alessi
Please send error reports and suggestions for improvements to Robert
Alessi <alessi@robertalessi.net>
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/>.
--]]
%</luapre>
%<*internal>
\fi
%</internal>
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{ekdosis.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{ekdosis}
%<*package>
[2020/07/08 v0.99a Typesetting TEI xml compliant critical editions]
%</package>
%<*driver>
\begin{filecontents}[overwrite]{\jobname.bib}
@Article{Alessi2020,
author = {Alessi, Robert},
title = {ekdosis: Using Lua\LaTeX{} for Producing \texttt{TEI
xml} Compliant Critical Editions and Highlighting
Parallel Writings},
journaltitle = {Journal of Data Mining and Digital Humanities},
date = 2020,
pubstate = {submitted},
issuetitle = {Collecting, Preserving, and Disseminating Endangered
Cultural Heritage for New Understandings through
Multilingual Approaches},
eprinttype = {hal},
eprint = {hal-02779803}
}
@Book{Caesar-BG-v2,
author = {{Caesar}},
title = {Gallic War},
origtitle = {Guerre des Gaules},
date = 1987,
origdate = 1926,
editor = {Constans, L.-A.},
volume = 2,
pagination = {none},
series = {Collection des Universités de France},
publisher = {Les Belles Lettres},
location = {Paris}
}
@Book{CaesarTr,
author = {{Caesar}},
title = {Gallic War},
date = 1869,
editor = {McDevitte, W. A., and Bohn, W. S.},
edition = 1,
series = {Harper's New Classical Library},
publisher = {Harper \& Brothers},
location = {New York}}
@Online{DLL-TC,
author = {{Digital Latin Library}},
title = {Textual Criticism},
url =
{https://digitallatin.org/library-digital-latin-texts/textual-criticism},
urldate = {2020-05-24}
}
@Online{Mastronarde.Tarrant2017,
author = {Mastronarde, Donald J. and Tarrant, Richard J.},
title = {Review: Guidelines for Encoding Critical Editions
for the Library of Digital Latin Texts},
date = {2017-12-04},
url =
{https://classicalstudies.org/scs-blog/donald-j-mastronarde/review-guidelines-encoding-critical-editions-library-digital-latin},
organization = {Society for Classical Studies}
}
\end{filecontents}
\begin{filecontents}[overwrite]{\jobname-cfg.tex}
\footnotelayout{m}
\DeclareApparatus{default}[
delim=\hskip0.75em,
ehook=.]
\DeclareWitness{M}{M}{\emph{Marcianus Gr.} 269}[
settlement=Venice,
institution=Marciana Library,
msName=\emph{Marcianus Gr.},
idno=269,
origDate=s. X]
\DeclareHand{M1}{M}{M\textsuperscript{1}}[Emendatio scribae ipsius]
\DeclareHand{M2}{M}{M\textsuperscript{2}}[Manus posterior]
% Peter and John Story:
\DeclareWitness{pjA}{A}{Manuscript A Call No 123}
\DeclareWitness{pjB}{B}{Manuscript B Call No 456}
% Caesar's Gallic War:
\DeclareWitness{cA}{A}{\emph{Bongarsianus} 81}[
msName=\emph{Bongarsianus},
settlement=Amsterdam,
idno=81,
institution=University Library,
origDate=s. IX--X]
\DeclareHand{cA1}{cA}{A\textsuperscript{1}}[\emph{Emendationes
scribae ipsius}]
\DeclareWitness{cM}{M}{\emph{Parisinus Lat.} 5056}[
origDate={s. XII}]
\DeclareWitness{cB}{B}{\emph{Parisinus Lat.} 5763}[
origDate={s. IX--X}]
\DeclareWitness{cR}{R}{\emph{Vaticanus Lat.} 3864}[
origDate={s. X}]
\DeclareWitness{cS}{S}{\emph{Laurentianus} R 33}[
origDate={s. X}]
\DeclareWitness{cL}{L}{\emph{Londinensis} Br. Mus. 10084}[
origDate={s. XI}]
\DeclareWitness{cN}{N}{\emph{Neapolitanus} IV, c. 11}[
origDate={s. XII}]
\DeclareWitness{cT}{T}{\emph{Parisinus Lat.} 5764}[
origDate={s. XI}]
\DeclareWitness{cf}{\emph{f}}{\emph{Vindobonensis} 95}[
origDate={s. XII}]
\DeclareWitness{cU}{U}{\emph{Vaticanus Lat.} 3324}[
origDate={s. XI}]
\DeclareWitness{cl}{\emph{l}}{\emph{Laurentianus} Riccard. 541}[
origDate={s. XI--XII}]
\DeclareShorthand{ca}{α}{cA,cM,cB,cR,cS,cL,cN}
\DeclareShorthand{cb}{β}{cT,cf,cU,cl}
\end{filecontents}
\documentclass{ltxdoc}
%\usepackage[letterpaper,margin=25mm,left=50mm,nohead]{geometry}
\usepackage[letterpaper,margin=1.25in,left=50mm,nohead]{geometry}
\usepackage{dox}
\doxitem{Option}{option}{options}
\usepackage{microtype}
\usepackage[no-math]{fontspec}
\usepackage[latin.classic,greek.ancient,american]{babel}
\babelfont{rm}[
SlantedFont={Old Standard},
SlantedFeatures={FakeSlant=0.25},
BoldSlantedFont={Old Standard},
BoldSlantedFeatures={FakeBold=1.5,FakeSlant=0.25}]{Old Standard}
\babelfont{sf}{NewComputerModern Sans}
\babelfont{tt}{NewComputerModern Mono}
\babelfont[greek]{rm}[
Script=Greek, RawFeature={+ss05;+ss06},
SlantedFont={Old Standard},
SlantedFeatures={FakeSlant=0.25},
BoldSlantedFont={Old Standard},
BoldSlantedFeatures={FakeBold=1.5,FakeSlant=0.25}]{Old Standard}
\babelfont[greek]{sf}[Script=Greek]{NewComputerModern Sans}
\babelfont[greek]{tt}[Script=Greek]{NewComputerModern Mono}
\babeltags{ancientgreek = greek}
\def\sg#1{\textancientgreek{#1}}
\usepackage[Old Standard]{mathfont}
\usepackage{arabluatex}
\usepackage[parnotes=roman,teiexport=tidy]{ekdosis}
\input{ekdosis-cfg}
\usepackage{xltabular}
\usepackage[prevent-all]{widows-and-orphans}
\usepackage[shortcuts,nospacearound]{extdash}
\usepackage[american]{isodate}
\usepackage{nextpage}
\usepackage{spacingtricks}
\usepackage{csquotes}
\usepackage{relsize}
\usepackage{enumitem}
\setlist{nosep}
\setlist[itemize]{label=\textendash}
\setlist[enumerate,1]{label=(\alph*)}
\newlist{remarks}{enumerate}{10}
\setlist[remarks]{
label*=\textsc{Rem.} \arabic*,
left=0.25in,
before=\smaller}
\usepackage{manfnt}
\usepackage{lettrine}
\newcommand\danger{\lettrine[loversize=-.5]{\textdbend}{\hskip6pt}}
\usepackage{metalogox}
\usepackage{hologo}
\usepackage{xcolor}
\newbool{nocolordoc}
\definecolor{ekdcolor}{RGB}{243,241,235}
\definecolor{cinnamon}{rgb}{0.82, 0.41, 0.12}
\ifbool{nocolordoc}{
\colorlet{ekdcolor}{white}
\colorlet{cinnamon}{black}}{}
\definecolor{gainsboro}{RGB}{222,222,222}
\PassOptionsToPackage{bookmarks=true}{hyperref}
\usepackage{xurl}
\usepackage[numbered]{hypdoc}
\usepackage[loadlang=en]{metastr}
\hypersetup{
colorlinks,
allcolors=cinnamon,
linktocpage=true,
pdftype={Text}
}
\usepackage{uri}
\labelformat{section}{sect.~#1}
\labelformat{subsection}{sect.~#1}
\labelformat{subsubsection}{sect.~#1}
\labelformat{figure}{fig.~#1}
\newcounter{dummy}
\newcommand{\dummy}{\refstepcounter{dummy}}
\usepackage[nospace,american]{varioref}
\usepackage[style=oxnotes-inote,dashed]{biblatex}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[fieldsource=issuetitle]
\step[fieldset=journalsubtitle,origfieldval]
}
}
}
\ifbool{nocolordoc}
{
\usepackage{fontawesome}
\def\oasymbol{\faUnlock}
\usepackage{biblatex-ext-oa}
}
{\usepackage[symbolpackage=l3draw]{biblatex-ext-oa}}
\DeclareDelimFormat[bib,biblist]{nametitledelim}{\addcomma\space}
\DeclareDelimFormat[bib,biblist]{innametitledelim}{\addcomma\space}
\renewcommand*\newunitpunct{\addcomma\space}
\newcommand*{\halurl}[1]{http://hal.archives-ouvertes.fr/#1}
\DeclareFieldFormat{eprint:hal}{%
\ifhyperref
{\href{\halurl{#1}}{hal:~\nolinkurl{#1}}}
{hal:~\nolinkurl{#1}}}
\DeclareFieldAlias{eprint:HAL}{eprint:hal}
\DeclareOpenAccessEprintUrl[always]{hal}{%
http://hal.archives-ouvertes.fr/\thefield{eprint}}
\DeclareOpenAccessEprintAlias{HAL}{hal}
\addbibresource{ekdosis.bib}
\metaset{titletext}{%
\metapick[#1]{title}%
\metacompose[#1]{subtitle}{\metaget[sep]{subtitle}}{}{}}
\metaset[print]{titletext}{%
\metatitleline[print]{title}%
\metatitleline[print]{subtitle}%
\metatitleline[print]{author}%
\metatitleline[print]{contactemail}%
\metatitlelinetwo[print]{date}[print]{draft}}
\metaset[skip]{subtitle}{\vspace{1ex}}
\metaset[skip]{author}{\vspace{2ex}}
\metaset[skip]{date}{\vspace{1ex}}
\metaset[style]{title}{\LARGE}
\metaset[style]{author}{\large}
\metaset[sep]{draft}{ -- }
\metasetlang{en-US}
\metaset{title}{ἔκδοσις}
\metaset{date}{\filedate}
\metaset{draft}{\fileversion}
\metaset{subject}{TEI xml compliant critical editions}
\metaset{subtitle}{Typesetting TEI xml Compliant Critical Editions}
\metaset[print]{subtitle}{Typesetting \texttt{TEI xml} Compliant
Critical Editions}
\metaset{author}{Robert Alessi}
\metaset{keywords}{LaTeX, Lua, TEI xml, multilingual critical
editions, alignment, segmentation}
\metaset{contactemail}{alessi@roberalessi.net}
\metaset[print]{contactemail}{\mailto[ekdosis]{alessi@robertalessi.net}}
\metaset{contacturl}{http://www.roberalessi.net}
\metaset{partof}{The ekdosis Package}
\metaset[print]{partof}{The \textsf{ekdosis} Package}
\metaset{copyrightowner}{\metapick[#1]{author}}
\metaset{copyrightdate}{2020}
\metaset{licensemessage}{Permission is granted to copy, distribute
and/or modify this document under the terms of the GNU Free
Documentation License, Version 1.3 or any later version published by
the Free Software Foundation; with no Invariant Sections, no
Front-Cover Texts, and no Back-Cover Texts. A copy of the license
is included in the section entitled ``GNU Free Documentation
License''.}
\metaset{licenseurl}{https://www.gnu.org/licenses/fdl-1.3.html}
\metaset[print]{licenseurl}{%
\url{https://www.gnu.org/licenses/fdl-1.3.html}}
\metaset[cmd]{licenselogo}{\includegraphics[scale=0.75]{#1}}
\metawritepdfinfo
\metawritepdfaux
\metawritepdfpreamble
\metawritepdfcontact
\metawritepdfrights
\usepackage{multicol}
\setlength\IndexMin{100pt}
\usepackage{tocloft}
\newlistof{listing}{lol}{List of listings}
\renewcommand\cfttocprehook{\begin{multicols}{2}}
\renewcommand\cfttocposthook{\end{multicols}}
\renewcommand\cfttoctitlefont{\Large\bfseries}
\renewcommand\cftlolprehook{\begin{multicols}{2}}
\renewcommand\cftlolposthook{\end{multicols}}
\renewcommand\cftloltitlefont{\Large\bfseries}
\usepackage{units}
\newcommand*\tred[1]{\textcolor{red}{#1}}
\usepackage{fbox}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\NewDocumentCommand{\pointto}{m}{%
\tikz[remember picture] \draw[>->,color=blue,overlay] (0em,0.5ex) to
([shift={(0.5em,0pt)}]pic cs:#1);%
\tikz[remember picture] \draw[color=gray, overlay]
([shift={(0.5em,0.5ex)}]pic cs:#1) circle [radius=8pt];}
\NewDocumentCommand{\pointtol}{m}{%
\tikz[remember picture] \draw[>->,color=blue,overlay] (0em,0.5ex) to
[bend left] ([shift={(0.5em,0pt)}]pic cs:#1);%
\tikz[remember picture] \draw[color=gray, overlay]
([shift={(0.5em,0.5ex)}]pic cs:#1) circle [radius=8pt];}
\NewDocumentCommand{\pointtor}{m}{%
\tikz[remember picture] \draw[>->,color=blue,overlay] (0em,0.5ex) to
[bend right] ([shift={(0.5em,0pt)}]pic cs:#1);%
\tikz[remember picture] \draw[color=gray, overlay]
([shift={(0.5em,0.5ex)}]pic cs:#1) circle [radius=8pt];}
\NewDocumentCommand{\pointtoer}{m}{%
\tikz[remember picture] \draw[>->,color=blue,overlay] (0em,0.5ex) to
[bend right] ([shift={(0em,0pt)}]pic cs:#1);%
\tikz[remember picture] \draw[color=gray, overlay]
([shift={(-0.5em,0.5ex)}]pic cs:#1) ellipse [x radius=45pt, y
radius=6pt];}
\usepackage[breakable, skins, xparse]{tcolorbox}
\tcbset{colback=white, boxrule=0.4pt, colframe=cinnamon,
breakable}
\usepackage[newfloat]{minted}
\labelformat{listing}{listing~#1}
\ifbool{nocolordoc}{\usemintedstyle{bw}}{}
\setminted{bgcolor=ekdcolor,linenos, fontsize=\small}
\newminted[ekdlua]{lua}{bgcolor={}, linenos, fontsize=\relsize{-0.5},
xleftmargin=12pt, breaklines, numberblanklines=false, numbersep=3pt,
firstnumber=last}
\renewcommand{\theFancyVerbLine}{\rmfamily\smaller\arabic{FancyVerbLine}}
\usepackage[contents]{colordoc}
\newcommand{\pkg}[1]{\textsf{#1}\index{#1=#1 (package)}}
\newcommand{\env}[1]{\texttt{#1}\index{#1=#1 (environment)}}
\backgroundcolor{c}{ekdcolor}
\usepackage{caption}
\captionsetup[listing]{position=above,skip=-1ex}
\usepackage{needspace}
\NewDocumentCommand{\captof}{O{listing} m O{}}{%
\bgroup
\needspace{5\baselineskip}%
\vskip 1ex plus 2pt minus 2pt%
\captionof{#1}{#2}%
#3%
\egroup}
% \usepackage{etoc}
% \etocsettocdepth{paragraph}
% \newcommand{\ekdtableofcontents}{%
% \begingroup
% \etocsetstyle{section}{}{}
% {\etocsavedsectiontocline{%
% \numberline{\etocnumber}\etocname}{\etocpage}}{}
% \etocsetstyle{subsection}{}{}
% {\etocsavedsubsectiontocline{%
% \numberline{\etocnumber}\etocname}{\etocpage}}{}%
% \etocsetstyle{subsubsection}{}{}
% {\etocsavedsubsubsectiontocline{%
% \numberline{\etocnumber}\etocname}{\etocpage}}{}%
% \etocsetstyle{paragraph}{}{\leftskip2cm\rightskip 2.2em \parfillskip
% 0pt plus 1fil\relax \nobreak}
% {\noindent\etocname{} \etocpage{} }{\par}%
% \etocmulticolstyle[2]{\section*{Contents}}
% \pdfbookmark[1]{Contents}{toc}
% \tableofcontents
% \endgroup}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
%\OnlyDescription
\begin{document}
\DocInput{\jobname.dtx}
\PrintChanges
\PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{1522}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
% Digits \0\1\2\3\4\5\6\7\8\9
% Exclamation \! Double quote \" Hash (number) \#
% Dollar \$ Percent \% Ampersand \&
% Acute accent \' Left paren \( Right paren \)
% Asterisk \* Plus \+ Comma \,
% Minus \- Point \. Solidus \/
% Colon \: Semicolon \; Less than \<
% Equals \= Greater than \> Question mark \?
% Commercial at \@ Left bracket \[ Backslash \\
% Right bracket \] Circumflex \^ Underscore \_
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
% \GetFileInfo{\jobname.dtx}
% \DoNotIndex{\newcommand,\newenvironment,\begin,\begingroup}
% \DoNotIndex{\bgroup,\def,\edef,\egroup,\else,\expandafter,\endgroup}
% \DoNotIndex{\fi,\ifdefined,\luadirect,\luastring,\luastringN}
% \DoNotIndex{\luastringO,\NewDocumentCommand,\space,\unexpanded}
%
% \pdfbookmark[1]{\metaterm{title}}{title}
% \begin{tcolorbox}[
% colframe=black,
% enhanced,
% drop lifted shadow,
% colback=white,
% boxrule=.25mm,
% halign=center,
% center
% ]
% \metapick[print]{titletext}
% \end{tcolorbox}
%
% \begin{tcolorbox}[title=Notice to the Gentle Reader]
% The current state of this documentation covers the basics of
% \pkg{ekdosis}, namely what should be enough to start a new
% document and see how it works. v1.0 with a full documentation
% should be out by the end of July. Until then, there is a web page
% that can be accessed,\footnote{%
% \url{http://www.robertalessi.net/ekdosis}} with a mailing list
% that one can subscribe to and a section entitled
% \enquote{Literature} where one will find some slides and a paper
% submitted to a journal.
% \end{tcolorbox}
%
% \tableofcontents
% \listoflistings
%
% \changes{v0.99a}{2020/07/08}{First public release (documentation in
% progress)}
%
% \begin{abstract}
% \pkg{ekdosis} is a Lua\LaTeX{} package designed for
% multilingual critical editions. It can be used to typeset texts
% and different layers of critical notes in any direction accepted
% by Lua\TeX. Texts can be arranged in running paragraphs or on
% facing pages, in any number of columns which in turn can be
% synchronized or not. In addition to printed texts,
% \pkg{ekdosis} can convert \texttt{.tex} source files so as to
% produce \texttt{TEI xml} compliant critical
% editions. Database-driven encoding under \LaTeX{} then allows
% extraction of texts entered segment by segment according to
% various criteria: main edited text, variant readings, translations
% or annotated borrowings between texts. It is published under the
% terms of the GNU General Public License (GPL) version 3.
% \end{abstract}
%
% \section*{License and Disclaimer}
% \addcontentsline{toc}{section}{License and disclamer}
% \subsection*{License Applicable to this Document}
% \pdfbookmark[2]{Licence applicable to this document}{copyright-doc}
% \leavevmode\marginpar{\hfill\texttt{fdl1.3}}
% \metapick[print]{rightstext} (See below \vref{sec:fdl}.)
%
% \subsection*{License Applicable to the Software}
% \pdfbookmark[2]{Licence applicable to the software}{copyright-soft}
% \label{sec:license-software}
%
% \pkg{ekdosis} --- \metapick[print]{subtitle}
% \metapick[print]{copyrightstatement}
%
% Please send error reports and suggestions for improvements to Robert
% Alessi:
% \begin{itemize}
% \item email: \mailto[ekdosis package]{alessi@roberalessi.net}
% \item website: \url{http://www.robertalessi.net/ekdosis}
% \item development: \url{http://git.robertalessi.net/ekdosis}
% \item comments, feature requests, bug reports:
% \url{https://gitlab.com/ralessi/eksodis/issues}
% \end{itemize}
%
% \leavevmode\marginpar{\hfill\texttt{gpl3+}}
% 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
% \href{http://www.gnu.org/licenses}%
% {\texttt{<http://www.gnu.org/licenses/>}}.
%
% This release of \pkg{ekdosis} consists of the following
% source files:
% \begin{itemize}
% \item |ekdosis.ins|
% \item |ekdosis.dtx|
% \item |ekdosis.el|
% \item |Makefile|
% \end{itemize}
%
% \section{Introduction}
% \label{sec:introduction}
% \begin{comment}
% \begin{keyfigure}{l={fig:grid-typesetting},c={Grid Typesetting
% (which never came into existence)}, t={Each square in the grid
% has a side length of \unit[10]{pt}. Therefore, the distance
% between the last line of the text and the first line of the
% apparatus is here approximately \unit[25]{pt}.}}
% \centering
% \begin{tikzpicture}
% \draw[gainsboro,thin] (0.5,0.5) grid [step=10pt] (10,5); %
% \path node [align=justify, text width=8cm] at (5.5,3) {%
% I saw my friend Peter at the station yesterday. We were both
% in a great mood. \enquote{How nice to find you here!} he
% said. I chuckled to myself, recalling the last time we
% met.\par
% \rule{3cm}{0.01cm}\par\footnotesize%
% \textbf{1}~saw A] met B\hskip1em Peter A] John B \hskip1em
% \textbf{2}~great A] good B\hskip1em \textbf{2--3}~How
% nice... said A] \emph{om.} B\hskip1em \textbf{4} \emph{post}
% met \emph{add.} there B.}; \node at (0,3) {\scriptsize
% $\approx$ \unit[25]{pt}}; \draw [->] (0,2.875) -- (0,2.025);
% \end{tikzpicture}
% \end{keyfigure}
% \end{comment}
%
% The reader will find here, by way of introduction, a summarized
% version of the first part of an article that the author submitted
% some weeks ago to the
% \mkbibemph{\citefield{Alessi2020}{journaltitle}} as a contribution
% to a Digital Humanities workshop held at Stanford University
% (\printdate{2019-04-15}).\footcite{Alessi2020}
%
% The name of this package, \pkg{ekdosis}, derives from a Greek
% action noun\---\sg{ἔκδοσις}\---the meaning of which is:
% \enquote{publishing a book}, and also in concrete sense: \enquote{a
% publication, treatise}. For us moderns, this term refers to a long
% tradition of scholarly work consisting in establishing from
% manuscript evidence the texts of Greek and Latin classics that were
% handled down through the Middle Ages to the time of the first
% printed editions. Of course, this definition is extendible to other
% languages as well. The basic premise is that critical editions
% exhibit reconstructed texts from manuscript evidence either under
% the title of the edited text (direct tradition) or from explicit
% citations or parallel passages or translations in other languages
% (indirect tradition).
%
% Whether in print or digital, critical editions come with an
% apparatus criticus in which is mentioned all the evidence that was
% used to build the edited text. Arguably, it is precisely on this
% common point that the two kind of editions part ways for reading a
% traditional, well written apparatus criticus is only meant for
% experienced readers. Getting oneself familiarized with its many
% conventional rules is not unrelated to learning a language, equipped
% with technical terms, grammar rules and style embellishments, which
% came into existence out of over three centuries of scholarly
% attainments. Nevertheless, whereas this language is immediately
% accessible to human mind's ability to use language and interpret
% conventional symbols, it is quite inaccessible to a computer unless
% every item of information has been encoded in the rather dumb format
% that is suited to machines.
%
% On the other hand, editions in print have their own limitations. For
% example, every detail that editors of classical texts decide to
% discard to save space, regardless to its relevance to the purpose of
% the edition, is lost permanently as in the case of dialectal
% coloring of ancient books. Furthermore, passages collected as
% indirect tradition are only available as references in the
% \emph{apparatus testium} and cannot be referred to the original
% text. As a result, the reader is refrained from bestowing attention
% upon major parallel passages to understand better difficult passages.
%
% To conclude on these issues, print publications and digital editions
% are often contrasted as they belonged to two different
% worlds.\footnote{For a good illustration of this point, see
% \cite[\mkbibquote{Content, not Display}]{DLL-TC}.} It is commonly
% said that the content of editions in print is the result of the
% binding of the book itself as an object, whereas digital editions,
% in which format and presentation are by definition separated from
% content, are free from limitations coming from such bindings. To sum
% up from the foregoing considerations, this statement is likely to be
% qualified: as already seen above, the apparatus criticus must be
% looked at as a brilliant production of mind refined by centuries of
% scholarly tradition\---and surely tradition must go on\---arguably
% not as compact paragraphs that require special and painful training
% to be \enquote*{decoded}. On the other hand, what editions in print
% do not provide are what \citename{Mastronarde.Tarrant2017}{author}
% have called \enquote{actionable texts for use in digital
% research},\footcite{Mastronarde.Tarrant2017} namely database-driven
% texts allowing the reader to select annotations and display or
% arrange translations, parallel passages or borrowings in a variety
% of ways.
%
% \pkg{ekdosis} can be seen as an attempt at combining the two
% approaches.
%
% \subsection{Requirements}
% \label{sec:requirements}
% Please refer to \vref{ref:ekdrequirements}.
%
% \subsection{Features}
% \label{sec:features}
% A list of the main features of \pkg{ekdosis} follows:---
% \begin{enumerate}
% \item \label{it:multicol-feature}\emph{Multilingual critical
% editions\/}: \pkg{ekdosis} can be used to typeset any number of
% texts in any direction accepted by \hologo{LuaTeX}. Running
% paragraphs of text can be arranged in any number of columns,
% either on single or facing pages, which in turn can be
% synchronized or not. \pkg{ekdosis} is also suitable for complex
% layouts as in the case of Arabic poetry or images where three-way
% alignment is required, or diagrams, \emph{\&c}.
% \item \emph{Apparatus criticus\/}: Edited texts can receive multiple
% layers of apparatus, e.g.\ apparatus criticus (to record variant
% readings), apparatus fontium (to collect references to texts quoted
% or cited in the edited text), apparatus testium (to collect
% testimonia or parallel passages), or any kind of short notes to be
% printed on the same page as the edited text, \emph{\&c}.
% \item \texttt{TEI xml} output: \pkg{ekdosis} can be instructed
% to output both PDF and \texttt{TEI xml} files at the same time.
% \item \emph{Database-driven encoding} under \LaTeX{} of texts
% entered segment by segment allows for alignment of parallel texts
% from multilingual corpora.
% \end{enumerate}
%
% Before going into detail, the following simple example will give the
% reader a general idea of the method of encoding with
% \pkg{ekdosis} authoritative texts composed of lemmata, in a way
% that is very close to \texttt{TEI xml} encoding:---
%
% \captof{The \enquote{Peter/John} basic example}[\label{lst:pj1}]
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
\begin{ekdosis}
I
\app{
\lem{saw}
\rdg{met}
}
my friend \app{\lem{Peter}\rdg{John}} at the station yesterday.
\end{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \needspace{4\baselineskip}PDF output:---
% \medskip
% \begin{alignment}[tcols=1,texts=specimen,apparatus=specimen]
% \begin{specimen}
% I
% \app{
% \lem{saw}
% \rdg{met}
% }
% my friend
% \app{
% \lem{Peter}
% \rdg{John}
% }
% at the station yesterday.
% \end{specimen}
% \end{alignment}
%
% \texttt{TEI xml} output:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<p>I
<app>
<lem>saw</lem>
<rdg>met</rdg>
</app>my friend
<app>
<lem>Peter</lem>
<rdg>John</rdg>
</app>at the station yesterday.</p>
\end{minted}
% \iffalse
%</example>
% \fi
%
% As can be seen from \vref{lst:pj1}, the edition text is inserted in
% the \env{ekdosis} environment (l.~1 to 8). Then two
% \cs{app}\marg{apparatus entry} commands (ll.~3 and 7) contain the
% lemma (\cs{lem}\marg{lemma}), namely the reading that is accepted by
% the editor, and at least one variant reading
% (\cs{rdg}\marg{reading}, ll.~5 and 7). As the listing shows, the
% editor is free to lay out the code in a legible manner to the eye:
% the first lemma above spans several lines whereas the second one is
% written in sequence without spaces.
%
% In the PDF ouput, the edition text is printed in the upper part of
% the page, above the line, and naturally shows the accepted
% readings. The margins are used for numeration. In the apparatus
% criticus, below the line, reference to the text is made by
% specifying the number of the line and if several entries refer to
% the same line, numbers are not repeated. Instead, entries are
% separated from one another by a broad horizontal space. Finally, a
% square bracket is used inside entries to distinguish the lemma from
% the variant readings.
%
% Furthermore, as said above, if a \texttt{TEI xml} output be
% required, \pkg{ekdosis} compiles an additional |.xml| file an
% excerpt of which is provided above.
%
% \section{The Basics of \pkg{ekdosis}}
% \label{sec:ekdosis-basics}
%
%\subsection{Loading the Package\---General Options}
%\label{sec:load-general-options}
%
% \pkg{ekdosis} is loaded in the preamble like so:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\usepackage{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \pkg{ekdosis} may be loaded with four optional \enquote*{named
% arguments} either of which is set using the syntax
% \meta{key}$=$\meta{value}. The description of the optional arguments
% follows.
%
% \danger The reader is invited to refer to the relevant sections of
% this documentation for more information on how to use them.
%
% \DescribeOption{layout}\label{ref:layout-opt}
% |layout|$=$\verb+float|footins+\hfill\tcboxverb{Default: float}\\
% By default, layers of critical notes are inserted as a floating
% environment to be printed at the bottom of pages. |layout=footins|
% can be set to insert critical notes in the default footnote block
% which can be considered to be a special kind of float that is
% printed at the bottom of pages. In this case, the apparatus criticus
% will be inserted between regular numbered footnotes, but will carry
% no footnote mark of its own.
%
% \DescribeOption{divs}\label{ref:divs-opt}
% |divs|$=$\verb+ekdosis|latex+\hfill\tcboxverb{Default: ekdosis}\\
% In many occasions, \LaTeX{} standard textual divisions do not meet
% the specific requirements of classical and literary texts, the
% divisions of which may depend on many different received
% traditions. \pkg{ekdosis} provides a flexible mechanism in which
% format and presentation have been carefully separated from
% content. It is designed to build un-numbered \texttt{TEI} divisions
% allowed to nest recursively. However, if |divs| be set to |latex|,
% \LaTeX{} standard textual divisions can be used and will be
% translated into \texttt{TEI} numbered |<div>| elements.
%
% \danger It must be noted that the two styles are mutually exclusive.
% \vskip\baselineskip
%
% \DescribeOption{parnotes}\label{ref:parnotes-opt}
% |parnotes|$=$\verb+true|false|roman+%
% \hfill\tcboxverb{Default: not set}\\
% This named argument does not need a value as it defaults to |true|
% if it is used. Apparatus criticus typeset by \pkg{ekdosis} may
% contain notes and footnotes. The latter can be laid out as
% paragraphed notes below the block of critical notes by means of the
% \pkg{parnotes} package. Additionally, |parnotes=roman| prints these
% footnotes numbered with Roman numerals.
%
% \DescribeOption{teiexport}\label{ref:teiexport-option}
% |teiexport|$=$\verb+true|false|tidy+%
% \hfill\tcboxverb{Default: not set}\\
% This named argument does not need a value as it defaults to |true|
% if it is used. If |teiexport| be set to |true|, \pkg{ekdosis} is
% instructed to output both PDF and \texttt{TEI xml} files at the same
% time. By default, the \texttt{TEI} file will receive the same
% basename as the |.tex| source file, suffixed with |-tei.xml|. The
% raw |.xml| file that is produced by \pkg{ekdosis} can be further
% processed by the \textsf{tidy} console application.\footnote{See
% \url{http://www.html-tidy.org}.} To make this happen, \textsf{tidy}
% must be installed and the |.tex| source file must be compiled with
% the |--shell-escape| facility so that spawning programs from
% \LaTeX{} can be allowed.\footnote{See
% \url{https://texfaq.org/FAQ-spawnprog} for more information on how
% to do this.}
%
% As an example, the following line loads \pkg{ekdosis} and instructs
% it to output a \texttt{TEI xml} file (in addition to the PDF one)
% and to use \pkg{parnotes} to format with Roman numerals the footnotes
% that are inserted in the apparatus criticus:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\usepackage[teiexport, parnotes=roman]{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \subsection{Witnesses, Hands, Shorthands \& Scholars }
% \label{sec:declarations}
% Any reference that is to be used in the apparatus criticus must be
% \enquote{declared} in the preamble beforehand, namely: manuscript
% sigla (either for single manuscripts or manuscript families, primary
% or later hands, \emph{\&c.}) or abbreviated last names of scholars.
% To that effect, \pkg{ekdosis} provides the following preamble-only
% commands:---
% \begin{comment}
% \begin{xltabular}[c]{0.4\linewidth}{lXr}
% \caption*{\textbf{Conspectus Siglorum}}\\
% \SigLine{M}\\
% \end{xltabular}
% \end{comment}
%
% \paragraph{Witnesses}
% \DescribeMacro{\DeclareWitness} \cs{DeclareWitness}\marg{unique
% id}\marg{rendition}\marg{description}\oarg{options}\\
% This command requires three mandatory arguments enclosed between
% curly braces used to specify consecutively:
% \begin{enumerate}
% \item The unique identifier of the witness to be used both in the
% |.tex| source file and as an |xml:id| in the \texttt{TEI xml}
% output if any.
% \item The rendition to be used in the printed apparatus criticus,
% which also will be found within the |<sourceDesc>| element of the
% \texttt{TEI} header where the description of the witness occurs,
% within a |<abbr type="siglum">| element.
% \item A basic description of the manuscript to be found in a typical
% printed Conspectus Siglorum, namely: the name of the manuscript
% followed by its call number.
% \end{enumerate}
% Finally, the optional argument of \cs{DeclareWitness} accepts a
% comma-separated list of the following \enquote{name=value} arguments
% that are used to collect items of information to be found within
% the |<msIdentifer>| element in the \texttt{TEI}
% header:---\footnote{See
% \url{https://tei-c.org/release/doc/tei-p5-doc/en/html/MS.html\#msid}
% for detailed information on these elements.}\\
% \DescribeOption{settlement} |settlement|$=$\meta{name}: The name of
% a city or administrative unit.\\
% \DescribeOption{institution} |institution|$=$\meta{name}: The name
% of an institution such as a university or library.\\
% \DescribeOption{repository} |repository|$=$\meta{name}: The name of
% the repository within which the witness is stored.\\
% \DescribeOption{collection} |collection|$=$\meta{name}: The name of
% a collection of manuscripts.\\
% \DescribeOption{idno} |idno|$=$\meta{call \#}: Any form of call
% number.\\
% \DescribeOption{msName} |msName|$=$\meta{name}: The name commonly
% used for the witness.\\
% \DescribeOption{origDate} |origDate|$=$\meta{date}: Any form of date
% used to identify the date of origin for the witness.
%
% To take here one example, a witness such as the \emph{Marcianus
% Graecus}~269, referred to as manuscript \enquote*{M} in the
% editions, which contains sixty treatises from Hippocrates, could be
% declared as follows:--- \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\DeclareWitness{M}{M}{\emph{Marcianus Gr.} 269}[
settlement=Venice,
institution=Marciana Library,
msName=\emph{Marcianus Gr.},
idno=269,
origDate=s. X]
\end{minted}
% \iffalse
%</example>
% \fi
%
% \paragraph{Hands}
% \DescribeMacro{\DeclareHand} \cs{DeclareHand}\marg{unique
% id}\marg{base ms.}\marg{rendition}\oarg{note}\\
% This command requires three mandatory arguments enclosed between
% curly braces and one optional argument between square brackets used
% to specify consecutively:---
% \begin{enumerate}
% \item The unique identifier of the hand to be used both in the
% |.tex| source file and as an |xml:id| in the \texttt{TEI xml} output
% if any.
% \item The unique idendifier of the witness the hand is related
% to. Of course, this witness must have been declared beforehand.
% \item The rendition to be used in the printed apparatus criticus,
% which also will be found within the |<handNote>| element of the
% \texttt{TEI} header where the description of the hand occurs, within
% a |<abbr type="siglum">| element.
% \item Some further information about the hand.
% \end{enumerate}
%
% To continue the preceding example, here is how additions and
% corrections found in the \emph{Marcianus Gr.}~269 could be declared
% after this witness has been declared itself:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\DeclareHand{M1}{M}{M\textsuperscript{1}}[Emendatio scribae ipsius]
\DeclareHand{M2}{M}{M\textsuperscript{2}}[Manus posterior]
\end{minted}
% \iffalse
%</example>
% \fi
%
% As can be seen, values such as |M|, |M1| and |M2| in the |.tex|
% source file will be printed as \getsiglum{M}, \getsiglum{M1} and
% \getsiglum{M2} respectively. Not only the code gains legibility, but
% also flexibility for simply changing any declared rendition will
% update corresponding sigla thoughout the entire edition.
%
% As a final example, here is how \pkg{ekdosis} would encode
% information as declared above for the \emph{Marcianus Gr.}~269
% should a \texttt{TEI} output be required:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<sourceDesc>
<listWit>
<witness xml:id="M">
<abbr type="siglum">M</abbr>
<emph>Marcianus Gr.</emph>269
<msDesc>
<msIdentifier>
<settlement>Venice</settlement>
<institution>Marciana Library</institution>
<idno>269</idno>
<msName>
<emph>Marcianus Gr.</emph>
</msName>
</msIdentifier>
<physDesc>
<handDesc hands="2">
<handNote xml:id="M1">
<abbr type="siglum">M
<hi rend="sup">1</hi></abbr>
<p>Emendatio scribae ipius</p>
</handNote>
<handNote xml:id="M2">
<abbr type="siglum">M
<hi rend="sup">2</hi></abbr>
<p>Manus posterior</p>
</handNote>
</handDesc>
</physDesc>
<history>
<origin>
<origDate>s. X</origDate>
</origin>
</history>
</msDesc></witness>
</listWit>
</sourceDesc>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \paragraph{Shorthands}
% \DescribeMacro{\DeclareShorthand} \cs{DeclareShorthand}\marg{unique
% id}\marg{rendition}\marg{csv list of witnesses}\\
% This command provides a convenient way to declare \emph{families} of
% witnesses. It takes three mandatory arguments used to specify
% consecutively:---
% \begin{enumerate}
% \item The unique identifier of the family to be used in the |.tex|
% source file.
% \item The rendition to be used in the printed apparatus criticus.
% \item A comma-separated list of previously declared witnesses.
% \end{enumerate}
%
% As an example, the manuscripts of Caesar's \emph{Gallic War} are
% divided into two families: α, which includes mss.\ A, M, B, R, S, L
% and N, and β, which includes mss.\ T, f, U and l. Therefore,
% provided that all these witnesses have been already declared, here
% is how the two families α and β could be
% declared:---\footnote{These witnesses are used in the example
% provided below in \vref{lst:caesar-bg}.}
% \label{ref:caesar-bg-sigla}
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\DeclareShorthand{a}{α}{A,M,B,R,S,L,N}
\DeclareShorthand{b}{β}{T,f,U,l}
\end{minted}
% \iffalse
%</example>
% \fi
%
% Then, symbols |a| and |b| can be used in the |.tex| source file in
% place of manuscripts that belong to either family.
%
% \paragraph{Scholars}
% \DescribeMacro{\DeclareScholar} \cs{DeclareScholar}\marg{unique
% label}\marg{rendition}\\
% The \emph{Conspectus Siglorum} that is placed ahead of the edition
% text is traditionally divided into two parts: a)~\emph{Codices},
% which provides the list of sigla used in the apparatus,
% b)~\emph{Editiones uel Studia}, which provides references to
% scholars whose published or unpublished works contain conjectures
% used in the apparatus criticus. \cs{DeclareScholar} takes two
% mandatory arguments used to specify consecutively:---
% \begin{enumerate}
% \item A unique label used in the |.tex| source file to refer to the
% work where the conjecture is found.
% \item The rendition to be used in the printed apparatus criticus.
% \end{enumerate}
%
% As \pkg{ekdosis} can include and use \texttt{TEI xml} compliant
% lists of references, it is avisable to use Bib\hologo{(La)TeX}
% labels in the first argument of \cs{DeclareScholar}. Likewise,
% shorthands fields from the bibliographical database can be recalled
% from within the second argument of \cs{DeclareScholar}:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\DeclareScholar{Wil}{Wilamowitz}
% or for example:
\DeclareScholar{Wil}{\citename{Wil}{shorteditor}}
\end{minted}
% \iffalse
%</example>
% \fi
% \label{sec:declarations-end}
%
% \subsection{Editing a Single Text With No Translation}
% \label{sec:single-text-editing}
% \DescribeEnv{ekdosis}
% Running paragraphs of one single text to be edited should be
% inserted in the \env{ekdosis} environment, like so:---\footnote{See
% above \vref{lst:pj1}.}
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\begin{ekdosis}
Edition text goes here.
\end{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \paragraph{Apparatus Entries}
% \DescribeMacro{\app} \cs{app}|[type=|\meta{type}|]|\marg{apparatus
% entries}\\
% This command takes one mandatory argument and accepts one optional
% argument. Once references to be used as witnesses in the apparatus
% criticus have been declared in the preamble as described in
% \ref{sec:declarations}
% \vpagerefrange{sec:declarations}{sec:declarations-end}, the \cs{app}
% command is used for inserting entries in the apparatus criticus,
% either lemmata, readings or notes, like so:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
I saw my friend \app{\lem{Peter}\rdg{John}} yesterday.
or:
I saw my friend
\app{
\lem{Peter}
\rdg{John}
}
yesterday.
\end{minted}
% \iffalse
%</example>
% \fi
% \cs{app} accepts one further optional argument:---\\
% \DescribeOption{type} |type|$=$\meta{type}\hfill%
% \tcboxverb{Default: default}\\
% By default, \pkg{ekdosis} sets one layer of notes\--- the |default|
% layer\---in the apparatus criticus. This layer is fit to receive
% notes related to variant readings from witnesses and sources used by
% the editor to establish the edition text. Additional layers can be
% defined to receive other kinds of notes, such as references to texts
% quoted or cited in the text of the edition (\emph{apparatus
% fontium}), references to testimonia, or quotations of the edited
% text by other authors (\emph{apparatus testium}), explanatory notes,
% and so forth.\footnote{See below, \vref{ref:type-app}.} Once
% additional layers have been defined and assigned to new
% \enquote*{types}, such as \enquote*{testium} and the like, these
% types can be used as values appended to the |type| \enquote*{named
% option}.
%
% \paragraph{Base text and variants} As can be seen in the example
% above, there are two kinds of individual readings: the \emph{lemma},
% which contains the base text accepted by the editor, and the
% \emph{reading}, which contains deviant readings rejected by the
% editor.
%
% \paragraph{Lemmata} \DescribeMacro{\lem}
% \cs{lem}\oarg{options}\marg{lemma text}\\
% As \meta{lemma text} is a word or a phrase judged by the editor to
% be authentic or authoritative, \cs{lem} prints it by default both in
% the edition text and as the first part of a new entry in the
% apparatus criticus, preceded by the line number where it occurs or a
% broad space if the entry refers to the same line as the preceding
% entry. \label{ref:lem-opts-b}The optional argument of \cs{lem}
% accepts the following
% comma-separated list of \enquote{name$=$value} arguments:---\\
% \DescribeOption{wit} |wit|$=$\meta{csv list of witnesses}\\
% While a single witness may be recorded as in |wit=A|,
% comma-separated lists of multiple witnesses must obviously be
% enclosed in curly braces, like so:
% |wit={A,B,C}|. \label{ref:mss-sep-families}It must be noted
% that witnesses can be grouped by using spaces as separators, like
% so: \verb*|wit={A,B,C, D,E,F}|.\\
% \DescribeOption{alt} |alt|$=$\meta{alternate lemma}\\
% While the mandatory argument of \cs{lem}, \meta{lemma text}, is
% always used to print the edition text in the upper part of the page,
% \meta{alternate lemma}, if specified, supersedes what is printed in
% the related entry of the apparatus criticus. This mechanism is useful
% in more than one respect. For instance, it can be used to insert
% abbreviated lemmata in the apparatus criticus, or to introduce an
% alternate way of writing entries with Latin technical terms in the
% apparatus criticus as will be demonstrated below in the example
% provided by \vref{lst:pj2}.\\
% \DescribeOption{sep} |sep|$=$\meta{separator}\\
% |sep| allows to change the symbol used to separate the lemma text
% from deviant readings, which is by default the closing square
% bracket (|]|)\\
% \DescribeOption{nosep} |nosep|$=$\verb+true|false+\\
% This named argument does not need a value as it defaults to |true|
% if it is used. Obviously, |nosep| removes the separator mentioned
% above.\\
% \DescribeOption{nolem} |nolem|$=$\verb+true|false+\\
% This named argument does not need a value as it defaults to |true|
% if it is used. |nolem| completely removes the lemma text from the
% related
% entry in the apparatus criticus.\\
% \DescribeOption{type} |type|$=$\meta{value}\\
% This named argument has no effect on the apparatus criticus of the
% edition in print, but it is used in the \texttt{TEI xml} ouput to
% classify the variation recorded in the entry according to some
% convenient typology. Categories such as lexical, morphological,
% orthographical and the like may apply.
%
% Finally, four named arguments can be used to insert words at the
% following specific places in the lemma text:\\
% \noindent
% \fparbox*{\centered{\textbf{1} \tikzmark{pre}\tred{pre} Peter
% \tikzmark{post}\tred{post} \tikzmark{prewit}\tred{prewit}
% \getsiglum{pjA}
% \tikzmark{postwit}\tred{postwit}] John \getsiglum{pjB}}}\\
% \DescribeOption{pre} |pre|$=$\meta{words}\pointtol{pre}\\
% |pre| inserts \meta{words} \emph{before} the lemma text.\\
% \DescribeOption{post} |post|$=$\meta{words}\pointto{post}\\
% |post| inserts \meta{words} \emph{after} the lemma text.\\
% \DescribeOption{prewit} |prewit|$=$\meta{words}\pointto{prewit}\\
% |prewit| inserts \meta{words} \emph{before} the list of witnesses.\\
% \DescribeOption{postwit} |postwit|$=$\meta{words}\pointtor{postwit}\\
% |postwit| inserts \meta{words} \emph{after} the list of witnesses.
% \label{ref:lem-opts-e}
%
% \paragraph{Readings} \DescribeMacro{\rdg}
% \cs{rdg}\oarg{options}\marg{variant reading}\\
% As \meta{reading} is a word or a phrase judged by the editor to be
% unsatisfactory or corrupted, \cs{rdg} prints it by default in the
% last part of the corresponding entry in the apparatus criticus,
% after the symbol that is used to separate words of the base text
% (the lemma text) from words rejected by the editor. The optional
% argument of \cs{rdg} accepts a comma-separated list of
% \enquote{name$=$value} arguments that is almost identical to
% \cs{app}. Therefore, emphasis will be placed here only on the
% differences. The reader is invited to refer to the description
% provided above \vpagerefrange{ref:lem-opts-b}{ref:lem-opts-e} for
% more detailed information:---\\
% \DescribeOption{wit} |wit|$=$\meta{csv list of witnesses}\\
% \DescribeOption{alt} |alt|$=$\meta{alternate reading}\\
% \DescribeOption{nordg} |nordg|$=$\verb+true|false+\\
% This named argument does not need a value as it defaults to |true|
% if it is used. |nordg| completely removes the variant reading from
% the related entry in the apparatus criticus.\\
% \DescribeOption{type} |type|$=$\meta{value}\\
% \DescribeOption{pre} |pre|$=$\meta{words}\\
% \DescribeOption{post} |post|$=$\meta{words}\\
% \DescribeOption{prewit} |prewit|$=$\meta{words}\\
% \DescribeOption{postwit} |postwit|$=$\meta{words}\\
%
% \paragraph{Notes}
% \DescribeMacro{\note}\DescribeMacro{\note*}
% \cs{note}\oarg{options}\marg{text} or
% \cs{note*}\oarg{options}\marg{text}\\
% It may happen that editorial notes be needed to record short
% comments of general nature \emph{between} lemmata and
% readings. \cs{note} inserts inline comments while \cs{note*} places
% comments below the entire apparatus block. Furthermore, if
% \pkg{ekdosis} has been loaded with the |parnotes| option as
% described above \vpageref{ref:parnotes-opt}, \cs{note*} will use the
% \pkg{parnotes} package to lay out the notes as an additional
% paragraph below the apparatus criticus. The optional argument of
% \cs{note}/\cs{note*} accepts the following comma-separated list of
% \enquote{name$=$value}
% arguments:---\\
% \DescribeOption{pre} |pre|$=$\meta{words}\\
% |pre| inserts \meta{words} immediately before the note.\\
% \DescribeOption{post} |post|$=$\meta{words}\\
% |post| inserts \meta{words} immediately after the note.\\
%
% \danger Under no circumstances is it permitted to insert the command
% \cs{note} or \cs{note*} inside the argument of \cs{lem} or
% \cs{rdg}. \cs{note}/\cs{note*} must go \emph{between} these
% commands. As a general rule, within \cs{app}|{}| elements, notes
% are inserted immediately \emph{after} the lemma or the variant
% reading they are related to.
%
% \Vref{lst:pj2} provides an illustration of some of the possibilities
% afforded by the commands just described:---
%
% \captof{The \enquote{Peter/John} full example}[\label{lst:pj2}]
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
\begin{ekdosis}
I
\app{
\lem[wit=A]{saw}
\rdg[wit=B]{met}}
my friend
\app{
\lem{Peter}
\rdg{John}
}
at the station yesterday. We were both in a
\app{
\lem[wit=A]{great}
\rdg[wit=B]{good}}
mood.
\app{
\lem[wit=A, alt={How nice... said}]{\enquote{How nice to find
you here!} he said.}
\note*{There are no quotation marks in the mss.}
\rdg[wit=B, alt=\emph{om.}]{}}
I chuckled to myself, recalling the last time we
\app{
\lem[wit=A,nolem]{met}
\rdg[wit=B, alt={\emph{post} met \emph{add.} there}]{met
there}
\note*{Ms. \getsiglum{B} provides other additions of this kind.}}.
\end{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
% \resetlinenumber
% \begin{alignment}[tcols=1,texts=specimen,apparatus=specimen]
% \begin{specimen}
% I \app{\lem[wit=pjA]{saw}\rdg[wit=pjB]{met}} my friend
% \app{
% \lem{Peter}
% \rdg{John}
% }
% at the station yesterday. We were both in a
% \app{
% \lem[wit=pjA]{great}
% \rdg[wit=pjB]{good}}
% mood.
% \app{
% \lem[wit=pjA, alt={\textooquote How nice... said}]{\enquote{How
% nice to find you here!} he said.}
% \note*{There are no quotation marks in the mss.}
% \rdg[wit=pjB, alt=\emph{om.}]{}}
% I chuckled to myself, recalling the last time we
% \app{
% \lem[wit=pjA,nolem]{met}
% \rdg[wit=pjB, alt={\emph{post} met \emph{add.} there}]{met
% there}
% \note*{Ms. \getsiglum{pjB} provides other additions of this kind.}}.
% \end{specimen}
% \end{alignment}
%
% \begin{remarks}
% \item Close examination of lines~17--8 from \vref{lst:pj2} shows how
% |alt| has been used to insert an abbridged lemma text in the
% apparatus criticus in print while keeping safe what is to be found
% in the \texttt{TEI xml} output.
% \item The same technique has been used at line~24 to insert
% alternate words, including Latin technical terms, in place of the
% variant reading. Hence the use of |nolem| at line~23 to remove the
% lemma text from the apparatus criticus in print.
% \item \cs{note*} has been used to insert short annotations in two
% places (ll.~19 and 26).
% \item For an example of the use of |nordg|, see below
% \vref{lst:caesar-bg}, l.~11.
% \end{remarks}
%
% The corresponding \texttt{TEI xml} output produced by \pkg{ekdosis}
% from the \LaTeX{} source file follows:---
%
% \captof{The \enquote{Peter/John} full example: \texttt{TEI xml}
% output}[\label{lst:pj2-tei}]
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<p>I
<app>
<lem wit="#A">saw</lem>
<rdg wit="#B">met</rdg>
</app>my friend
<app>
<lem>Peter</lem>
<rdg>John</rdg>
</app>at the station yesterday. We were both in a
<app>
<lem wit="#A">great</lem>
<rdg wit="#B">good</rdg>
</app>mood.
<app>
<lem wit="#A">
<quote>How nice to find you here!</quote> he said.</lem>
<note>There are no quotation marks in the mss.</note>
<rdg wit="#B" />
</app>I chuckled to myself, recalling the last time we
<app>
<lem wit="#A">met</lem>
<rdg wit="#B">met there</rdg>
<note>Ms.
<ref target="#B">B</ref>provides other additions of
this kind.</note>
</app>.</p>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \section{Alignment of Parallel Texts}
% \label{sec:alignment-basic}
% As already said above,\footnote{See point
% \vref{it:multicol-feature}.} \pkg{ekdosis} can arrange sundry texts
% in parallel columns\---synchronized or not\---either on the same
% page or on facing pages. Depending on what is needed, any text can
% be equipped with an apparatus criticus. The most common example is
% that of an edition of a classical text with an apparatus criticus
% accompanied by a translation into a modern language on the facing
% page. One can also imagine an edition of two classical texts or two
% different recensions of the same text, each of which provides
% variants recorded in separate apparatus crititus, laid out on the
% left-hand pages, with one or more translations on the corresponding
% right-hand pages, and so forth.
%
% \paragraph{The \env{alignment} Environment}
% \DescribeEnv{alignment} \cs{begin}|{alignment}|\oarg{options}\dots
% \cs{end}|{alignment}|\label{ref:alignment-syntax}\\
% This environment can be used as it is provided to typeset a standard
% critical edition, namely an edition text, equipped with an apparatus
% criticus and laid out on the left-hand pages, accompanied by a
% translation into a modern language on the facing pages.
%
% \DescribeEnv{edition}\DescribeEnv{translation} Within
% \env{alignment}, two environments are available by default:
% \cs{begin}|{edition}|\allowbreak\dots
% \cs{end}|{ed|\allowbreak|ition}| and \cs{begin}|{translation}|\dots
% \cs{end}|{translation}|. Obviously, the former is used to typeset
% the edition text with an apparatus criticus on the left, while the
% latter is used to typeset the translation on the right, like so:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\begin{alignment}
\begin{edition}
First § of the edition text.
\end{edition}
\begin{translation}
First § of the translation.
\end{translation}
\begin{edition}
Second § of the edition text.
\end{edition}
\begin{translation}
Second § of the translation.
\end{translation}
\end{alignment}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \DescribeEnv{edition*}\DescribeEnv{translation*} Furthermore,
% so-called \enquote{starred} versions of these environments can be
% used at any point to synchronize texts, that is to print them in
% such a way that the tops of all paragraphs are vertically
% aligned. To that effect, it must be noted that merely applying this
% command on a single environment\---for instance the leftmost
% one\---will have all other associated paragraphs printed aligned.
%
% \danger While the whole edition text and the whole translation can
% be inserted in a single \env{edition}/\env{translation} environment
% respectively, it is recommended to enter both texts paragraph by
% paragraph as shown in the example above. Not only this method of
% encoding allows not to lose sight of paragraphs that are meant to be
% read together, but it is also the only way to align paragraphs in
% print, and it is much more suitable to mark up correspondence
% between spans of texts as will be demonstrated below in
% \vref{ref:segmentation}.
%
% As an illustration, a short extract of Caesar's \emph{Gallic War},
% VI, XIII.1 follows.\footnote{Latin text: \cite{Caesar-BG-v2};
% English translation: \cite{CaesarTr}.} See the list of sigla for
% manuscripts and manuscript families above
% \vpageref{ref:caesar-bg-sigla}. As this document is not set for
% duplex printing, both texts have been put together on the same
% page. However, the reader will find the full |.tex| source file
% in \vref{sec:caesar-gw-tex} and \texttt{TEI xml} output in
% \vref{sec:caesar-gw-tei}. The corresponding PDF output is available
% in \href{samples/Caesar_BG-6-13-1.pdf}{a separate file}:---
%
% \captof{Caesar's \emph{Gallic War}, VI, 13.1}[\label{lst:caesar-bg}]
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
\begin{alignment}
\begin{edition}
\ekddiv{head=XIII, depth=2, n=6.13, type=section}
In omni Gallia eorum hominum qui \app{
\lem[wit=a]{aliquo}
\rdg[wit=b, alt=in al-]{in aliquo}}
sunt numero atque honore genera sunt duo. Nam plebes paene
seruorum habetur loco, quae \app{
\lem[wit={A,M}, alt={nihil audet (aut et \getsiglum{A1})
per se}]{nihil audet per se}
\rdg[wit=A1,nordg]{nihil aut et per se}
\rdg[wit={R,S,L,N}]{nihil habet per se}
\rdg[wit=b]{per se nihil audet}}, \app{
\lem[wit=a]{nullo}
\rdg[wit=b]{nulli}} adhibetur \app{
\lem{consilio}
\rdg[wit={T, U}, alt=conc-]{concilio}}.
\end{edition}
\begin{translation}
\ekddiv{head=XIII, depth=2, n=6.13, type=section}
Throughout all Gaul there are two orders of those men who are of
any rank and dignity: for the commonality is held almost in the
condition of slaves, and dares to undertake nothing of itself,
and is admitted to no deliberation.
\end{translation}
\end{alignment}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \resetlinenumber
% \ekdfmtdiv{2}{}{.}
% \begin{alignment}[lcols=2,
% texts=edition[xml:lang="la"];
% translation[xml:lang="en"]]
% \AtBeginEnvironment{edition}{\selectlanguage{latin}}
% \AtBeginEnvironment{translation}{\selectlanguage{american}}
% \begin{edition}
% \ekddiv{head=XIII, depth=2, n=6.13, type=section}
% In omni Gallia eorum hominum qui \app{
% \lem[wit=ca]{aliquo}
% \rdg[wit=cb, alt=in al-]{in aliquo}}
% sunt numero atque honore genera sunt duo. Nam plebes paene
% seruorum habetur loco, quae \app{
% \lem[wit={cA,cM}, alt={nihil audet (aut et \getsiglum{cA1})
% per se}]{nihil audet per se}
% \rdg[wit=cA1,nordg]{nihil aut et per se}
% \rdg[wit={cR,cS,cL,cN}]{nihil habet per se}
% \rdg[wit=cb]{per se nihil audet}}, \app{
% \lem[wit=ca]{nullo}
% \rdg[wit=cb]{nulli}} adhibetur \app{
% \lem{consilio}
% \rdg[wit={cT, cU}, alt=conc-]{concilio}}.
% \end{edition}
% \begin{translation}
% \ekddiv{head=XIII, depth=2, n=6.13, type=section}
% Throughout all Gaul there are two orders of those men who are of
% any rank and dignity: for the commonality is held almost in the
% condition of slaves, and dares to undertake nothing of itself,
% and is admitted to no deliberation.
% \end{translation}
% \end{alignment}
%
% \begin{remarks}
% \item As can be seen from the apparatus entry related to l.~4 above,
% a subvariant has been inserted in the lemma part: \enquote{(aut et
% \getsiglum{cA1})}. This was done by using |alt| in
% \vref{lst:caesar-bg}, ll.~9--10. But as this variant is already
% recorded\---and printed\---in the lemma part, it was necessary to
% remove the entire otherwise redundant variant from the apparatus
% criticus in print. Hence the use of |nordg| at l.~11.
% \item For examples of abbreviations, see ll.~6 and 17.
% \item Line~17 shows how mss.\ T and U (which belong to two distinct
% subfamilies) have been separated from one another: %
% \verb*+wit={T, U}+. See above \vpageref{ref:mss-sep-families} for
% more information on this technique.
% \end{remarks}
%
% Finally, the corresponding \texttt{TEI xml} output follows:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<div xml:id="div-edition_1" xml:lang="la">
<div type="section" n="6.13">
<head>XIII</head>
<p>In omni Gallia eorum hominum qui
<app>
<lem wit="#A #M #B #R #S #L #N">aliquo</lem>
<rdg wit="#T #f #U #l">in aliquo</rdg>
</app>sunt numero atque honore genera sunt duo. Nam
plebes paene seruorum habetur loco, quae
<app>
<lem wit="#A #M">nihil audet per se</lem>
<rdg wit="#A1">nihil aut et per se</rdg>
<rdg wit="#R #S #L #N">nihil habet per se</rdg>
<rdg wit="#T #f #U #l">per se nihil audet</rdg>
</app>,
<app>
<lem wit="#A #M #B #R #S #L #N">nullo</lem>
<rdg wit="#T #f #U #l">nulli</rdg>
</app>adhibetur
<app>
<lem>consilio</lem>
<rdg wit="#T #U">concilio</rdg>
</app>.</p>
</div>
</div>
<div xml:id="div-translation_1" xml:lang="en">
<div type="section" n="6.13">
<head>XIII</head>
<p>Throughout all Gaul there are two orders of those men
who are of any rank and dignity: for the commonality is
held almost in the condition of slaves, and dares to
undertake nothing of itself, and is admitted to no
deliberation.</p>
</div>
</div>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \subsection{Alignment of Several Texts}
% \label{sec:multiple-alignment}
% As described above \vpageref{ref:alignment-syntax}, the
% \env{alignment} environment may receive an optional argument in which
% the following \enquote{name$=$value} arguments are accepted:---\\
% \DescribeOption{tcols}
% |tcols|$=$\meta{number}\hfill\tcboxverb{Default: 2}\\
% |tcols| stores the \underLine{t}otal number of
% \underLine{col}umn\underLine{s} of text to be aligned.\\
% \DescribeOption{lcols}
% |lcols|$=$\meta{number}\hfill\tcboxverb{Default: 1}\\
% |lcols| stores the number of \underLine{col}umn\underLine{s} to be
% printed on the \underLine{l}eft-hand page, \emph{out of the total
% number} of columns specified with |tcols|. As can be seen from the
% preceding two default values, \env{alignment} initially sets two
% columns of text on facing pages. Of course, for this setting to work
% properly, one must ensure that the \env{alignment} environment is
% started on a
% left page.\\
% \DescribeOption{texts}
% |texts|$=$\meta{\underLine{semicolon}-separated
% values}\hfill\tcboxverb{Default: edition;translation}\\
% Depending on the total number of columns that has been specified
% with |tcols| above, |texts| is then used to define the names of the
% environments that shall receive edition texts, translations,
% \emph{\&c.} Some very important points need to be emphasized in this
% respect:---
% \begin{enumerate}
% \item Only unaccented letters of the alphabet (whatever the case)
% are allowed to compose the names of \LaTeX{} environments.
% \item These names must be separated from one another by
% \emph{semicolons}, as shown in red in the listing below at the end
% of lines~1 and 2.
% \begin{enumerate}
% \item[\dbend] The colon at the end of line~3 closes the whole
% value of |text| and acts as a higher level separator.
% \end{enumerate}
% \item Each name may be followed by a \enquote*{suboptional} argument
% between square brackets which will then be used to insert
% \texttt{TEI xml} attributes in the corresponding |<div>|
% element. For example,
% \iffalse
%<*example>
% \fi
\begin{minted}[escapeinside=++]{latex}
texts=latin[xml:lang="la"]+\textcolor{red}{;}+
english[xml:lang="en"]+\textcolor{red}{;}+
french[xml:lang="fr"]+\textcolor{red}{,}+
\end{minted}
% \iffalse
%</example>
% \fi
% will be converted into \texttt{TEI xml} as follows:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<div xml:id="div-latin_1" xml:lang="la">
...
</div>
<div xml:id="div-english_1" xml:lang="en">
...
</div>
<div xml:id="div-french_1" xml:lang="fr">
...
</div>
\end{minted}
% \iffalse
%</example>
% \fi
% \begin{enumerate}
% \item[\dbend] As can be seen, \pkg{ekdosis} takes care of
% computing and inserting the |xml:id| attributes which are
% therefore not accepted in the \enquote*{suboptional} arguments
% of |texts|.
% \end{enumerate}
% \item The names of the environments must be specified in exactly the
% same order as they are supposed to appear in the print edition,
% from left to right.
% \end{enumerate}
% \DescribeOption{apparatus}
% |apparatus|$=$\meta{\underLine{semicolon}-separated
% values}\hfill\tcboxverb{Default: edition}\\
% Then, the |apparatus| option, just as |texts|, takes a
% \underLine{semicolon}-separated list of previously defined
% environments that shall receive at least one layer of apparatus
% criticus.\\
% \DescribeOption{paired} |paired|$=$\verb+true|false+%
% \hfill\tcboxverb{Default: true (initially not set)}\\
% This named argument does not need a value as it defaults to |true|
% if it is used. By default, \pkg{ekdosis} follows the \LaTeX{} page
% numbering scheme when multiple texts are arranged on facing
% pages. The |paired| option leaves every right-hand page number
% unchanged, so that both facing pages hold the same page number.\\
% \DescribeOption{lineation} |lineation|$=$\verb+page|document+
% \hfill\tcboxverb{Default: document}\\
% This option applies to edition texts initially set to receive an
% apparatus criticus. By default, lines are continuously numbered
% throughout the document. |lineation=page| sets the numbering to
% start afresh at the top of each page.\\
% \DescribeOption{flush} |flush|$=$\verb+true|false+
% \hfill\tcboxverb{Default: false}\\
% This named argument does not need a value as it defaults to |true|
% if it is used. This option applies on rare occasions only, when two
% or more distinct \env{alignment} environments are started on the same
% page. Should this happen, any subsequent \env{alignment} environment
% must be set with the |flush| option so that every one of them
% carry its own apparatus criticus.
%
% As an example, the alignment of the Latin edition text of Caesar's
% \emph{Gallic War}, printed on left-hand pages, along with two
% translations into English and French, printed on right-hand pages,
% can be set as follows:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\begin{alignment}[tcols=3,
lcols=1,
texts=latin[xml:lang="la"];
english[xml:lang="en"];
french[xml:lang="fr"],
apparatus=latin,
lineation=page]
\begin{latin}
Gallia est omnis divisa in partes tres quarum unam incolunt
Belgae, [...]
\end{latin}
\begin{english}
All Gaul is divided into three parts, one of which the Belgae
inhabit, [...]
\end{english}
\begin{french}
L'ensemble de la Gaule est divisé en trois parties: l'une est
habitée par les Belges, [...]
\end{french}
\end{alignment}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \DescribeMacro{\SetEkdosisAlignment}
% \cs{SetEkdosisAlignment}\marg{alignment settings}\\
% If the same alignment settings are to be shared by several
% \env{alignment} environments, common settings can be collected in
% the argument of \cs{SetEkdosisEnvironment}, like
% so:---\\
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\SetEkdosisAlignment{
tcols=3,
lcols=1,
texts=latin[xml:lang="la"];
english[xml:lang="en"];
french[xml:lang="fr"],
apparatus=latin,
lineation=page
}
\begin{alignment}
...
\end{alignment}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \cs{SetEkdosisAlignment} can be used either in the preamble or at
% any point of the document to set or to modify alignment settings.
%
% \section{To Be Continued...}
% v1.0 of \pkg{ekdosis}, which should be available by the end of July
% 2020, will include a full documentation. At the time of writing, the
% author is working on this part of the package.
%
% \begin{comment}
% \section{Multiple-Layer Apparatus Criticus}
% \end{comment}
% \label{sec:multilayer-apparatus}
%
% \label{ref:type-app}
% \begin{comment}
% \section{Correspondence and Alignment}
% \end{comment}
% \label{sec:correspondance-alignment}
%
% \label{ref:segmentation}
%
% \section{GNU Free Documentation License}
% \label{sec:fdl}
% \textbf{Version 1.3, 3 November 2008}
%
% \begin{center}
% Version 1.3, 3 November 2008
%
% Copyright \copyright{} 2000, 2001, 2002, 2007, 2008 Free
% Software Foundation, Inc.
%
% \bigskip
%
% \url{https://fsf.org/}
%
% \bigskip
%
% Everyone is permitted to copy and distribute verbatim copies
% of this license document, but changing it is not allowed.
% \end{center}
%
% \needspace{3\baselineskip}
% \begin{center}
% {\bf\large Preamble}
% \end{center}
%
% The purpose of this License is to make a manual, textbook, or other
% functional and useful document \enquote{free} in the sense of
% freedom: to assure everyone the effective freedom to copy and
% redistribute it, with or without modifying it, either commercially
% or noncommercially. Secondarily, this License preserves for the
% author and publisher a way to get credit for their work, while not
% being considered responsible for modifications made by others.
%
% This License is a kind of \enquote{copyleft}, which means that
% derivative works of the document must themselves be free in the same
% sense. It complements the GNU General Public License, which is a
% copyleft license designed for free software.
%
% We have designed this License in order to use it for manuals for
% free software, because free software needs free documentation: a
% free program should come with manuals providing the same freedoms
% that the software does. But this License is not limited to software
% manuals; it can be used for any textual work, regardless of subject
% matter or whether it is published as a printed book. We recommend
% this License principally for works whose purpose is instruction or
% reference.
%
% \needspace{3\baselineskip}
% \begin{center}
% {\large\bf 1. APPLICABILITY AND DEFINITIONS\par}
% \end{center}
%
% This License applies to any manual or other work, in any medium,
% that contains a notice placed by the copyright holder saying it can
% be distributed under the terms of this License. Such a notice
% grants a world-wide, royalty-free license, unlimited in duration, to
% use that work under the conditions stated herein. The
% \enquote{\textbf{Document}}, below, refers to any such manual or
% work. Any member of the public is a licensee, and is addressed as
% \enquote{\textbf{you}}. You accept the license if you copy, modify
% or distribute the work in a way requiring permission under copyright
% law.
%
% A \enquote{\textbf{Modified Version}} of the Document means any work
% containing the Document or a portion of it, either copied verbatim,
% or with modifications and/or translated into another language.
%
% A \enquote{\textbf{Secondary Section}} is a named appendix or a
% front-matter section of the Document that deals exclusively with the
% relationship of the publishers or authors of the Document to the
% Document's overall subject (or to related matters) and contains
% nothing that could fall directly within that overall subject.
% (Thus, if the Document is in part a textbook of mathematics, a
% Secondary Section may not explain any mathematics.) The
% relationship could be a matter of historical connection with the
% subject or with related matters, or of legal, commercial,
% philosophical, ethical or political position regarding them.
%
% The \enquote{\textbf{Invariant Sections}} are certain Secondary
% Sections whose titles are designated, as being those of Invariant
% Sections, in the notice that says that the Document is released
% under this License. If a section does not fit the above definition
% of Secondary then it is not allowed to be designated as Invariant.
% The Document may contain zero Invariant Sections. If the Document
% does not identify any Invariant Sections then there are none.
%
% The \enquote{\textbf{Cover Texts}} are certain short passages of
% text that are listed, as Front-Cover Texts or Back-Cover Texts, in
% the notice that says that the Document is released under this
% License. A Front-Cover Text may be at most 5 words, and a
% Back-Cover Text may be at most 25 words.
%
% A \enquote{\textbf{Transparent}} copy of the Document means a
% machine-readable copy, represented in a format whose specification
% is available to the general public, that is suitable for revising
% the document straightforwardly with generic text editors or (for
% images composed of pixels) generic paint programs or (for drawings)
% some widely available drawing editor, and that is suitable for input
% to text formatters or for automatic translation to a variety of
% formats suitable for input to text formatters. A copy made in an
% otherwise Transparent file format whose markup, or absence of
% markup, has been arranged to thwart or discourage subsequent
% modification by readers is not Transparent. An image format is not
% Transparent if used for any substantial amount of text. A copy that
% is not \enquote{Transparent} is called \enquote{\textbf{Opaque}}.
%
% Examples of suitable formats for Transparent copies include plain
% ASCII without markup, Texinfo input format, LaTeX input format, SGML
% or XML using a publicly available DTD, and standard-conforming
% simple HTML, PostScript or PDF designed for human modification.
% Examples of transparent image formats include PNG, XCF and JPG.
% Opaque formats include proprietary formats that can be read and
% edited only by proprietary word processors, SGML or XML for which
% the DTD and/or processing tools are not generally available, and the
% machine-generated HTML, PostScript or PDF produced by some word
% processors for output purposes only.
%
% The \enquote{\textbf{Title Page}} means, for a printed book, the
% title page itself, plus such following pages as are needed to hold,
% legibly, the material this License requires to appear in the title
% page. For works in formats which do not have any title page as
% such, \enquote{Title Page} means the text near the most prominent
% appearance of the work's title, preceding the beginning of the body
% of the text.
%
% The \enquote{\textbf{publisher}} means any person or entity that
% distributes copies of the Document to the public.
%
% A section \enquote{\textbf{Entitled XYZ}} means a named subunit of
% the Document whose title either is precisely XYZ or contains XYZ in
% parentheses following text that translates XYZ in another language.
% (Here XYZ stands for a specific section name mentioned below, such
% as \enquote{\textbf{Acknowledgements}},
% \enquote{\textbf{Dedications}}, \enquote{\textbf{Endorsements}}, or
% \enquote{\textbf{History}}.) To \enquote{\textbf{Preserve the
% Title}} of such a section when you modify the Document means that it
% remains a section \enquote{Entitled XYZ} according to this
% definition.
%
% The Document may include Warranty Disclaimers next to the notice
% which states that this License applies to the Document. These
% Warranty Disclaimers are considered to be included by reference in
% this License, but only as regards disclaiming warranties: any other
% implication that these Warranty Disclaimers may have is void and has
% no effect on the meaning of this License.
%
% \needspace{3\baselineskip}
% \begin{center}
% {\large\bf 2. VERBATIM COPYING\par}
% \end{center}
%
% You may copy and distribute the Document in any medium, either
% commercially or noncommercially, provided that this License, the
% copyright notices, and the license notice saying this License
% applies to the Document are reproduced in all copies, and that you
% add no other conditions whatsoever to those of this License. You
% may not use technical measures to obstruct or control the reading or
% further copying of the copies you make or distribute. However, you
% may accept compensation in exchange for copies. If you distribute a
% large enough number of copies you must also follow the conditions in
% section~3.
%
% You may also lend copies, under the same conditions stated above,
% and you may publicly display copies.
%
% \needspace{3\baselineskip}
% \begin{center}
% {\large\bf 3. COPYING IN QUANTITY\par}
% \end{center}
%
% If you publish printed copies (or copies in media that commonly have
% printed covers) of the Document, numbering more than 100, and the
% Document's license notice requires Cover Texts, you must enclose the
% copies in covers that carry, clearly and legibly, all these Cover
% Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
% the back cover. Both covers must also clearly and legibly identify
% you as the publisher of these copies. The front cover must present
% the full title with all words of the title equally prominent and
% visible. You may add other material on the covers in addition.
% Copying with changes limited to the covers, as long as they preserve
% the title of the Document and satisfy these conditions, can be
% treated as verbatim copying in other respects.
%
% If the required texts for either cover are too voluminous to fit
% legibly, you should put the first ones listed (as many as fit
% reasonably) on the actual cover, and continue the rest onto adjacent
% pages.
%
% If you publish or distribute Opaque copies of the Document numbering
% more than 100, you must either include a machine-readable
% Transparent copy along with each Opaque copy, or state in or with
% each Opaque copy a computer-network location from which the general
% network-using public has access to download using public-standard
% network protocols a complete Transparent copy of the Document, free
% of added material. If you use the latter option, you must take
% reasonably prudent steps, when you begin distribution of Opaque
% copies in quantity, to ensure that this Transparent copy will remain
% thus accessible at the stated location until at least one year after
% the last time you distribute an Opaque copy (directly or through
% your agents or retailers) of that edition to the public.
%
% It is requested, but not required, that you contact the authors of
% the Document well before redistributing any large number of copies,
% to give them a chance to provide you with an updated version of the
% Document.
%
% \needspace{3\baselineskip}
% \begin{center}
% {\large\bf 4. MODIFICATIONS\par}
% \end{center}
%
% You may copy and distribute a Modified Version of the Document under
% the conditions of sections 2 and 3 above, provided that you release
% the Modified Version under precisely this License, with the Modified
% Version filling the role of the Document, thus licensing
% distribution and modification of the Modified Version to whoever
% possesses a copy of it. In addition, you must do these things in
% the Modified Version:
%
% \begin{itemize}
% \item[A.] Use in the Title Page (and on the covers, if any) a title
% distinct from that of the Document, and from those of previous
% versions (which should, if there were any, be listed in the
% History section of the Document). You may use the same title as a
% previous version if the original publisher of that version gives
% permission.
%
% \item[B.] List on the Title Page, as authors, one or more persons
% or entities responsible for authorship of the modifications in
% the Modified Version, together with at least five of the
% principal authors of the Document (all of its principal authors,
% if it has fewer than five), unless they release you from this
% requirement.
%
% \item[C.] State on the Title page the name of the publisher of the
% Modified Version, as the publisher.
%
% \item[D.] Preserve all the copyright notices of the Document.
%
% \item[E.] Add an appropriate copyright notice for your
% modifications adjacent to the other copyright notices.
%
% \item[F.] Include, immediately after the copyright notices, a
% license notice giving the public permission to use the Modified
% Version under the terms of this License, in the form shown in the
% Addendum below.
%
% \item[G.] Preserve in that license notice the full lists of
% Invariant Sections and required Cover Texts given in the
% Document's license notice.
%
% \item[H.] Include an unaltered copy of this License.
%
% \item[I.] Preserve the section Entitled \enquote{History},
% Preserve its Title, and add to it an item stating at least the
% title, year, new authors, and publisher of the Modified Version
% as given on the Title Page. If there is no section Entitled
% \enquote{History} in the Document, create one stating the title,
% year, authors, and publisher of the Document as given on its
% Title Page, then add an item describing the Modified Version as
% stated in the previous sentence.
%
% \item[J.] Preserve the network location, if any, given in the
% Document for public access to a Transparent copy of the Document,
% and likewise the network locations given in the Document for
% previous versions it was based on. These may be placed in the
% \enquote{History} section. You may omit a network location for a
% work that was published at least four years before the Document
% itself, or if the original publisher of the version it refers to
% gives permission.
%
% \item[K.] For any section Entitled \enquote{Acknowledgements} or
% \enquote{Dedications}, Preserve the Title of the section, and
% preserve in the section all the substance and tone of each of the
% contributor acknowledgements and/or dedications given therein.
%
% \item[L.] Preserve all the Invariant Sections of the Document,
% unaltered in their text and in their titles. Section numbers or
% the equivalent are not considered part of the section titles.
%
% \item[M.] Delete any section Entitled \enquote{Endorsements}.
% Such a section may not be included in the Modified Version.
%
% \item[N.] Do not retitle any existing section to be Entitled
% \enquote{Endorsements} or to conflict in title with any Invariant
% Section.
%
% \item[O.] Preserve any Warranty Disclaimers.
% \end{itemize}
%
% If the Modified Version includes new front-matter sections or
% appendices that qualify as Secondary Sections and contain no
% material copied from the Document, you may at your option designate
% some or all of these sections as invariant. To do this, add their
% titles to the list of Invariant Sections in the Modified Version's
% license notice. These titles must be distinct from any other
% section titles.
%
% You may add a section Entitled \enquote{Endorsements}, provided it
% contains nothing but endorsements of your Modified Version by
% various parties---for example, statements of peer review or that the
% text has been approved by an organization as the authoritative
% definition of a standard.
%
% You may add a passage of up to five words as a Front-Cover Text, and
% a passage of up to 25 words as a Back-Cover Text, to the end of the
% list of Cover Texts in the Modified Version. Only one passage of
% Front-Cover Text and one of Back-Cover Text may be added by (or
% through arrangements made by) any one entity. If the Document
% already includes a cover text for the same cover, previously added
% by you or by arrangement made by the same entity you are acting on
% behalf of, you may not add another; but you may replace the old one,
% on explicit permission from the previous publisher that added the
% old one.
%
% The author(s) and publisher(s) of the Document do not by this
% License give permission to use their names for publicity for or to
% assert or imply endorsement of any Modified Version.
%
% \needspace{3\baselineskip}
% \begin{center}
% {\large\bf 5. COMBINING DOCUMENTS\par}
% \end{center}
%
% You may combine the Document with other documents released under
% this License, under the terms defined in section~4 above for
% modified versions, provided that you include in the combination all
% of the Invariant Sections of all of the original documents,
% unmodified, and list them all as Invariant Sections of your combined
% work in its license notice, and that you preserve all their Warranty
% Disclaimers.
%
% The combined work need only contain one copy of this License, and
% multiple identical Invariant Sections may be replaced with a single
% copy. If there are multiple Invariant Sections with the same name
% but different contents, make the title of each such section unique
% by adding at the end of it, in parentheses, the name of the original
% author or publisher of that section if known, or else a unique
% number. Make the same adjustment to the section titles in the list
% of Invariant Sections in the license notice of the combined work.
%
% In the combination, you must combine any sections Entitled
% \enquote{History} in the various original documents, forming one
% section Entitled \enquote{History}; likewise combine any sections
% Entitled \enquote{Acknowledgements}, and any sections Entitled
% \enquote{Dedications}. You must delete all sections Entitled
% \enquote{Endorsements}.
%
% \needspace{3\baselineskip}
% \begin{center}
% {\large\bf 6. COLLECTIONS OF DOCUMENTS\par}
% \end{center}
%
% You may make a collection consisting of the Document and other
% documents released under this License, and replace the individual
% copies of this License in the various documents with a single copy
% that is included in the collection, provided that you follow the
% rules of this License for verbatim copying of each of the documents
% in all other respects.
%
% You may extract a single document from such a collection, and
% distribute it individually under this License, provided you insert a
% copy of this License into the extracted document, and follow this
% License in all other respects regarding verbatim copying of that
% document.
%
% \needspace{3\baselineskip}
% \begin{center}
% {\large\bf 7. AGGREGATION WITH INDEPENDENT WORKS\par}
% \end{center}
%
% A compilation of the Document or its derivatives with other separate
% and independent documents or works, in or on a volume of a storage
% or distribution medium, is called an \enquote{aggregate} if the
% copyright resulting from the compilation is not used to limit the
% legal rights of the compilation's users beyond what the individual
% works permit. When the Document is included in an aggregate, this
% License does not apply to the other works in the aggregate which are
% not themselves derivative works of the Document.
%
% If the Cover Text requirement of section~3 is applicable to these
% copies of the Document, then if the Document is less than one half
% of the entire aggregate, the Document's Cover Texts may be placed on
% covers that bracket the Document within the aggregate, or the
% electronic equivalent of covers if the Document is in electronic
% form. Otherwise they must appear on printed covers that bracket the
% whole aggregate.
%
% \needspace{3\baselineskip}
% \begin{center}
% {\large\bf 8. TRANSLATION\par}
% \end{center}
%
% Translation is considered a kind of modification, so you may
% distribute translations of the Document under the terms of
% section~4. Replacing Invariant Sections with translations requires
% special permission from their copyright holders, but you may include
% translations of some or all Invariant Sections in addition to the
% original versions of these Invariant Sections. You may include a
% translation of this License, and all the license notices in the
% Document, and any Warranty Disclaimers, provided that you also
% include the original English version of this License and the
% original versions of those notices and disclaimers. In case of a
% disagreement between the translation and the original version of
% this License or a notice or disclaimer, the original version will
% prevail.
%
% If a section in the Document is Entitled \enquote{Acknowledgements},
% \enquote{Dedications}, or \enquote{History}, the requirement
% (section~4) to Preserve its Title (section~1) will typically require
% changing the actual title.
%
% \needspace{3\baselineskip}
% \begin{center}
% {\large\bf 9. TERMINATION\par}
% \end{center}
%
% You may not copy, modify, sublicense, or distribute the Document
% except as expressly provided under this License. Any attempt
% otherwise to copy, modify, sublicense, or distribute it is void, and
% will automatically terminate your rights under this License.
%
% However, if you cease all violation of this License, then your
% license from a particular copyright holder is reinstated (a)
% provisionally, unless and until the copyright holder explicitly and
% finally terminates your license, and (b) permanently, if the
% copyright holder fails to notify you of the violation by some
% reasonable means prior to 60 days after the cessation.
%
% Moreover, your license from a particular copyright holder is
% reinstated permanently if the copyright holder notifies you of the
% violation by some reasonable means, this is the first time you have
% received notice of violation of this License (for any work) from
% that copyright holder, and you cure the violation prior to 30 days
% after your receipt of the notice.
%
% Termination of your rights under this section does not terminate the
% licenses of parties who have received copies or rights from you
% under this License. If your rights have been terminated and not
% permanently reinstated, receipt of a copy of some or all of the same
% material does not give you any rights to use it.
%
% \needspace{3\baselineskip}
% \begin{center}
% {\large\bf 10. FUTURE REVISIONS OF THIS LICENSE\par}
% \end{center}
%
% The Free Software Foundation may publish new, revised versions of
% the GNU Free Documentation License from time to time. Such new
% versions will be similar in spirit to the present version, but may
% differ in detail to address new problems or concerns. See
% \url{https://www.gnu.org/licenses/}.
%
% Each version of the License is given a distinguishing version
% number. If the Document specifies that a particular numbered
% version of this License \enquote{or any later version} applies to
% it, you have the option of following the terms and conditions either
% of that specified version or of any later version that has been
% published (not as a draft) by the Free Software Foundation. If the
% Document does not specify a version number of this License, you may
% choose any version ever published (not as a draft) by the Free
% Software Foundation. If the Document specifies that a proxy can
% decide which future versions of this License can be used, that
% proxy's public statement of acceptance of a version permanently
% authorizes you to choose that version for the Document.
%
% \needspace{3\baselineskip}
% \begin{center}
% {\large\bf 11. RELICENSING\par}
% \end{center}
%
% \enquote{Massive Multiauthor Collaboration Site} (or \enquote{MMC
% Site}) means any World Wide Web server that publishes copyrightable
% works and also provides prominent facilities for anybody to edit
% those works. A public wiki that anybody can edit is an example of
% such a server. A \enquote{Massive Multiauthor Collaboration} (or
% \enquote{MMC}) contained in the site means any set of copyrightable
% works thus published on the MMC site.
%
% \enquote{CC-BY-SA} means the Creative Commons Attribution-Share
% Alike 3.0 license published by Creative Commons Corporation, a
% not-for-profit corporation with a principal place of business in San
% Francisco, California, as well as future copyleft versions of that
% license published by that same organization.
%
% \enquote{Incorporate} means to publish or republish a Document, in
% whole or in part, as part of another Document.
%
% An MMC is \enquote{eligible for relicensing} if it is licensed under
% this License, and if all works that were first published under this
% License somewhere other than this MMC, and subsequently incorporated
% in whole or in part into the MMC, (1) had no cover texts or
% invariant sections, and (2) were thus incorporated prior to November
% 1, 2008.
%
% The operator of an MMC Site may republish an MMC contained in the
% site under CC-BY-SA on the same site at any time before August 1,
% 2009, provided the MMC is eligible for relicensing.
%
% \needspace{3\baselineskip}
% \begin{center}
% {\large\bf ADDENDUM: How to use this License for your documents\par}
% \end{center}
%
% To use this License in a document you have written, include a copy
% of the License in the document and put the following copyright and
% license notices just after the title page:
%
% \bigskip
% \begin{quote}
% Copyright \copyright{} YEAR YOUR NAME. Permission is granted to
% copy, distribute and/or modify this document under the terms of
% the GNU Free Documentation License, Version 1.3 or any later
% version published by the Free Software Foundation; with no
% Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
% A copy of the license is included in the section entitled
% \enquote{GNU Free Documentation License}.
% \end{quote}
% \bigskip
%
% If you have Invariant Sections, Front-Cover Texts and Back-Cover
% Texts, replace the \enquote{with \dots\ Texts.}\ line with this:
%
% \bigskip
% \begin{quote}
% with the Invariant Sections being LIST THEIR TITLES, with the
% Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
% \end{quote}
% \bigskip
%
% If you have Invariant Sections without Cover Texts, or some other
% combination of the three, merge those two alternatives to suit the
% situation.
%
% If your document contains nontrivial examples of program code, we
% recommend releasing these examples in parallel under your choice of
% free software license, such as the GNU General Public License,
% to permit their use in free software.
%
% \printbibliography[heading=bibintoc]
%
% \StopEventually{}
%
% \section{Implementation}
% \label{sec:implementation}
%
% \iffalse
%<*package>
% \fi
%
% \pkg{ekdosis} relies on Lua functions and tables. Read the
% |.lua| files that accompany \pkg{ekdosis} for more
% information.
% \begin{macrocode}
\RequirePackage{iftex}
% \end{macrocode}
% Of course, \pkg{ekdosis} requires {\LuaLaTeX}. Issue an error
% if the document is processed with another engine.
% \begin{macrocode}
\RequireLuaTeX
% \end{macrocode}
% Set global options:---
% \begin{macrocode}
\RequirePackage{expkv-opt}
\RequirePackage{expkv-def}
\newif\if@pkg@float
\newif\if@pkg@footins
\newif\if@pkg@ekddivs
\newif\if@parnotesroman
\newif\if@pkg@parnotes
\newif\iftei@export
\ekvdefinekeys{ekdosis}{
choice layout = {float = {\@pkg@floattrue},
footins = {\@pkg@footinstrue}},
initial layout = float,
unknown-choice layout = \PackageError{ekdosis}{unknown
layout=#1}{`layout' must be either `float' or `footins'.},
choice divs = {ekdosis = {\@pkg@ekddivstrue},
latex = {\@pkg@ekddivsfalse
\AtBeginDocument{\luadirect{ekdosis.setekddivsfalse()}}}},
initial divs = ekdosis,
unknown-choice divs = \PackageError{ekdosis}{unknown divs=#1}{`divs'
must be either `ekdosis' or `latex'.},
choice parnotes = {false = {},
true = {\@pkg@parnotestrue},
roman = {\@pkg@parnotestrue\@parnotesromantrue}},
default parnotes = true,
unknown-choice parnotes = \PackageError{ekdosis}{unknown
parnotes=#1}{`parnotes' must be either `true', or `false' or
`roman'.},
choice teiexport = {false = {},
true = {\tei@exporttrue
\AtBeginDocument{\luadirect{ekdosis.openteistream()}}%
\AtEndDocument{\luadirect{ekdosis.closeteistream()}}},
tidy = {\tei@exporttrue
\AtBeginDocument{\luadirect{ekdosis.openteistream()}}%
\AtEndDocument{\luadirect{ekdosis.closeteistream("tidy")}}}},
default teiexport = true,
unknown-choice teiexport = \PackageError{ekdosis}{unknown
teiexport=#1}{`teiexport' must be either `true', `false' or
`tidy'.}
}
\ekvoProcessLocalOptions{ekdosis}
% \end{macrocode}
% \paragraph{Required Packages} \label{ref:ekdrequirements} In
% addition to \pkg{iftex}, \pkg{expkv-opt} and \pkg{expkv-def}, a list
% of the packages that are required by \pkg{ekdosis} follows:---
% \begin{macrocode}
% \RequirePackage{iftex} % already loaded above
% \RequirePackage{expkv-opt} % already loaded above
% \RequirePackage{expkv-def} % already loaded above
\RequirePackage{luacode}
\RequirePackage{paracol}
\RequirePackage{xparse}
\RequirePackage{etoolbox}
\RequirePackage{lineno}
\RequirePackage{keyfloat}
\RequirePackage{refcount}
\RequirePackage[user,abspage]{zref}
\RequirePackage{ltxcmds}
\if@pkg@parnotes
\RequirePackage{parnotes}
\fi
% \end{macrocode}
% \paragraph{Lua} Here begins the real work: load |ekdosis.lua|:---
% \begin{macrocode}
\luadirect{dofile(kpse.find_file("ekdosis.lua"))}
% \end{macrocode}
% \begin{macrocode}
\AtEndDocument{
\luadirect{ekdosis.closestream()}
}
% \end{macrocode}
% Use |\normalfont| for line numbers:---
% \begin{macrocode}
\renewcommand\linenumberfont{\normalfont\footnotesize}
% \end{macrocode}
% \begin{macro}{\SetEkdosisHooks} \cs{SetEkdosisHooks} is used to set
% hooks meant to be shared by all declared apparatuses, such as the
% font size, the format of numerals, \emph{\&c.} This command can be
% used in the preamble or at any point of the document.
% \begin{macrocode}
\ekvdefinekeys{ekd@hooks}{
store appfontsize = \ekd@appfontsize,
store refnumstyle = \ekd@refnumstyle,
store postrefnum = \ekd@postrefnum,
initial appfontsize = \footnotesize,
initial refnumstyle = \bfseries,
initial postrefnum = ~
}
\NewDocumentCommand{\SetEkdosisHooks}{m}{\ekvset{ekd@hooks}{#1}}
% \end{macrocode}
% \end{macro}
% Build and process the list of witnesses and hands:---
% \begin{macrocode}
\ekvdefinekeys{ekd@witness}{
store settlement = \settlement@value,
store institution = \institution@value,
store repository = \repository@value,
store collection = \collection@value,
store idno = \idno@value,
store msName = \msName@value,
store origDate = \origDate@value
}
% \end{macrocode}
% \begin{macro}{\DeclareWitness} \cs{DeclareWitness} is a
% preamble-only command. It takes three mandatory arguments and one
% optional argument. It is meant to collect data related to
% witnesses to be used in the edition text. Data are stored in |Lua|
% tables and are used to encode the |<listWit>| part of the |TEI|
% header as well as the Conspectus Siglorum in the edition in print.
% \begin{macrocode}
\NewDocumentCommand{\DeclareWitness}{m m m O{}}{%
\bgroup
\ekvset{ekd@witness}{#4}
\luadirect{ekdosis.newwitness(
\luastringN{#1},
\luastringN{#2},
\luastringN{#3},
\luastringO{\settlement@value},
\luastringO{\institution@value},
\luastringO{\repository@value},
\luastringO{\collection@value},
\luastringO{\idno@value},
\luastringO{\msName@value},
\luastringO{\origDate@value})}
\egroup
}
\@onlypreamble\DeclareWitness
% \end{macrocode}
% \end{macro}
% \begin{macro}{\DeclareHand} As \cs{DeclareWitness}, \cs{DeclareHand}
% is a preamble-only command meant to collect data and store them in
% |Lua| tables. It takes three mandatory arguments and one optional
% argument. The second argument is used to connect the hand to a
% declared witness it is related to. Then the table in which this
% witness is recorded can be fed with new data.
% \begin{macrocode}
\NewDocumentCommand{\DeclareHand}{m m m +O{}}{
\luadirect{ekdosis.newhand(\luastringN{#1},
\luastringN{#2},
\luastringN{#3},
\luastringN{#4})}
}
\@onlypreamble\DeclareHand
% \end{macrocode}
% \end{macro}
% \begin{macro}{\DeclareScholar} There is also a table in which are
% collected data related to scholars' names to be used in the
% apparatus criticus. \cs{DeclareScholar} is a preamble-only command
% and takes two mandatory arguments: a unique id and a shorthand to
% be used in the apparatus criticus which can be extracted from a
% bibliographic database.
% \begin{macrocode}
\NewDocumentCommand{\DeclareScholar}{m m}{
\luadirect{ekdosis.newscholar(\luastringN{#1},
\luastringN{#2})}
}
\@onlypreamble\DeclareScholar
% \end{macrocode}
% \end{macro}
% \begin{macro}{\DeclareShorthand} \cs{DeclareShorthand} is a
% preamble-only command that can be used to record manuscript
% families or any kind of shorthand to be used to refer to
% previously declared ids, for example the shorthand |codd| can be
% used to point to all declared witnesses. This command takes three
% mandatory arguments: a unique id, its rendition in print and a
% csv-list of previously declared ids.
% \begin{macrocode}
\NewDocumentCommand{\DeclareShorthand}{m m m}{
\luadirect{ekdosis.newshorthand(\luastringN{#1},
\luastringN{#2},
\luastringN{#3})}
}
\@onlypreamble\DeclareShorthand
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\NewDocumentCommand{\getsiglum}{m}{%
\luadirect{tex.sprint(ekdosis.getsiglum(\luastringN{#1}))}%
}
\NewDocumentCommand{\SigLine}{m}{%
\luadirect{tex.sprint(ekdosis.basic_cs(\luastringN{#1}))}
}
% \end{macrocode}
% \paragraph{\TeX\ to \texttt{TEI xml}}
% The following three commands can be used to instruct \pkg{ekdosis}
% how to convert unknown or unusual \hologo{(La)TeX} commands into
% \texttt{TEI xml} equivalents.
% \begin{macro}{\TeXtoTEI}
% \cs{TeXtoTEI}\marg{csname}\marg{TEI element}\oarg{TEI attribute(s)}
% takes two mandatory arguments and one optional argument, namely: the
% control sequence name to be converted, the \texttt{TEI} element it
% is to be converted into and any additional \texttt{xml} attributes
% to be appended to the opening \texttt{TEI} element:---
% \begin{macrocode}
\NewDocumentCommand{\TeXtoTEI}{m m O{}}{%
\luadirect{ekdosis.newcmdtotag(\luastringN{#1},
\luastringN{#2},
\luastringN{#3})}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\EnvtoTEI}
% \begin{macro}{\EnvtoTEI*}
% \cs{EnvtoTEI}\meta{*}\marg{env name}\marg{TEI element}\oarg{TEI
% attribute(s)} instructs how to convert \LaTeX{} environments into
% \texttt{TEI xml} equivalents. It takes two mandatory arguments and
% one optional argument, namely the name of the \LaTeX{} environment
% to be converted, the \texttt{TEI} element it is to be converted into
% and any additional attributes to be appended to the \texttt{TEI}
% opening element. \cs{EnvtoTEI*} is restricted to \texttt{TEI}
% elements that must never appear within |<p>| elements, such as
% |<div>|, |<lg>| and the like.
% \begin{macrocode}
\NewDocumentCommand{\EnvtoTEI}{s m m O{}}{%
\IfBooleanTF{#1}{%
\luadirect{ekdosis.newenvtotag(\luastringN{#2},
\luastringN{#3},
\luastringN{#4},
"yes")}
}{%
\luadirect{ekdosis.newenvtotag(\luastringN{#2},
\luastringN{#3},
\luastringN{#4})}
}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\TeXtoTEIPatt}
% Finally, the more flexible\---and more delicate to
% handle\---\cs{TeXtoTEIPatt}\marg{\TeX\
% pattern}\allowbreak\marg{\texttt{TEI} pattern} uses pattern matching
% to instruct \pkg{ekdosis} how to convert \hologo{(La)TeX} commands
% into \texttt{TEI} equivalents.
% \begin{macrocode}
\NewDocumentCommand{\TeXtoTEIPatt}{m m}{%
\luadirect{ekdosis.newpatttotag(\luastringN{#1}, \luastringN{#2})}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\SetTEIFilename} \cs{SetTEIFilename}\marg{basename} is
% a preamble-only command. It is used to set the base name of the
% |TEI xml| output file, to which the suffix |.xml| is appended. By
% default, the base name is |\jobname-tei|:---
% \begin{macrocode}
\NewDocumentCommand{\SetTEIFileName}{m}{
\luadirect{ekdosis.setteifilename(\luastringN{#1})}
}
\@onlypreamble\SetTEIFileName
% \end{macrocode}
% \end{macro}
% \begin{macro}{\SetxmlBibResource} This is a preamble-only command.
% If a base name for a \texttt{TEI xml} compliant bibliographical
% database file is provided with
% \cs{SetxmlBibResource}\marg{basename}, \pkg{ekdosis} will use
% insert formatted data in the back matter section of its own
% \texttt{TEI xml} output file, as |<biblStruct>| elements within a
% |<listBibl>| section.
% \begin{macrocode}
\NewDocumentCommand{\SetxmlBibResource}{m}{
\luadirect{ekdosis.setxmlbibresource(\luastringN{#1})}
}
\@onlypreamble\SetxmlBibResource
% \end{macrocode}
% \end{macro}
%
%\paragraph{Multi-layer apparatuses}
% \pkg{ekdosis} must know is an entry is to be processed in a single-
% or multiple-layer context:---
% \begin{macrocode}
\newif\ifekd@mapps
% \end{macrocode}
% Now the key-value options can be defined:---
% \begin{macrocode}
\ekvdefinekeys{ekd@newapp}{
choice direction = {LR = \def\direction@val{LR},
RL = \def\direction@val{RL}},
unknown-choice direction = \PackageError{ekdosis}{unknown
direction=#1}{`direction' must be either `LR' or `RL'.},
store rule = \rule@val,
store delim = \delim@val,
store sep = \sep@val,
store bhook = \bhook@val,
store ehook = \ehook@val,
initial direction = LR,
initial ehook = {\csname ekd@end@apparatus\endcsname}
}
% \end{macrocode}
% \begin{macro}{\DeclareApparatus}
% \cs{DeclareApparatus}\marg{apparatus name}\oarg{options} is a
% preamble-only command. As a mandatory argument, it takes the name of
% the new layer of notes to be inserted in the apparatus block. Then,
% the following six key-value options can be used to lay out the
% layer: \verb+direction=LR|RL+, |rule|, |delim| (the delimiter between
% entries), |sep| (the separator between lemma part and readings or
% notes), |bhook| (\LaTeX{} code inserted as the layer begins),
% |ehook| (\LaTeX{} code inserted as the layer ends):---
% \begin{macrocode}
\NewDocumentCommand{\DeclareApparatus}{m O{}}{
\newbool{subsq@unit@#1}
\booltrue{subsq@unit@#1}
\unless\ifekd@mapps\global\ekd@mappstrue\fi
\bgroup
\ekvset{ekd@newapp}{#2}
\luadirect{ekdosis.newapparatus(
\luastringN{#1},
\luastring{\direction@val},
\luastringO{\rule@val},
\luastringO{\delim@val},
\luastringO{\sep@val},
\luastringO{\bhook@val},
\luastringO{\ehook@val}
)}
\egroup
}
\@onlypreamble\DeclareApparatus
% \end{macrocode}
% \end{macro}
% Apparatus-related settings and functions. Some booleans to check if
% an apparatus should be inserted and what is the current environment.
% \begin{macrocode}
\newbool{do@app}
\newif\ifekd@state
\newif\ifekd@isinapp
\newif\ifekd@isinlem
% \end{macrocode}
% The next boolean is shared with \pkg{arabluatex}. \cs{LRnum} is used
% internally to ensure that numerals referring to line spans are
% displayed in the right order.
% \begin{macrocode}
\providebool{al@rlmode}
\@ifpackageloaded{arabluatex}{}{%
\def\setRL{\booltrue{al@rlmode}\pardir TRT\textdir TRT}
\def\setLR{\boolfalse{al@rlmode}\pardir TLT \textdir TLT}
}
\protected\def\LRnum#1{\bgroup\textdir TLT#1\egroup}
% \end{macrocode}
% Set counter referring to line numbers and make it global.
% \begin{macrocode}
\newcounter{ekd@lab}
\globalcounter{ekd@lab}
% \end{macrocode}
% This command inserts words in the apparatus criticus without
% checking if both |ekd@isinapp| and |ekd@state| are set to |true|.
% \begin{macrocode}
\NewDocumentCommand{\unconditional@appin}{o m}{%
\IfNoValueTF{#1}
{\luadirect{ekdosis.appin(\luastringO{#2})}}
{\luadirect{ekdosis.appin(\luastringO{#2}, \luastringO{#1})}}%
}
% \end{macrocode}
% \begin{macro}{\blfootnote} \cs{blfootnote}\marg{footnote} is used
% internally to insert the apparatus in the footnote block should the
% global optional argument |layout| be set to |footins|. Therefore, it
% is not documented.
% \begin{macrocode}
% \def\blfootnote{\gdef\@thefnmark{\relax}\@footnotetext}
\def\blfootnote{\gdef\@thefnmark{}\@blfootnotetext}
\long\def\@blfootnotetext#1{\insert\footins{%
\reset@font\footnotesize
\interlinepenalty\interfootnotelinepenalty
\splittopskip\footnotesep
\splitmaxdepth \dp\strutbox \floatingpenalty \@MM
\hsize\columnwidth \@parboxrestore
\protected@edef\@currentlabel{%
\csname p@footnote\endcsname\@thefnmark
}%
\color@begingroup
\@makeblfntext{%
\rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
\color@endgroup}}%
\newcommand\@makeblfntext[1]{%
\parindent 1em%
\noindent
\hb@xt@0em{\hss\@makefnmark}#1}
% \end{macrocode}
% \end{macro}
% \paragraph{Single-layer apparatus} The following commands are for
% general settings. All of them can be used in the preamble or at any
% point of the document:---
% \begin{macro}{\SetLTRapp}
% \begin{macro}{\SetRTLapp}
% \cs{SetLTRapp} and \cs{SetRTLapp} are two argument-less commands to
% set the direction of single-layer apparatus criticus, either LTR or
% RTL:---
% \begin{macrocode}
\newif\ifrtl@app
\NewDocumentCommand{\SetRTLapp}{}{\rtl@apptrue}
\NewDocumentCommand{\SetLTRapp}{}{\rtl@appfalse}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\SetSeparator}
% \cs{SetSeparator}\marg{separator} allows to change the separator
% between lemma texts and variant readings, which is by default
% a closing square bracket followed by a space (\verb*+] +):---
% \begin{macrocode}
\edef\ekdsep{] }
\NewDocumentCommand{\SetSeparator}{m}{\edef\ekdsep{#1}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\SetEndApparatus}
% \cs{SetEndApparatus}\marg{characters} can be used to append
% characters at the end of the apparatus block\---such as a full stop,
% as it is customary in some editions. By default, nothing is
% appended:---
% \begin{macrocode}
\edef\ekd@end@apparatus{}
\NewDocumentCommand{\SetEndApparatus}{m}{\edef\ekd@end@apparatus{#1}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\SetUnitDelimiter}
% \cs{SetUnitDelimiter}\marg{delimiter} can be used to set the
% delimiter between entries in the apparatus criticus. By default,
% there is no delimiter except a simple space. \cs{SetUnitDelimiter}
% can be used to insert a broad space (with |\hskip| for instance, as
% in the OCT series) or the divider-sign (‖, as in the Budé series):---
% \begin{macrocode}
\def\ekd@unit@delim{}
\NewDocumentCommand{\SetUnitDelimiter}{m}{\def\ekd@unit@delim{#1}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\footnoteruletrue}
% \begin{macro}{\footnoterulefalse}
% As \pkg{ekdosis} takes care of drawing a rule separating the main
% text from the apparatus block as well as layers of notes from each
% other inside this block, it may not be desirable to have
% the standard \LaTeX{} \enquote{footnoterule} printed on every page
% of the edition text. \cs{footnoterulefalse} removes it while
% \cs{footnoteruletrue} leaves it untouched. The latter is set by
% default.
% \begin{macrocode}
\def\ekd@default@rule{\rule{2truein}{0.5pt}}
\newif\iffootnoterule
\footnoteruletrue
\let\dflt@footnoterule\footnoterule
\let\dflt@pcol@footnoterule\pcol@footnoterule
\renewcommand\footnoterule{%
\iffootnoterule
\dflt@footnoterule%
\fi
}
\renewcommand\pcol@footnoterule{%
\iffootnoterule
\dflt@pcol@footnoterule%
\fi
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\SetDefaultRule}
% By default, \pkg{ekdosis} draws separating rules the definition of
% which is |\rule{2truein}{0.5pt}|. This can be changed in the
% preamble or at any point of the document with
% \cs{SetDefaultRule}\marg{\allowbreak{}rule definition}. Leaving this
% argument empty as in \cs{SetDefaultRule}|{}| removes the rule.
% \begin{macrocode}
\NewDocumentCommand{\SetDefaultRule}{m}{%
\def\@tempa{#1}
\ifx\@tempa\empty\def\ekd@default@rule{\mbox{}}%
\else%
\def\ekd@default@rule{#1}%
\fi}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\NLS}
% \cs{NLS} is adapted from a snippet written by Heiko Oberdiek. It is
% used by \pkg{ekdosis} internally to prevent page breaks between
% separating rules and subsequent notes. Therefore, it is not
% documented.
% \begin{macrocode}
\newcommand*{\NLS}{%
\par%
\nobreak%
\vspace{-\parskip}%
\noindent%
\ignorespaces}
% \end{macrocode}
% \end{macro}
% This boolean is used to test if a given entry is to be preceded by a
% numeral referring to the line of the edition text.
% \begin{macrocode}
\newif\ifsubsq@unit
\subsq@unittrue
% \end{macrocode}
% \cs{add@@apparatus} inserts the apparatus block on a given page
% either in the footnote floating block or in a float of its own,
% depending on the value set in the |layout| global option.
% \begin{macrocode}
\def\add@@apparatus{%
\if@pkg@parnotes\parnotes\else\fi%
\if@pkg@footins%
\bgroup%
\ifrtl@app\setRL\else\setLR\fi%
\blfootnote{%
\if@pkg@parnotes%
\if@parnotesroman%
\renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi%
\parnoteclear\else\fi%
\footnotesize\apparatus\unless\ifekd@mapps\ekd@end@apparatus\fi%
\if@pkg@parnotes\parnotes\parnotereset\else\fi%
}%
\egroup%
\fi%
\if@pkg@float%
\keyparbox[!b]{}{\ifrtl@app\setRL\else\setLR\fi%
\if@pkg@parnotes%
\if@parnotesroman%
\renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi%
\parnoteclear\else\fi%
\ekd@appfontsize\apparatus\unless\ifekd@mapps\ekd@end@apparatus\fi%
\if@pkg@parnotes\parnotes\parnotereset\else\fi%
}%
\fi%
}
% \end{macrocode}
% Before inserting any new entry, \cs{add@apparatus} is called
% \cs{test@apparatus} to decide whether a new apparatus block must be
% created on a given page.
% \begin{macrocode}
\def\add@apparatus{%
\test@apparatus%
\ifbool{do@app}{\subsq@unitfalse\add@@apparatus}{}%
}
% \end{macrocode}
% \cs{append@app} inserts a bare (sub)entry in the apparatus...
% \begin{macrocode}
\NewDocumentCommand{\append@app}{o +m}{%
\ifekd@isinapp%
\ifekd@state%
\IfNoValueTF{#1}%
{\luadirect{ekdosis.appin(\luastringO{#2})}}%
{\luadirect{ekdosis.appin(\luastringO{#2}, \luastringO{#1})}}%
\fi%
\fi}
% \end{macrocode}
% while \cs{append@ln@app} inserts a (sub)entry possibly preceded by a
% line number.
% \begin{macrocode}
\NewDocumentCommand{\append@ln@app}{o +m}{%
\IfNoValueTF{#1}
{\luadirect{tex.sprint(ekdosis.mdvappend(\luastringO{#2}))}}
{\luadirect{tex.sprint(ekdosis.mdvappend(\luastringO{#2},
\luastringO{#1}))}}}
% \end{macrocode}
% \begin{macro}{\EkdosisDefaultApparatus}
% By default, \pkg{ekdosis} defines one layer of critical notes which
% is called |default|. This name can be changed at any point of the
% document with \cs{EkdosisDefaultApparatus}\marg{name}.
% \begin{macrocode}
\ekvdefinekeys{appnote}{
store type = \ekdan@type,
initial type = default
}
\NewDocumentCommand{\EkdosisDefaultApparatus}{m}{%
\ekvset{appnote}{type=#1}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\app}
% \cs{app}|[type=|\meta{type}|]|\marg{apparatus entries} takes one
% mandatory argument and accepts one optional argument. |type=| refers
% to the layer the note must go into and \meta{apparatus entries}
% contains command used to insert the entries, either \cs{lem},
% \cs{rdg} or \cs{note}\meta{*}:---
% \begin{macrocode}
\NewDocumentCommand{\app}{O{} > { \TrimSpaces } +m}{%
\begingroup
\ekvset{appnote}{#1}%
\ekd@isinapptrue%
\stepcounter{ekd@lab}%
\zlabel{ekd:\theekd@lab}%
\luadirect{ekdosis.storeabspg(
\luastring{\zref@extract{ekd:\theekd@lab}{abspage}})}%
\ifekd@state\add@apparatus\fi%
\luadirect{tex.sprint(ekdosis.removesp(\luastringN{#2}))}%
\ekd@isinappfalse%
\endgroup}
% \end{macrocode}
% \end{macro}
% \cs{current@ref@arg} is used outside \cs{app} by \cs{note}. It takes
% two mandatory arguments: the beginning line label and the ending
% line label\---which are manually inserted---and returns the formatted
% reference to be inserted in the apparatus criticus.
% \begin{macrocode}
\def\current@ref@arg#1#2{{%\textdir TLT%
\unexpanded\expandafter{\ekd@refnumstyle}%
\ifnum%
\getpagerefnumber{#1}
=
\getpagerefnumber{#2}
\ifnum%
\getrefnumber{#1}
=
\getrefnumber{#2}
%
\ifekd@mapps%
\ifbool{subsq@unit@\ekdan@type}{%
\ifnum%
\getrefnumber{#1}
=
\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevnotelab())}}
\else
\LRnum{\getrefnumber{#1}}% issue the no
\fi%
}%
{\LRnum{\getrefnumber{#1}}}% issue the no
\else
\ifsubsq@unit%
%
\ifnum%
\getrefnumber{#1}
=
\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevnotelab())}}
\else
\LRnum{\getrefnumber{#1}}% issue the no
\fi
%
\else
\LRnum{\getrefnumber{#1}}% issue the no
\fi
\fi
%
\else
\LRnum{\getrefnumber{#1}}--%
\LRnum{\getrefnumber{#2}}% issue the nos
\fi%
\else
\LRnum{\getrefnumber{#1}}--%
\LRnum{\getpagerefnumber{#2}}.%
\LRnum{\getrefnumber{#2}}% issue pg and ln nos
\fi%
}\unexpanded\expandafter{\ekd@postrefnum}%
}
% \end{macrocode}
% \cs{current@ref} is pretty much the same as \cs{current@reg@arg},
% but takes no argument. It is used by commands such as \cs{lem} when
% references to page and line numbers can be returned by \textsf{Lua}.
% \begin{macrocode}
\def\current@ref{{%\textdir TLT%
\unexpanded\expandafter{\ekd@refnumstyle}%
\ifnum%
\getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}
=
\getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}
\ifnum%
\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}
=
\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}
%
\ifekd@mapps%
\ifbool{subsq@unit@\ekdan@type}{%
\ifnum%
\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}
=
\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-b}
\else
\LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% issue the no
\fi%
}{\LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}}% issue the no
\else
\ifsubsq@unit%
%
\ifnum%
\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}
=
\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-b}
\else
\LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% issue the no
\fi
%
\else
\LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% issue the no
\fi
\fi
%
\else
\LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--%
\LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}% issue the nos
\fi%
\else
\LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--%
\LRnum{\getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}.%
\LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}% issue pg and ln nos
\fi%
}\unexpanded\expandafter{\ekd@postrefnum}%
}
% \end{macrocode}
% Define keys to be used by the optional arguments of \cs{lem} and
% \cs{rdg}:---
% \begin{macrocode}
\ekvdefinekeys{lem}{
code wit = \def\ekdlr@wit{#1},
code alt = \def\ekdlr@alt{#1},
code pre = \def\ekdlr@pre{#1},
code post = \def\ekdlr@post{#1},
code prewit = \def\ekdlr@prewit{#1},
code postwit = \def\ekdlr@postwit{#1},
store type = \ekdlr@type,
store sep = \ekdl@sep,
bool nolem = \ifekdl@nolem,
bool nosep = \ifekdl@nosep,
initial sep = \ekdsep
}
\ekvdefinekeys{rdg}{
code wit = \def\ekdlr@wit{#1},
code alt = \def\ekdlr@alt{#1},
code pre = \def\ekdlr@pre{#1},
code post = \def\ekdlr@post{#1},
code prewit = \def\ekdlr@prewit{#1},
code postwit = \def\ekdlr@postwit{#1},
store type = \ekdlr@type,
bool nordg = \ifekdr@nordg
}
% \end{macrocode}
% \begin{macro}{\lem}
% \cs{lem}\oarg{options}\marg{lemma text} inserts \meta{lemma text}
% both in the edition text and in the apparatus criticus by default,
% preceded by the reference to the line number or a space if it is the
% same number as the one of the previous entry. This command accepts
% the optional key-value arguments just defined above.
% \begin{macrocode}
\NewDocumentCommand{\lem}{O{} m}{%
\ekd@isinlemtrue%
\luadirect{ekdosis.dolnlab(\luastringN{#2})}%
\bgroup%
\ekvset{lem}{#1}%
\ifekd@mapps%
\ifnum%
\luadirect{tex.sprint(ekdosis.get_bagunits(\luastringO{\ekdan@type}))}
= 1
\boolfalse{subsq@unit@\ekdan@type}%
\fi%
\luadirect{ekdosis.increment_bagunits(\luastringO{\ekdan@type})}%
\def\ekd@munit@delim{%
\luadirect{tex.sprint(ekdosis.getappdelim(\luastringO{\ekdan@type}))}}%
\fi%
\ifekdl@nolem\edef\lem@app{%
% \hskip .75em
\ifekd@mapps
\ifbool{subsq@unit@\ekdan@type}%
{\ekd@munit@delim}{}%
\else%
\ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi%
\fi%
\current@ref}%\hskip .25em}%
\else%
\ifbool{al@rlmode}{%
\edef\lem@app{%
% \hskip .75em
\ifekd@mapps
\ifbool{subsq@unit@\ekdan@type}%
{\ekd@munit@delim}{}%
\else%
\ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi%
\fi%
\current@ref%\hskip .25em
\ifdefined\ekdlr@alt%
\ifdefined\ekdlr@post%
\space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
{\textdir TRT\unexpanded\expandafter{\ekdlr@alt}}%
\ifdefined\ekdlr@pre%
\space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
\else
\ifdefined\ekdlr@post%
\space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
{\textdir TRT\unexpanded{#2}}%
\ifdefined\ekdlr@pre%
\space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
\fi
\ifdefined\ekdlr@postwit%
\space\unexpanded\expandafter{\ekdlr@postwit}\else\fi
\ifdefined\ekdlr@wit\space\getsiglum{\ekdlr@wit}\else\fi
\ifdefined\ekdlr@prewit%
\space\unexpanded\expandafter{\ekdlr@prewit}\space\else\fi
\ifekdl@nosep\else\unexpanded\expandafter{\ekdl@sep}\fi
}%
}%
{%
\edef\lem@app{%
% \hskip .75em
\ifekd@mapps
\ifbool{subsq@unit@\ekdan@type}%
{\ekd@munit@delim}{}%
\else%
\ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi%
\fi%
\current@ref%\hskip .25em
\ifdefined\ekdlr@alt%
\ifdefined\ekdlr@pre%
\space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
\ltx@ifpackageloaded{babel}%
{\noexpand\selectlanguage{\languagename}%
\unexpanded\expandafter{\ekdlr@alt}}%
{\unexpanded\expandafter{\ekdlr@alt}}%
\ifdefined\ekdlr@post%
\space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
\else
\ifdefined\ekdlr@pre%
\space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
\ltx@ifpackageloaded{babel}%
{\noexpand\selectlanguage{\languagename}\unexpanded{#2}}{%
\unexpanded{#2}}%
\ifdefined\ekdlr@post%
\space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
\fi
\ifdefined\ekdlr@prewit%
\space\unexpanded\expandafter{\ekdlr@prewit}\space\else\fi
\ifdefined\ekdlr@wit\space\getsiglum{\ekdlr@wit}\else\fi
\ifdefined\ekdlr@postwit%
\space\unexpanded\expandafter{\ekdlr@postwit}\else\fi
\ifekdl@nosep\else\unexpanded\expandafter{\ekdl@sep}\fi
}%
}%
\fi%
\ifekd@mapps%
\append@ln@app[\ekdan@type]{\lem@app}%
\else%
\append@ln@app{\lem@app}%
\fi%
\egroup%
\ekd@isinlemfalse%
\subsq@unittrue%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\rdg}
% \cs{rdg}\oarg{options}\marg{variant reading} inserts \meta{variant
% reading} in the second part of the entry, after the lemma text and
% the separator, in the apparatus criticus. This command accepts the
% optional key-value arguments defined above.
% \begin{macrocode}
\NewDocumentCommand{\rdg}{O{} m}{%
\bgroup%
\ekvset{rdg}{#1}%
% \ifekdr@nordg\append@app{}\else% do we need \append@app{} here? If
% % so, keep in mind \ifekd@mapps,
% like so:
\ifekdr@nordg%
\ifekd@mapps%
\append@app[\ekdan@type]{}%
\else%
\append@app{}%
\fi%
\else%
\ifbool{al@rlmode}{%
\edef\rdg@app{%
\ifdefined\ekdlr@alt%
\ifdefined\ekdlr@post%
\space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
{\textdir TRT\unexpanded\expandafter{\ekdlr@alt}}%
\ifdefined\ekdlr@pre%
\space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
\else
\ifdefined\ekdlr@post%
\space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
{\textdir TRT\unexpanded{#2}}%
\ifdefined\ekdlr@pre%
\space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
\fi
\ifdefined\ekdlr@postwit%
\space\unexpanded\expandafter{\ekdlr@postwit}\else\fi
\ifdefined\ekdlr@wit\space\getsiglum{\ekdlr@wit}\else\fi
\ifdefined\ekdlr@prewit%
\space\unexpanded\expandafter{\ekdlr@prewit}\space\else\fi
}%
}%
{%
\edef\rdg@app{%
\ifdefined\ekdlr@alt%
\ifdefined\ekdlr@pre%
\space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
\ltx@ifpackageloaded{babel}%
{\noexpand\selectlanguage{\languagename}%
\unexpanded\expandafter{\ekdlr@alt}}%
{\unexpanded\expandafter{\ekdlr@alt}}%
\ifdefined\ekdlr@post%
\space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
\else
\ifdefined\ekdlr@pre%
\space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
\ltx@ifpackageloaded{babel}%
{\noexpand\selectlanguage{\languagename}\unexpanded{#2}}{%
\unexpanded{#2}}%
\ifdefined\ekdlr@post%
\space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
\fi
\ifdefined\ekdlr@prewit%
\space\unexpanded\expandafter{\ekdlr@prewit}\space\else\fi
\ifdefined\ekdlr@wit\space\getsiglum{\ekdlr@wit}\else\fi
\ifdefined\ekdlr@postwit%
\space\unexpanded\expandafter{\ekdlr@postwit}\else\fi
}%
}%
\ifekd@mapps%
\append@app[\ekdan@type]{\rdg@app}%
\else%
\append@app{\rdg@app}%
\fi%
\fi%
\egroup%
}
% \end{macrocode}
% \end{macro}
% Define keys to be used by the optional argument of \cs{note} when
% this command is found outside \cs{app}:---
% \begin{macrocode}
\ekvdefinekeys{note}{
store type = \ekdan@type,
store lem = \ekdn@lem,
code labelb = \def\ekdn@labelb{#1},
code labele = \def\ekdn@labele{#1},
store sep = \ekdn@sep,
initial type = default,
initial sep = \ekdsep
}
% \end{macrocode}
% \cs{note@noapp} is used internally when a \cs{note} command is found
% outside \cs{app}. This command is mostly used to insert short
% comments or references to texts quoted or cited in the edition text
% to go into additional layers of the apparatus criticus, e.g.\ the
% \emph{apparatus testium}. It accepts the optional key-value
% arguments just defined above. It must be noted that |labelb| must be
% specified; otherwise \pkg{ekdosis} will issue an error message.
% \begin{macrocode}
\NewDocumentCommand{\note@noapp}{O{} +m}{%
\bgroup%
\ekvset{note}{#1}%
\stepcounter{ekd@lab}%
\zlabel{ekd:\theekd@lab}%
\luadirect{ekdosis.storeabspg(
\luastring{\zref@extract{ekd:\theekd@lab}{abspage}})}%
\ifekd@state\add@apparatus\fi%
\ifekd@mapps%
\ifnum%
\luadirect{tex.sprint(ekdosis.get_bagunits(\luastringO{\ekdan@type}))}
= 1
\boolfalse{subsq@unit@\ekdan@type}%
\fi%
\luadirect{ekdosis.increment_bagunits(\luastringO{\ekdan@type})}%
\def\ekd@munit@delim{%
\luadirect{tex.sprint(ekdosis.getappdelim(\luastringO{\ekdan@type}))}}%
\fi%
\ifdefined\ekdn@labelb%
\luadirect{tex.sprint(ekdosis.setnotelab(\luastringO{\ekdn@labelb}))}%
\ifdefined\ekdn@labele\else\def\ekdn@labele{\ekdn@labelb}\fi%
\else\PackageError{ekdosis}{missing labelb}{`labelb' must be
set.}\fi%
\ifbool{al@rlmode}%
{\edef\note@contents{%
% \hskip .75em
\ifekd@mapps
\ifbool{subsq@unit@\ekdan@type}%
{\ekd@munit@delim}{}%
\else%
\ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi%
\fi%
\current@ref@arg{\ekdn@labelb}{\ekdn@labele}%\hskip .25em
\ifdefined\ekdn@lem%
{\textdir TRT\unexpanded\expandafter{\ekdn@lem}}%
\unexpanded\expandafter{\ekdn@sep}\else\fi%
{\textdir TRT\unexpanded{#2}}}}%
{\edef\note@contents{%
% \hskip .75em
\ifekd@mapps
\ifbool{subsq@unit@\ekdan@type}%
{\ekd@munit@delim}{}%
\else%
\ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi%
\fi%
\current@ref@arg{\ekdn@labelb}{\ekdn@labele}%\hskip .25em
\ifdefined\ekdn@lem
\ltx@ifpackageloaded{babel}%
{\noexpand\selectlanguage{\languagename}%
\unexpanded\expandafter{\ekdn@lem}}%
{\unexpanded\expandafter{\ekdn@lem}}%
\unexpanded\expandafter{\ekdn@sep}\else\fi%
\ltx@ifpackageloaded{babel}%
{\noexpand\selectlanguage{\languagename}\unexpanded{#2}}{%
\unexpanded{#2}}}}%
\ifekd@mapps%
\unconditional@appin[\ekdan@type]{\note@contents}%
\else%
\unconditional@appin{\note@contents}%
\fi%
\luadirect{ekdosis.setprevnotelab(\luastringO{\ekdn@labelb})}%
\egroup%
\subsq@unittrue%
}
% \end{macrocode}
% Define keys to be used by the optional argument of \cs{note} when
% this command is found inside \cs{app}:---
% \begin{macrocode}
\ekvdefinekeys{ekd@note}{
store pre = \pre@value,
store post = \post@value
}
% \end{macrocode}
% The following three commands, \cs{note@app}, \cs{ekd@note} and
% \cs{ekd@note@star} are used internally when a \cs{note} command is
% found inside \cs{app}. These commands are used to insert short
% comments after the lemma text or after any variant reading in the
% apparatus criticus. \cs{note@app} and subsequently \cs{ekd@note} and
% \cs{ekd@note@star} accept the optional key-value arguments just
% defined above.
% \begin{macrocode}
\NewDocumentCommand{\ekd@note}{O{} m}{%
\bgroup%
\ekvset{ekd@note}{#1}%
\edef\note@contents{%
\ekvifdefinedNoVal{note}{pre}{}{%
\unexpanded\expandafter{\pre@value}}%
\unexpanded{#2}%
\ekvifdefinedNoVal{note}{post}{}{%
\unexpanded\expandafter{\post@value}}%
}%
\append@app{\note@contents}%
\egroup%
}
\NewDocumentCommand{\ekd@note@star}{O{} m}{%
\if@pkg@parnotes
\bgroup%
\ekvset{ekd@note}{#1}%
\edef\note@contents{%
\ekvifdefinedNoVal{note}{pre}{}{%
\unexpanded\expandafter{\pre@value}}%
\unskip\noexpand\parnote{#2}%
\ekvifdefinedNoVal{note}{post}{}{%
\unexpanded\expandafter{\post@value}}%
}%
\append@app{\note@contents}%
\egroup%
\else
\append@app{\unskip\footnote{#2}}%
\fi%
}
\NewDocumentCommand{\note@app}{s O{} +m}{%
\ifbool{al@rlmode}{%
\IfBooleanTF{#1}{\ekd@note@star[#2]{%
{\textdir TRT#3}}}
{\ekd@note[#2]{{\textdir TRT#3}}}%
}{%
\IfBooleanTF{#1}{\ekd@note@star[#2]{#3}}
{\ekd@note[#2]{#3}}%
}%
}
% \end{macrocode}
% \begin{macro}{\note}
% Finally, \cs{note} is a simple command designed to check whether
% \cs{note} itself is called inside or outside \cs{app}. Then, unless
% it is found inside \cs{lem}, it calls \cs{note@app} in the former
% case and \cs{note@noapp} in the latter case:---
% \begin{macrocode}
\NewDocumentCommand{\note}{s O{} +m}{%
\ifekd@state%
\ifekd@isinapp%
\ifekd@isinlem%
\note@noapp[#2]{#3}%
\else%
\IfBooleanTF{#1}{\note@app*[#2]{#3}}{\note@app[#2]{#3}}%
\fi%
\else%
\note@noapp[#2]{#3}%
\fi%
\fi%
}
% \end{macrocode}
% \end{macro}
% \cs{apparatus} is used internally by \pkg{ekdosis} to print the
% apparatus at the bottom of pages. Therefore, it is not documented,
% but this may change in the future for it will be possible to have
% apparatuses printed at other places.
% \begin{macrocode}
\NewDocumentCommand{\apparatus}{}{%
\luadirect{tex.sprint(ekdosis.appout())}}
% \end{macrocode}
% The following two commands call \textsf{Lua} functions to check
% whether an apparatus should be printed on a given page and to store
% the current column id.
% \begin{macrocode}
\NewDocumentCommand{\test@apparatus}{}{%
\luadirect{tex.sprint(ekdosis.testapparatus())}}
\NewDocumentCommand{\ekd@storecol}{}{%
\luadirect{ekdosis.storecurcol(\luastring{\thecolumn})}%
}
% \end{macrocode}
% Start and stop |ekdosis|:
% \begin{macrocode}
\NewDocumentCommand{\EkdosisOn}{}{%
\ekd@statetrue}
\NewDocumentCommand{\EkdosisOff}{}{%
\ekd@statefalse%
}
% \end{macrocode}
% Neutralize unwanted commands provided by \pkg{lineno} within the
% \env{ekdosis} environment:---
% \begin{macrocode}
\def\ekd@setlineno{%
\let\setpagewiselinenumbers\relax%
\let\pagewiselinenumbers\relax%
\let\endpagewiselinenumbers\relax%
\let\runningpagewiselinenumbers\relax%
\let\realpagewiselinenumbers\relax%
}
% \end{macrocode}
% \begin{environment}{ekdosis}
% Finally comes the \env{ekdosis} environment meant to receive the
% edition text equipped with an apparatus criticus. This environment
% collects its contents and delivers it to \textsf{Lua} functions if a
% \texttt{TEI xml} output file be desired.
% \begin{macrocode}
\NewDocumentEnvironment{ekdosis}{+b}{%
\ekd@setlineno%
\runninglinenumbers
\EkdosisOn#1}{%
\EkdosisOff
\endrunninglinenumbers%
\iftei@export
\luadirect{ekdosis.exporttei(\luastringN{\par #1\par })}\fi}
% \end{macrocode}
% \end{environment}
% \paragraph{Alignment} What follows isto arrange texts in parallel
% columns either on single pages or on facing pages.
%
% Define keys to be used by the \env{alignment} environment:---
% \begin{macrocode}
\newif\ifekd@pagelineation
\ekvdefinekeys{ekd@align}{
store tcols = \tcols@num,
store lcols = \lcols@num,
store texts = \texts@value,
store apparatus = \apparatus@value,
bool paired = \ifekd@paired,
choice lineation = {page = \ekd@pagelineationtrue,
document = \ekd@pagelineationfalse},
unknown-choice lineation = \PackageError{ekdosis}{unknown
lineation=#1}{`lineation' must be either `page' or `document'.},
choice segmentation = {auto = \def\segmentation@val{auto},
noauto = \def\segmentation@val{noauto}},
unknown-choice segmentation = \PackageError{ekdosis}{unknown
segmentation=#1}{`segmentation' must be either `auto' or
`noauto'.},
bool flush = \ifekd@flushapp,
initial tcols = 2,
initial lcols = 1,
initial texts = edition;translation,
initial apparatus = edition,
default segmentation = auto
}
% \end{macrocode}
% \begin{macro}{\SetEkdosisAlignment}
% \cs{SetEkdosisAlignment}\marg{settings} can be used either in the
% preamble or at any point of the document to set or modify the
% keys-value settings just defined above.
% \begin{macrocode}
\NewDocumentCommand{\SetEkdosisAlignment}{m}{
\ekvset{ekd@align}{#1}
}
% \end{macrocode}
% \end{macro}
% Patch \pkg{paracol} to insert a hook in \cs{pcol@nextpage}. This
% hook is used to reset line numbers on new pages.
% \begin{macrocode}
\patchcmd{\pcol@nextpage}{%
\endgroup}{%
\ifekd@pagelineation\resetlinenumber\fi
\endgroup}{}{}
% \end{macrocode}
% \cs{EkdosisColStart} and \cs{EkdosisColStop} initialize columns
% meant to receive edition texts. These commands are used internally
% by \pkg{ekdosis}.
% \begin{macrocode}
\NewDocumentCommand{\EkdosisColStart}{}{%
\ekd@setlineno%
\runninglinenumbers
\ekd@storecol%
\stepcounter{ekd@lab}%
\zlabel{ekd:\theekd@lab}%
\luadirect{%
ekdosis.storeabspg(\luastring{\zref@extract{ekd:\theekd@lab}{abspage}},
"pg_i")}%
\ifekd@pagelineation
\luadirect{tex.sprint(ekdosis.checkresetlineno())}
\fi
}
\NewDocumentCommand{\EkdosisColStop}{}{%
\stepcounter{ekd@lab}%
\zlabel{ekd:\theekd@lab}%
\luadirect{%
ekdosis.storeabspg(\luastring{\zref@extract{ekd:\theekd@lab}{abspage}},
"pg_ii")}%
\endrunninglinenumbers%
}
% \end{macrocode}
% \begin{environment}{alignment}
% \cs{begin}|{alignment}|\oarg{options}\dots\cs{end}|{alignment}| can
% be used as it is provided to typeset a standard critical edition
% text on the left-hand pages accompanied with a translation on the
% right-hand pages. To that effect, it provides by default two new
% environments, \env{edition} and \env{translation}, to be used to
% typeset both texts. (Either whole texts or texts entered by
% paragraphs alternately.) The optional argument of \env{aligment}
% accepts the exact same key-value options as \cs{SetEkdosisAlignment}
% described above. One may contrast these options with those accepted
% by \cs{SetEkdosisAlignment} as \enquote{local settings}.
% \begin{macrocode}
\NewDocumentEnvironment{alignment}{O{}}
{%
\ekvset{ekd@align}{#1}%
\luadirect{ekdosis.mkenvdata(
\luastring{\texts@value},
"texts"
)}
\ifekd@flushapp
\luadirect{ekdosis.newalignment("set")}
\fi
\luadirect{ekdosis.mkenvdata(
\luastring{\apparatus@value}, "apparatus"
)}
\setrunninglinenumbers
\luadirect{tex.sprint(ekdosis.mkenv())}
\ifekd@paired
\begin{paracol}[\lcols@num]{\tcols@num}
\else
\begin{paracol}[\lcols@num]*{\tcols@num}
\fi
}
{\end{paracol}
\iftei@export\luadirect{ekdosis.export_coldata_totei()}\fi
\ifekd@flushapp
\luadirect{ekdosis.newalignment("reset")}
\fi
\luadirect{ekdosis.flushenvdata()}
\luadirect{ekdosis.flushcolnums()}
}
% \end{macrocode}
% \end{environment}
% \paragraph{Divisions of the Body}
% \pkg{ekdosis} can convert \cs{book}, \cs{part}, \cs{chapter},
% \cs{section}, \cs{subsec{\allowbreak}tion} and \cs{subsubsection}
% into corresponding \texttt{TEI} \enquote*{numbered}
% |<div|\textsubscript{\emph{n}}|>| elements, where $1\leq n\leq 6$.
% \begin{macro}{\MkBodyDivs}
% \cs{MkBodyDivs} is used to let \pkg{ekdosis} know which sectional
% commands are actually being used in an edition text. This command
% takes six mandatory arguments. For example, if \cs{section} and
% \cs{subsection} are the only sectional commands being used,
% |\MkBodyDivs{section}{subsection}{}{}{}{}| will have \cs{section}
% and \cs{subsection} converted into |<div1>| and |<div2>|
% respectively.
% \begin{macrocode}
\NewDocumentCommand{\MkBodyDivs}{mmmmmm}{
\luadirect{ekdosis.mkdivdepths(
\luastringN{#1},
\luastringN{#2},
\luastringN{#3},
\luastringN{#4},
\luastringN{#5},
\luastringN{#6}
)
}
}
% \end{macrocode}
% \end{macro}
% Divisions specific to \pkg{ekdosis}. Define keys to be used by
% \cs{ekddiv}:---
% \begin{macrocode}
\ekvdefinekeys{ekd@div}{
code type = \def\type@value{#1},
code n = \def\n@value{#1},
code head = \def\head@value{#1},
code barehead = \def\barehead@value{#1},
store depth = \depth@value,
choice toc = {book = \def\toc@value{book},
part = \def\toc@value{part},
chapter = \def\toc@value{chapter},
section = \def\toc@value{section},
subsection = \def\toc@value{subsection},
subsubsection = \def\toc@value{subsubsection},
paragraph = \def\toc@value{paragraph},
subparagraph = \def\toc@value{subparagraph}},
unknown-choice toc = \PackageError{ekdosis}{unknown toc=#1}{`toc'
must be either `book', `part', `chapter', `section', `subsection',
\MessageBreak `subsubsection', `paragraph' or `subparagraph'.},
initial depth = 1
}
% \end{macrocode}
% \begin{macro}{\ekdfmtdiv}
% \cs{ekdfmtdiv}\marg{n}\marg{code before}\marg{code after} is
% used to lay out the heading of the title. It takes three mandatory
% arguments: \emph{n}, namely the number referring to the particular
% depth of the division, and then some \LaTeX{} formatting commands
% to go before and after the heading itself:---
% \begin{macrocode}
\NewDocumentCommand{\ekdfmtdiv}{m m m}{
\luadirect{ekdosis.fmtdiv(\luastring{#1},
\luastringN{#2},
\luastringN{#3})}
}
% \end{macrocode}
% \end{macro}
% \cs{ekd@getfmtdiv} gets the formatting commands that have been
% stored by \cs{ekdfmtdiv}.
% \begin{macrocode}
\NewDocumentCommand{\ekd@getfmtdiv}{m m}{%
\luadirect{tex.sprint(ekdosis.getfmtdiv(\luastringO{#1},
\luastringN{#2}))}%
}
% \end{macrocode}
% \begin{macro}{\ekddiv}
% \cs{ekddiv}\marg{key-value arguments} is the standard command
% provided by \pkg{ekdosis} to meet the requirements of classical and
% literary texts the divisions of which depend on many different
% received traditions. It takes one optional argument in which the
% key-value arguments defined above are accepted, and converts the
% divisions into \texttt{TEI} \enquote*{un-numbered} |<div>|
% elements.
% \begin{macrocode}
\NewDocumentCommand{\ekddiv}{m}{
\begingroup
\ekvset{ekd@div}{#1}%
\ifdefined\head@value
\bgroup
\ekd@getfmtdiv{\depth@value}{b}%
\head@value
\ekd@getfmtdiv{\depth@value}{e}%
\egroup
\ifdefined\toc@value
\ltx@ifpackageloaded{hyperref}{\phantomsection}{}%
\ifdefined\barehead@value
\addcontentsline{toc}{\toc@value}{\barehead@value}%
\else
\addcontentsline{toc}{\toc@value}{\head@value}%
\fi
\fi
\fi
\endgroup
}
% \end{macrocode}
% \end{macro}
% A very basic and provisional implementation of poetry lines
% follows:---
% \begin{macrocode}
\newlength{\ekdverseindentlength}
\setlength{\ekdverseindentlength}{\parindent}
\newenvironment*{ekdverse}[1][\ekdverseindentlength]{
\begin{list}{}{%
\setlength{\leftmargin}{#1}
\setlength{\itemsep}{0pt}
\setlength{\topsep}{0pt}
\setlength{\partopsep}{0pt}
}
\item[]
}{\end{list}}
% \end{macrocode}
%
% \iffalse
%</package>
% \fi
%
% \Finale
% \iffalse
%<*lua>
% \fi
% \begin{comment}
% \begin{ekdlua}
-- `'
-- This table will hold the functions:
ekdosis = {}
-- lpeg equivalent for string.gsub()
local function gsub(s, patt, repl)
patt = lpeg.P(patt)
patt = lpeg.Cs((patt / repl + 1)^0)
return lpeg.match(patt, s)
end
-- some basic patterns:
local letters = lpeg.R("az", "AZ")
local ascii = lpeg.R("az", "AZ", "@@")
local dblbkslash = lpeg.Cs("\\")
local bsqbrackets = lpeg.Cs{ "[" * ((1 - lpeg.S"[]") + lpeg.V(1))^0 * "]" }
local bcbraces = lpeg.Cs{ "{" * ((1 - lpeg.S"{}") + lpeg.V(1))^0 * "}" }
local spce = lpeg.Cs(" ")
local spcenc = lpeg.P(" ")
local cmdstar = lpeg.Cs(spce * lpeg.P("*"))
local bsqbracketsii = lpeg.Cs(bsqbrackets^-2)
local bcbracesii = lpeg.Cs(bcbraces^-2)
local cmd = lpeg.Cs(dblbkslash * ascii^1 * cmdstar^-1)
local rawcmd = lpeg.Cs(dblbkslash * ascii^1)
local aftercmd = lpeg.Cs(lpeg.S("*[{,.?;:'`\"") + dblbkslash)
local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1)
local app = lpeg.Cs("app")
local lemrdg = lpeg.Cs(lpeg.Cs("lem") + lpeg.Cs("rdg"))
local note = lpeg.Cs("note")
local lnbrk = lpeg.Cs("\\\\")
local poemline = lpeg.Cs(lnbrk * bsqbrackets^-1)
local endpoem = lpeg.Cs(lnbrk * lpeg.S("*!") * bsqbrackets^-1)
local sections = lpeg.Cs(lpeg.P("book") + lpeg.P("part") + lpeg.P("chapter")
+ lpeg.P("section") + lpeg.P("subsection")
+ lpeg.P("subsubsection"))
local par = lpeg.P(lpeg.P("\\par") * spce^1)
local parb = lpeg.P(lpeg.Cs("\\p@rb") * spce^1)
local para = lpeg.P(lpeg.Cs("\\p@ra") * spce^1)
-- Bind to local variables
local next = next
-- General
xmlids = {}
local function xmlidfound(element)
for i = 1,#xmlids do
if xmlids[i].xmlid == element then
return true
end
end
return false
end
-- Witnesses
listWit = {}
idsRend = {}
shorthands = {}
local function isfound(table, value)
for i = 1,#table do
if table[i] == value then
return true
end
end
return false
end
local function isintable(table, value)
for i = 1,#table do
if table[i].a == value then
return true
end
end
return false
end
local function get_a_index(id, table)
local idfound = nil
for i = 1,#table
do
if table[i].a == id then
idfound = i
break
end
end
return idfound
end
local function getindex(id, table)
local idfound = nil
for i = 1,#table
do
if table[i].xmlid == id then
idfound = i
break
end
end
return idfound
end
function ekdosis.newwitness(id,
siglum,
description,
Settlement,
Institution,
Repository,
Collection,
Idno,
MsName,
OrigDate)
if xmlidfound(id)
then
tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
..id..
"\" already exists as a xml:id. "
..
"Please pick another id.}}")
else
table.insert(xmlids, {xmlid = id})
table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end)
table.insert(idsRend, {xmlid = id, abbr = siglum})
table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end)
table.insert(listWit, {xmlid = id,
abbr = siglum,
detailsDesc = description,
msIdentifier = {
settlement = Settlement,
institution = Institution,
repository = Repository,
collection = Collection,
idno = Idno,
msName = MsName}
})
local indexwit = getindex(id, listWit)
if OrigDate ~= "" then
listWit[indexwit].history = {}
listWit[indexwit].history.origin = {origDate = OrigDate}
end
end
return true
end
function ekdosis.newhand(id, witid, siglum, description)
if xmlidfound(id) or not xmlidfound(witid)
then
tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
..id..
"\" already exists as a xml:id. "
..
"Please pick another id.}}")
else
table.insert(xmlids, {xmlid = id})
table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end)
table.insert(idsRend, {xmlid = id, abbr = siglum})
table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end)
local indexwit = getindex(witid, listWit)
-- listWit[indexwit].handDesc = {xmlid = id, abbr = siglum, handNote = description}
if listWit[indexwit].handDesc == nil
then
listWit[indexwit].handDesc = {}
else
end
table.insert(listWit[indexwit].handDesc,
{xmlid = id, abbr = siglum, detailsDesc = description})
end
return true
end
function ekdosis.newshorthand(id, rend, xmlids)
if isintable(shorthands, id)
then
tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
..id..
"\" already exists as a shorthand. "
..
"Please pick another shorthand.}}")
else
table.insert(shorthands, { a = id, b = rend, c = xmlids })
table.sort(shorthands, function(a ,b) return(#a.a > #b.a) end)
table.insert(idsRend, {xmlid = id, abbr = rend})
table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end)
end
return true
end
local xmlbibresource = nil
function ekdosis.setxmlbibresource(str)
xmlbibresource = str..".xml"
return true
end
function ekdosis.newscholar(id, siglum)
if xmlidfound(id)
then
tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
..id..
"\" already exists as a xml:id. "
..
"Please pick another id.}}")
else
table.insert(xmlids, {xmlid = id})
table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end)
table.insert(idsRend, {xmlid = id, abbr = siglum})
table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end)
end
return true
end
function ekdosis.getsiglum(str, opt)
str = str..","
str = string.gsub(str, "%s-(%,)", "%1")
ctrl = str
if opt == "tei" then
for i = 1,#shorthands do
str = string.gsub(str, shorthands[i].a, shorthands[i].c)
end
for i = 1,#idsRend do
str = string.gsub(str, "(%f[%w])"..idsRend[i].xmlid.."(%,)",
"%1#"..idsRend[i].xmlid.."%2")
ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "")
end
str = string.gsub(str, "%,(%s-)([%#])", " %2")
str = string.gsub(str, "%,$", "")
else
for i = 1,#idsRend do
str = string.gsub(str, idsRend[i].xmlid.."%,", idsRend[i].abbr)
ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "")
end
end
-- if string.find(ctrl, "[A-Za-z0-9]")
if string.find(ctrl, "%S")
then
return "<??>"
else
return str
end
end
-- begin totei functions
local cmdtotags = {
{a="textsuperscript", b="hi", c=" rend=\"sup\""},
{a="textsubscript", b="hi", c=" rend=\"sub\""},
{a="LRfootnote", b="note", c=" place=\"bottom\""},
{a="RLfootnote", b="note", c=" place=\"bottom\""},
{a="enquote *", b="quote", c=""},
{a="footnote", b="note", c=" place=\"bottom\""},
{a="enquote", b="quote", c=""},
{a="txtrans", b="s", c=" xml:lang=\"ar-Latn\" type=\"transliterated\""},
{a="textbf", b="hi", c=" rend=\"bold\""},
{a="textit", b="hi", c=" rend=\"italic\""},
{a="textsc", b="hi", c=" rend=\"smallcaps\""},
{a="textsf", b="hi", c=" rend=\"sf\""},
{a="arbup", b="hi", c=" rend=\"sup\""},
{a="txarb", b="s", c=" xml:lang=\"arb\""},
{a="arb", b="foreign",
c=" xml:lang=\"ar-Latn\" type=\"transliterated\" subtype=\"arabtex\""}
}
local texpatttotags = {
{a="\\icite%s?%[(.-)%]%[(.-)%]{(.-)}", b="%1 <ref target=\"#%3\">%2</ref>"},
{a="\\icite%s?%[(.-)%]{(.-)}", b="<ref target=\"#%2\">%1</ref>"},
{a="\\icite%s?{(.-)}", b="<ptr target=\"#%1\"/>"},
{a="\\linelabel%s?{(.-)}", b="<anchor xml:id=\"%1\"/>"},
{a="\\label%s?{(.-)}", b="<anchor xml:id=\"%1\"/>"},
{a="\\v?pageref%s?{(.-)}", b="<ptr target=\"#%1\"/>"},
{a="\\v?ref%s?{(.-)}", b="<ptr target=\"#%1\"/>"}
}
local envtotags = {
{a="flushright", b="p", c=" rend=\"align(right)\""},
{a="flushleft", b="p", c=" rend=\"align(left)\""},
{a="quotation", b="quote", c=""},
{a="ekdverse", b="lg", c=""},
{a="txarabtr", b="p", c=" xml:lang=\"ar-Latn\" type=\"transliterated\""},
{a="txarab", b="p", c=" xml:lang=\"arb\""},
{a="center", b="p", c=" rend=\"align(center)\""},
{a="verse", b="lg", c=""},
{a="arab", b="p",
c=" xml:lang=\"ar-Latn\" type=\"transliterated\" subtype=\"arabtex\""}
}
local close_p = {
"p",
"lg"
}
local forbid_xmlid = true
function ekdosis.newcmdtotag(cmd, tag, attr)
if forbid_xmlid
then
attr = string.gsub(attr, "xml:id", "n") -- xml:id is not allowed here
else
end
if isintable(cmdtotags, cmd)
then
local index = get_a_index(cmd, cmdtotags)
table.remove(cmdtotags, index)
table.insert(cmdtotags, {a = cmd, b = tag, c = " "..attr})
table.sort(cmdtotags, function(a ,b) return(#a.a > #b.a) end)
else
table.insert(cmdtotags, {a = cmd, b = tag, c = " "..attr})
table.sort(cmdtotags, function(a ,b) return(#a.a > #b.a) end)
end
return true
end
function ekdosis.newpatttotag(pat, repl)
pat = string.gsub(pat, "([%[%]])", "%%%1")
pat = string.gsub(pat, "%#[1-9]", "(.-)")
repl = string.gsub(repl, "%#([1-9])", "%%%1")
table.insert(texpatttotags, { a = pat, b = repl })
table.sort(texpatttotags, function(a ,b) return(#a.a > #b.a) end)
return true
end
function ekdosis.newenvtotag(env, tag, attr, closep)
if forbid_xmlid
then
attr = string.gsub(attr, "xml:id", "n") -- xml:id is not allowed here
else
end
if isintable(envtotags, env)
then
local index = get_a_index(env, envtotags)
table.remove(envtotags, index)
table.insert(envtotags, {a = env, b = tag, c = " "..attr, d = closep})
table.sort(envtotags, function(a ,b) return(#a.a > #b.a) end)
else
table.insert(envtotags, {a = env, b = tag, c = " "..attr, d = closep})
table.sort(envtotags, function(a ,b) return(#a.a > #b.a) end)
end
return true
end
-- Get values of attributes
local function get_attr_value(str, attr)
str = str..","
local attrval = string.match(str, "%f[%w]"..attr.."%s?%=%s?%b{}")
or string.match(str, "%f[%w]"..attr.."%s?%=%s?.-%,")
or ""
attrval = string.gsub(attrval, attr.."%s?%=%s?(%b{})", function(bbraces)
bbraces = string.sub(bbraces, 2, -2)
return string.format("%s", bbraces)
end)
attrval = string.gsub(attrval, attr.."%s?%=%s?(.-)%s?%,", "%1")
return attrval
end
local function xml_entities(str)
str = string.gsub(str, "%<", "<")
str = string.gsub(str, "%>", ">")
return str
end
local function note_totei(str)
str = gsub(str,
dblbkslash *
note *
spcenc^-1 *
bsqbrackets *
bcbraces *
spcenc^-1,
function(bkslash, cmd, opt, arg)
opt = string.sub(opt, 2, -2)
arg = string.sub(arg, 2, -2)
teitype = get_attr_value(opt, "type")
if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end
right = get_attr_value(opt, "labelb")
left = get_attr_value(opt, "labele")
if left ~= ""
then
return string.format(
"<%s%s target=\"#range(right(%s),left(%s))\">%s</%s><anchor xml:id=\"%s\"/>",
cmd, teitype, right, left, arg, cmd, right)
elseif left == ""
then
return string.format(
"<%s%s target=\"#right(%s)\">%s</%s><anchor xml:id=\"%s\"/>",
cmd, teitype, right, arg, cmd, right)
end
end)
return str
end
local function app_totei(str)
str = gsub(str,
dblbkslash *
app *
spcenc^-1 *
bsqbrackets *
bcbraces *
spcenc^-1,
function(bkslash, cmd, opt, arg)
opt = string.sub(opt, 2, -2)
arg = string.sub(arg, 2, -2)
opt = get_attr_value(opt, "type")
if opt ~= "" then opt = " type=\""..opt.."\"" else end
return app_totei(string.format("<%s%s>%s</%s>",
cmd, opt, arg, cmd))
end)
return str
end
local function lem_rdg_totei(str)
str = gsub(str,
spcenc^-1 *
dblbkslash *
lemrdg *
spcenc^-1 *
bsqbrackets *
bcbraces *
spcenc^-1,
function(bkslash, cmd, opt, arg)
opt = string.sub(opt, 2, -2)
arg = string.sub(arg, 2, -2)
-- opt = get_attr_value(opt, "wit")
--
teiwit = get_attr_value(opt, "wit")
if teiwit ~= "" then teiwit = " wit=\""..ekdosis.getsiglum(teiwit, "tei").."\"" else end
teitype = get_attr_value(opt, "type")
if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end
--
if opt == ""
then
return lem_rdg_totei(string.format("<%s>%s</%s>",
cmd, arg, cmd))
else
-- opt = ekdosis.getsiglum(opt, "tei")
return lem_rdg_totei(string.format("<%s%s%s>%s</%s>",
cmd, teiwit, teitype, arg, cmd))
end
end)
str = gsub(str, spcenc^-0 * dblbkslash * lemrdg * spcenc^-1 * bcbraces * spcenc^-1,
function(bkslash, cmd, arg)
arg = string.sub(arg, 2, -2)
return lem_rdg_totei(string.format("<%s>%s</%s>", cmd, arg, cmd))
end)
return str
end
local function relocate_notes(str)
str = string.gsub(str, "(%<lem.-%>.-)(%<note.->.-%<%/note%>)(.-%<%/lem%>)", "%1%3%2")
return str
end
local function linestotei(str)
-- str = "\n<l>"..str
str = string.gsub(str, "^%s?(.-)%s?$", "\n<l>%1</l>\n")
-- str = gsub(str, endpoem, "</l>\n")
str = gsub(str, poemline * spcenc^-1 * lpeg.P(">"), "\n<lb/>")
str = gsub(str, poemline * spcenc^-1, "</l>\n<l>")
-- str = str.."</l>\n"
return str
end
-- better use lpeg: look into this later
local function versetotei(str)
str = string.gsub(str, "(\\begin%s?%{ekdverse%})(%b[])(.-)(\\end%s?%{ekdverse%})", function(benv, opt, arg, eenv)
arg = linestotei(arg)
return string.format("%s%s%s%s", benv, opt, arg, eenv)
end)
str = string.gsub(str, "(\\begin%s?%{ekdverse%})(.-)(\\end%s?%{ekdverse%})", function(benv, arg, eenv)
arg = linestotei(arg)
return string.format("%s%s%s", benv, arg, eenv)
end)
str = string.gsub(str, "(\\begin%s?%{verse%})(%b[])(.-)(\\end%s?%{verse%})", function(benv, opt, arg, eenv)
arg = linestotei(arg)
return string.format("%s%s%s%s", benv, opt, arg, eenv)
end)
str = string.gsub(str, "(\\begin%s?%{verse%})(.-)(\\end%s?%{verse%})", function(benv, arg, eenv)
arg = linestotei(arg)
return string.format("%s%s%s", benv, arg, eenv)
end)
return str
end
local function envtotei(str)
for i = 1,#envtotags
do
if envtotags[i].b ~= ""
then
if isfound(close_p, envtotags[i].b) or envtotags[i].d == "yes"
then
str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
* lpeg.Cs(envtotags[i].a) * lpeg.P("}")
* bsqbracketsii * bcbracesii * spcenc^-1,
"\\p@rb <"..envtotags[i].b..envtotags[i].c..">")
str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
* lpeg.Cs(envtotags[i].a) * lpeg.P("}"),
"</"..envtotags[i].b..">\\p@ra ")
else
str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
* lpeg.Cs(envtotags[i].a) * lpeg.P("}")
* bsqbracketsii * bcbracesii * spcenc^-1,
"<"..envtotags[i].b..envtotags[i].c..">")
str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
* lpeg.Cs(envtotags[i].a) * lpeg.P("}"),
"</"..envtotags[i].b..">")
end
else
str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
* lpeg.Cs(envtotags[i].a) * lpeg.P("}")
* bsqbracketsii * bcbracesii * spcenc^-1,
"")
str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
* lpeg.Cs(envtotags[i].a) * lpeg.P("}"),
"")
end
end
str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
* lpeg.Cs(ascii^1) * lpeg.P("}") * bsqbracketsii
* bcbracesii * spcenc^-1,
"<%1>")
str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
* lpeg.Cs(ascii^1) * lpeg.P("}") * bsqbracketsii
* bcbracesii,
"</%1>")
return str
end
local function texpatttotei(str)
for i = 1,#texpatttotags do
str = string.gsub(str, texpatttotags[i].a, texpatttotags[i].b)
end
return str
end
local function cmdtotei(str)
for i = 1,#cmdtotags
do
str = gsub(str, lpeg.P("\\") * lpeg.Cs(cmdtotags[i].a) * spcenc^-1 * bsqbrackets * -bcbraces, "\\%1%2{}")
str = gsub(str, lpeg.P("\\") * lpeg.Cs(cmdtotags[i].a) * spcenc^-1 * -(bsqbrackets + bcbraces), "\\%1[]{}")
str = string.gsub(str, "(\\"..cmdtotags[i].a..")%s?%*?(%b{})", "%1[]%2")
str = string.gsub(str, "(\\"..cmdtotags[i].a..")%s?%*?(%b[])(%b{})",
function(cmd, arg, body)
body = string.sub(body, 2, -2)
arg = string.sub(arg, 2, -2)
arg = string.gsub(arg, "(%b{})", function(braces)
braces = string.sub(braces, 2, -2)
return string.format("\"%s\"", braces)
end)
body = cmdtotei(body)
-- return string.format("<"..cmdtotags[i].b..cmdtotags[i].c.." %s>%s</"..cmdtotags[i].b..">", arg, body)
if cmdtotags[i].b ~= ""
then
return string.format("<"..cmdtotags[i].b..cmdtotags[i].c..">%s</" ..
cmdtotags[i].b..">", body)
else
return ""
end
end)
end
-- temporarily:
str = string.gsub(str, "\\(getsiglum)%s?(%b{})",
function(cmd, body)
body = string.sub(body, 2, -2)
teisiglum = ekdosis.getsiglum(body, "tei")
printsiglum = ekdosis.getsiglum(body)
-- body = cmdtotei(body)
return string.format("<ref target=\"%s\">%s</ref>",
teisiglum, printsiglum)
end)
str = string.gsub(str, "\\(%a+)%s?%*?(%b[])(%b{})",
function(cmd, opt, body)
body = string.sub(body, 2, -2)
body = cmdtotei(body)
return string.format("<%s>%s</%s>", cmd, body, cmd)
end)
str = string.gsub(str, "\\(%a+)%s?%*?(%b{})",
function(cmd, body)
body = string.sub(body, 2, -2)
body = cmdtotei(body)
return string.format("<%s>%s</%s>", cmd, body, cmd)
end)
str = string.gsub(str, "(%s)(%>)", "%2")
return str
end
local function partotei(str)
str = gsub(str, lpeg.P(lpeg.P("\\par") * spcenc^1)^1, "\\par ")
str = gsub(str, ((para + parb) * par^-1)^2, "\\p@r ")
str = string.gsub(str, "\\p@ra%s+", "<p>")
str = string.gsub(str, "\\p@rb%s+", "</p>")
str = string.gsub(str, "\\p@r%s+", "")
str = string.gsub(str, "%s?\\par%s?", "<p>", 1)
str = string.gsub(str, "(%<p%>)(%s-)(%<%/?div%d?)", "%3")
str = string.gsub(str, "%s?\\par%s?", "</p><p>")
str = string.gsub(str, "<p>%s?</p>", "")
str = string.gsub(str, "(%<p%>)%s?(%</div%>)$", "%2")
str = string.gsub(str, "(%<p%>)%s?$", "")
str = string.gsub(str, "(<p>)%s?(<div.->)", "%2%1")
return str
end
local function self_close_tags(str)
str = gsub(str, lpeg.P("<" * -lpeg.S("/"))
* lpeg.Cs(letters^1)
* lpeg.Cs((1 - lpeg.S"<>")^0)
* lpeg.P(">")
* lpeg.P("</")
* lpeg.Cs(letters^1)
* lpeg.P(">"), function(ftag, arg, ltag)
if ftag == ltag
then
return string.format("<%s%s/>", ftag, arg)
else
end
end)
return str
end
local divdepth = {
book = 1,
part = 2,
chapter = 3,
section = 4,
subsection = 5,
subsubsection = 6
}
function ekdosis.mkdivdepths(...)
divdepth = {}
local num = 1
for _, y in ipairs{...}
do
if y == "book" or "part" or "chapter"
or "section" or "subsection" or "subsubsection"
then
divdepth[y] = num
num = num + 1
else
end
end
return true
end
-- LaTeX side: format the divisions
local fmtdiv = {}
function ekdosis.fmtdiv(n, fmtb, fmte)
if isintable(fmtdiv, n)
then
local index = get_a_index(n, fmtdiv)
table.remove(fmtdiv, index)
else
end
table.insert(fmtdiv, { a = n, formatb = fmtb, formate = fmte} )
return true
end
function ekdosis.getfmtdiv(n, pos)
local index = get_a_index(n, fmtdiv)
if index ~= nil
then
if pos == "b"
then
return fmtdiv[index].formatb
elseif pos == "e"
then
return fmtdiv[index].formate
end
else
return ""
end
end
local ekddivs = true
function ekdosis.setekddivsfalse()
ekddivs = false
end
local function ekddivs_totei(str)
str = gsub(str, dblbkslash * lpeg.Cs("ekddiv") * spce^-1 * bcbraces,
function(bkslash, cmd, space, arg)
if ekddivs
then
arg = string.sub(arg, 2, -2)
teitype = get_attr_value(arg, "type")
tein = get_attr_value(arg, "n")
teihead = get_attr_value(arg, "head")
teidepth = get_attr_value(arg, "depth")
if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end
if tein ~= "" then tein = " n=\""..tein.."\"" else end
if teidepth ~= ""
then
teidepth = " depth=\""..teidepth.."\""
else
teidepth = " depth=\"1\""
end
return string.format("\\p@rb <div%s%s%s><head>%s</head>\\p@ra ",
teitype, tein, teidepth, teihead)
else
return ""
end
end)
return str
end
local function section_totei(str)
str = gsub(str, dblbkslash * sections * spce^-1 * bcbraces, "%1%2%3[]%4")
str = gsub(str, dblbkslash * sections * spce^-1 * bsqbrackets * bcbraces,
function(bkslash, secname, space, opt, arg)
if ekddivs
then
return ""
else
ctr = divdepth[secname]
arg = string.sub(arg, 2, -2)
return string.format("\\p@rb <div%s type=\"%s\"><head>%s</head>\\p@ra ",
ctr, secname, arg)
end
end)
return str
end
local used_ndivs = {}
local function close_ekddivs_at_end(str)
local isdiv = false
if string.find(str, "</div>$")
then
isdiv = true
str = string.gsub(str, "(.*)(</div>)$", "%1")
else
end
-- collect used depth numbers
for i in string.gmatch(str, "<div .-depth%=\"%d\".->")
do
i = string.match(i, "depth=\"%d\"")
i = string.match(i, "%d")
if isintable(used_ndivs, i)
then
else
table.insert(used_ndivs, {a = i} )
end
end
if next(used_ndivs) ~= nil
then
table.sort(used_ndivs, function(a ,b) return(#a.a > #b.a) end)
else
end
local firstdiv = string.match(str, "<div .-depth%=\"%d\".->") or ""
firstdiv = string.match(firstdiv, "depth%=\"%d\"") or ""
firstdiv = string.match(firstdiv, "%d") or ""
local lastdiv = string.match(string.reverse(str), ">.-\"%d\"%=htped.- vid<") or ""
lastdiv = string.match(lastdiv, "\"%d\"%=htped") or ""
lastdiv = string.match(lastdiv, "%d") or ""
local firstdivindex = get_a_index(firstdiv, used_ndivs)
local lastdivindex = get_a_index(lastdiv, used_ndivs)
firstdivindex = tonumber(firstdivindex)
lastdivindex = tonumber(lastdivindex)
local closedivs = ""
if isintable(used_ndivs, firstdiv)
then
while lastdivindex >= firstdivindex
do
closedivs = closedivs.."</div>"
lastdivindex = lastdivindex - 1
end
end
if isdiv
then
return str..closedivs.."</div>"
else
return str..closedivs
end
end
local function close_ndivs_at_end(str)
local isdiv = false
if string.find(str, "</div>$")
then
isdiv = true
str = string.gsub(str, "(.*)(</div>)$", "%1")
else
end
-- collect used div numbers
for i in string.gmatch(str, "<div[1-6]")
do
i = string.match(i, "[1-6]")
if isintable(used_ndivs, i)
then
else
table.insert(used_ndivs, {a = i} )
end
end
if next(used_ndivs) ~= nil
then
table.sort(used_ndivs, function(a ,b) return(#a.a > #b.a) end)
else
end
local firstdiv = string.match(str, "<div[1-6]") or ""
firstdiv = string.match(firstdiv, "[1-6]") or ""
local lastdiv = string.match(string.reverse(str), "[1-6]vid<") or ""
lastdiv = string.match(lastdiv, "[1-6]") or ""
local firstdivindex = get_a_index(firstdiv, used_ndivs)
local lastdivindex = get_a_index(lastdiv, used_ndivs)
firstdivindex = tonumber(firstdivindex)
lastdivindex = tonumber(lastdivindex)
local closedivs = ""
if isintable(used_ndivs, firstdiv)
then
while lastdivindex >= firstdivindex
do
closedivs = closedivs.."</div"..used_ndivs[lastdivindex].a..">"
lastdivindex = lastdivindex - 1
end
end
if isdiv
then
return str..closedivs.."</div>"
else
return str..closedivs
end
end
local function close_ekddivs_in_between(str)
local maxdepth = 1
for i in string.gmatch(str, "<div.-depth=\"(%d)\".->", "%1")
do
if tonumber(i) > tonumber(maxdepth)
then
maxdepth = i
else
end
end
for ndivi = 1, maxdepth
do
str = string.gsub(str, "(<div .-depth%=\")("..ndivi..")(\".->)(.-)(<div .-depth%=\")(%d)(\".->)",
function(bdivi, ndivi, edivi, between, bdivii, ndivii, edivii)
local firstdiv = ndivi
local lastdiv = ndivii
local firstdivindex = get_a_index(firstdiv, used_ndivs)
local lastdivindex = get_a_index(lastdiv, used_ndivs)
firstdivindex = tonumber(firstdivindex)
lastdivindex = tonumber(lastdivindex)
local closedivs = ""
if firstdivindex >= lastdivindex
then
while firstdivindex >= lastdivindex
do
closedivs = closedivs.."</div>"
firstdivindex = firstdivindex - 1
end
end
return string.format("%s%s%s%s%s%s%s%s",
bdivi, ndivi, edivi, between, closedivs, bdivii, ndivii, edivii)
end)
end
str = string.gsub(str, "(<div.-)(%sdepth%=\"%d\")(.->)", "%1%3")
used_ndivs = {}
return str
end
local function close_ndivs_in_between(str)
for ndivi = 1, 6
do
str = string.gsub(str, "(<div)("..ndivi..")(.->)(.-)(<div)([1-6])(.->)",
function(bdivi, ndivi, edivi, between, bdivii, ndivii, edivii)
local firstdiv = ndivi
local lastdiv = ndivii
local firstdivindex = get_a_index(firstdiv, used_ndivs)
local lastdivindex = get_a_index(lastdiv, used_ndivs)
firstdivindex = tonumber(firstdivindex)
lastdivindex = tonumber(lastdivindex)
local closedivs = ""
if firstdivindex >= lastdivindex
then
while firstdivindex >= lastdivindex
do
closedivs = closedivs.."</div"..used_ndivs[firstdivindex].a..">"
firstdivindex = firstdivindex - 1
end
end
return string.format("%s%s%s%s%s%s%s%s",
bdivi, ndivi, edivi, between, closedivs, bdivii, ndivii, edivii)
end)
end
used_ndivs = {}
return str
end
local function textotei(str)
str = xml_entities(str)
str = texpatttotei(str)
str = note_totei(str)
str = app_totei(str)
str = lem_rdg_totei(str)
str = relocate_notes(str)
str = versetotei(str)
str = envtotei(str)
str = ekddivs_totei(str)
str = section_totei(str)
str = cmdtotei(str)
str = self_close_tags(str)
str = partotei(str)
if ekddivs
then
str = close_ekddivs_at_end(str)
str = close_ekddivs_in_between(str)
else
str = close_ndivs_at_end(str)
str = close_ndivs_in_between(str)
end
return str
end
local teifilename = tex.jobname.."-tei"
function ekdosis.setteifilename(str)
teifilename = str
return true
end
function ekdosis.openteistream()
local f = io.open(teifilename.."_tmp.xml", "a+")
f:write('<?xml version="1.0" encoding="utf-8"?>', "\n")
f:write("<TEI xmlns=\"http://www.tei-c.org/ns/1.0\">", "\n")
f:write("<teiHeader>", "\n")
f:write("<fileDesc>", "\n")
f:write("<titleStmt>", "\n")
f:write("<title><!-- Title --></title>", "\n")
f:write("<respStmt>", "\n")
f:write("<resp><!-- Edited by --></resp>", "\n")
f:write("<name><!-- Name --></name>", "\n")
f:write("</respStmt>", "\n")
f:write("</titleStmt>", "\n")
f:write("<publicationStmt>", "\n")
f:write("<distributor><!-- Distributor name --></distributor>", "\n")
f:write("</publicationStmt>", "\n")
f:write("<sourceDesc>", "\n")
f:write("<listWit>", "\n")
for i = 1,#listWit do
f:write('<witness xml:id=\"', listWit[i].xmlid, "\">", "\n")
f:write('<abbr type="siglum">', textotei(listWit[i].abbr), "</abbr>", "\n")
f:write(textotei(listWit[i].detailsDesc), "\n")
f:write("<msDesc>", "\n")
if listWit[i].msIdentifier.settlement == ""
and listWit[i].msIdentifier.institution == ""
and listWit[i].msIdentifier.repository == ""
and listWit[i].msIdentifier.collection == ""
and listWit[i].msIdentifier.idno == ""
and listWit[i].msIdentifier.msName == ""
then
f:write("<msIdentifier/>", "\n")
else
f:write("<msIdentifier>", "\n")
if listWit[i].msIdentifier.settlement ~= "" then
f:write("<settlement>", textotei(listWit[i].msIdentifier.settlement), "</settlement>", "\n")
else end
if listWit[i].msIdentifier.institution ~= "" then
f:write("<institution>", textotei(listWit[i].msIdentifier.institution), "</institution>", "\n")
else end
if listWit[i].msIdentifier.repository ~= "" then
f:write("<repository>", textotei(listWit[i].msIdentifier.repository), "</repository>", "\n")
else end
if listWit[i].msIdentifier.collection ~= "" then
f:write("<collection>", textotei(listWit[i].msIdentifier.collection), "</collection>", "\n")
else end
if listWit[i].msIdentifier.idno ~= "" then
f:write("<idno>", textotei(listWit[i].msIdentifier.idno), "</idno>", "\n")
else end
if listWit[i].msIdentifier.msName ~= "" then
f:write("<msName>", textotei(listWit[i].msIdentifier.msName), "</msName>", "\n")
else end
f:write("</msIdentifier>", "\n")
end
if listWit[i].handDesc ~= nil then
f:write("<physDesc>", "\n")
f:write("<handDesc hands=\"", #listWit[i].handDesc, "\">", "\n")
local j = 1
while listWit[i].handDesc[j]
do
f:write("<handNote xml:id=\"", listWit[i].handDesc[j].xmlid, "\">", "\n")
f:write('<abbr type="siglum">', textotei(listWit[i].handDesc[j].abbr), "</abbr>", "\n")
f:write("<p>", textotei(listWit[i].handDesc[j].detailsDesc), "</p>", "\n")
f:write("</handNote>", "\n")
j = j + 1
end
f:write("</handDesc>", "\n")
f:write("</physDesc>", "\n")
else end
if listWit[i].history ~= nil then
f:write("<history>", "\n")
f:write("<origin>", "\n")
f:write("<origDate>", textotei(listWit[i].history.origin.origDate), "</origDate>", "\n")
f:write("</origin>", "\n")
f:write("</history>", "\n")
end
f:write("</msDesc>", "\n")
f:write("</witness>", "\n")
end
f:write("</listWit>", "\n")
f:write("</sourceDesc>", "\n")
f:write("</fileDesc>", "\n")
f:write("<encodingDesc>", "\n")
f:write('<variantEncoding method="parallel-segmentation" location="internal"/>', "\n")
f:write("</encodingDesc>", "\n")
f:write("</teiHeader>", "\n")
f:write("<text>", "\n")
f:write("<body>", "\n")
f:close()
return true
end
local tidy = nil
local function cleanup_tei()
local f = assert(io.open(teifilename.."_tmp.xml", "r"))
t = f:read("*a")
t = string.gsub(t, "%<p%>%s?%</p%>", "")
t = string.gsub(t, "^\n", "")
f:close()
local fw = assert(io.open(teifilename.."_tmp.xml", "w"))
fw:write(t)
fw:close()
return true
end
function ekdosis.closeteistream(opt)
local f = io.open(teifilename.."_tmp.xml", "a+")
f:write("\n", "</body>", "\n")
if xmlbibresource ~= nil then
bibf = assert(io.open(xmlbibresource, "r"))
t = bibf:read("*a")
t = string.gsub(t, "%s+corresp%=%b\"\"", "")
t = string.gsub(t, "\n\n", "\n")
f:write("<back>", "\n")
f:write("<listBibl>", "\n")
for i in string.gmatch(t, "<biblStruct.->.-</biblStruct>")
do
f:write(i, "\n")
end
f:write("</listBibl>", "\n")
f:write("</back>", "\n")
bibf:close()
else
end
f:write("</text>", "\n")
f:write("</TEI>", "\n")
f:close()
cleanup_tei()
os.remove(teifilename..".xml")
os.rename(teifilename.."_tmp.xml", teifilename..".xml")
if opt == "tidy" then
os.execute("tidy -qmi -xml --output-xml yes "..teifilename..".xml")
else
end
return true
end
function ekdosis.exporttei(str)
local f = io.open(teifilename.."_tmp.xml", "a+")
-- f:write("\n<p>")
str = textotei(str)
f:write(str)
f:close()
return true
end
-- end totei functions
-- begin basic TeX Conspectus siglorum
function ekdosis.basic_cs(msid)
local indexwit = getindex(msid, listWit)
siglum = listWit[indexwit].abbr
-- if listWit[indexwit].detailsDesc == ""
-- then
-- name = listWit[indexwit].msIdentifier.msName
-- else
-- name = listWit[indexwit].msIdentifier.msName
-- .."\\thinspace\\newline\\bgroup\\footnotesize{}"..
-- listWit[indexwit].detailsDesc
-- .."\\egroup{}"
-- end
name = listWit[indexwit].detailsDesc
if listWit[indexwit].history ~= nil
and
listWit[indexwit].history.origin ~= nil
then
date = listWit[indexwit].history.origin.origDate
else
date = ""
end
return siglum.."&"..name.."&"..date
end
-- end basic TeX Conspectus siglorum
function ekdosis.removesp(str)
str = gsub(str, cmd * cmdargs * spcenc^-1, "%1%2")
return str
end
function ekdosis.closestream()
os.remove(tex.jobname..".ekd")
os.rename(tex.jobname.."_tmp.ekd", tex.jobname..".ekd")
return true
end
local cur_abs_pg = 0
local pg_i = nil
local pg_ii = nil
local prevcol = nil
local curcol = "x"
local check_resetlineno = {}
function ekdosis.update_abspg(n) -- not used
cur_abs_pg = n
return true
end
function ekdosis.storeabspg(n, pg)
if pg == "pg_i" then
pg_i = n
elseif pg == "pg_ii" then
pg_ii = n
table.insert(check_resetlineno, curcol.."-"..pg_ii)
end
cur_abs_pg = n
return true
end
function ekdosis.checkresetlineno()
if isfound(check_resetlineno, curcol.."-"..pg_i)
then
return ""
else
return "\\resetlinenumber"
end
end
--
-- Build environments to be aligned
--
local cur_alignment = "-"
local cur_alignment_patt = "%-"
local cur_alignment_cnt = 1
local newalignment = false
function ekdosis.newalignment(str)
if str == "set"
then
newalignment = true
cur_alignment = "-"..cur_alignment_cnt.."-"
cur_alignment_patt = "%-"..cur_alignment_cnt.."%-"
cur_alignment_cnt = cur_alignment_cnt + 1
elseif str == "reset"
then
newalignment = false
cur_alignment = "-"
cur_alignment_patt = "-"
end
return true
end
local aligned_texts = {}
local texts_w_apparatus = {}
local coldata_totei = {}
local function sanitize_envdata(str) -- look for a better way to achieve this
str = string.gsub(str, "(%a+)%s+(%b[])", "%1%2")
str = string.gsub(str, "(%a+)(%b[])%s+", "%1%2")
str = string.gsub(str, "%s+(%a+)(%b[])", "%1%2")
str = gsub(str, lpeg.Cs(letters^1)
* spcenc^-1
* -bsqbrackets
* lpeg.Cs(";"), "%1[]%2")
str = string.gsub(str, "%s+(%a+)(%b[])", "%1%2")
return str
end
function ekdosis.mkenvdata(str, opt)
if not string.find(str, "%;", -1) then str = str .. ";" else end
-- str = str ..";"
-- str = string.gsub(str, "%s+", "")
local fieldstart = 1
local col = 0
if opt == "texts" then
str = sanitize_envdata(str)
repeat
local _s, nexti = string.find(str, "%b[]%s-%;", fieldstart)
local namediv = string.gsub(string.sub(str, fieldstart, nexti-1), "(%a+)%s-(%b[])", "%1")
local attr = string.gsub(string.sub(str, fieldstart, nexti-1), "(%a+)%s-(%b[])", "%2")
attr = string.sub(attr, 2, -2)
if forbid_xmlid
then
attr = string.gsub(attr, "xml:id", "n") -- xml:id is not allowed here
else
end
table.insert(aligned_texts, { text = namediv,
attribute = attr,
column = col })
table.insert(coldata_totei, { environment = namediv,
data = {} })
col = col + 1
fieldstart = nexti + 1
until fieldstart > string.len(str)
return aligned_texts
elseif opt == "apparatus" then
repeat
local nexti = string.find(str, "%;", fieldstart)
table.insert(texts_w_apparatus, string.sub(str, fieldstart, nexti-1))
fieldstart = nexti +1
until fieldstart > string.len(str)
return texts_w_apparatus
end
end
-- Reminder: the following two variables are already set above
-- local prevcol = nil
-- local curcol = "x"
function ekdosis.storecurcol(n)
curcol = n
return true
end
function ekdosis.flushcolnums()
prevcol = nil
curcol = "x"
return true
end
function ekdosis.flushenvdata()
aligned_texts = {}
texts_w_apparatus = {}
coldata_totei = {}
return true
end
function ekdosis.storecoldata(nthcol, chunk)
local tindex = tonumber(nthcol) + 1
table.insert(coldata_totei[tindex].data, chunk)
return true
end
local environment_div = {}
function ekdosis.newscholar(id, siglum)
if xmlidfound(id)
then
tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
..id..
"\" already exists as a xml:id. "
..
"Please pick another id.}}")
else
table.insert(xmlids, {xmlid = id})
table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end)
table.insert(idsRend, {xmlid = id, abbr = siglum})
table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end)
end
return true
end
local function build_envdiv(str)
if not environment_div[str]
then
environment_div[str] = 1
else
environment_div[str] = environment_div[str] + 1
end
local div = "div-"..str.."_"..environment_div[str]
if xmlidfound(div)
then
tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
..div..
"\" already exists as a xml:id. "
..
"ekdosis has generated some random id.}}")
return "div-"..math.random(1000,9999)
else
table.insert(xmlids, {xmlid = div})
table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end)
return div
end
end
function ekdosis.mkenv()
local environments = {}
for i = 1,#aligned_texts
do
if isfound(texts_w_apparatus, aligned_texts[i].text)
then
table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."}{+b}"
.."{\\begin{nthcolumn}{".. aligned_texts[i].column.."}"
.."\\par"
.."\\EkdosisColStart"
.."\\EkdosisOn#1"
.."}{\\EkdosisOff"
.."\\EkdosisColStop"
.."\\end{nthcolumn}"
.."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata("
.. aligned_texts[i].column
..", \\luastringN{\\par#1\\par})}\\fi"
.."}")
table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."*}{+b}"
.."{\\begin{nthcolumn*}{".. aligned_texts[i].column.."}[]"
.."\\par"
.."\\EkdosisColStart"
.."\\EkdosisOn#1"
.."}{\\EkdosisOff"
.."\\EkdosisColStop"
.."\\end{nthcolumn*}"
.."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata("
.. aligned_texts[i].column
..", \\luastringN{\\par#1\\par})}\\fi"
.."}")
else
table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."}{+b}"
.."{\\begin{nthcolumn}{".. aligned_texts[i].column.."}"
.."\\par"
.."#1"
.."}{\\end{nthcolumn}"
.."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata("
.. aligned_texts[i].column
..", \\luastringN{\\par#1\\par})}\\fi"
.."}")
table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."*}{+b}"
.."{\\begin{nthcolumn*}{"..aligned_texts[i].column.."}[]"
.."\\par"
.."#1"
.."}{"
.."\\end{nthcolumn*}"
.."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata("
.. aligned_texts[i].column
..", \\luastringN{\\par#1\\par})}\\fi"
.."}")
end
forbid_xmlid = false
if aligned_texts[i].attribute ~= ""
then
ekdosis.newenvtotag(aligned_texts[i].text, "div",
"xml:id=\""
..build_envdiv(aligned_texts[i].text)
.."\" "
..aligned_texts[i].attribute)
else
ekdosis.newenvtotag(aligned_texts[i].text, "div",
"xml:id=\""
..build_envdiv(aligned_texts[i].text)
.."\"")
end
forbid_xmlid = true
end
str = table.concat(environments)
return str
end
function ekdosis.export_coldata_totei()
for i = 1,#coldata_totei
do
ekdosis.exporttei("\\begin{".. coldata_totei[i].environment .."}"
.. table.concat(coldata_totei[i].data)
.. "\\end{".. coldata_totei[i].environment .."}")
end
end
-- handle multiple layers in apparatuses
--
local apparatuses = {}
local bagunits = {}
function ekdosis.newapparatus(teitype,
appdir,
apprule,
appdelim,
appsep,
appbhook,
appehook)
if isintable(apparatuses, teitype)
then
tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
..teitype..
"\" already exists.}}")
else
table.insert(apparatuses, {a = teitype,
direction = appdir,
rule = apprule,
delim = appdelim,
sep = appsep,
bhook = appbhook,
ehook = appehook})
end
bagunits[teitype] = 1
return true
end
function ekdosis.getappdelim(str)
for i = 1,#apparatuses
do
if apparatuses[i].a == str then
delimfound = apparatuses[i].delim
break
end
end
return delimfound
end
function ekdosis.get_bagunits(teitype)
return bagunits[teitype]
end
function ekdosis.increment_bagunits(teitype)
bagunits[teitype] = (bagunits[teitype] or 0) + 1
end
local function reset_bagunits()
for i = 1,#apparatuses
do
bagunits[apparatuses[i].a] = 1
end
end
function ekdosis.appin(str, teitype)
local f = io.open(tex.jobname.."_tmp.ekd", "a+")
if next(apparatuses) == nil
then
f:write("<", cur_abs_pg, cur_alignment, curcol, "-0>", str, "</",
cur_abs_pg, cur_alignment, curcol, "-0>\n")
else
for i = 1,#apparatuses
do
if apparatuses[i].a == teitype then
appno = i
break
end
end
f:write("<", cur_abs_pg, cur_alignment, curcol, "-",
appno, ">", str, "</", cur_abs_pg, cur_alignment, curcol, "-", appno, ">\n")
end
f:close()
return true
end
function ekdosis.appout()
local file = io.open(tex.jobname..".ekd", "r")
if file ~= nil then io.close(file)
f = assert(io.open(tex.jobname..".ekd", "r"))
t = f:read("*a")
local output = {}
if next(apparatuses) == nil then
-- table.insert(output, "BEGIN")
table.insert(output, "\\noindent\\csname ekd@default@rule\\endcsname\\NLS{}")
-- table.insert(output, "\\noindent ")
for i in string.gmatch(t,
"<"..cur_abs_pg
..cur_alignment_patt
..curcol.."%-0>.-</"
..cur_abs_pg
..cur_alignment_patt
..curcol.."%-0>")
do
table.insert(output, i)
end
-- table.insert(output, "END")
else
local n = 1
while apparatuses[n]
do
if string.match(t, "<"..cur_abs_pg..
cur_alignment_patt
..curcol.."%-"..n..">.-</"
..cur_abs_pg
..cur_alignment_patt
..curcol.."%-"..n..">")
then
-- table.insert(output, "BEGIN")
table.insert(output, "\\bgroup{}")
if apparatuses[n].direction == "LR"
then
table.insert(output, "\\pardir TLT\\textdir TLT{}")
elseif apparatuses[n].direction == "RL"
then
table.insert(output, "\\pardir TRT\\textdir TRT{}")
end
if apparatuses[n].rule == "none"
then
if n > 1
then
table.insert(output, "\\NLS{}")
else
table.insert(output, "\\noindent ")
end
elseif apparatuses[n].rule ~= ""
then
if n > 1
then
table.insert(output, "\\NLS{}" .. apparatuses[n].rule .. "\\NLS{}")
else
-- table.insert(output, "\\noindent ")
table.insert(output, apparatuses[n].rule .. "\\NLS{}")
end
else
if n > 1
then
table.insert(output, "\\NLS\\csname ekd@default@rule\\endcsname\\NLS{}")
else
-- table.insert(output, "\\noindent ")
table.insert(output, "\\csname ekd@default@rule\\endcsname\\NLS{}")
end
end
if apparatuses[n].sep ~= ""
then
table.insert(output, "\\edef\\ekdsep{" .. apparatuses[n].sep .. "}")
else
end
if apparatuses[n].bhook ~= ""
then
table.insert(output, apparatuses[n].bhook)
else
table.insert(output, "\\relax")
end
for i in string.gmatch(t,
"<"..cur_abs_pg
..cur_alignment_patt
..curcol.."%-"..n..">.-</"
..cur_abs_pg
..cur_alignment_patt
..curcol.."%-"..n..">")
do
table.insert(output, i)
end
if apparatuses[n].ehook ~= ""
then
table.insert(output, apparatuses[n].ehook)
else
end
table.insert(output, "\\egroup{}")
-- table.insert(output, "END")
end
n = n + 1
end
end
f:close()
str = table.concat(output)
str = string.gsub(str, "</"..cur_abs_pg..cur_alignment_patt..curcol.."%-[0-9]>", "")
str = string.gsub(str, "<"..cur_abs_pg..cur_alignment_patt..curcol.."%-[0-9]>", " ")
return str
else
end
end
function ekdosis.appin_out(str, nl)
local f = io.open(tex.jobname.."_tmp.ekd", "a+")
if nl == "yes" then
f:write(str, "\n")
else
f:write(str)
end
f:close()
return true
end
local curcol_curabspg = {}
function ekdosis.testapparatus()
if isfound(curcol_curabspg, curcol.."-"..cur_abs_pg)
then
if newalignment
then
if next(apparatuses) ~= nil then
reset_bagunits()
end
newalignment = false
return "\\booltrue{do@app}"
else
return "\\boolfalse{do@app}"
end
else
table.insert(curcol_curabspg, curcol.."-"..cur_abs_pg)
if next(apparatuses) ~= nil then
reset_bagunits()
end
return "\\booltrue{do@app}"
end
end
local lnlabs = {}
local lnlab_salt = 0
local current_lnlab = nil
local prev_lnlab = nil
local current_notelab = nil
local prev_notelab = nil
local current_lemma = nil
local salt = 0
local function mdvisintable(table, value)
for _, v in pairs(table) do
if v == value then return true end
end
return false
end
function ekdosis.dolnlab(str)
prev_lnlab = current_lnlab
current_lemma = str
i = md5.sumhexa(str)
if not mdvisintable(lnlabs, i) then
table.insert(lnlabs, i)
else
i = i..salt
table.insert(lnlabs, i)
salt = salt + 1
end
current_lnlab = i
return true
end
function ekdosis.getlnlab()
return current_lnlab
end
function ekdosis.getprevlnlab()
return prev_lnlab
end
function ekdosis.setnotelab(str)
current_notelab = str
return "\\linelabel{" .. current_notelab .. "}"
end
function ekdosis.getnotelab()
return current_notelab
end
function ekdosis.setprevnotelab(str)
prev_notelab = str
return true
end
function ekdosis.getprevnotelab()
return prev_notelab
end
local function remove_note(str)
str = gsub(str, dblbkslash * lpeg.P("note") * cmdargs, "")
return str
end
function ekdosis.mdvappend(str, teitype)
if teitype == nil
then
return "\\linelabel{" .. current_lnlab .. "-b}\\wordboundary{}"
..
current_lemma
..
"\\linelabel{" .. current_lnlab .. "-e}"
..
"\\csname append@app\\endcsname{"
.. remove_note(str) .. "}"
else
return "\\linelabel{" .. current_lnlab .. "-b}\\wordboundary{}"
..
current_lemma
..
"\\linelabel{" .. current_lnlab .. "-e}"
..
"\\csname append@app\\endcsname" .. "[" .. teitype .. "]{"
.. remove_note(str) .. "}"
end
end
% \end{ekdlua}
% \end{comment}
% \iffalse
%</lua>
% \fi
%
% \section{Sample: C. J. Caesar, \emph{Gallic War},
% VI, XIII.1}
% \label{sec:caesar-gw-6-1-13}
% \subsection{\texttt{.tex} Source File}
% \label{sec:caesar-gw-tex}
% \inputminted[linenos=false]{latex}{samples/Caesar_BG-6-13-1.tex}
% \subsection{\texttt{TEI xml} Output}
% \label{sec:caesar-gw-tei}
% \inputminted[linenos=false]{xml}{samples/Caesar_BG-6-13-1-tei.xml}
%
\endinput
|