aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/util_editors.org
blob: f88e9d10a56c2fccffe1fab7fd5932ea1c71a897 (plain)
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
-*- mode: org -*-
#+TITLE:       sisudoc spine (doc_reform) editor syntax highlighting & colorschemes
#+DESCRIPTION: documents - structuring, various output representations & search
#+FILETAGS:    :spine:info:
#+AUTHOR:      Ralph Amissah
#+EMAIL:       [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]]
#+COPYRIGHT:   Copyright (C) 2015 (continuously updated, current 2026) Ralph Amissah
#+LANGUAGE:    en
#+STARTUP:     content hideblocks hidestars noindent entitiespretty
#+PROPERTY:    header-args+ :eval never-export :exports code
#+PROPERTY:    header-args+ :noweb yes :padline no
#+PROPERTY:    header-args+ :results silent :cache no
#+PROPERTY:    header-args+ :mkdirp yes
#+OPTIONS:     H:3 num:nil toc:t \n:t ::t |:t ^:nil -:t f:t *:t
- magic single double-quote → " ← FIX changes hilighting behavior (occuring
  after it) in org document. INVESTIGATE (org-mode CONFIG?) FIND & FIX

- [[./doc-reform.org][doc-reform.org]]  [[./][org/]]

* Vim Syntax highlighting
** filetype

#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/filetype.vim"
#+BEGIN_SRC text
" SiSU filetype file
if exists("did_load_filetypes")
  finish
endif
augroup filetypedetect
  au! BufNewFile,BufRead *.sst,*.ssm,*.ssi,*.-sst setf sisu-spine
  au! BufNewFile,BufRead *._sst,*.sst.meta,*.-sst.meta,*._sst.meta setf sisu-spine
augroup END
#+END_SRC

** debian vim addon manager

#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/vim-sisu.yaml"
#+BEGIN_SRC text
#vim-addons: debian vim-addon-manager
addon: sisu
description: SiSU documents - structuring, publishing in multiple formats and search
basedir: /usr/share/vim-scripts/
files:
  - ftplugin/sisu.vim
  - syntax/sisu.vim
#+END_SRC

** markup syntax
*** sisu.vim

#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/syntax/sisu.vim"
#+BEGIN_SRC text
" SiSU Vim syntax file
" SiSU Maintainer: Ralph Amissah <ralph.amissah@gmail.com>
" SiSU Markup:     SiSU (sisu-5.6.7)
" Last Change:     2017-06-22
" URL: <https://git.sisudoc.org/projects/sisudoc-spine/tree/sundry/editor-syntax-etc/vim/syntax/sisu.vim>
"      <https://sisudoc.org/>
"(originally looked at Ruby Vim by Mirko Nasato)

if version < 600
  syntax clear
elseif exists("b:current_syntax")
  finish
else
endif
let s:cpo_save = &cpo
set cpo&vim

"% "Errors:
syn match sisu_error contains=sisu_link,sisu_error_wspace "<![^ei]\S\+!>"

"% "Markers Identifiers:
if !exists("sisu_no_identifiers")
  syn match   sisu_mark_endnote                                           "\~^"
  syn match   sisu_break               contains=@NoSpell                  " \\\\\( \|$\)\|<br>\|<br />"
  syn match   sisu_control             contains=@NoSpell                  "^\(-\\\\-\|=\\\\=\|-\.\.-\|<:p[bn]>\)\s*$"
  syn match   sisu_control             contains=@NoSpell                  "^<:\(bo\|---\)>\s*$"
  syn match   sisu_marktail            contains=@NoSpell                  "^--[+~-]#\s*$"
  syn match   sisu_marktail                                               "[~-]#"
  syn match   sisu_control                                                "\""
  syn match   sisu_underline                                              "\(^\| \)_[a-zA-Z0-9]\+_\([ .,]\|$\)"
  syn match   sisu_number              contains=@NoSpell                  "[0-9a-f]\{32\}\|[0-9a-f]\{64\}"
  syn match   sisu_link                contains=@NoSpell                  "\(_\?https\?://\|\.\.\/\)\S\+"
  syn match   sisu_link                                                   " \*\~\S\+"
  syn match   sisu_require             contains=@NoSpell                  "^<<\s*[a-zA-Z0-9^./_-]\+\.ss[it]$"
  syn match   sisu_structure                                              "^:A\~$"

"% "Document Sub Headers:
  syn match   sisu_sub_header_title                                       "^\s\+:\(subtitle\|short\|edition\|language\|lang_char\|note\):\s" "group=sisu_header_content
  syn match   sisu_sub_header_creator                                     "^\s\+:\(author\|editor\|contributor\|illustrator\|photographer\|translator\|digitized_by\|prepared_by\|audio\|video\):\s"                               " &hon &institution
  syn match   sisu_sub_header_rights                                      "^\s\+:\(copyright\|text\|translation\|illustrations\|photographs\|preparation\|digitization\|audio\|video\|license\|all\):\s"                   " access_rights license
  syn match   sisu_sub_header_classify                                    "^\s\+:\(topic_register\|keywords\|subject\|dewey\|loc\):\s"
  syn match   sisu_sub_header_identifier                                  "^\s\+:\(oclc\|isbn\):\s"
  syn match   sisu_sub_header_date                                        "^\s\+:\(added_to_site\|available\|created\|issued\|modified\|published\|valid\|translated\|original_publication\):\s"
  syn match   sisu_sub_header_original                                    "^\s\+:\(publisher\|date\|language\|lang_char\|institution\|nationality\|source\):\s"
  syn match   sisu_sub_header_make                                        "^\s\+:\(headings\|num_top\|breaks\|language\|italics\|bold\|emphasis\|substitute\|omit\|plaintext_wrap\|texpdf_font_mono\|texpdf_font\|stamp\|promo\|ad\|manpage\|home_button_text\|home_button_image\|cover_image\|footer\):\s"
  syn match   sisu_sub_header_notes                                       "^\s\+:\(description\|abstract\|comment\|coverage\|relation\|source\|history\|type\|format\|prefix\|prefix_[ab]\|suffix\):\s"
  syn match   sisu_within_index_ignore                                    "\S\+[:;]\(\s\+\|$\)"
  syn match   sisu_within_index                                           "[:|;]\|+\d\+"

"% "semantic markers: (ignore)
  syn match   sisu_sem_marker                                             ";{\|};[a-z._]*[a-z]"
  syn match   sisu_sem_marker_block                                       "\([a-z][a-z._]*\|\):{\|}:[a-z._]*[a-z]"
  syn match   sisu_sem_ex_marker                                          ";\[\|\];[a-z._]*[a-z]"
  syn match   sisu_sem_ex_marker_block                                    "\([a-z][a-z._]*\|\):\[\|\]:[a-z._]*[a-z]"
  syn match   sisu_sem_block contains=sisu_error,sisu_error_wspace,sisu_content_alt,sisu_link,sisu_linked,sisu_break,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_mark_endnote,sisu_content_endnote "\([a-z]*\):{[^}].\{-}}:\1"
  syn match   sisu_sem_content contains=sisu_error,sisu_error_wspace,sisu_content_alt,sisu_link,sisu_linked,sisu_break,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker ";{[^}].\{-}};[a-z]\+"
  syn match   sisu_sem_ex_block contains=sisu_error,sisu_error_wspace,sisu_content_alt,sisu_link,sisu_linked,sisu_break,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_mark_endnote,sisu_content_endnote "\([a-z]*\):\[[^}].\{-}\]:\1"
  syn match   sisu_sem_ex_content contains=sisu_error,sisu_error_wspace,sisu_content_alt,sisu_link,sisu_linked,sisu_break,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker ";\[[^}].\{-}\];[a-z]\+"
endif

"% "URLs Numbers And ASCII Codes:
syn match   sisu_number                              "\<\(0x\x\+\|0b[01]\+\|0\o\+\|0\.\d\+\|0\|[1-9][\.0-9_]*\)\>"
syn match   sisu_number                              "?\(\\M-\\C-\|\\c\|\\C-\|\\M-\)\=\(\\\o\{3}\|\\x\x\{2}\|\\\=\w\)"

"% "Tuned Error: (is error if not already matched)
syn match sisu_error             contains=sisu_error "[\~/\*!_]{\|}[\~/\*!_]"
syn match sisu_error             contains=sisu_error "<a href\|</a>]"

"% "Simple Paired Enclosed Markup:
"url/link
syn region sisu_link contains=sisu_error,sisu_error_wspace matchgroup=sisu_action start="^<<\s*|[a-zA-Z0-9^._-]\+|@|[a-zA-Z0-9^._-]\+|"rs=s+2 end="$"

"% "Document Header:
" title
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_title matchgroup=sisu_header start="^[@]title:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" creator
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_creator matchgroup=sisu_header start="^[@]creator:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" dates
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_date matchgroup=sisu_header start="^[@]date:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" publisher
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_publisher matchgroup=sisu_header start="^[@]publisher:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" rights
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_rights matchgroup=sisu_header start="^[@]rights:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" classify document
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_classify matchgroup=sisu_header start="^[@]classify:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" identifier document
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_identifier matchgroup=sisu_header start="^[@]identifier:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" original language (depreciated)
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_original matchgroup=sisu_header start="^[@]original:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" notes
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_notes matchgroup=sisu_header start="^[@]notes:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" links of interest
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_linked,sisu_sub_header_links matchgroup=sisu_header start="^[@]links:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" make, processing instructions
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_make matchgroup=sisu_header start="^[@]make:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"

"% "Headings:
syn region sisu_heading contains=sisu_mark_endnote,sisu_content_endnote,sisu_marktail,sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_ocn,sisu_error,sisu_error_wspace matchgroup=sisu_structure start="^\([1-4]\|:\?[A-D]\)\~\(\S\+\|[^-]\)" end="$"

"% "Block Group Text:
" table
syn region sisu_content_alt contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^table{.\+" end="}table"
" table
syn region sisu_content_alt contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^```\s\+table" end="^```\(\s\|$\)"
syn region sisu_content_alt contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^{\(t\|table\)\(\~h\)\?\(\sc[0-9]\+;\)\?[0-9; ]*}" end="\n$"
" block, group, poem, alt
syn region sisu_content_alt contains=sisu_mark_endnote,sisu_content_endnote,sisu_link,sisu_mark,sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^\z(block\|group\|poem\|alt\){" end="^}\z1"
syn region sisu_content_alt contains=sisu_mark_endnote,sisu_content_endnote,sisu_link,sisu_mark,sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^```\s\+\(block\|group\|poem\|alt\)" end="^```\(\s\|$\)"
" box
syn region sisu_content_alt contains=sisu_mark_endnote,sisu_content_endnote,sisu_link,sisu_mark,sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^box\(\.[a-z]\+\)\?{" end="^}box"
syn region sisu_content_alt contains=sisu_mark_endnote,sisu_content_endnote,sisu_link,sisu_mark,sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^```\s\+\box\(\.[a-z]\+\)\?" end="^```\(\s\|$\)"
" code
syn region sisu_content_alt contains=sisu_error,@NoSpell matchgroup=sisu_contain start="^code\(\.[a-z][0-9a-z_]\+\)\?{" end="^}code"
syn region sisu_content_alt contains=sisu_error,@NoSpell matchgroup=sisu_contain start="^```\s\+code\(\.[a-z][0-9a-z_]\+\)\?" end="^```\(\s\|$\)"
" quote
syn region sisu_normal contains=sisu_fontface,sisu_bold,sisu_control,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_link,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_linked,sisu_error,sisu_error_wspace matchgroup=sisu_contain start="^```\s\+quote" end="^```\(\s\|$\)"

"% "Endnotes:
" regular endnote or asterisk or plus sign endnote
syn region sisu_content_endnote contains=sisu_link,sisu_strikeout,sisu_underline,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error,sisu_error_wspace,sisu_mark,sisu_break,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker matchgroup=sisu_mark_endnote start="\~{[*+]*" end="}\~" skip="\n"
" numbered asterisk or plus sign endnote
syn region sisu_content_endnote contains=sisu_link,sisu_strikeout,sisu_underline,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error,sisu_error_wspace,sisu_mark,sisu_break,sisu_sem_block,sisu_sem_content,sisu_sem_marker matchgroup=sisu_mark_endnote start="\~\[[*+]*" end="\]\~" skip="\n"
" endnote content marker (for binary content marking)
syn region sisu_content_endnote contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_link,sisu_identifier,sisu_error,sisu_error_wspace,sisu_mark,sisu_break matchgroup=sisu_mark_endnote start="\^\~" end="\n$"

"% "Links And Images:
" image with url link (and possibly footnote of url)
syn region sisu_linked contains=sisu_fontface,sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_sem_block,sisu_error matchgroup=sisu_link start="{\(\~^\s\)\?" end="}\(https\?:/\/\|:\|\.\.\/\|#\)\S\+" oneline
" sisu outputs, short notation
syn region sisu_linked contains=sisu_fontface,sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_sem_block,sisu_error matchgroup=sisu_link start="{\(\~^\s\)\?" end="\[[1-5][sS]*\]}\S\+\.ss[tm]" oneline
" image
syn region sisu_linked contains=sisu_fontface,sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_link start="{" end="}image" oneline

"% "Some Line Operations:
" bold line
syn region sisu_bold contains=sisu_strikeout,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_error,sisu_error_wspace matchgroup=sisu_markpara start="^!_ " end=" \\\\\|$"
" indent and bullet paragraph
syn region sisu_normal contains=sisu_fontface,sisu_bold,sisu_control,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_link,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_linked,sisu_error,sisu_error_wspace matchgroup=sisu_markpara start="^_\([1-9*]\|[1-9]\*\) " end="$"
" indent and bullet (bold start) paragraph
syn region sisu_bold contains=sisu_fontface,sisu_bold,sisu_control,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_link,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_linked,sisu_error,sisu_error_wspace matchgroup=sisu_markpara start="^_\([1-9*]\|[1-9]\*\)!_\? " end=" \\\\\|$"
" hanging indent paragraph [proposed]
syn region sisu_normal contains=sisu_fontface,sisu_bold,sisu_control,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_link,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_linked,sisu_error,sisu_error_wspace matchgroup=sisu_markpara start="^_[0-9]\?_[0-9] " end="$"
" hanging indent (bold start/ definition) paragraph [proposed]
syn region sisu_bold contains=sisu_fontface,sisu_bold,sisu_control,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_link,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_linked,sisu_error,sisu_error_wspace matchgroup=sisu_markpara start="^_[0-9]\?_[0-9]!_\? " end=" \\\\\|$"
" list numbering
syn region sisu_normal contains=sisu_strikeout,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_link,sisu_linked,sisu_error,sisu_error_wspace matchgroup=sisu_markpara start="^\(#[ 1]\|_# \)" end="$"

"% "Font Face Curly Brackets:
"syn region sisu_identifier contains=sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_sem start="\S\+:{" end="}:[^<>,.!?:; ]\+" oneline
" book index:
syn region sisu_index contains=sisu_within_index_ignore,sisu_within_index matchgroup=sisu_index_block start="^={" end="}"
" emphasis:
syn region sisu_bold contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_fontface start="\*{" end="}\*"
" bold:
syn region sisu_bold contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_fontface start="!{" end="}!"
" underscore:
syn region sisu_underline contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_fontface start="_{" end="}_"
" italics:
syn region sisu_identifier contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_fontface start="/{" end="}/"
" added:
syn region sisu_underline contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_fontface start="+{" end="}+"
" superscript:
syn region sisu_identifier contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_fontface start="\^{" end="}\^"
" subscript:
syn region sisu_identifier contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_fontface start=",{" end="},"
" monospace:
syn region sisu_identifier contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_fontface start="#{" end="}#"
" strikethrough:
syn region sisu_strikeout contains=sisu_error matchgroup=sisu_fontface start="-{" end="}-"

"% "Single Words Bold Italicise Etc: (depreciated)
syn region sisu_bold contains=sisu_error matchgroup=sisu_bold start="\([ (]\|^\)\*[^\|{\n\~\\]"hs=e-1 end="\*"he=e-0 skip="[a-zA-Z0-9']" oneline
syn region sisu_identifier contains=sisu_error matchgroup=sisu_content_alt start="\([ ]\|^\)/[^{ \|\n\\]"hs=e-1 end="/\[ \.\]" skip="[a-zA-Z0-9']" oneline
"misc
syn region sisu_identifier contains=sisu_error matchgroup=sisu_fontface start="\^[^ {\|\n\\]"rs=s+1 end="\^[ ,.;:'})\\\n]" skip="[a-zA-Z0-9']" oneline

"% "Expensive Mode:
if !exists("sisu_no_expensive")
else " not Expensive
  syn region  sisu_content_alt  matchgroup=sisu_control start="^\s*def\s" matchgroup=NONE end="[?!]\|\>" skip="\.\|\(::\)" oneline
endif " Expensive?

"% "Headers And Headings: (Document Instructions)
syn match sisu_control contains=sisu_error,sisu_error_wspace "4\~! \S\+"
syn region  sisu_markpara contains=sisu_error,sisu_error_wspace start="^=begin" end="^=end.*$"

"% "Errors:
syn match sisu_error_wspace contains=sisu_error_wspace "^\s\+[^:]"
syn match sisu_error_wspace contains=sisu_error_wspace "\s\s\+"
syn match sisu_error_wspace contains=sisu_error_wspace "\s\+$"
syn match sisu_error contains=sisu_error_wspace "\t\+"
syn match sisu_error contains=sisu_error,sisu_error_wspace "\([^ (][_\\]\||[^ (}]\)https\?:\S\+"
syn match sisu_error contains=sisu_error "_\?https\?:\S\+[}><]"
syn match sisu_error contains=sisu_error "\([!*/_\+,^]\){\([^(\}\1)]\)\{-}\n$"
syn match sisu_error contains=sisu_error "^[\~]{[^{]\{-}\n$"
syn match sisu_error contains=sisu_error "\s\+.{{"
syn match sisu_error contains=sisu_error "^\~\s*$"
syn match sisu_error contains=sisu_error "^0\~.*"
syn match sisu_error contains=sisu_error "^[1-9]\~\s*$"
syn match sisu_error contains=sisu_error "^[1-9]\~\S\+\s*$"
syn match sisu_error contains=sisu_error "[^{]\~\^[^ \)]"
syn match sisu_error contains=sisu_error "\~\^\s\+\.\s*"
syn match sisu_error contains=sisu_error "{\~^\S\+"
syn match sisu_error contains=sisu_error "[_/\*!^]{[ .,:;?><]*}[_/\*!^]"
syn match sisu_error contains=sisu_error "[^ (\"'(\[][_/\*!]{\|}[_/\*!][a-zA-Z0-9)\]\"']"
syn match sisu_error contains=sisu_error "<dir>"
"errors for filetype sisu, though not error in 'metaverse':
syn match sisu_error contains=sisu_error,sisu_match,sisu_strikeout,sisu_contain,sisu_content_alt,sisu_mark,sisu_break,sisu_number "<[a-zA-Z\/]\+>"
syn match sisu_error  "/\?<\([biu]\)>[^(</\1>)]\{-}\n$"

"% "Error Exceptions:
syn match sisu_control "\n$" "contains=ALL
"syn match sisu_control " //"
syn match sisu_error   "%{"
syn match sisu_error   "<br>_\?https\?:\S\+\|_\?https\?:\S\+<br>"
syn match sisu_error   "[><]_\?https\?:\S\+\|_\?https\?:\S\+[><]"
syn match sisu_comment "^%\{1,2\}.\+"

"% "Definitions Default Highlighting:
hi def link sisu_normal                Normal
hi def link sisu_bold                  Statement
hi def link sisu_header                PreProc
hi def link sisu_header_content        Normal
hi def link sisu_sub_header_title      Statement
hi def link sisu_sub_header_creator    Statement
hi def link sisu_sub_header_date       Statement
hi def link sisu_sub_header_publisher  Statement
hi def link sisu_sub_header_rights     Statement
hi def link sisu_sub_header_classify   Statement
hi def link sisu_sub_header_identifier Statement
hi def link sisu_sub_header_original   Statement
hi def link sisu_sub_header_links      Statement
hi def link sisu_sub_header_notes      Statement
hi def link sisu_sub_header_make       Statement
hi def link sisu_heading               Title
hi def link sisu_structure             Operator
hi def link sisu_contain               Include
hi def link sisu_mark_endnote          Delimiter
hi def link sisu_require               NonText
hi def link sisu_link                  NonText
hi def link sisu_linked                String
hi def link sisu_fontface              Delimiter
hi def link sisu_strikeout             DiffDelete
hi def link sisu_content_alt           Special
hi def link sisu_sem_content           SpecialKey
hi def link sisu_sem_block             Special
hi def link sisu_sem_marker            Visual
"hi def link sisu_sem_marker            Structure
hi def link sisu_sem_marker_block      MatchParen
hi def link sisu_sem_ex_marker         FoldColumn
hi def link sisu_sem_ex_marker_block   Folded
hi def link sisu_sem_ex_content        Comment
"hi def link sisu_sem_ex_content        SpecialKey
hi def link sisu_sem_ex_block          Comment
hi def link sisu_index                 SpecialKey
hi def link sisu_index_block           Visual
hi def link sisu_content_endnote       Special
hi def link sisu_control               Delimiter
hi def link sisu_within_index          Delimiter
hi def link sisu_within_index_ignore   SpecialKey
hi def link sisu_ocn                   Include
hi def link sisu_number                Number
hi def link sisu_identifier            Function
hi def link sisu_underline             Underlined
hi def link sisu_markpara              Include
hi def link sisu_marktail              Include
hi def link sisu_mark                  Identifier
hi def link sisu_break                 Structure
hi def link sisu_html                  Type
hi def link sisu_action                Identifier
hi def link sisu_comment               Comment
hi def link sisu_error_sem_marker      Error
hi def link sisu_error_wspace          Error
hi def link sisu_error                 Error
let b:current_syntax = "sisu"
let &cpo = s:cpo_save
unlet s:cpo_save
#+END_SRC

*** sisu-spine.vim

#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/syntax/sisu-spine.vim"
#+BEGIN_SRC text
" SiSU Vim syntax    file (sisu-spine) - Vim 8 fallback (regex)
" SiSU Maintainer:   Ralph Amissah <ralph.amissah@gmail.com>
" SiSU Markup:       SiSU (sisu-5.6.7)
" sisu-spine Markup: sisu-spine
" Last Change:       2017-06-22, 2025-02-21, 2026-05-09
" URL: <https://git.sisudoc.org/projects/sisudoc-spine/tree/sundry/editor-syntax-etc/vim/syntax/sisu-spine.vim>
"      <https://git.sisudoc.org/projects/sisudoc-spine/tree/sundry/editor-syntax-etc/vim/syntax/sisu.vim>
"      <https://sisudoc.org/>
"(originally looked at Ruby Vim by Mirko Nasato)
"
" Status: This is the regex-based Vim 8 fallback. For Neovim users, the
" tree-sitter-sisu grammar provides structural highlighting, folding and
" textobjects with strictly better behaviour on nested markup, multi-line
" footnotes, block bodies, and segmented headings; see
"   sundry/editor-syntax-etc/nvim/README.md
" Emacs 29+ users have an equivalent treesit-based mode at
"   sundry/editor-syntax-etc/emacs/sisu-spine-ts-mode.el
" This file remains the supported path for classic Vim, where tree-sitter
" is not available without third-party plugins.

if version < 600
  syntax clear
elseif exists("b:current_syntax")
  finish
else
endif
let s:cpo_save = &cpo
set cpo&vim

"% "Errors:
syn match sisu_error contains=sisu_link,sisu_error_wspace "<![^ei]\S\+!>"

"% "Markers Identifiers:
if !exists("sisu_no_identifiers")
  syn match   sisu_mark_endnote                                           "\~^"
  syn match   sisu_break               contains=@NoSpell                  " \\\\\( \|$\)\|<br>\|<br />"
  syn match   sisu_control             contains=@NoSpell                  "^\(-\\\\-\|=\\\\=\|-\.\.-\|<:p[bn]>\)\s*$"
  syn match   sisu_control             contains=@NoSpell                  "^<:\(bo\|---\)>\s*$"
  syn match   sisu_marktail            contains=@NoSpell                  "^--[+~-]#\s*$"
  syn match   sisu_marktail                                               "[~-]#"
  syn match   sisu_control                                                "\""
  syn match   sisu_underline                                              "\(^\| \)_[a-zA-Z0-9]\+_\([ .,]\|$\)"
  syn match   sisu_number              contains=@NoSpell                  "[0-9a-f]\{32\}\|[0-9a-f]\{64\}"
  syn match   sisu_link                contains=@NoSpell                  "\(_\?https\?://\|\.\.\/\)\S\+"
  syn match   sisu_link                                                   " \*\~\S\+"
  syn match   sisu_require             contains=@NoSpell                  "^<<\s*[a-zA-Z0-9^./_-]\+\.ss[it]$"
  syn match   sisu_structure                                              "^:A\~$"

"% "Document Sub Headers:
  syn match   sisu_sub_header_title                                       "^\s\+:\(subtitle\|short\|edition\|language\|lang_char\|note\):\s" "group=sisu_header_content
  syn match   sisu_sub_header_creator                                     "^\s\+:\(author\|editor\|contributor\|illustrator\|photographer\|translator\|digitized_by\|prepared_by\|audio\|video\):\s"                               " &hon &institution
  syn match   sisu_sub_header_rights                                      "^\s\+:\(copyright\|text\|translation\|illustrations\|photographs\|preparation\|digitization\|audio\|video\|license\|all\):\s"                   " access_rights license
  syn match   sisu_sub_header_classify                                    "^\s\+:\(topic_register\|keywords\|subject\|dewey\|loc\):\s"
  syn match   sisu_sub_header_identifier                                  "^\s\+:\(oclc\|isbn\):\s"
  syn match   sisu_sub_header_date                                        "^\s\+:\(added_to_site\|available\|created\|issued\|modified\|published\|valid\|translated\|original_publication\):\s"
  syn match   sisu_sub_header_original                                    "^\s\+:\(publisher\|date\|language\|lang_char\|institution\|nationality\|source\):\s"
  syn match   sisu_sub_header_make                                        "^\s\+:\(headings\|num_top\|breaks\|language\|italics\|bold\|emphasis\|substitute\|omit\|plaintext_wrap\|texpdf_font_mono\|texpdf_font\|stamp\|promo\|ad\|manpage\|home_button_text\|home_button_image\|cover_image\|footer\):\s"
  syn match   sisu_sub_header_notes                                       "^\s\+:\(description\|abstract\|comment\|coverage\|relation\|source\|history\|type\|format\|prefix\|prefix_[ab]\|suffix\):\s"
  syn match   sisu_within_index_ignore                                    "\S\+[:;]\(\s\+\|$\)"
  syn match   sisu_within_index                                           "[:|;]\|+\d\+"

"% "semantic markers: (ignore)
  syn match   sisu_sem_marker                                             ";{\|};[a-z._]*[a-z]"
  syn match   sisu_sem_marker_block                                       "\([a-z][a-z._]*\|\):{\|}:[a-z._]*[a-z]"
  syn match   sisu_sem_ex_marker                                          ";\[\|\];[a-z._]*[a-z]"
  syn match   sisu_sem_ex_marker_block                                    "\([a-z][a-z._]*\|\):\[\|\]:[a-z._]*[a-z]"
  syn match   sisu_sem_block contains=sisu_error,sisu_error_wspace,sisu_content_alt,sisu_link,sisu_linked,sisu_break,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_mark_endnote,sisu_content_endnote "\([a-z]*\):{[^}].\{-}}:\1"
  syn match   sisu_sem_content contains=sisu_error,sisu_error_wspace,sisu_content_alt,sisu_link,sisu_linked,sisu_break,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker ";{[^}].\{-}};[a-z]\+"
  syn match   sisu_sem_ex_block contains=sisu_error,sisu_error_wspace,sisu_content_alt,sisu_link,sisu_linked,sisu_break,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_mark_endnote,sisu_content_endnote "\([a-z]*\):\[[^}].\{-}\]:\1"
  syn match   sisu_sem_ex_content contains=sisu_error,sisu_error_wspace,sisu_content_alt,sisu_link,sisu_linked,sisu_break,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker ";\[[^}].\{-}\];[a-z]\+"
endif

"% "URLs Numbers And ASCII Codes:
syn match   sisu_number                              "\<\(0x\x\+\|0b[01]\+\|0\o\+\|0\.\d\+\|0\|[1-9][\.0-9_]*\)\>"
syn match   sisu_number                              "?\(\\M-\\C-\|\\c\|\\C-\|\\M-\)\=\(\\\o\{3}\|\\x\x\{2}\|\\\=\w\)"

"% "Tuned Error: (is error if not already matched)
syn match sisu_error             contains=sisu_error "[\~/\*!_]{\|}[\~/\*!_]"
syn match sisu_error             contains=sisu_error "<a href\|</a>]"

"% "Simple Paired Enclosed Markup:
"url/link
syn region sisu_link contains=sisu_error,sisu_error_wspace matchgroup=sisu_action start="^<<\s*|[a-zA-Z0-9^._-]\+|@|[a-zA-Z0-9^._-]\+|"rs=s+2 end="$"

"% "Document Header:
" title
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_title matchgroup=sisu_header start="^[@]title:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" creator
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_creator matchgroup=sisu_header start="^[@]creator:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" dates
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_date matchgroup=sisu_header start="^[@]date:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" publisher
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_publisher matchgroup=sisu_header start="^[@]publisher:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" rights
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_rights matchgroup=sisu_header start="^[@]rights:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" classify document
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_classify matchgroup=sisu_header start="^[@]classify:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" identifier document
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_identifier matchgroup=sisu_header start="^[@]identifier:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" original language (depreciated)
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_original matchgroup=sisu_header start="^[@]original:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" notes
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_notes matchgroup=sisu_header start="^[@]notes:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" links of interest
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_linked,sisu_sub_header_links matchgroup=sisu_header start="^[@]links:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
" make, processing instructions
syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_make matchgroup=sisu_header start="^[@]make:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"

"% "Headings:
syn region sisu_heading contains=sisu_mark_endnote,sisu_content_endnote,sisu_marktail,sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_ocn,sisu_error,sisu_error_wspace matchgroup=sisu_structure start="^\([1-4]\|:\?[A-D]\)\~\(\S\+\|[^-]\)" end="$"

"% "Block Group Text:
" table
syn region sisu_content_alt contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^table{.\+" end="}table"
" table
syn region sisu_content_alt contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^```\s\+table" end="^```\(\s\|$\)"
syn region sisu_content_alt contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^'''\s\+table" end="^'''\(\s\|$\)"
syn region sisu_content_alt contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^{\(t\|table\)\(\~h\)\?\(\sc[0-9]\+;\)\?[0-9; ]*}" end="\n$"
" block, group, poem, alt
syn region sisu_content_alt contains=sisu_mark_endnote,sisu_content_endnote,sisu_link,sisu_mark,sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^\z(block\|group\|poem\|alt\){" end="^}\z1"
syn region sisu_content_alt contains=sisu_mark_endnote,sisu_content_endnote,sisu_link,sisu_mark,sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^```\s\+\(block\|group\|poem\|alt\)" end="^```\(\s\|$\)"
syn region sisu_content_alt contains=sisu_mark_endnote,sisu_content_endnote,sisu_link,sisu_mark,sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^'''\s\+\(block\|group\|poem\|alt\)" end="^'''\(\s\|$\)"
" box
syn region sisu_content_alt contains=sisu_mark_endnote,sisu_content_endnote,sisu_link,sisu_mark,sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^box\(\.[a-z]\+\)\?{" end="^}box"
syn region sisu_content_alt contains=sisu_mark_endnote,sisu_content_endnote,sisu_link,sisu_mark,sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^```\s\+\box\(\.[a-z]\+\)\?" end="^```\(\s\|$\)"
syn region sisu_content_alt contains=sisu_mark_endnote,sisu_content_endnote,sisu_link,sisu_mark,sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^'''\s\+\box\(\.[a-z]\+\)\?" end="^'''\(\s\|$\)"
" code
syn region sisu_content_alt contains=sisu_error,@NoSpell matchgroup=sisu_contain start="^code\(\.[a-z][0-9a-z_]\+\)\?{" end="^}code"
syn region sisu_content_alt contains=sisu_error,@NoSpell matchgroup=sisu_contain start="^```\s\+code\(\.[a-z][0-9a-z_]\+\)\?" end="^```\(\s\|$\)"
syn region sisu_content_alt contains=sisu_error,@NoSpell matchgroup=sisu_contain start="^'''\s\+code\(\.[a-z][0-9a-z_]\+\)\?" end="^'''\(\s\|$\)"
" quote
syn region sisu_normal contains=sisu_fontface,sisu_bold,sisu_control,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_link,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_linked,sisu_error,sisu_error_wspace matchgroup=sisu_contain start="^```\s\+quote" end="^```\(\s\|$\)"
syn region sisu_normal contains=sisu_fontface,sisu_bold,sisu_control,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_link,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_linked,sisu_error,sisu_error_wspace matchgroup=sisu_contain start="^'''\s\+quote" end="^'''\(\s\|$\)"

"% "Endnotes:
" regular endnote or asterisk or plus sign endnote
syn region sisu_content_endnote contains=sisu_link,sisu_strikeout,sisu_underline,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error,sisu_error_wspace,sisu_mark,sisu_break,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker matchgroup=sisu_mark_endnote start="\~{[*+]*" end="}\~" skip="\n"
" numbered asterisk or plus sign endnote
syn region sisu_content_endnote contains=sisu_link,sisu_strikeout,sisu_underline,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error,sisu_error_wspace,sisu_mark,sisu_break,sisu_sem_block,sisu_sem_content,sisu_sem_marker matchgroup=sisu_mark_endnote start="\~\[[*+]*" end="\]\~" skip="\n"
" endnote content marker (for binary content marking)
syn region sisu_content_endnote contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_link,sisu_identifier,sisu_error,sisu_error_wspace,sisu_mark,sisu_break matchgroup=sisu_mark_endnote start="\^\~" end="\n$"

"% "Links And Images:
" image with url link (and possibly footnote of url)
syn region sisu_linked contains=sisu_fontface,sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_sem_block,sisu_error matchgroup=sisu_link start="{\(\~^\s\)\?" end="}\(https\?:/\/\|:\|\.\.\/\|#\)\S\+" oneline
" sisu outputs, short notation
syn region sisu_linked contains=sisu_fontface,sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_sem_block,sisu_error matchgroup=sisu_link start="{\(\~^\s\)\?" end="\[[1-5][sS]*\]}\S\+\.ss[tm]" oneline
" image
syn region sisu_linked contains=sisu_fontface,sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_link start="{" end="}image" oneline

"% "Some Line Operations:
" bold line
syn region sisu_bold contains=sisu_strikeout,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_error,sisu_error_wspace matchgroup=sisu_markpara start="^!_ " end=" \\\\\|$"
" indent and bullet paragraph
syn region sisu_normal contains=sisu_fontface,sisu_bold,sisu_control,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_link,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_linked,sisu_error,sisu_error_wspace matchgroup=sisu_markpara start="^_\([1-9*]\|[1-9]\*\) " end="$"
" indent and bullet (bold start) paragraph
syn region sisu_bold contains=sisu_fontface,sisu_bold,sisu_control,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_link,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_linked,sisu_error,sisu_error_wspace matchgroup=sisu_markpara start="^_\([1-9*]\|[1-9]\*\)!_\? " end=" \\\\\|$"
" hanging indent paragraph [proposed]
syn region sisu_normal contains=sisu_fontface,sisu_bold,sisu_control,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_link,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_linked,sisu_error,sisu_error_wspace matchgroup=sisu_markpara start="^_[0-9]\?_[0-9] " end="$"
" hanging indent (bold start/ definition) paragraph [proposed]
syn region sisu_bold contains=sisu_fontface,sisu_bold,sisu_control,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_link,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_linked,sisu_error,sisu_error_wspace matchgroup=sisu_markpara start="^_[0-9]\?_[0-9]!_\? " end=" \\\\\|$"
" list numbering
syn region sisu_normal contains=sisu_strikeout,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_link,sisu_linked,sisu_error,sisu_error_wspace matchgroup=sisu_markpara start="^\(#[ 1]\|_# \)" end="$"

"% "Font Face Curly Brackets:
"syn region sisu_identifier contains=sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_sem start="\S\+:{" end="}:[^<>,.!?:; ]\+" oneline
" book index:
syn region sisu_index contains=sisu_within_index_ignore,sisu_within_index matchgroup=sisu_index_block start="^={" end="}"
" emphasis:
syn region sisu_bold contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_fontface start="\*{" end="}\*"
" bold:
syn region sisu_bold contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_fontface start="!{" end="}!"
" underscore:
syn region sisu_underline contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_fontface start="_{" end="}_"
" italics:
syn region sisu_identifier contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_fontface start="/{" end="}/"
" added:
syn region sisu_underline contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_fontface start="+{" end="}+"
" superscript:
syn region sisu_identifier contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_fontface start="\^{" end="}\^"
" subscript:
syn region sisu_identifier contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_fontface start=",{" end="},"
" monospace:
syn region sisu_identifier contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_fontface start="#{" end="}#"
" strikethrough:
syn region sisu_strikeout contains=sisu_error matchgroup=sisu_fontface start="-{" end="}-"

"% "Single Words Bold Italicise Etc: (depreciated)
syn region sisu_bold contains=sisu_error matchgroup=sisu_bold start="\([ (]\|^\)\*[^\|{\n\~\\]"hs=e-1 end="\*"he=e-0 skip="[a-zA-Z0-9']" oneline
syn region sisu_identifier contains=sisu_error matchgroup=sisu_content_alt start="\([ ]\|^\)/[^{ \|\n\\]"hs=e-1 end="/\[ \.\]" skip="[a-zA-Z0-9']" oneline
"misc
syn region sisu_identifier contains=sisu_error matchgroup=sisu_fontface start="\^[^ {\|\n\\]"rs=s+1 end="\^[ ,.;:'})\\\n]" skip="[a-zA-Z0-9']" oneline

"% "Expensive Mode:
if !exists("sisu_no_expensive")
else " not Expensive
  syn region  sisu_content_alt  matchgroup=sisu_control start="^\s*def\s" matchgroup=NONE end="[?!]\|\>" skip="\.\|\(::\)" oneline
endif " Expensive?

"% "Headers And Headings: (Document Instructions)
syn match sisu_control contains=sisu_error,sisu_error_wspace "4\~! \S\+"
syn region  sisu_markpara contains=sisu_error,sisu_error_wspace start="^=begin" end="^=end.*$"

"% "Errors:
syn match sisu_error_wspace contains=sisu_error_wspace "^\s\+[^:]"
syn match sisu_error_wspace contains=sisu_error_wspace "\s\s\+"
syn match sisu_error_wspace contains=sisu_error_wspace "\s\+$"
syn match sisu_error contains=sisu_error_wspace "\t\+"
syn match sisu_error contains=sisu_error,sisu_error_wspace "\([^ (][_\\]\||[^ (}]\)https\?:\S\+"
syn match sisu_error contains=sisu_error "_\?https\?:\S\+[}><]"
syn match sisu_error contains=sisu_error "\([!*/_\+,^]\){\([^(\}\1)]\)\{-}\n$"
syn match sisu_error contains=sisu_error "^[\~]{[^{]\{-}\n$"
syn match sisu_error contains=sisu_error "\s\+.{{"
syn match sisu_error contains=sisu_error "^\~\s*$"
syn match sisu_error contains=sisu_error "^0\~.*"
syn match sisu_error contains=sisu_error "^[1-9]\~\s*$"
syn match sisu_error contains=sisu_error "^[1-9]\~\S\+\s*$"
syn match sisu_error contains=sisu_error "[^{]\~\^[^ \)]"
syn match sisu_error contains=sisu_error "\~\^\s\+\.\s*"
syn match sisu_error contains=sisu_error "{\~^\S\+"
syn match sisu_error contains=sisu_error "[_/\*!^]{[ .,:;?><]*}[_/\*!^]"
syn match sisu_error contains=sisu_error "[^ (\"'(\[][_/\*!]{\|}[_/\*!][a-zA-Z0-9)\]\"']"
syn match sisu_error contains=sisu_error "<dir>"
"errors for filetype sisu, though not error in 'metaverse':
syn match sisu_error contains=sisu_error,sisu_match,sisu_strikeout,sisu_contain,sisu_content_alt,sisu_mark,sisu_break,sisu_number "<[a-zA-Z\/]\+>"
syn match sisu_error  "/\?<\([biu]\)>[^(</\1>)]\{-}\n$"

"% "Error Exceptions:
syn match sisu_control "\n$" "contains=ALL
"syn match sisu_control " //"
syn match sisu_error   "%{"
syn match sisu_error   "<br>_\?https\?:\S\+\|_\?https\?:\S\+<br>"
syn match sisu_error   "[><]_\?https\?:\S\+\|_\?https\?:\S\+[><]"
syn match sisu_comment "^%\{1,2\}.\+"

"% "Definitions Default Highlighting:
hi def link sisu_normal                Normal
hi def link sisu_bold                  Statement
hi def link sisu_header                PreProc
hi def link sisu_header_content        Normal
hi def link sisu_sub_header_title      Statement
hi def link sisu_sub_header_creator    Statement
hi def link sisu_sub_header_date       Statement
hi def link sisu_sub_header_publisher  Statement
hi def link sisu_sub_header_rights     Statement
hi def link sisu_sub_header_classify   Statement
hi def link sisu_sub_header_identifier Statement
hi def link sisu_sub_header_original   Statement
hi def link sisu_sub_header_links      Statement
hi def link sisu_sub_header_notes      Statement
hi def link sisu_sub_header_make       Statement
hi def link sisu_heading               Title
hi def link sisu_structure             Operator
hi def link sisu_contain               Include
hi def link sisu_mark_endnote          Delimiter
hi def link sisu_require               NonText
hi def link sisu_link                  NonText
hi def link sisu_linked                String
hi def link sisu_fontface              Delimiter
hi def link sisu_strikeout             DiffDelete
hi def link sisu_content_alt           Special
hi def link sisu_sem_content           SpecialKey
hi def link sisu_sem_block             Special
hi def link sisu_sem_marker            Visual
"hi def link sisu_sem_marker            Structure
hi def link sisu_sem_marker_block      MatchParen
hi def link sisu_sem_ex_marker         FoldColumn
hi def link sisu_sem_ex_marker_block   Folded
hi def link sisu_sem_ex_content        Comment
"hi def link sisu_sem_ex_content        SpecialKey
hi def link sisu_sem_ex_block          Comment
hi def link sisu_index                 SpecialKey
hi def link sisu_index_block           Visual
hi def link sisu_content_endnote       Special
hi def link sisu_control               Delimiter
hi def link sisu_within_index          Delimiter
hi def link sisu_within_index_ignore   SpecialKey
hi def link sisu_ocn                   Include
hi def link sisu_number                Number
hi def link sisu_identifier            Function
hi def link sisu_underline             Underlined
hi def link sisu_markpara              Include
hi def link sisu_marktail              Include
hi def link sisu_mark                  Identifier
hi def link sisu_break                 Structure
hi def link sisu_html                  Type
hi def link sisu_action                Identifier
hi def link sisu_comment               Comment
hi def link sisu_error_sem_marker      Error
hi def link sisu_error_wspace          Error
hi def link sisu_error                 Error
let b:current_syntax = "sisu"
let &cpo = s:cpo_save
unlet s:cpo_save
#+END_SRC

** color files
*** def.vim

#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/colors/def.vim"
#+BEGIN_SRC text
"%% Vim color file
"  Name:           def
"  Maintainer:     Ralph Amissah <ralph@amissah.com>
"  Last Change:    2013-02-14, 2016-07-28, 2022-09-05
"  URL:            <https://git.sisudoc.org/projects/sisudoc-spine/tree/sundry/editor-syntax-etc/vim/colors/def.vim>
"                  <https://sisudoc.org/>
"  Note:           primarily 16 color cterm improved by tweaking of .Xdefaults
"                  (with occasional other colors selected from 256 color palate)
"                  .Xdefaults tweaking to make identical to def (256) provided,
"                  along with an alternative possibility using colors beyond
"                  256 color palate
:  hi clear
:  if exists("syntax_on") | syntax reset | endif
:  let colors_name = "def"
:  set t_Co=256
:  set background=dark
"  -------
"  terminal def
"  -------
:  hi Normal                                     ctermfg=7      ctermbg=236
:  hi Cursor                                     ctermfg=0      ctermbg=166
:  hi lCursor        cterm=reverse
:  hi CursorLine     cterm=bold,underline                                      "ctermul=166   "bg:236,59
:  hi CursorLineNr   cterm=bold                  ctermfg=0      ctermbg=166
:  hi LineNr         cterm=bold                  ctermfg=59     ctermbg=16
:  hi StatusLine     cterm=bold,reverse
:  hi StatusLineNC   cterm=reverse
:  hi StatusLineTerm cterm=bold                  ctermfg=15     ctermbg=2
:  hi StatusLineTermNC                           ctermfg=15     ctermbg=2
:  hi ColorColumn    cterm=none                  ctermfg=231    ctermbg=236                   "bg:233,59,242,67
"  hi ColorColumn     cterm=inverse
"  hi ColorColumn                                ctermfg=16     ctermbg=235
"  hi ColorColumn                                ctermfg=5      ctermbg=90
:  hi Folded         cterm=none                  ctermfg=67     ctermbg=16                     "fg:248,59,242,3,2,67
"  hi Folded         cterm=none                  ctermfg=59     ctermbg=16                     "fg:248,59,242,3
:  hi FoldColumn                                 ctermfg=4      ctermbg=69
:  hi Search         cterm=none                  ctermfg=0      ctermbg=57                     "bg:57,11
:  hi IncSearch      cterm=none                  ctermfg=0      ctermbg=154
:  hi SpecialKey                                 ctermfg=4
:  hi Visual         cterm=reverse
:  hi VisualNOS      cterm=bold,underline
:  hi MoreMsg                                    ctermfg=2
:  hi ModeMsg        cterm=bold
:  hi Question                                   ctermfg=2
:  hi Title          cterm=bold                  ctermfg=3
:  hi NonText        cterm=bold                  ctermfg=4
:  hi Directory                                  ctermfg=4
:  hi WildMenu                                   ctermfg=0      ctermbg=3
:  hi VertSplit      cterm=reverse
:  hi DiffAdd        cterm=none                  ctermfg=0      ctermbg=2
:  hi DiffChange     cterm=none                  ctermfg=0      ctermbg=7
:  hi DiffDelete     cterm=none                  ctermfg=0      ctermbg=7
:  hi DiffText       cterm=none                  ctermfg=0      ctermbg=6
:  hi String         cterm=none                  ctermfg=3
:  hi Comment        cterm=none                  ctermfg=4
:  hi Constant                                   ctermfg=1
:  hi Special                                    ctermfg=6                                     "fg:67,140,5
:  hi Identifier     cterm=none                  ctermfg=2                                     "bg:172,4,2 (default usually bold; choose orange, blue or lime green)
:  hi Statement                                  ctermfg=4
:  hi Operator                                   ctermfg=2
:  hi PreProc                                    ctermfg=1                                     "fg:2,5,140
:  hi Type                                       ctermfg=3                                     "fg:67,2
:  hi Include                                    ctermfg=1                                     "fg:124,140,5
:  hi Delimiter      cterm=none                  ctermfg=2
:  hi Ignore         cterm=bold                  ctermfg=7
:  hi Todo                                       ctermfg=0      ctermbg=3
:  hi Underlined     cterm=underline                                           "ctermul=166    "fg:4,6
:  hi Define                                     ctermfg=3
:  hi Function                                   ctermfg=6
:  hi Structure                                  ctermfg=2
:  hi MatchParen     cterm=bold                  ctermfg=7      ctermbg=4
:  hi SpellBad       cterm=underline             ctermfg=5      ctermbg=0
:  hi SpellCap       cterm=underline             ctermfg=5      ctermbg=0
:  hi SpellLocal     cterm=underline             ctermfg=5      ctermbg=0
:  hi SpellRare      cterm=underline             ctermfg=5      ctermbg=0
:  hi TrailingWhitespace                                        ctermbg=1
:  hi ExtraWhitespace                                           ctermbg=1
:  hi WarningMsg                                 ctermfg=1
:  hi ErrorMsg       cterm=bold                  ctermfg=7      ctermbg=1
:  hi Error          cterm=bold                  ctermfg=7      ctermbg=1
:  if &diff
:    highlight! link DiffText MatchParen
:  endif
"  -------
"  gui def
"  -------
:  hi Normal                                     guifg=#D3D3D3  guibg=#000000
:  hi Cursor                                     guifg=#000000  guibg=#CC9966
:  hi lCursor        gui=reverse
:  hi CursorLine     gui=bold
:  hi CursorLineNr   gui=bold                    guifg=#000000  guibg=#D75F00
:  hi CursorColumn                                               guibg=#00005F
:  hi LineNr         gui=bold                    guifg=#808080  guibg=#000000
:  hi StatusLine     gui=bold,reverse
:  hi StatusLineNC   gui=reverse
:  hi Search         gui=none                    guifg=#000000  guibg=#5F00FF
:  hi IncSearch      gui=none                    guifg=#000000  guibg=#AFFF00
:  hi SpecialKey                                 guifg=#5971AD
:  hi Visual         gui=reverse
:  hi VisualNOS      gui=bold,underline
:  hi MoreMsg                                    guifg=#4E9A06
:  hi ModeMsg        gui=bold
:  hi Question                                   guifg=#4E9A06
:  hi Title          gui=bold                    guifg=#C4A000
:  hi NonText        gui=bold                    guifg=#5971AD
:  hi Directory                                  guifg=#5971AD
:  hi WildMenu                                   guifg=#000000  guibg=#C4A000
:  hi VertSplit      gui=reverse
:  hi Folded         gui=none                    guifg=#808080  guibg=#000000
:  hi FoldColumn                                 guifg=#5971AD  guibg=#D3D3D3
:  hi DiffAdd        gui=none                    guifg=#000000  guibg=#4E9A06
:  hi DiffChange     gui=none                    guifg=#000000  guibg=#D3D3D3
:  hi DiffDelete     gui=none                    guifg=#000000  guibg=#D3D3D3
:  hi DiffText       gui=none                    guifg=#000000  guibg=#06989A
:  hi String         gui=none                    guifg=#C4A000
:  hi Comment        gui=none                    guifg=#5971AD  guibg=#000000
:  hi Constant                                   guifg=#CC0000
:  hi Special                                    guifg=#06989A
:  hi Identifier                                 guifg=#06989A
:  hi Statement                                  guifg=#4E9A06
:  hi Operator                                   guifg=#4E9A06
:  hi PreProc                                    guifg=#CC0000
:  hi Type           gui=bold                    guifg=#C4A000
:  hi Delimiter      gui=none                    guifg=#4E9A06
:  hi Ignore         gui=bold                    guifg=#D3D3D3
:  hi Todo                                       guifg=#000000  guibg=#C4A000
:  hi Underlined     gui=underline
:  hi Include                                    guifg=#CC0000
:  hi Define                                     guifg=#C4A000
:  hi Function                                   guifg=#06989A
:  hi Structure                                  guifg=#4E9A06
:  hi MatchParen     gui=bold                    guifg=#D3D3D3  guibg=#5971AD
:  hi ColorColumn                                               guibg=#00005F
:  hi SpellBad       gui=underline               guifg=#75507B  guibg=#000000
:  hi SpellCap       gui=underline               guifg=#75507B  guibg=#000000
:  hi SpellLocal     gui=underline               guifg=#75507B  guibg=#000000
:  hi SpellRare      gui=underline               guifg=#75507B  guibg=#000000
:  hi TrailingWhitespace                                        guibg=#080000
:  hi ExtraWhitespace                                           guibg=#CC0000
:  hi WarningMsg                                 guifg=#CC0000
:  hi ErrorMsg       gui=bold                    guifg=#D3D3D3  guibg=#CC0000
:  hi Error          gui=bold                    guifg=#D3D3D3  guibg=#CC0000
#+END_SRC

*** slate.vim

#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/colors/slate.vim"
#+BEGIN_SRC text
"%% SiSU Vim color file
"  Name:           Slate
"  Maintainer:     Ralph Amissah <ralph@amissah.com>
"  Last Change:    2013-02-09, 2022-09-05
"  URL:            <https://git.sisudoc.org/projects/sisudoc-spine/tree/sundry/editor-syntax-etc/vim/colors/slate.vim>
"                  <https://sisudoc.org/>
"                  <https://sisudoc.org/>
"  Notes:          cterm now uses frugal-sisu 8 colors for term
"                  (for gui originally looked at desert Hans Fugal <hans@fugal.net>
"                  <http://hans.fugal.net/vim/colors/desert.vim> (April/May 2003))
:  hi clear
:  if exists("syntax_on")
:    syntax reset
:  endif
:  let colors_name = "slate"
:  set background=dark
"  -------
"  0 = black, 1 = red, 2 = green, 3 = yellow/orange, 4 = blue, 5 = magenta, 6 = cyan, 7 = white
"  -------
:  hi Normal                                                           ctermbg=0           ctermfg=7                     guibg=grey15        guifg=white
:  hi Cursor         term=reverse             cterm=reverse                                                              guibg=khaki         guifg=slategrey
:  hi lCursor        term=reverse             cterm=reverse
:  hi StatusLine     term=reverse             cterm=bold,reverse                                               gui=none  guibg=#c2bfa5       guifg=black
:  hi StatusLineNC   term=reverse             cterm=reverse                                                    gui=none  guibg=#c2bfa5       guifg=grey40
:  hi Search         term=reverse             cterm=none               ctermbg=2           ctermfg=0                     guibg=peru          guifg=wheat
:  hi IncSearch      term=reverse             cterm=bold               ctermbg=2           ctermfg=7                     guibg=black         guifg=green
:  hi SpecialKey     term=bold                                                             ctermfg=4                                         guifg=yellowgreen
:  hi Visual         term=reverse             cterm=reverse                                                    gui=none  guibg=olivedrab     guifg=khaki
:  hi VisualNOS      term=bold,underline      cterm=bold,underline
:  hi MoreMsg        term=bold                                                             ctermfg=2                                         guifg=SeaGreen
:  hi ModeMsg        term=bold                cterm=bold                                                                                     guifg=goldenrod
:  hi Question       term=standout                                                         ctermfg=2                                         guifg=springgreen
:  hi Title          term=bold                cterm=bold                                   ctermfg=3           gui=bold                      guifg=gold
:  hi NonText        term=bold                cterm=bold                                   ctermfg=4                     guibg=grey15        guifg=RoyalBlue
:  hi LineNr         term=underline           cterm=bold               ctermbg=0           ctermfg=0*                                        guifg=grey50
:  hi Directory      term=bold                                                             ctermfg=4
:  hi WildMenu       term=standout                                     ctermbg=3           ctermfg=0                     guibg=darkyellow    guifg=black
:  hi VertSplit      term=reverse             cterm=reverse                                                    gui=none  guibg=#c2bfa5       guifg=grey40
:  hi Folded         term=standout            cterm=none               ctermbg=0           ctermfg=7                     guibg=black         guifg=grey40
:  hi FoldColumn     term=standout                                     ctermbg=7           ctermfg=4                     guibg=black         guifg=grey20
:  hi DiffChange                              cterm=none               ctermbg=7           ctermfg=0                     guibg=darkgrey      guifg=white
:  hi DiffText                                cterm=none               ctermbg=6           ctermfg=0                     guibg=darkcyan      guifg=white
:  hi DiffAdd                                 cterm=none               ctermbg=2           ctermfg=0                     guibg=darkgreen     guifg=white
:  hi DiffDelete                              cterm=none               ctermbg=7           ctermfg=0                     guibg=darkgrey      guifg=black
:  hi String                                  cterm=none                                   ctermfg=3                                         guifg=SkyBlue
:  hi Comment        term=bold                cterm=none               ctermbg=0           ctermfg=7                                         guifg=grey40
:  hi Constant       term=underline                                                        ctermfg=1                                         guifg=#ffa0a0
:  hi Special        term=bold                                                             ctermfg=6                                         guifg=darkkhaki
:  hi Identifier     term=underline                                                        ctermfg=6                                         guifg=salmon
:  hi Statement      term=bold                                                             ctermfg=6                                         guifg=CornflowerBlue
:  hi Operator       term=bold                                                             ctermfg=1                                         guifg=red
:  hi PreProc        term=underline                                    ctermbg=7           ctermfg=1                     guibg=white         guifg=red
:  hi Type           term=underline                                                        ctermfg=2                                         guifg=CornflowerBlue
:  hi Delimiter      term=none                cterm=none                                   ctermfg=1
:  hi Ignore                                  cterm=bold                                   ctermfg=7                                         guifg=grey40
:  hi Todo           term=standout                                     ctermbg=3           ctermfg=0                     guibg=yellow2       guifg=orangered
:  hi Underlined     term=underline           cterm=underline
:  hi Include                                                                              ctermfg=1                                         guifg=red
:  hi Define                                                                               ctermfg=3           gui=bold                      guifg=gold
:  hi Function                                                                             ctermfg=6                                         guifg=navajowhite
:  hi Structure                                                                            ctermfg=2                                         guifg=green
:  hi MatchParen                              cterm=bold               ctermbg=4           ctermfg=7
:  hi CursorLine                              cterm=bold,underline                                                            guibg=black
:  hi CursorColumn                            cterm=bold                                                                 guibg=black
:  hi SpellBad       term=underline,standout  cterm=none               ctermbg=7           ctermfg=0                     guibg=darkmagenta   guifg=white
:  hi SpellCap       term=underline,standout  cterm=none               ctermbg=7           ctermfg=0
:  hi SpellLocal     term=underline,standout  cterm=none               ctermbg=7           ctermfg=0                     guibg=darkmagenta   guifg=white
:  hi SpellRare      term=underline,standout  cterm=none               ctermbg=7           ctermfg=0
:  hi WarningMsg     term=standout                                                         ctermfg=1                     guibg=darkmagenta   guifg=salmon
:  hi ErrorMsg       term=standout            cterm=bold               ctermbg=1           ctermfg=7                     guibg=darkmagenta   guifg=white
:  hi Error          term=reverse             cterm=bold               ctermbg=1           ctermfg=7                     guibg=darkmagenta   guifg=white
:  if &diff
:    highlight! link DiffText MatchParen
:  endif
:  hi Black                                                            ctermbg=grey        ctermfg=black                 guibg=grey          guifg=black
:  hi Red                                                              ctermbg=black       ctermfg=red                   guibg=black         guifg=red
:  hi Magenta                                                          ctermbg=black       ctermfg=magenta               guibg=black         guifg=magenta
:  hi Blue                                                             ctermbg=black       ctermfg=blue                  guibg=black         guifg=blue
:  hi Cyan                                                             ctermbg=black       ctermfg=cyan                  guibg=black         guifg=cyan
:  hi Green                                                            ctermbg=black       ctermfg=green                 guibg=black         guifg=green
:  hi Yellow                                                           ctermbg=black       ctermfg=yellow                guibg=black         guifg=yellow
:  hi White                                                            ctermbg=black       ctermfg=white                 guibg=black         guifg=white
#+END_SRC

*** def-sisu.vim

#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/colors/def-sisu.vim"
#+BEGIN_SRC text
" Vim color file
" Name:            def-sisu
" Maintainer:      Ralph Amissah <ralph@amissah.com>
" Last Change:     2013-02-14
" URL:             <https://git.sisudoc.org/projects/sisudoc-spine/tree/sundry/editor-syntax-etc/vim/colors/def-sisu.vim>
"                  <https://sisudoc.org/>
" Note:            primarily 16 color cterm improved by tweaking of .Xdefaults
"                  (with occasional other colors selected from 256 color palate)
"                  .Xdefaults tweaking to make identical to def (256) provided,
"                  along with an alternative possibility using colors beyond
"                  256 color palate
:hi clear
if exists("syntax_on")
  syntax reset
endif
:set t_Co=256
:set background=dark
:let colors_name = "def-sisu"
" -------
" terminal def
" -------
:hi Normal                             ctermbg=0           ctermfg=7
":hi Cursor                             ctermbg=5           ctermfg=0
:hi lCursor        cterm=reverse
:hi StatusLine     cterm=bold,reverse
:hi StatusLineNC   cterm=reverse
:hi Search         cterm=none          ctermbg=57          ctermfg=0
:hi IncSearch      cterm=none          ctermbg=154         ctermfg=0
:hi SpecialKey                                             ctermfg=4
:hi Visual         cterm=reverse
:hi VisualNOS      cterm=bold,underline
:hi MoreMsg                                                ctermfg=2
:hi ModeMsg        cterm=bold
:hi Question                                               ctermfg=2
:hi Title          cterm=bold                              ctermfg=3
:hi NonText        cterm=bold                              ctermfg=4
:hi LineNr         cterm=bold          ctermbg=0           ctermfg=0*
:hi CursorLineNr   cterm=bold          ctermbg=166         ctermfg=0
:hi Directory                                              ctermfg=4
:hi WildMenu                           ctermbg=3           ctermfg=0
:hi VertSplit      cterm=reverse
:hi Folded         cterm=none          ctermbg=0           ctermfg=8
:hi FoldColumn                         ctermbg=7           ctermfg=4
:hi DiffAdd        cterm=none          ctermbg=2           ctermfg=0
:hi DiffChange     cterm=none          ctermbg=7           ctermfg=0
:hi DiffDelete     cterm=none          ctermbg=7           ctermfg=0
:hi DiffText       cterm=none          ctermbg=6           ctermfg=0
:hi String         cterm=none                              ctermfg=3
:hi Comment        cterm=none          ctermbg=0           ctermfg=4
:hi Constant                                               ctermfg=1
:hi Special                                                ctermfg=6
:hi Identifier                                             ctermfg=6
:hi Statement                                              ctermfg=6
:hi Operator                                               ctermfg=1
:hi PreProc                            ctermbg=7           ctermfg=1
:hi Type                                                   ctermfg=2
:hi Delimiter      cterm=none                              ctermfg=1
:hi Ignore         cterm=bold                              ctermfg=7
:hi Todo                               ctermbg=3           ctermfg=0
:hi Underlined     cterm=underline
:hi Include                                                ctermfg=1
:hi Define                                                 ctermfg=3
:hi Function                                               ctermfg=6
:hi Structure                                              ctermfg=2
:hi MatchParen     cterm=bold          ctermbg=4           ctermfg=7
:hi CursorLine     cterm=bold
:hi CursorColumn                       ctermbg=17
:hi ColorColumn                        ctermbg=17
:hi SpellBad       cterm=underline     ctermbg=0           ctermfg=5
:hi SpellCap       cterm=underline     ctermbg=0           ctermfg=5
:hi SpellLocal     cterm=underline     ctermbg=0           ctermfg=5
:hi SpellRare      cterm=underline     ctermbg=0           ctermfg=5
:hi TrailingWhitespace                 ctermbg=1
:hi ExtraWhitespace                    ctermbg=1
:hi WarningMsg                                             ctermfg=1
:hi ErrorMsg       cterm=bold          ctermbg=1           ctermfg=7
:hi Error          cterm=bold          ctermbg=1           ctermfg=7
" -------
" gui def
" -------
:hi Normal                             guibg=#000000       guifg=#D3D3D3
:hi Cursor                             guibg=#CC9966       guifg=#000000
:hi lCursor        gui=reverse
:hi StatusLine     gui=bold,reverse
:hi StatusLineNC   gui=reverse
:hi Search         gui=none            guibg=#5F00FF       guifg=#000000
:hi IncSearch      gui=none            guibg=#AFFF00       guifg=#000000
:hi SpecialKey                                             guifg=#5971AD
:hi Visual         gui=reverse
:hi VisualNOS      gui=bold,underline
:hi MoreMsg                                                guifg=#4E9A06
:hi ModeMsg        gui=bold
:hi Question                                               guifg=#4E9A06
:hi Title          gui=bold                                guifg=#C4A000
:hi NonText        gui=bold                                guifg=#5971AD
:hi LineNr         gui=bold            guibg=#000000       guifg=#808080
:hi CursorLineNr   gui=bold            guibg=#D75F00       guifg=#000000
:hi Directory                                              guifg=#5971AD
:hi WildMenu                           guibg=#C4A000       guifg=#000000
:hi VertSplit      gui=reverse
:hi Folded         gui=none            guibg=#000000       guifg=#808080
:hi FoldColumn                         guibg=#D3D3D3       guifg=#5971AD
:hi DiffAdd        gui=none            guibg=#4E9A06       guifg=#000000
:hi DiffChange     gui=none            guibg=#D3D3D3       guifg=#000000
:hi DiffDelete     gui=none            guibg=#D3D3D3       guifg=#000000
:hi DiffText       gui=none            guibg=#06989A       guifg=#000000
:hi String         gui=none                                guifg=#C4A000
:hi Comment        gui=none            guibg=#000000       guifg=#5971AD
:hi Constant                                               guifg=#CC0000
:hi Special                                                guifg=#06989A
:hi Identifier                                             guifg=#06989A
:hi Statement                                              guifg=#06989A
:hi Operator                                               guifg=#CC0000
:hi PreProc                            guibg=#D3D3D3       guifg=#CC0000
:hi Type                                                   guifg=#4E9A06
:hi Delimiter      gui=none                                guifg=#CC0000
:hi Ignore         gui=bold                                guifg=#D3D3D3
:hi Todo                               guibg=#C4A000       guifg=#000000
:hi Underlined     gui=underline
:hi Include                                                guifg=#CC0000
:hi Define                                                 guifg=#C4A000
:hi Function                                               guifg=#06989A
:hi Structure                                              guifg=#4E9A06
:hi MatchParen     gui=bold            guibg=#5971AD       guifg=#D3D3D3
:hi CursorLine     gui=bold
:hi CursorColumn                       guibg=#00005F
:hi ColorColumn                        guibg=#00005F
:hi SpellBad       gui=underline       guibg=#000000       guifg=#75507B
:hi SpellCap       gui=underline       guibg=#000000       guifg=#75507B
:hi SpellLocal     gui=underline       guibg=#000000       guifg=#75507B
:hi SpellRare      gui=underline       guibg=#000000       guifg=#75507B
:hi TrailingWhitespace                 guibg=#080000
:hi ExtraWhitespace                    guibg=#CC0000
:hi WarningMsg                                             guifg=#CC0000
:hi ErrorMsg       gui=bold            guibg=#CC0000       guifg=#D3D3D3
:hi Error          gui=bold            guibg=#CC0000       guifg=#D3D3D3
" -------
"256 color .Xdefaults vim: cterm giu
"<https://vim.wikia.com/wiki/Xterm256_color_names_for_console_Vim>
"<https://guns.github.com/xterm-color-table.vim/images/xterm-color-table-with-visible-rgb.png>
" -------
" 256 color .Xdefaults vim: cterm giu def
" -------
"      16 color     standard     altered 256     altered beyond 256
" black/dark grey
"        0        [ 0:#000000]                   #000000
"        8        [ 8:#808080]   [59:#5F5F5F]    #555555
" red
"        1        [ 1:#800000]   160:#DF0000     #CC0000
"        9        [ 9:#FF0000]                   #EF2929
" green
"        2        [ 2:#008000]   112:#87DF00     #4E9A06
"       10        [10:#00FF00]   154:#AFFF00     #8AE234
" yellow/orange
"        3        [ 3:#808000]   178:#DFAF00     #C4A000
"       11        [11:#FFFF00]   184:#DFDF00     #FC9E4F
" blue
"        4        [ 4:#000080]    24:#005F87     #5971AD
"       12        [12:#0000FF]    73:#5FAFAF     #729FCF
" magenta
"        5        [ 5:#800080]    90:#870087     #75507B
"       13        [13:#FF00FF]   126:#AF0087     #AD7FA8
" cyan
"        6        [ 6:#008080]    37:#00AFAF     #06989A
"       14        [14:#00FFFF]    87:#5FFFFF     #34E2E2
" white
"        7        [ 7:#C0C0C0]                   #D3D3D3
"       15        [15:#FFFFFF]                   #EEEEEE
" --------
" .Xdefaults (rxvt urxvt setting beyond 256 colors, vim colorscheme "def" gui settings)
" (vim colorscheme "def" cterm matches "def" gui if .Xdefaults set thus)
" --------
" ! black
" Rxvt.color0  : #000000
" Rxvt.color8  : #555555
" ! red
" Rxvt.color1  : #CC0000
" Rxvt.color9  : #EF2929
" ! green
" Rxvt.color2  : #4E9A06
" Rxvt.color10 : #8AE234
" ! yellow
" Rxvt.color3  : #C4A000
" Rxvt.color11 : #FCE94F
" ! blue
" Rxvt.color4  : #5971AD
" Rxvt.color12 : #729FCF
" ! magenta
" Rxvt.color5  : #75507B
" Rxvt.color13 : #AD7FA8
" ! cyan
" Rxvt.color6  : #06989A
" Rxvt.color14 : #34E2E2
" ! white
" Rxvt.color7  : #D3D7CF
" Rxvt.color15 : #EEEEEE
" --------
" .Xdefaults 256 (rxvt urxvt setting, vim colorscheme "def256" cterm & gui settings)
" (vim colorscheme "def" cterm matches "def256" if .Xdefaults set thus)
" --------
" ! black
" Rxvt.color0  : #000000
" Rxvt.color8  : #808080
" ! red
" Rxvt.color1  : #DF0000
" Rxvt.color9  : #FF0000
" ! green
" Rxvt.color2  : #87DF00
" Rxvt.color10 : #AFFF00
" ! yellow
" Rxvt.color3  : #DFAF00
" Rxvt.color11 : #FFFF00
" ! blue
" Rxvt.color4  : #5F87DF
" Rxvt.color12 : #87DFFF
" ! magenta
" Rxvt.color5  : #8700DF
" Rxvt.color13 : #87DFFF
" ! cyan
" Rxvt.color6  : #00DFDF
" Rxvt.color14 : #5F5FDF
" ! white
" Rxvt.color7  : #C0C0C0
" Rxvt.color15 : #FFFFFF
#+END_SRC

*** redo.vim

#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/colors/redo.vim"
#+BEGIN_SRC text
"%% Vim color file
"  Name:            redo
"  Maintainer:      Ralph Amissah <ralph@amissah.com>
"  Last Change:     2013-02-14, 2016-07-28, 2022-09-05
"  URL:             <>
"  Note:            this is a redo of def

:  hi clear
:  if exists("syntax_on") | syntax reset | endif
:  let colors_name = "redo"
:  set t_Co=256
:  set background=dark
"  -------
"  terminal def
"  -------
:  hi Normal                                     ctermfg=7      ctermbg=234
:  hi Cursor                                     ctermfg=0      ctermbg=166
:  hi lCursor        cterm=reverse
:  hi CursorLine     cterm=bold,underline                                      "ctermul=242   "bg:236,59
:  hi CursorLineNr   cterm=bold                  ctermfg=0      ctermbg=166
:  hi LineNr         cterm=none                  ctermfg=248    ctermbg=236
:  hi StatusLine     cterm=bold,reverse
:  hi StatusLineNC   cterm=reverse
:  hi StatusLineTerm cterm=bold                  ctermfg=15     ctermbg=2
:  hi StatusLineTermNC                           ctermfg=15     ctermbg=2
:  hi ColorColumn                                ctermfg=231    ctermbg=236                   "bg:233,59,236
"  hi ColorColumn     cterm=inverse
"  hi ColorColumn                                ctermfg=16     ctermbg=235
"  hi ColorColumn                                ctermfg=5      ctermbg=90
:  hi Folded         cterm=none                  ctermfg=248    ctermbg=0                     "fg:248,59,242,3
:  hi FoldColumn                                 ctermfg=4      ctermbg=69
:  hi Search         cterm=none                  ctermfg=0      ctermbg=57                    "bg:57,11
:  hi IncSearch      cterm=none                  ctermfg=0      ctermbg=154
:  hi SpecialKey                                 ctermfg=4
:  hi Visual         cterm=reverse
:  hi VisualNOS      cterm=bold,underline
:  hi MoreMsg                                    ctermfg=2
:  hi ModeMsg        cterm=bold
:  hi Question                                   ctermfg=2
:  hi Title          cterm=bold                  ctermfg=3
:  hi NonText        cterm=bold                  ctermfg=4
:  hi Directory                                  ctermfg=4
:  hi WildMenu                                   ctermfg=0      ctermbg=3
:  hi VertSplit      cterm=reverse
:  hi DiffAdd        cterm=none                  ctermfg=0      ctermbg=2
:  hi DiffChange     cterm=none                  ctermfg=0      ctermbg=7
:  hi DiffDelete     cterm=none                  ctermfg=0      ctermbg=7
:  hi DiffText       cterm=none                  ctermfg=0      ctermbg=6
:  hi String         cterm=none                  ctermfg=3
:  hi Comment        cterm=none                  ctermfg=244
:  hi Constant                                   ctermfg=124
:  hi Special                                    ctermfg=67                                   "fg:67,140,5
:  hi Identifier     cterm=none                  ctermfg=172                                  "bg:172,4,2 (default usually bold; choose orange, blue or lime green)
:  hi Statement                                  ctermfg=130
:  hi Operator                                   ctermfg=2
:  hi PreProc                                    ctermfg=196                                  "fg:2,5,140,1,166,196
:  hi Type                                       ctermfg=67                                   "fg:67,2
:  hi Include                                    ctermfg=124                                  "fg:124,140,5
:  hi Delimiter      cterm=none                  ctermfg=2
:  hi Ignore         cterm=bold                  ctermfg=7
:  hi Todo                                       ctermfg=0      ctermbg=3
:  hi Underlined     cterm=underline             ctermfg=4                     "ctermul=6     "fg:4,6
:  hi Define                                     ctermfg=3
:  hi Function                                   ctermfg=6
:  hi Structure                                  ctermfg=2
:  hi MatchParen     cterm=bold                  ctermfg=7      ctermbg=4
:  hi SpellBad       cterm=underline             ctermfg=5      ctermbg=0
:  hi SpellCap       cterm=underline             ctermfg=5      ctermbg=0
:  hi SpellLocal     cterm=underline             ctermfg=5      ctermbg=0
:  hi SpellRare      cterm=underline             ctermfg=5      ctermbg=0
:  hi TrailingWhitespace                                        ctermbg=1
:  hi ExtraWhitespace                                           ctermbg=1
:  hi WarningMsg                                 ctermfg=1
:  hi ErrorMsg       cterm=bold                  ctermfg=7      ctermbg=1
:  hi Error          cterm=bold                  ctermfg=7      ctermbg=1
:  if &diff
:    highlight! link DiffText MatchParen
:  endif
#+END_SRC

*** shift.vim

#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/colors/shift.vim"
#+BEGIN_SRC text
"%% Vim color file
"  Name:            shift
"  Maintainer:      Ralph Amissah <ralph@amissah.com>
"  Last Change:     2013-02-14, 2016-07-28, 2022-09-09
"  URL:             <>
"  Note:            this is a shift in redo which as a redo of def

:  hi clear
:  if exists("syntax_on") | syntax reset | endif
:  let colors_name = "shift"
:  set t_Co=256
:  set background=dark
"  -------
"  terminal def
"  -------
:  hi Normal                                     ctermfg=7      ctermbg=234
:  hi Cursor                                     ctermfg=0      ctermbg=166
:  hi lCursor        cterm=reverse
:  hi CursorLine     cterm=bold,underline                                      ctermul=166    "bg:236,59
:  hi CursorLineNr   cterm=bold                  ctermfg=0      ctermbg=166
:  hi LineNr         cterm=none                  ctermfg=248    ctermbg=236
:  hi StatusLine     cterm=bold,reverse
:  hi StatusLineNC   cterm=reverse
:  hi StatusLineTerm cterm=bold                  ctermfg=15     ctermbg=2
:  hi StatusLineTermNC                           ctermfg=15     ctermbg=2
:  hi ColorColumn    cterm=none                  ctermfg=7      ctermbg=236                   "bg:233,59
"  hi ColorColumn     cterm=inverse
"  hi ColorColumn                                ctermfg=16     ctermbg=235
"  hi ColorColumn                                ctermfg=5      ctermbg=90
:  hi Folded         cterm=none                  ctermfg=242    ctermbg=16                    "fg:248,59,242,3
:  hi FoldColumn                                 ctermfg=4      ctermbg=69
:  hi Search         cterm=none                  ctermfg=0      ctermbg=57                    "bg:57,11
:  hi IncSearch      cterm=none                  ctermfg=0      ctermbg=154
:  hi SpecialKey                                 ctermfg=4
:  hi Visual         cterm=reverse
:  hi VisualNOS      cterm=bold,underline
:  hi MoreMsg                                    ctermfg=2
:  hi ModeMsg        cterm=bold
:  hi Question                                   ctermfg=2
:  hi Title          cterm=bold                  ctermfg=3
:  hi NonText        cterm=bold                  ctermfg=4
:  hi Directory                                  ctermfg=4
:  hi WildMenu                                   ctermfg=0      ctermbg=3
:  hi VertSplit      cterm=reverse
:  hi DiffAdd        cterm=none                  ctermfg=0      ctermbg=2
:  hi DiffChange     cterm=none                  ctermfg=0      ctermbg=7
:  hi DiffDelete     cterm=none                  ctermfg=0      ctermbg=7
:  hi DiffText       cterm=none                  ctermfg=0      ctermbg=6
:  hi String         cterm=none                  ctermfg=3
:  hi Comment        cterm=none                  ctermfg=244
:  hi Constant                                   ctermfg=124
:  hi Special                                    ctermfg=67                                   "fg:67,140,5
:  hi Identifier     cterm=none                  ctermfg=4                                    "bg:172,4,2 (default usually bold; choose orange, blue or lime green)
:  hi Statement                                  ctermfg=130
:  hi Operator                                   ctermfg=2
:  hi PreProc                                    ctermfg=196                                  "fg:2,5,140,1,166,196
:  hi Type                                       ctermfg=67                                   "fg:67,2
:  hi Include                                    ctermfg=124                                  "fg:124,140,5
:  hi Delimiter      cterm=none                  ctermfg=2
:  hi Ignore         cterm=bold                  ctermfg=7
:  hi Todo                                       ctermfg=0      ctermbg=3
:  hi Underlined     cterm=underline             ctermfg=6                     ctermul=6      "fg:4,6
:  hi Define                                     ctermfg=3
:  hi Function                                   ctermfg=6
:  hi Structure                                  ctermfg=2
:  hi MatchParen     cterm=bold                  ctermfg=7      ctermbg=4
:  hi SpellBad       cterm=underline             ctermfg=5      ctermbg=0
:  hi SpellCap       cterm=underline             ctermfg=5      ctermbg=0
:  hi SpellLocal     cterm=underline             ctermfg=5      ctermbg=0
:  hi SpellRare      cterm=underline             ctermfg=5      ctermbg=0
:  hi TrailingWhitespace                                        ctermbg=1
:  hi ExtraWhitespace                                           ctermbg=1
:  hi WarningMsg                                 ctermfg=1
:  hi ErrorMsg       cterm=bold                  ctermfg=7      ctermbg=1
:  hi Error          cterm=bold                  ctermfg=7      ctermbg=1
:  if &diff
:    highlight! link DiffText MatchParen
:  endif
#+END_SRC

*** frugal-cterm.vim

#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/colors/frugal-cterm-sisu.vim"
#+BEGIN_SRC text
" Vim color file
" Name:            frugal-cterm-sisu
" Maintainer:      Ralph Amissah <ralph@amissah.com>
" Last Change:     2013-02-09
" URL:             <https://git.sisudoc.org/projects/sisudoc-spine/tree/sundry/editor-syntax-etc/vim/colors/frugal-cterm-sisu.vim>
"                  <https://sisudoc.org/>
" Note:            8 color cterm, related colorschemes 8 & sparse
:set background=dark
:hi clear
if exists("syntax_on")
  syntax reset
endif
:let colors_name = "frugal-cterm-sisu"
" 0 = black, 1 = red, 2 = green, 3 = yellow/orange, 4 = blue, 5 = magenta, 6 = cyan, 7 = white
:hi Normal                             ctermbg=0           ctermfg=7
:hi Cursor         cterm=reverse
:hi lCursor        cterm=reverse
:hi StatusLine     cterm=bold,reverse
:hi StatusLineNC   cterm=reverse
:hi Search         cterm=none          ctermbg=2           ctermfg=0
:hi IncSearch      cterm=bold          ctermbg=2           ctermfg=7
:hi SpecialKey                                             ctermfg=4
:hi Visual         cterm=reverse
:hi VisualNOS      cterm=bold,underline
:hi MoreMsg                                                ctermfg=2
:hi ModeMsg        cterm=bold
:hi Question                                               ctermfg=2
:hi Title          cterm=bold                              ctermfg=3
:hi NonText        cterm=bold                              ctermfg=4
:hi LineNr         cterm=bold          ctermbg=0           ctermfg=0*
:hi Directory                                              ctermfg=4
:hi WildMenu                           ctermbg=3           ctermfg=0
:hi VertSplit      cterm=reverse
:hi Folded         cterm=none          ctermbg=0           ctermfg=7
:hi FoldColumn                         ctermbg=7           ctermfg=4
:hi DiffChange     cterm=none          ctermbg=7           ctermfg=0
:hi DiffText       cterm=none          ctermbg=6           ctermfg=0
:hi DiffAdd        cterm=none          ctermbg=2           ctermfg=0
:hi DiffDelete     cterm=none          ctermbg=7           ctermfg=0
:hi String         cterm=none                              ctermfg=3
:hi Comment        cterm=none          ctermbg=0           ctermfg=7
:hi Constant                                               ctermfg=1
:hi Special                                                ctermfg=6
:hi Identifier                                             ctermfg=6
:hi Statement                                              ctermfg=6
:hi Operator                                               ctermfg=1
:hi PreProc                            ctermbg=7           ctermfg=1
:hi Type                                                   ctermfg=2
:hi Delimiter      cterm=none                              ctermfg=1
:hi Ignore         cterm=bold                              ctermfg=7
:hi Todo                               ctermbg=3           ctermfg=0
:hi Underlined     cterm=underline
:hi Include                                                ctermfg=1
:hi Define                                                 ctermfg=3
:hi Function                                               ctermfg=6
:hi Structure                                              ctermfg=2
:hi MatchParen     cterm=bold          ctermbg=4           ctermfg=7
:hi CursorLine     cterm=bold,underline
:hi CursorColumn   cterm=bold
:hi ColorColumn                        ctermbg=8
:hi SpellBad       cterm=none          ctermbg=7           ctermfg=0
:hi SpellCap       cterm=none          ctermbg=7           ctermfg=0
:hi SpellLocal     cterm=none          ctermbg=7           ctermfg=0
:hi SpellRare      cterm=none          ctermbg=7           ctermfg=0
:hi WarningMsg                                             ctermfg=1
:hi ErrorMsg       cterm=bold          ctermbg=1           ctermfg=7
:hi Error          cterm=bold          ctermbg=1           ctermfg=7
#+END_SRC

** ftplugin sisu.vim & spine.vim (for the same files)
*** sisu.vim

#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/ftplugin/sisu.vim"
#+BEGIN_SRC text
"%% SiSU Vim ftplugin
" SiSU Maintainer: Ralph Amissah <ralph@amissah.com>
" SiSU Markup:     SiSU (sisu-3.3) 2012-08-18
" an ftplugin setting defaults for editing sisu markup files
:syntax on
:filetype off
":filetype on
:filetype indent on
:autocmd FileType sisu :set nonumber
:set encoding=utf-8 fileencodings=
:set ff=unix
:set autowrite          " Automatically save before commands like :next and :make
:set nocompatible
:set tabstop=2
:set expandtab
:set shiftwidth=2
:set autoindent
:set showcmd            " Show (partial) command in status line.
:set showmatch          " Show matching brackets.
:set ignorecase         " Do case insensitive matching
:set smartcase
:set incsearch
:set hlsearch
:set gdefault
:set guioptions=agr     " add 'm' for menu
:map <silent> <C-m> :if &guioptions =~# 'm' <Bar>
    \set guioptions-=m <Bar>
    \set guioptions-=T <Bar>
  \else <Bar>
    \set guioptions+=m <Bar>
    \set guioptions-=T <Bar>
  \endif<CR>
:set paste
""% statusline
"set statusline=                                  "
"set fillchars=stl:―,stlnc:—,vert:│,fold:۰,diff:·
"" [ buffer number ]
"set statusline +=%#Normal#[                      "
"set statusline +=%#Identifier#%n                 " buffer number
"set statusline +=%#PreProc#%M                    " modified flag
"set statusline +=%#Normal#]                      "
"" [ file name (& modified?) ]
"set statusline +=%#Normal#\ [                    "
"set statusline +=%#Statement#%<%F%*              " full path
""set statusline +=%#Statement#%<%t               " full path
"set statusline +=%#PreProc#%M                    " modified flag
"set statusline +=%#Normal#]                      "
"" [ column : line number / number of lines in file, percentage of file ] [%v:%l/%L\ %p%%]
"set statusline +=%#Normal#\ [                    "
"set statusline +=%#Identifier#%v                 " column & line
"set statusline +=%#Normal#:                      "
"set statusline +=%#Identifier#%l                 " column & line
"set statusline +=%#SpecialKey#/%L\               " total lines
"set statusline +=%#Identifier#%p                 " percentage of file
"set statusline +=%#SpecialKey#%%                 "
"set statusline +=%#Normal#]     "                "
"" [ file format : file type ]
"set statusline +=%#Normal#\ [                    "
"set statusline +=%#SpecialKey#%{&fenc}           " file format
"set statusline +=%#Normal#:                      "
"set statusline +=%#SpecialKey#%{&ff}             " file format
"set statusline +=%#Normal#:                      "
"set statusline +=%#SpecialKey#%y                 " file type
"set statusline +=%#Normal#]                      "
"" [ character under cursor ]
"set statusline +=%#Normal#\ [                    "
"set statusline +=%#String#0x%04B                 " character under cursor
"set statusline +=%#Normal#]\                     "
"" [ syntastic ]
"set statusline +=%#warningmsg#
"set statusline +=%{SyntasticStatuslineFlag()}\   "
""set statusline+=%*
""  Status line background
"set statusline +=%#Folded#\                  "
"" misc
"set laststatus=2                                 " status line always on
"% textwrap
:set whichwrap=<,>,h,l,[,]
:set nolinebreak        " only affects display not buffer
:set wrap
:set wrapmargin=0
"% map
":let mapleader = ","    " consider
:map <leader>paste :set invpaste<cr>
"% wrap/formatting paragraph according to the current 'textwidth' with ^\ (control-\):
:imap <C-\> <C-O>gqap
:nmap <C-\>      gqap
:vmap <C-\>      gq
"% save file, go to next file in buffer
:map <leader>nf :w <enter> :n <enter>
"% vimdiff q exits
:if &diff
:  cmap q qa
:endif
"% directory files, placed in vertical split window
:map <leader>ls :vs<cr> :Explore<cr>
:map <leader>dir :vs<cr> :Explore<cr>
"% remapping lines make cursor jump a line at a time within wrapped text
:nnoremap j gj
:nnoremap k gk
:vnoremap j gj
:vnoremap k gk
:nnoremap <Down> gj
:nnoremap <Up> gk
:vnoremap <Down> gj
:vnoremap <Up> gk
:inoremap <Down> <C-o>gj
:inoremap  <Up> <C-o>gk
"% search and replace
:map <leader>rd :.,$s///c "search and replace down
:map <leader>rg :%s///c "search and replace whole file
:map <leader>rr :rubyd gsub!(//,"")
"% pwd t64 working directory set to that of the file you're editing
"changes pwd to directory of file in current buffer
:function! CHANGE_CURR_DIR()
:  let _dir = expand("%:p:h")
:    exec "cd " . _dir
:    unlet _dir
:endfunction
"% Change to the directory the file in your current buffer is in
:if has("autocmd")
   autocmd BufEnter * :lcd %:p:h
:endif
"% autocompletefilenames To search for files in the current directory
:set path=,,
"auto-completion for file to edit in current dir, used in normal mode
:map <leader>e :e <c-r>=expand("%:p:h") . "/" <cr>
:map <leader>pwd :exe 'cd ' . expand ("%:p:h")<cr>
"% searchhighlight t93: Toggle search highlight <C-n>
:function! ToggleHLSearched()
:  if &hls
:    set nohls
:  else
:    set hls
:  endif
:endfun
:nmap <silent> <C-n> :silent call ToggleHLSearched()<cr>
"%% SiSU vim folds
"% foldsearchx FoldSearch (opens result of search all else closed) t77
:map <leader>fs :set foldmethod=expr foldcolumn=2 foldlevel=0 <cr>
:map <leader>ff :F<cr>
:map <leader>fe :F<cr> zE
"% foldtoggle Fold Toggle mapped to <space>
:fun! ToggleFold()
:  if foldlevel('.') == 0
:    normal! l
:  else
:    if foldclosed('.') < 0
:      foldclose
:    else
:      foldopen
:    endif
:  endif
"  Clear status line
:  echo
:endfun
" Map this function to Space key.
:noremap <space> :call ToggleFold()<cr>
"% foldtype Fold? set foldtext
:set foldtext=v:folddashes.substitute(getline(v:foldstart),'\\=','','g',)
:set foldexpr=getline(v:lnum-1)!~@/&&getline(v:lnum)!~@/&&getline(v:lnum+1)!~@/
"% foldsearch t77: Fold on search result
:function! FoldMake(search)
:  set fdm=manual
:  normal zE
:  normal G$
:  let folded = 0     "flag to set when a fold is found
:  let flags = "w"    "allow wrapping in the search
:  let line1 =  0     "set marker for beginning of fold
:  while search(a:search, flags) > 0
:    let  line2 = line(".")
:      if (line2 -1 > line1)
:        "echo line1 . ":" . (line2-1)
:        "echo "a fold goes here."
:        execute ":" . line1 . "," . (line2-1) . "fold"
:        let folded = 1       "at least one fold has been found
:     endif
:     let line1 = line2     "update marker
:     let flags = "W"       "turn off wrapping
:  endwhile
"  create the last fold which goes to the end of the file.
:  normal $G
:  let  line2 = line(".")
:  if (line2  > line1 && folded == 1)
:    execute ":". line1 . "," . line2 . "fold"
:  endif
:  normal 1G
:endfunction
"% folds Fold Patterns
:command! -nargs=+ -complete=command FMake call FoldMake(<q-args>)
:  if ( &filetype == "ruby" )
:    command! F FMake ^# ==\?\|^\s*\(\(def\|class\|module\)\s\|\(public\|protected\|private\|__END__\)\s*$\)\|\(^\s*\|\s\+\)#%\s
:    command! Fa FMake \(^# ==\?\|^\s*\(\(\(def\|class\|module\)\s\)\|\(\(public\|protected\|private\|__END__\)\(\s*$\)\)\)\)\|^[0-9]\~\|\([#%]\|^["]\)\{1,4\}\s*%\|{\({\|!!\)
:    command! FD FMake \(^# ==\?\|^\s*\(\(def\|class\|module\)\s\)\)\|^\s*\([#%"0-9]\{0,4\}\~\(%\+\s\|!!\)\|#\s\+=\+\s\+\)
:  else
"% folds :F Fold Patterns SiSU Markup :F
:    command! F FMake  ^\([1-8]\|:\?[A-C]\)\~\|\(^%\|\(^\|\s\+\)[#"]\)%\{1,2\}\(\s\|$\)\|^<<\s*|
:    command! Fa FMake ^\([1-8]\|:\?[A-C]\)\~\|\(^%\|\(^\|\s\+\)[#"]\)%\{1,2\}\(\s\|$\)\|^<<\s*|\|^\(Book\|Part\|Chapter\|Section\|Article\|BOOK\|PART\|CHAPTER\|SECTION\|ARTICLE\)\s
:    command! F0 FMake ^\(\s*0\~\|@\S\+:[+-]\?\s\+\)
:    command! FA FMake ^:\?A\~
:    command! FB FMake ^:\?[AB]\~
:    command! FC FMake ^:\?[A-C]\~
:    command! F1 FMake ^\(:\?[A-C]\|1\)\~
:    command! F2 FMake ^\(:\?[A-C]\|[12]\)\~
:    command! F3 FMake ^\(:\?[A-C]\|[1-3]\)\~
:    command! F4 FMake ^[1-4]\~
:    command! F5 FMake ^[4-5]\~
:    command! F6 FMake ^[4-6]\~
:    command! Fc FMake ^[%]\+\s\+
:  endif
"% folds Fold Patterns misc
":command! Fp FMake ^\s*[A-Za-z0-9#]
:command! Fp FMake ^\s*\S
:command! Fo FMake ^[%\"]\s*[{>]
"% linenumbering, on, relative, off
:map <Leader>nn :set <c-r>={'00':'','01':'r','10':'nor'}[&rnu.&nu]<CR>nu<CR>
"% cursorline
:map <leader>cu :if &cursorcolumn <Bar>
    \set nocursorline nocursorcolumn <Bar>
  \else <Bar>
    \set cursorline cursorcolumn <Bar>
  \endif<cr>
:map <leader>cu- :set nocursorline nocursorcolumn<cr>
:map <leader>cu+ :set cursorline cursorcolumn<cr>
#+END_SRC

*** sisu-spine.vim

#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/ftplugin/sisu-spine.vim"
#+BEGIN_SRC text
"%% SiSU Vim ftplugin
" SiSU Maintainer: Ralph Amissah <ralph@amissah.com>
" SiSU Markup:     SiSU (sisu-3.3) 2012-08-18
" an ftplugin setting defaults for editing sisu markup files
:syntax on
:filetype off
":filetype on
:filetype indent on
:autocmd FileType sisu :set nonumber
:set encoding=utf-8 fileencodings=
:set ff=unix
:set autowrite          " Automatically save before commands like :next and :make
:set nocompatible
:set tabstop=2
:set expandtab
:set shiftwidth=2
:set autoindent
:set showcmd            " Show (partial) command in status line.
:set showmatch          " Show matching brackets.
:set ignorecase         " Do case insensitive matching
:set smartcase
:set incsearch
:set hlsearch
:set gdefault
:set guioptions=agr     " add 'm' for menu
:map <silent> <C-m> :if &guioptions =~# 'm' <Bar>
    \set guioptions-=m <Bar>
    \set guioptions-=T <Bar>
  \else <Bar>
    \set guioptions+=m <Bar>
    \set guioptions-=T <Bar>
  \endif<CR>
:set paste
""% statusline
"set statusline=                                  "
"set fillchars=stl:―,stlnc:—,vert:│,fold:۰,diff:·
"" [ buffer number ]
"set statusline +=%#Normal#[                      "
"set statusline +=%#Identifier#%n                 " buffer number
"set statusline +=%#PreProc#%M                    " modified flag
"set statusline +=%#Normal#]                      "
"" [ file name (& modified?) ]
"set statusline +=%#Normal#\ [                    "
"set statusline +=%#Statement#%<%F%*              " full path
""set statusline +=%#Statement#%<%t               " full path
"set statusline +=%#PreProc#%M                    " modified flag
"set statusline +=%#Normal#]                      "
"" [ column : line number / number of lines in file, percentage of file ] [%v:%l/%L\ %p%%]
"set statusline +=%#Normal#\ [                    "
"set statusline +=%#Identifier#%v                 " column & line
"set statusline +=%#Normal#:                      "
"set statusline +=%#Identifier#%l                 " column & line
"set statusline +=%#SpecialKey#/%L\               " total lines
"set statusline +=%#Identifier#%p                 " percentage of file
"set statusline +=%#SpecialKey#%%                 "
"set statusline +=%#Normal#]     "                "
"" [ file format : file type ]
"set statusline +=%#Normal#\ [                    "
"set statusline +=%#SpecialKey#%{&fenc}           " file format
"set statusline +=%#Normal#:                      "
"set statusline +=%#SpecialKey#%{&ff}             " file format
"set statusline +=%#Normal#:                      "
"set statusline +=%#SpecialKey#%y                 " file type
"set statusline +=%#Normal#]                      "
"" [ character under cursor ]
"set statusline +=%#Normal#\ [                    "
"set statusline +=%#String#0x%04B                 " character under cursor
"set statusline +=%#Normal#]\                     "
"" [ syntastic ]
"set statusline +=%#warningmsg#
"set statusline +=%{SyntasticStatuslineFlag()}\   "
""set statusline+=%*
""  Status line background
"set statusline +=%#Folded#\                  "
"" misc
"set laststatus=2                                 " status line always on
"% textwrap
:set whichwrap=<,>,h,l,[,]
:set nolinebreak        " only affects display not buffer
:set wrap
:set wrapmargin=0
"% map
":let mapleader = ","    " consider
:map <leader>paste :set invpaste<cr>
"% wrap/formatting paragraph according to the current 'textwidth' with ^\ (control-\):
:imap <C-\> <C-O>gqap
:nmap <C-\>      gqap
:vmap <C-\>      gq
"% save file, go to next file in buffer
:map <leader>nf :w <enter> :n <enter>
"% vimdiff q exits
:if &diff
:  cmap q qa
:endif
"% directory files, placed in vertical split window
:map <leader>ls :vs<cr> :Explore<cr>
:map <leader>dir :vs<cr> :Explore<cr>
"% remapping lines make cursor jump a line at a time within wrapped text
:nnoremap j gj
:nnoremap k gk
:vnoremap j gj
:vnoremap k gk
:nnoremap <Down> gj
:nnoremap <Up> gk
:vnoremap <Down> gj
:vnoremap <Up> gk
:inoremap <Down> <C-o>gj
:inoremap  <Up> <C-o>gk
"% search and replace
:map <leader>rd :.,$s///c "search and replace down
:map <leader>rg :%s///c "search and replace whole file
:map <leader>rr :rubyd gsub!(//,"")
"% pwd t64 working directory set to that of the file you're editing
"changes pwd to directory of file in current buffer
:function! CHANGE_CURR_DIR()
:  let _dir = expand("%:p:h")
:    exec "cd " . _dir
:    unlet _dir
:endfunction
"% Change to the directory the file in your current buffer is in
:if has("autocmd")
   autocmd BufEnter * :lcd %:p:h
:endif
"% autocompletefilenames To search for files in the current directory
:set path=,,
"auto-completion for file to edit in current dir, used in normal mode
:map <leader>e :e <c-r>=expand("%:p:h") . "/" <cr>
:map <leader>pwd :exe 'cd ' . expand ("%:p:h")<cr>
"% searchhighlight t93: Toggle search highlight <C-n>
:function! ToggleHLSearched()
:  if &hls
:    set nohls
:  else
:    set hls
:  endif
:endfun
:nmap <silent> <C-n> :silent call ToggleHLSearched()<cr>
"%% SiSU vim folds
"% foldsearchx FoldSearch (opens result of search all else closed) t77
:map <leader>fs :set foldmethod=expr foldcolumn=2 foldlevel=0 <cr>
:map <leader>ff :F<cr>
:map <leader>fe :F<cr> zE
"% foldtoggle Fold Toggle mapped to <space>
:fun! ToggleFold()
:  if foldlevel('.') == 0
:    normal! l
:  else
:    if foldclosed('.') < 0
:      foldclose
:    else
:      foldopen
:    endif
:  endif
"  Clear status line
:  echo
:endfun
" Map this function to Space key.
:noremap <space> :call ToggleFold()<cr>
"% foldtype Fold? set foldtext
:set foldtext=v:folddashes.substitute(getline(v:foldstart),'\\=','','g',)
:set foldexpr=getline(v:lnum-1)!~@/&&getline(v:lnum)!~@/&&getline(v:lnum+1)!~@/
"% foldsearch t77: Fold on search result
:function! FoldMake(search)
:  set fdm=manual
:  normal zE
:  normal G$
:  let folded = 0     "flag to set when a fold is found
:  let flags = "w"    "allow wrapping in the search
:  let line1 =  0     "set marker for beginning of fold
:  while search(a:search, flags) > 0
:    let  line2 = line(".")
:      if (line2 -1 > line1)
:        "echo line1 . ":" . (line2-1)
:        "echo "a fold goes here."
:        execute ":" . line1 . "," . (line2-1) . "fold"
:        let folded = 1       "at least one fold has been found
:     endif
:     let line1 = line2     "update marker
:     let flags = "W"       "turn off wrapping
:  endwhile
"  create the last fold which goes to the end of the file.
:  normal $G
:  let  line2 = line(".")
:  if (line2  > line1 && folded == 1)
:    execute ":". line1 . "," . line2 . "fold"
:  endif
:  normal 1G
:endfunction
"% folds Fold Patterns
:command! -nargs=+ -complete=command FMake call FoldMake(<q-args>)
:  if ( &filetype == "ruby" )
:    command! F FMake ^# ==\?\|^\s*\(\(def\|class\|module\)\s\|\(public\|protected\|private\|__END__\)\s*$\)\|\(^\s*\|\s\+\)#%\s
:    command! Fa FMake \(^# ==\?\|^\s*\(\(\(def\|class\|module\)\s\)\|\(\(public\|protected\|private\|__END__\)\(\s*$\)\)\)\)\|^[0-9]\~\|\([#%]\|^["]\)\{1,4\}\s*%\|{\({\|!!\)
:    command! FD FMake \(^# ==\?\|^\s*\(\(def\|class\|module\)\s\)\)\|^\s*\([#%"0-9]\{0,4\}\~\(%\+\s\|!!\)\|#\s\+=\+\s\+\)
:  else
"% folds :F Fold Patterns SiSU Markup :F
:    command! F FMake  ^\([1-8]\|:\?[A-C]\)\~\|\(^%\|\(^\|\s\+\)[#"]\)%\{1,2\}\(\s\|$\)\|^<<\s*|
:    command! Fa FMake ^\([1-8]\|:\?[A-C]\)\~\|\(^%\|\(^\|\s\+\)[#"]\)%\{1,2\}\(\s\|$\)\|^<<\s*|\|^\(Book\|Part\|Chapter\|Section\|Article\|BOOK\|PART\|CHAPTER\|SECTION\|ARTICLE\)\s
:    command! F0 FMake ^\(\s*0\~\|@\S\+:[+-]\?\s\+\)
:    command! FA FMake ^:\?A\~
:    command! FB FMake ^:\?[AB]\~
:    command! FC FMake ^:\?[A-C]\~
:    command! F1 FMake ^\(:\?[A-C]\|1\)\~
:    command! F2 FMake ^\(:\?[A-C]\|[12]\)\~
:    command! F3 FMake ^\(:\?[A-C]\|[1-3]\)\~
:    command! F4 FMake ^[1-4]\~
:    command! F5 FMake ^[4-5]\~
:    command! F6 FMake ^[4-6]\~
:    command! Fc FMake ^[%]\+\s\+
:  endif
"% folds Fold Patterns misc
":command! Fp FMake ^\s*[A-Za-z0-9#]
:command! Fp FMake ^\s*\S
:command! Fo FMake ^[%\"]\s*[{>]
"% linenumbering, on, relative, off
:map <Leader>nn :set <c-r>={'00':'','01':'r','10':'nor'}[&rnu.&nu]<CR>nu<CR>
"% cursorline
:map <leader>cu :if &cursorcolumn <Bar>
    \set nocursorline nocursorcolumn <Bar>
  \else <Bar>
    \set cursorline cursorcolumn <Bar>
  \endif<cr>
:map <leader>cu- :set nocursorline nocursorcolumn<cr>
:map <leader>cu+ :set cursorline cursorcolumn<cr>
#+END_SRC

** templates
*** sst.tpl

#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/templates/sst.tpl"
#+BEGIN_SRC text
# SiSU 8.0

title:
  main:             "#___#"
  sub:              "#___#"
  language:         "#___#"

creator:
  author:           "#___#"

date:
 :published:        "YYYY-MM-DD"

rights:
  copyright:        "#___#"
  license:          "#___#"

classify:
  topic_register:   "#___#"

make:
  breaks:           "new=:B; break=1"
#  home_button_text: "#___#"
#  footer:           "#___#"

#% -- body ---

:A~ @title @author

1~  #___#
#+END_SRC

*** ssm.tpl

#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/templates/ssm.tpl"
#+BEGIN_SRC text
# SiSU 8.0 master

title:
  main:             "#___#"
  sub:              "#___#"
  language:         "#___#"

creator:
  author:           "#___#"

date:
 :published:        "YYYY-MM-DD"

rights:
  copyright:        "#___#"
  license:          "#___#"

classify:
  topic_register:   "#___#"

make:
  breaks:           "new=:B; break=1"
#  home_button_text: "#___#"
#  footer:           "#___#"

#% -- body ---

:A~ @title @author

1~  #___#
#+END_SRC

*** ssm.tpl

#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/templates/ssi.tpl"
#+BEGIN_SRC text
# SiSU 8.0 insert

title:
  main:             "#___#"
  sub:              "#___#"
  language:         "#___#"

creator:
  author:           "#___#"

date:
 :published:        "YYYY-MM-DD"

rights:
  copyright:        "#___#"
  license:          "#___#"

classify:
  topic_register:   "#___#"

make:
  breaks:           "new=:B; break=1"
#  home_button_text: "#___#"
#  footer:           "#___#"

#% -- body ---

:A~ @title @author

1~  #___#
#+END_SRC

* NVim tree-sitter Syntax highlighting
** README.md

#+HEADER: :tangle "../sundry/editor-syntax-etc/nvim/README.md"
#+BEGIN_SRC markdown
# Neovim integration for SiSU spine markup

Tree-sitter-backed syntax highlighting, folding, and structural
navigation for `.sst` / `.ssm` / `.ssi` files in Neovim (>= 0.9).

## What is in this directory

```
nvim/
  ftdetect/sisu.lua        - register .sst/.ssm/.ssi as filetype "sisu"
  ftplugin/sisu.lua        - per-buffer settings (commentstring, conceal)
  lua/sisu-spine/init.lua  - entry point: registers parser config
  queries/sisu/            - tree-sitter queries (mirrors tree-sitter-sisu/queries/)
    highlights.scm
    folds.scm
    injections.scm
    textobjects.scm
    indents.scm
```

## Install (manual)

1. Symlink or copy this directory into your Neovim runtime path:

   ```sh
   ln -s /path/to/sisudoc-spine/sundry/editor-syntax-etc/nvim \
         ~/.config/nvim/pack/sisu/start/sisu-spine
   ```

2. Tell `nvim-treesitter` how to fetch the parser. Add to your config
   (`init.lua`):

   ```lua
   require("sisu-spine").setup()
   require("nvim-treesitter.configs").setup({
     ensure_installed = { "sisu" },
     highlight       = { enable = true },
     indent          = { enable = true },
     fold            = { enable = true },
     textobjects     = { select = { enable = true, lookahead = true } },
   })
   ```

3. Build the parser:

   ```vim
   :TSInstall sisu
   ```

That is it. Open a `.sst` file - highlighting, folding, and textobject
selection should all work.

## Install (lazy.nvim)

```lua
{
  dir = "/path/to/sisudoc-spine/sundry/editor-syntax-etc/nvim",
  name = "sisu-spine",
  ft = { "sisu" },
  dependencies = { "nvim-treesitter/nvim-treesitter" },
  config = function()
    require("sisu-spine").setup()
  end,
}
```

## Sync queries from upstream

The query files are duplicated from `tree-sitter-sisu/queries/` so that
this Neovim drop-in works without depending on the parser repo's
checkout layout. To refresh them after grammar changes:

```sh
cp ../../../sisudoc-spine-tools/tree-sitter-sisu/queries/*.scm \
   queries/sisu/
```

(Path is relative to this README.)

## Upstreaming the parser

When the parser is publicly hosted under a stable URL it is worth
submitting a config to `nvim-treesitter` so users can run `:TSInstall
sisu` without the local `setup()` call. The required fields are in
`lua/sisu-spine/init.lua` (`install_info` table); send a PR to
<https://github.com/nvim-treesitter/nvim-treesitter> patching
`lua/nvim-treesitter/parsers.lua`.
#+END_SRC

** lua
*** init

#+HEADER: :tangle "../sundry/editor-syntax-etc/nvim/lua/sisu-spine/init.lua"
#+BEGIN_SRC lua
-- Entry point for the SiSU spine markup Neovim integration.
--
-- Registers a tree-sitter parser config so users can run
--   :TSInstall sisu
-- to fetch and build the parser via nvim-treesitter.
--
-- The parser source lives can be found under the
-- `projects/` namespace on git.sisudoc.org.

local M = {}

--- Register the `sisu` parser with nvim-treesitter and ensure that
--- `.sst` / `.ssm` / `.ssi` are detected as filetype "sisu".
---
--- Call once from your init.lua before invoking `:TSInstall sisu`.
function M.setup()
  local ok, parsers = pcall(require, "nvim-treesitter.parsers")
  if not ok then
    vim.notify(
      "sisu-spine: nvim-treesitter is not installed; "
        .. "syntax highlighting will not be available.",
      vim.log.levels.WARN
    )
    return
  end

  local parser_config = parsers.get_parser_configs()
  parser_config.sisu = {
    install_info = {
      url = "https://git.sisudoc.org/projects/tree-sitter-sisu",
      files = {
        "src/parser.c",
        "src/scanner.c",
      },
      branch = "main",
      generate_requires_npm = false,
      requires_generate_from_grammar = false,
    },
    filetype = "sisu",
  }
end

return M
#+END_SRC

*** ftdetect

#+HEADER: :tangle "../sundry/editor-syntax-etc/nvim/ftdetect/sisu.lua"
#+BEGIN_SRC lua
vim.filetype.add({
  extension = {
    sst = "sisu",
    ssm = "sisu",
    ssi = "sisu",
  },
})
#+END_SRC

*** ftplugin

#+HEADER: :tangle "../sundry/editor-syntax-etc/nvim/ftplugin/sisu.lua"
#+BEGIN_SRC lua
-- Buffer-local settings for SiSU spine markup.

vim.bo.commentstring = "%% %s"
vim.bo.comments = ":%"

-- Soft wrap suits prose.
vim.wo.wrap = true
vim.wo.linebreak = true

-- Conceal inline-formatting delimiters when the user opts in
-- (`:set conceallevel=2`).  See queries/sisu/highlights.scm for
-- @conceal captures.
vim.wo.conceallevel = vim.wo.conceallevel
#+END_SRC

** queries
*** folds

#+HEADER: :tangle "../sundry/editor-syntax-etc/nvim/queries/sisu/folds.scm"
#+BEGIN_SRC vimrc
; Code folding queries for SiSU Spine markup

; Block elements are foldable
(code_block_curly) @fold
(code_block_tic) @fold
(poem_block_curly) @fold
(poem_block_tic) @fold
(block_block_curly) @fold
(block_block_tic) @fold
(group_block_curly) @fold
(group_block_tic) @fold
(table_block_curly) @fold
(table_block_tic) @fold
(quote_block_tic) @fold

; Multi-line book index entries are foldable
(book_index) @fold

; Pipe tables are foldable
(pipe_table) @fold

; Header fields with continuations are foldable
(header_field) @fold
#+END_SRC

*** highlights

#+HEADER: :tangle "../sundry/editor-syntax-etc/nvim/queries/sisu/highlights.scm"
#+BEGIN_SRC vimrc
; Syntax highlighting queries for SiSU Spine markup
; Compatible with tree-sitter highlight capture names from
; https://tree-sitter.github.io/tree-sitter/syntax-highlighting

; =================================================================
; Comments
; =================================================================
(version_comment) @comment.documentation
(header_comment) @comment
(body_comment) @comment

; =================================================================
; Header (document metadata)
; =================================================================
(header_field
  key: (header_key) @keyword)

(header_field
  value: (header_value) @string)

(header_continuation) @string

; =================================================================
; Headings
; =================================================================
(part_marker) @keyword.directive
(segment_marker) @keyword.directive

(heading_part
  content: (heading_content) @markup.heading)

(heading_segment
  content: (heading_content) @markup.heading)

(segment_name) @label
(suppress_marker) @punctuation.special

; Heading levels for more specific styling
(heading_part
  marker: (part_marker) @markup.heading.1
  (#match? @markup.heading.1 "^:A~$"))

(heading_part
  marker: (part_marker) @markup.heading.2
  (#match? @markup.heading.2 "^:B~$"))

(heading_part
  marker: (part_marker) @markup.heading.3
  (#match? @markup.heading.3 "^:C~$"))

(heading_part
  marker: (part_marker) @markup.heading.4
  (#match? @markup.heading.4 "^:D~$"))

(heading_segment
  marker: (segment_marker) @markup.heading.5
  (#match? @markup.heading.5 "^1~$"))

(heading_segment
  marker: (segment_marker) @markup.heading.6
  (#match? @markup.heading.6 "^2~$"))

; =================================================================
; Inline formatting
; =================================================================
(emphasis) @markup.italic
(bold) @markup.bold
(italic) @markup.italic
(underline) @markup.underline
(citation_mark) @markup.quote
(superscript) @markup.superscript
(subscript) @markup.subscript
(inserted) @markup.underline
(strikethrough) @markup.strikethrough
(monospace_inline) @markup.raw

; Formatting delimiters
["*{" "}*"] @punctuation.special
["!{" "}!"] @punctuation.special
["/{" "}/"] @punctuation.special
["_{" "}_"] @punctuation.special
["\"{" "}\""] @punctuation.special
["^{" "}^"] @punctuation.special
[",{" "},"] @punctuation.special
["+{" "}+"] @punctuation.special
["-{" "}-"] @punctuation.special
["#{" "}#"] @punctuation.special

; =================================================================
; Footnotes and editor notes
; =================================================================
(footnote) @markup.link
(footnote_marker) @punctuation.special
(editor_note) @markup.link

["~{" "}~"] @punctuation.special
; Editor-note channel selector: ~[* (asterisk set) or ~[+ (plus set).
; A distinct capture lets themes colour the two channels separately
; from the generic footnote delimiters above.
(editor_note_marker) @attribute
["]~"] @punctuation.special

; =================================================================
; Links and images
; =================================================================
(link
  text: (link_text) @markup.link.label)

(link
  target: (url) @markup.link.url)

(link
  target: (anchor_ref) @markup.link.url)

(link
  target: (collection_path) @markup.link.url)

(auto_footnote_marker) @punctuation.special

(image
  spec: (image_spec) @markup.link.label)

(url) @markup.link.url

(inline_anchor) @label
(anchor_name) @label

; =================================================================
; Block elements
; =================================================================
(block_open) @keyword.directive
(block_close) @keyword.directive
(raw_content) @markup.raw

; Code blocks get more specific highlighting
(code_block_curly
  open: (block_open) @keyword.directive)
(code_block_curly
  content: (raw_content) @markup.raw.block)
(code_block_curly
  close: (block_close) @keyword.directive)

(code_block_tic
  open: (block_open) @keyword.directive)
(code_block_tic
  content: (raw_content) @markup.raw.block)
(code_block_tic
  close: (block_close) @keyword.directive)

; =================================================================
; Book index
; =================================================================
(book_index) @markup.list
(index_content) @string

; =================================================================
; Paragraph prefixes
; =================================================================
(paragraph_prefix) @punctuation.special

; =================================================================
; Special markers
; =================================================================
(ocn_suppress) @comment
(ocn_suppress_open) @comment
(ocn_suppress_close) @comment

(page_break) @punctuation.special
(horizontal_rule) @punctuation.special

; =================================================================
; Composite includes
; =================================================================
(composite_include) @keyword.import
(include_path) @string.special.path

; =================================================================
; Pipe table
; =================================================================
(table_spec) @keyword.directive
(table_row) @markup.raw

; =================================================================
; Text
; =================================================================
(text) @spell

; Line break
(line_break) @punctuation.special
#+END_SRC

*** indents

#+HEADER: :tangle "../sundry/editor-syntax-etc/nvim/queries/sisu/indents.scm"
#+BEGIN_SRC vimrc
; Indentation queries for SiSU Spine markup.
;
; SiSU markup is largely flat: paragraphs and headings live at column 0,
; block bodies preserve their author-supplied indentation verbatim, and
; nesting is by markers rather than by indent. So indents.scm is mostly a
; no-op - the goal is to ensure that auto-indent on <CR> stays at column 0
; for normal lines and respects existing indentation inside header
; continuations and blocks.

; Tree-sitter indent semantics (per nvim-treesitter and treesit):
;   @indent.begin - increases indent for the following line
;   @indent.end   - matches the @indent.begin and decreases indent
;   @indent.zero  - resets indent to column 0
;   @indent.align - aligns following lines with this node
;   @indent.branch - same level as the parent (for else/elif-style joins)

; Top-level structures live at column 0 - reset to zero on the next line.
(heading_part)         @indent.zero
(heading_segment)      @indent.zero
(paragraph)            @indent.zero
(book_index)           @indent.zero
(composite_include)    @indent.zero
(page_break)           @indent.zero
(horizontal_rule)      @indent.zero
(ocn_suppress_open)    @indent.zero
(ocn_suppress_close)   @indent.zero
(body_comment)         @indent.zero

; Block elements: opening line increases indent for the body, closing
; line returns to zero. Editors that respect this will visually indent
; raw content one step from the delimiter line, which is conventional.
(code_block_curly)  @indent.align
(code_block_tic)    @indent.align
(poem_block_curly)  @indent.align
(poem_block_tic)    @indent.align
(block_block_curly) @indent.align
(block_block_tic)   @indent.align
(group_block_curly) @indent.align
(group_block_tic)   @indent.align
(table_block_curly) @indent.align
(table_block_tic)   @indent.align
(quote_block_tic)   @indent.align

; Header continuation lines are indented by two spaces from column 0;
; mark continuations as align so a host that chooses to auto-indent the
; next continuation line matches the previous one.
(header_field)         @indent.align
(header_continuation)  @indent.align
#+END_SRC

*** injections

#+HEADER: :tangle "../sundry/editor-syntax-etc/nvim/queries/sisu/injections.scm"
#+BEGIN_SRC vimrc
; Language injection queries for SiSU Spine markup
;
; Code blocks could potentially inject language-specific highlighting,
; but SiSU code blocks don't specify language. These queries are
; provided as a starting point for future extension.

; Code block content could be injected with a specific language
; if the block type or context provides a hint.
; For now, raw content in code blocks is left unhighlighted.

; Example: if code blocks specified a language, e.g. code(d){
; ((code_block_curly
;   open: (block_open) @_open
;   content: (raw_content) @injection.content)
;  (#match? @_open "code\\(d\\)")
;  (#set! injection.language "d"))
#+END_SRC

*** textobjects

#+HEADER: :tangle "../sundry/editor-syntax-etc/nvim/queries/sisu/textobjects.scm"
#+BEGIN_SRC vimrc
; Text-object queries for SiSU Spine markup.
;
; Capture conventions follow nvim-treesitter/textobjects:
;   @<thing>.outer  -> select including delimiters / surrounding whitespace
;   @<thing>.inner  -> select content only
;
; Hosts that consume these (Neovim's nvim-treesitter-textobjects, Helix,
; Emacs treesit) bind keys such as `af` / `if` to .outer / .inner.

; =================================================================
; Headings (sectioning units)
; =================================================================
; A whole heading line is a "section header" object. Heading sections
; (the heading plus its body content up to the next heading of equal or
; higher level) are not directly expressible in tree-sitter without
; additional grammar work; hosts can synthesise that from these captures.

(heading_part) @class.outer
(heading_part
  content: (heading_content) @class.inner)

(heading_segment) @class.outer
(heading_segment
  content: (heading_content) @class.inner)

; =================================================================
; Block elements (code / poem / block / group / table / quote)
; =================================================================
; Whole block including delimiters; raw_content is the inner.

(code_block_curly) @function.outer
(code_block_curly
  content: (raw_content) @function.inner)

(code_block_tic) @function.outer
(code_block_tic
  content: (raw_content) @function.inner)

(poem_block_curly) @function.outer
(poem_block_curly
  content: (raw_content) @function.inner)

(poem_block_tic) @function.outer
(poem_block_tic
  content: (raw_content) @function.inner)

(block_block_curly) @function.outer
(block_block_curly
  content: (raw_content) @function.inner)

(block_block_tic) @function.outer
(block_block_tic
  content: (raw_content) @function.inner)

(group_block_curly) @function.outer
(group_block_curly
  content: (raw_content) @function.inner)

(group_block_tic) @function.outer
(group_block_tic
  content: (raw_content) @function.inner)

(table_block_curly) @function.outer
(table_block_curly
  content: (raw_content) @function.inner)

(table_block_tic) @function.outer
(table_block_tic
  content: (raw_content) @function.inner)

(quote_block_tic) @function.outer
(quote_block_tic
  content: (raw_content) @function.inner)

(pipe_table) @function.outer

; =================================================================
; Footnotes and editor notes
; =================================================================
; Both share the same outer/inner shape; the inner skips the markers and
; closing delimiters.

(footnote) @comment.outer
(footnote
  (_)+ @comment.inner)

(editor_note) @comment.outer
(editor_note
  (_)+ @comment.inner)

; =================================================================
; Links and images
; =================================================================

(link) @parameter.outer
(link
  text: (link_text) @parameter.inner)

(image) @parameter.outer
(image
  spec: (image_spec) @parameter.inner)

; =================================================================
; Paragraph / inline-formatting runs
; =================================================================

(paragraph) @block.outer
(paragraph
  (_)+ @block.inner)

; Inline formatting pairs - useful as fine-grained text objects.
; The same delimiter character pattern (e.g. `*{` / `}*`) opens and
; closes each, so .inner is everything between them.

(emphasis)         @assignment.outer
(bold)             @assignment.outer
(italic)           @assignment.outer
(underline)        @assignment.outer
(citation_mark)    @assignment.outer
(superscript)      @assignment.outer
(subscript)        @assignment.outer
(inserted)         @assignment.outer
(strikethrough)    @assignment.outer
(monospace_inline) @assignment.outer

; =================================================================
; Book index entries
; =================================================================

(book_index) @attribute.outer
(book_index
  (index_content) @attribute.inner)

; =================================================================
; Header fields
; =================================================================

(header_field) @assignment.outer
(header_field
  value: (header_value) @assignment.inner)
#+END_SRC

* Emacs Syntax highlighting
** README

#+HEADER: :tangle "../sundry/editor-syntax-etc/emacs/README"
#+BEGIN_SRC elisp
; put this into your .emacs file, then use the mode file:

(load-file "~/emacs/el/sisu-spine-mode.el")
(add-to-list 'auto-mode-alist '("\\.sst$" . sisu-spine-mode))
#+END_SRC

** autoload sisuspine-mode-autoloads.el

#+HEADER: :tangle "../sundry/editor-syntax-etc/emacs/sisu-spine-mode-autoloads.el"
#+BEGIN_SRC elisp
(add-to-list 'load-path (or (file-name-directory #$) (car load-path)))
;; Regex / font-lock major mode.  Fallback for Emacs < 29 and for users
;; who have not installed the tree-sitter-sisu parser.
(autoload 'sisu-spine-mode "sisu-spine-mode" "\
Major mode for editing SiSU (spine) markup files.
SiSU (https://www.sisudoc.org/) document structuring, publishing
and search.

\(fn)" t nil)

;; Tree-sitter major mode (Emacs 29+).  When the parser is installed it
;; is selected by `auto-mode-alist'; otherwise the regex mode is used.
(autoload 'sisu-spine-ts-mode "sisu-spine-ts-mode" "\
Tree-sitter major mode for editing SiSU (spine) markup files.

\(fn)" t nil)
(autoload 'sisu-spine-ts-install-grammar "sisu-spine-ts-mode" "\
Install the tree-sitter-sisu grammar for `sisu-spine-ts-mode'.
\(fn)" t nil)
(defun sisu-spine-auto-mode ()
  "Choose `sisu-spine-ts-mode' if the parser is installed, else fall back."
  (if (and (fboundp 'treesit-ready-p) (treesit-ready-p 'sisu t))
    (sisu-spine-ts-mode)
  (sisu-spine-mode)))

(add-to-list 'auto-mode-alist '("\\.sst\\'" . sisu-spine-auto-mode))
(add-to-list 'auto-mode-alist '("\\.ssm\\'" . sisu-spine-auto-mode))
(add-to-list 'auto-mode-alist '("\\.ssi\\'" . sisu-spine-auto-mode))
#+END_SRC

** mode sisu-spine-mode.el (regex)

#+HEADER: :tangle "../sundry/editor-syntax-etc/emacs/sisu-spine-mode.el"
#+BEGIN_SRC elisp
;;; sisu-spine-mode.el --- Major mode for SiSU (spine parser) markup text

;; Copyright (C) 2011, 2025  Free Software Foundation, Inc.

;; Author: Ralph Amissah & Ambrose Kofi Laing
;; Maintainer: Ralph Amissah <ralph.amissah@gmail.com>
;; Keywords: text, syntax, processes, tools
;; Version:   8.0.0
;; URL: https://git.sisudoc.org/projects/sisudoc-spine/tree/sundry/editor-syntax-etc/emacs/sisu-spine-mode.el
;;      https://sisudoc.org/
;; originally looked at (based on) doc-mode, with kind permission of the author
;;   Author: SUN, Tong <suntong001@users.sf.net>, (c)2001-6, all right reserved
;;   Version: $Date: 2006/01/19 03:13:41 $ $Revision: 1.14 $
;;   Home URL: https://xpt.sourceforge.net/
;; with contributions from Kevin Ryde and Stefan Monnier

;; 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, 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 <https://www.gnu.org/licenses/>.

;; Viva Software Libre!
;; Support the free software movement!
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; Commentary:

;; SiSU (https://www.sisudoc.org/) is a document structuring and
;; publishing framework.  This package provides an Emacs major mode
;; for SiSU markup, as used by the spine parser (in D) which has a different
;; header (based on yaml) from the original sisu parser (in Ruby) which has
;; bespoke headers.

;; When this package is installed, files ending in ".sst" are automatically
;; associated with sisu-spine-mode.  If a file doesn't have a
;; .sst extension, add a first line:
;; # -*- sisuSpine -*-

;; The documentation for the "Structure Of The Hierarchy Text" can be
;; found in the sisustring for the sisu-spine-mode function.

;;; Code:

;; Variables:

(defgroup sisu-faces nil
  "AsciiSisu highlighting"
  :group 'sisus)

;; == Colors
; color n is more prominent than color n+1

(defface sisu-title-1-face
  `((((class color)
      (background dark))
     (:foreground "brown3" :bold t :height 1.2 :inherit variable-pitch))
    (((class color)
      (background light))
     (:foreground "brown3" :bold t :height 1.2 :inherit variable-pitch))
    (t (:weight bold :inherit variable-pitch)))
  "Face for AsciiSisu titles at level 1."
  :group 'sisu-faces)

(defface sisu-title-2-face
  `((((class color)
      (background dark))
     (:foreground "yellow4" :bold t :height 1.1 :inherit variable-pitch))
    (((class color)
      (background light))
     (:foreground "yellow4" :bold t :height 1.1 :inherit variable-pitch))
    (t (:weight bold :inherit variable-pitch)))
  "Face for AsciiSisu titles at level 2."
  :group 'sisu-faces)

(defface sisu-title-3-face
  `((((class color)
      (background dark))
     (:foreground "sienna3" :bold t))
    (((class color)
      (background light))
     (:foreground "sienna3" :bold t))
    (t (:weight bold)))
  "Face for AsciiSisu titles at level 3."
  :group 'sisu-faces)

(defface sisu-title-4-face
  `((((class color)
      (background dark))
     (:foreground "burlywood3"))
    (((class color)
      (background light))
     (:foreground "burlywood3"))
    (t ()))
  "Face for AsciiSisu titles at level 4."
  :group 'sisu-faces)

(defface info-node
  '((((class color) (background light)) (:foreground "brown" :bold t :italic t))
    (((class color) (background dark)) (:foreground "white" :bold t :italic t))
    (t (:bold t :italic t)))
  "Face for Info node names."
  :group 'sisu-faces)

(defvar sisu-title-1 'sisu-title-1-face)
(defvar sisu-title-2 'sisu-title-2-face)
(defvar sisu-title-3 'sisu-title-3-face)
(defvar sisu-title-4 'sisu-title-4-face)

(defvar sisu-general-font-lock-red1 font-lock-warning-face)
(defvar sisu-general-font-lock-red2 font-lock-comment-face)
(defvar sisu-general-font-lock-red3 font-lock-string-face)

(defvar sisu-general-font-lock-green1 font-lock-type-face)
(defvar sisu-general-font-lock-green2 font-lock-constant-face)

(defvar sisu-general-font-lock-blue1 font-lock-keyword-face)
(defvar sisu-general-font-lock-blue2 font-lock-function-name-face)
(defvar sisu-general-font-lock-blue3 font-lock-builtin-face)

(defvar sisu-general-font-lock-yellow1 font-lock-variable-name-face)
(defvar sisu-general-font-lock-yellow2 font-lock-comment-face)

;; == sisu-spine-mode settings

(defvar sisu-spine-mode-hook nil
  "Normal hook run when entering Sisu Text mode.")

(defvar sisu-spine-mode-abbrev-table nil
  "Abbrev table in use in Sisu-spine-mode buffers.")
(define-abbrev-table 'sisu-spine-mode-abbrev-table ())

(defconst sisu-font-lock-keywords
  (eval-when-compile
    (list
      ;;grouped text ---------
      ;(cons "^```[ ]code\\(.\\|\n\\)+?\n```\n"      'sisu-general-font-lock-red2)
      (cons "^```[ ]+code.*?$\\|^```$"  'sisu-general-font-lock-red2)
      (cons "^```[ ]+table.*?$\\|^```$" 'sisu-general-font-lock-red2)
      (cons "^```[ ]+group$\\|^```$"    'sisu-general-font-lock-red2)
      (cons "^```[ ]+block$\\|^```$"    'sisu-general-font-lock-red2)
      (cons "^```[ ]+poem$\\|^```$"     'sisu-general-font-lock-red2)
      (cons "^```[ ]+alt$\\|^```$"      'sisu-general-font-lock-red2)
      ;;grouped text ---------
      ;(cons "^'''[ ]code\\(.\\|\n\\)+?\n'''\n"      'sisu-general-font-lock-red2)
      (cons "^'''[ ]+code.*?$\\|^'''$"  'sisu-general-font-lock-red2)
      (cons "^'''[ ]+table.*?$\\|^'''$" 'sisu-general-font-lock-red2)
      (cons "^'''[ ]+group$\\|^'''$"    'sisu-general-font-lock-red2)
      (cons "^'''[ ]+block$\\|^'''$"    'sisu-general-font-lock-red2)
      (cons "^'''[ ]+poem$\\|^'''$"     'sisu-general-font-lock-red2)
      (cons "^'''[ ]+alt$\\|^'''$"      'sisu-general-font-lock-red2)
      ;;grouped text ---------
      (cons "^group{\\|^}group"       'sisu-general-font-lock-red2)
      (cons "^block{\\|^}block"       'sisu-general-font-lock-red2)
      (cons "^code{\\|^}code"         'sisu-general-font-lock-red2)
      (cons "^poem{\\|^}poem"         'sisu-general-font-lock-red2)
      (cons "^alt{\\|^}alt"           'sisu-general-font-lock-red2)
      (cons "^table{.+\\|^}table"     'sisu-general-font-lock-red2)
      (cons "^{table[^}]+}"           'sisu-general-font-lock-red2)

      (list
        (concat
          "^\`\\{3\\}[ ]+code.*?$"
          "\\(.\\|\n\\)+?"
          "\`\\{3\\}$"
        )
        '(1 sisu-general-font-lock-red2 t)
        '(2 nil t)
        '(3 sisu-general-font-lock-red2 t)
      )
      (list
        (concat
          "^\`\\{3\\}[ ]+table.*?$"
          "\\(.\\|\n\\)+?"
          "\`\\{3\\}$"
        )
        '(1 sisu-general-font-lock-red2 t)
        '(2 nil t)
        '(3 sisu-general-font-lock-red2 t)
      )
      (list
        (concat
          "^\`\\{3\\}[ ]+\\(group\\|block\\|alt\\|poem\\)$"
          "\\(.\\|\n\\)+?"
          "^\`\\{3\\}$"
        )
        '(1 sisu-general-font-lock-red2 t)
        '(2 nil t)
        '(3 sisu-general-font-lock-red2 t)
      )

      ;; footnote/endnote ----
      ;(cons "\~{.+?}\~"  'sisu-general-font-lock-green1)
      (cons "\~{\\*\\*\\|\~{\\*\\|\~{\\|}\~"   'sisu-general-font-lock-red2)
      (cons "\~\\[\\+\\|\~\\[\\*\\|\~\\[\\|\\]\~"  'sisu-general-font-lock-red2)
      (cons "\~\\^ \\|^\\^\~ " 'sisu-general-font-lock-red2)
      (list
        (concat
          "\\(\*\~\\)"
          "\\([^ \r\t\n]+\\)"
        )
        '(1 sisu-general-font-lock-red1 t)
        '(2 sisu-general-font-lock-blue2 t)
      )

      ;; emphasis (can be program configured to be bold italics or underscore)
      (list
        (concat
          "\\([*]{\\)"
          "\\([^}]+\\)"
          "\\(}[*]\\)"
        )
        '(1 sisu-general-font-lock-red1 t)
        '(2 sisu-general-font-lock-red1 t)
        '(3 sisu-general-font-lock-red1 t)
      )

      ;; bold ----------------
      (list
        (concat
          "\\([!]{\\)"
          "\\([^}]+\\)"
          "\\(}[!]\\)"
        )
        '(1 sisu-general-font-lock-red1 t)
        '(2 sisu-general-font-lock-red1 t)
        '(3 sisu-general-font-lock-red1 t)
      )
      (cons "\\*[^ ]+\\*"               'sisu-general-font-lock-red1)
      (cons "^!_ .+"                    'sisu-general-font-lock-red1)

      ;; italics -------------
      (list
        (concat
          "\\([/]{\\)"
          "\\([^}]+\\)"
          "\\(}[/]\\)"
        )
        '(1 sisu-general-font-lock-red1 t)
        '(2 sisu-general-font-lock-blue1 t)
        '(3 sisu-general-font-lock-red1 t)
      )

      ;; underscore ----------
      (list
        (concat
          "\\([_]{\\)"
          "\\([^}]+\\)"
          "\\(\}[_]\\)"
        )
        '(1 sisu-general-font-lock-red1 t)
        '(2 sisu-general-font-lock-red1 t)
        '(3 sisu-general-font-lock-red1 t)
      )

      ;; monospace -----------
      (list
        (concat
          "\\([#]{\\)"
          "\\([^}]+\\)"
          "\\(}[#]\\)"
        )
        '(1 sisu-general-font-lock-red1 t)
        '(2 sisu-general-font-lock-red1 t)
        '(3 sisu-general-font-lock-red1 t)
      )

      ;; citation ------------
      (list
        (concat
          "\\([\"]{\\)"
          "\\([^}]+\\)"
          "\\(}[\"]\\)"
        )
        '(1 sisu-general-font-lock-red1 t)
        '(2 sisu-general-font-lock-red1 t)
        '(3 sisu-general-font-lock-red1 t)
      )

      ;; inserted text -------
      (list
        (concat
          "\\([\+]{\\)"
          "\\([^}]+\\)"
          "\\(}[\+]\\)"
        )
        '(1 sisu-general-font-lock-red1 t)
        '(2 sisu-general-font-lock-red1 t)
        '(3 sisu-general-font-lock-red1 t)
      )

      ;; strike through ------
      (list
        (concat
          "\\(\\-{\\)"
          "\\([^}]+\\)"
          "\\(}\\-\\)"
        )
        '(1 sisu-general-font-lock-red1 t)
        '(2 sisu-general-font-lock-red1 t)
        '(3 sisu-general-font-lock-red1 t)
      )

      ;; superscript ---------
      (list
        (concat
          "\\(\\^{\\)"
          "\\([^}]+\\)"
          "\\(}\\^\\)"
        )
        '(1 sisu-general-font-lock-red1 t)
        '(2 sisu-general-font-lock-red1 t)
        '(3 sisu-general-font-lock-red1 t)
      )

      ;; subscript -----------
      (list
        (concat
          "\\([,]{\\)"
          "\\([^}]+\\)"
          "\\(}[,]\\)"
        )
        '(1 sisu-general-font-lock-red1 t)
        '(2 sisu-general-font-lock-red1 t)
        '(3 sisu-general-font-lock-red1 t)
      )

      ;; numbered list
      (cons "^# \\|^_# "                'sisu-general-font-lock-red1)

      ;; bullet text
      (cons "^_\\*[1-9] \\|^_\\* "      'sisu-general-font-lock-red1)

      ;; indented text
      (cons "^_[1-9] "                  'sisu-general-font-lock-red1)
      (cons "^_[1-9]! "                 'sisu-general-font-lock-red1)

      ;; hanging indented text [proposed enable when implemented]
      (cons "^__[1-9] "                'sisu-general-font-lock-red1)
      (cons "^_[0-9]_[0-9] "           'sisu-general-font-lock-red1)
      (cons "^__[1-9]! "               'sisu-general-font-lock-red1)
      (cons "^_[0-9]_[0-9]! "          'sisu-general-font-lock-red1)

      ;; url
      (cons "\\(^\\|[ ]\\)https?:[/][/][^ \t\n\r<]+" 'sisu-general-font-lock-blue2)

      ;; Comment Lines
      (cons "^% .*"                     'sisu-general-font-lock-blue1)

      ;; page break
      (cons "^\\(-\\\\\\\\-\\|=\\\\\\\\=\\|-\\.\\.-\\)" 'sisu-general-font-lock-red2)

      ;; line break
      (cons " \\\\\\\\ "                'sisu-general-font-lock-red1)

      ;; line break (depreciated)
      (cons "<br>"                      'sisu-general-font-lock-red1)

      ;; Section titles
      (list "^\\(\\([1-4]\\|:?[A-D]\\)\\~\\)\\(.*\\)"
        '(1 sisu-title-1 t)
        '(3 sisu-title-2 t)
      )

      ;; hyper-links
      (list
        (concat
          "\\({~^\\|{\\)"
          "\\([^}{]+\\)"
          "\\(}https?:[/][/][^ \r\n\t<]+\\)"
        )
        '(1 sisu-general-font-lock-blue2 t)
        '(2 sisu-general-font-lock-red1 t)
        '(3 sisu-general-font-lock-blue2 t)
      )

      ;; book index
      (list
        (concat
          "^\\(\={\\)"
          "\\([^}{]+\\)"
          "\\(}\\)$"
        )
        '(1 sisu-general-font-lock-green1 t)
        '(2 nil t)
        '(3 sisu-general-font-lock-green1 t)
      )

      ;(cons "^\={.+}"                 'sisu-general-font-lock-green1)

      ;; numbers
      (cons "\\<[.0-9]+\\>"             'sisu-general-font-lock-green2)

      ;; bullets sisu_normal (nearly copied regexp)
      (cons "^_\\([1-9*]\\|[1-9]\\*\\) " 'sisu-general-font-lock-blue2)

      ;; image links
      (list
        (concat
          "\\({\\)"
          "\\([^}{]+\\)"
          "\\(}image\\)"
        )
        '(1 sisu-general-font-lock-blue2 t)
        '(2 sisu-general-font-lock-red1 t)
        '(3 sisu-general-font-lock-blue2 t)
      )

      ;; insert file links
      (list
        (concat
          "\\(<< \\)"
          "\\([^ \r\t\n]+\\.ss\\)"
          "\\(i\\|t\\)"
        )
        '(1 sisu-general-font-lock-blue2 t)
        '(2 sisu-general-font-lock-blue2 t)
        '(3 sisu-general-font-lock-blue2 t)
      )

      ;; raw keywords
      (list
        (concat
          "^\\(\\("
          "creator\\|"
          "title\\|"
          "date\\|"
          "rights\\|"
          "publisher\\|"
          "classify\\|"
          "identifier\\|"
          "original\\|"
          "notes\\|"
          "links\\|"
          "make\\|"
          "\\):\\)\\(.*\\)"
        )
        '(1 sisu-title-2 keep)
        '(3 sisu-title-3 keep)
      )
    )
  )
  "Default expressions to highlight in AsciiSisu mode."
)

;; outline mode evil "folding" if available
;; (define-key evil-normal-state-map ",0"   'show-all)
;; (define-key evil-normal-state-map ",-"   'hide-body)
;; (define-key evil-normal-state-map ",+"   'show-subtree)
;; (define-key evil-normal-state-map ",="   'show-subtree)

;;

;; Sisu & Autoload:

;;;###autoload
(define-derived-mode sisu-spine-mode text-mode "SiSU"
  "Major mode for editing SiSU files.
SiSU document structuring, publishing in multiple formats and search.
URL `https://www.sisudoc.org/'"
  (modify-syntax-entry ?\'  ".")
  ;;(flyspell-mode nil)

  (make-local-variable 'paragraph-start)
  (setq paragraph-start (concat "$\\|>" page-delimiter))
  (make-local-variable 'paragraph-separate)
  (setq paragraph-separate paragraph-start)
  (make-local-variable 'paragraph-ignore-fill-prefix)
  (setq paragraph-ignore-fill-prefix t)

  (set (make-local-variable 'outline-regexp)
       "^\\(\\([1-4]\\|:?[A-D]\\)\\~\\|\\@[a-z]+:\\( \\|$\\)\\)")

  (make-local-variable 'require-final-newline)
  (setq require-final-newline t)

  (make-local-variable 'font-lock-defaults)
  (setq font-lock-defaults
        '(sisu-font-lock-keywords
          nil                           ; KEYWORDS-ONLY: no
          nil                           ; CASE-FOLD: no
          ((?_ . "w"))                  ; SYNTAX-ALIST
          ))
  ;; Enable outlining.
  ;; TODO with outlining make sure linum (line numbering) is off,
  ;; else performance penalty, sucks bigtime
  (outline-minor-mode 1))

;;;###autoload (add-to-list 'auto-mode-alist '("\\.ss[imt]\\'" . sisu-spine-mode))

(provide 'sisu-spine-mode)

;;

;;; sisu-spine-mode.el ends here
#+END_SRC

** mode sisu-spine-ts-mode.el (tree-sitter)

#+HEADER: :tangle "../sundry/editor-syntax-etc/emacs/sisu-spine-ts-mode.el"
#+BEGIN_SRC elisp
;;; sisu-spine-ts-mode.el --- Tree-sitter major mode for SiSU spine markup -*- lexical-binding: t; -*-

;; Copyright (C) 2026  Free Software Foundation, Inc.

;; Author: Ralph Amissah <ralph.amissah@gmail.com>
;; Maintainer: Ralph Amissah <ralph.amissah@gmail.com>
;; Keywords: text, syntax, processes, tools
;; Version:   1.0.0
;; URL: https://git.sisudoc.org/projects/sisudoc-spine/tree/sundry/editor-syntax-etc/emacs/sisu-spine-ts-mode.el
;;      https://sisudoc.org/

;; 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, or (at your option)
;; any later version.

;;; Commentary:

;; Tree-sitter-backed major mode for SiSU spine markup (.sst / .ssm /
;; .ssi).  Sibling to `sisu-spine-mode' (regex / font-lock); requires
;; Emacs 29 or newer with `treesit' built in and the tree-sitter-sisu
;; parser installed.
;;
;; To install the parser inside Emacs:
;;
;;   M-x sisu-spine-ts-install-grammar RET
;;
;; or, equivalently:
;;
;;   (add-to-list 'treesit-language-source-alist
;;     '(sisu "https://git.sisudoc.org/projects"
;;            :source-dir "tree-sitter-sisu/src"))
;;   M-x treesit-install-language-grammar RET sisu RET
;;
;; The mode is auto-enabled for .sst / .ssm / .ssi files when the parser
;; is available.  When it is not, `sisu-spine-mode' (the regex variant)
;; remains available as a fallback.

;;; Code:

(require 'treesit nil t)

(defgroup sisu-spine-ts nil
  "Tree-sitter mode for SiSU spine markup."
  :group 'text
  :prefix "sisu-spine-ts-")

;; ---------------------------------------------------------------------
;; Faces (mirror the structural categories the highlights.scm assigns)
;; ---------------------------------------------------------------------

(defface sisu-spine-ts-heading-1-face
  '((t (:inherit outline-1 :weight bold)))
  "Face for :A~ headings."
  :group 'sisu-spine-ts)

(defface sisu-spine-ts-heading-2-face
  '((t (:inherit outline-2 :weight bold)))
  "Face for :B~ headings."
  :group 'sisu-spine-ts)

(defface sisu-spine-ts-heading-3-face
  '((t (:inherit outline-3 :weight bold)))
  "Face for :C~ / :D~ headings."
  :group 'sisu-spine-ts)

(defface sisu-spine-ts-heading-segment-face
  '((t (:inherit outline-4)))
  "Face for 1~ / 2~ / 3~ segment headings."
  :group 'sisu-spine-ts)

(defface sisu-spine-ts-block-delimiter-face
  '((t (:inherit font-lock-keyword-face)))
  "Face for block opening/closing delimiters."
  :group 'sisu-spine-ts)

(defface sisu-spine-ts-raw-content-face
  '((t (:inherit font-lock-string-face)))
  "Face for raw block content (code, table, etc.)."
  :group 'sisu-spine-ts)

(defface sisu-spine-ts-footnote-face
  '((t (:inherit font-lock-doc-face)))
  "Face for footnote and editor-note bodies."
  :group 'sisu-spine-ts)

(defface sisu-spine-ts-link-face
  '((t (:inherit link)))
  "Face for link text and target URLs."
  :group 'sisu-spine-ts)

(defface sisu-spine-ts-book-index-face
  '((t (:inherit font-lock-preprocessor-face)))
  "Face for book-index entries (={...})."
  :group 'sisu-spine-ts)

(defface sisu-spine-ts-marker-face
  '((t (:inherit font-lock-builtin-face)))
  "Face for inline-formatting delimiters and other punctuation markers."
  :group 'sisu-spine-ts)

;; ---------------------------------------------------------------------
;; Font-lock rules
;; ---------------------------------------------------------------------

(defvar sisu-spine-ts--font-lock-settings
  (when (fboundp 'treesit-font-lock-rules)
    (treesit-font-lock-rules
     :language 'sisu
     :feature 'comment
     '((version_comment) @font-lock-doc-face
       (header_comment)  @font-lock-comment-face
       (body_comment)    @font-lock-comment-face)

     :language 'sisu
     :feature 'header
     '((header_field key: (header_key)   @font-lock-keyword-face)
       (header_field value: (header_value) @font-lock-string-face)
       (header_continuation) @font-lock-string-face)

     :language 'sisu
     :feature 'heading
     '(((heading_part marker: (part_marker) @m
                       content: (heading_content) @sisu-spine-ts-heading-1-face)
        (:match "^:A~$" @m))
       ((heading_part marker: (part_marker) @m
                       content: (heading_content) @sisu-spine-ts-heading-2-face)
        (:match "^:B~$" @m))
       ((heading_part marker: (part_marker) @m
                       content: (heading_content) @sisu-spine-ts-heading-3-face)
        (:match "^:[CD]~$" @m))
       (heading_part marker: (part_marker) @sisu-spine-ts-marker-face)
       (heading_segment marker: (segment_marker) @sisu-spine-ts-marker-face
                        content: (heading_content) @sisu-spine-ts-heading-segment-face)
       (segment_name) @font-lock-function-name-face
       (suppress_marker) @sisu-spine-ts-marker-face)

     :language 'sisu
     :feature 'block
     '((block_open)  @sisu-spine-ts-block-delimiter-face
       (block_close) @sisu-spine-ts-block-delimiter-face
       (raw_content) @sisu-spine-ts-raw-content-face
       (table_spec)  @sisu-spine-ts-block-delimiter-face)

     :language 'sisu
     :feature 'inline
     '((emphasis)         @italic
       (bold)             @bold
       (italic)           @italic
       (underline)        @underline
       (citation_mark)    @font-lock-string-face
       (superscript)      @font-lock-type-face
       (subscript)        @font-lock-type-face
       (inserted)         @underline
       (strikethrough)    @shadow
       (monospace_inline) @font-lock-constant-face)

     :language 'sisu
     :feature 'note
     '((footnote)         @sisu-spine-ts-footnote-face
       (footnote_marker)  @sisu-spine-ts-marker-face
       (editor_note)      @sisu-spine-ts-footnote-face)

     :language 'sisu
     :feature 'link
     '((link text: (link_text) @sisu-spine-ts-link-face)
       (link target: (url) @sisu-spine-ts-link-face)
       (link target: (anchor_ref) @sisu-spine-ts-link-face)
       (link target: (collection_path) @sisu-spine-ts-link-face)
       (image spec: (image_spec) @sisu-spine-ts-link-face)
       (auto_footnote_marker) @sisu-spine-ts-marker-face
       (inline_anchor) @font-lock-function-name-face
       (anchor_name)   @font-lock-function-name-face)

     :language 'sisu
     :feature 'index
     '((book_index)    @sisu-spine-ts-book-index-face
       (index_content) @font-lock-string-face)

     :language 'sisu
     :feature 'misc
     '((paragraph_prefix) @sisu-spine-ts-marker-face
       (page_break)       @sisu-spine-ts-marker-face
       (horizontal_rule)  @sisu-spine-ts-marker-face
       (line_break)       @sisu-spine-ts-marker-face
       (ocn_suppress)        @font-lock-comment-face
       (ocn_suppress_open)   @font-lock-comment-face
       (ocn_suppress_close)  @font-lock-comment-face
       (composite_include) @font-lock-preprocessor-face
       (include_path)      @font-lock-string-face)))
  "Tree-sitter font-lock rules for `sisu-spine-ts-mode'.")

;; ---------------------------------------------------------------------
;; Imenu / navigation / things
;; ---------------------------------------------------------------------

(defvar sisu-spine-ts--imenu-settings
  '(("Part headings"
     "\\`heading_part\\'"
     nil
     sisu-spine-ts--imenu-name-part)
    ("Segment headings"
     "\\`heading_segment\\'"
     nil
     sisu-spine-ts--imenu-name-segment))
  "`treesit-simple-imenu-settings' for `sisu-spine-ts-mode'.")

(defun sisu-spine-ts--imenu-name-part (node)
  "Return display name for a heading_part NODE."
  (let ((c (treesit-node-child-by-field-name node "content"))
        (m (treesit-node-child-by-field-name node "marker")))
    (concat (and m (treesit-node-text m t)) " "
            (and c (treesit-node-text c t)))))

(defun sisu-spine-ts--imenu-name-segment (node)
  "Return display name for a heading_segment NODE."
  (let ((c (treesit-node-child-by-field-name node "content"))
        (m (treesit-node-child-by-field-name node "marker")))
    (concat (and m (treesit-node-text m t)) " "
            (and c (treesit-node-text c t)))))

(defvar sisu-spine-ts--thing-settings
  '((sisu
     (defun "\\`heading_\\(part\\|segment\\)\\'")
     (sentence "\\`paragraph\\'")
     (text "\\`\\(text\\|raw_content\\|heading_content\\)\\'")))
  "`treesit-thing-settings' for `sisu-spine-ts-mode'.")

;; ---------------------------------------------------------------------
;; Grammar install helper
;; ---------------------------------------------------------------------

;;;###autoload
(defun sisu-spine-ts-install-grammar ()
  "Register and install the tree-sitter-sisu grammar.
Convenience wrapper around `treesit-install-language-grammar' with the
upstream URL and source directory pre-filled."
  (interactive)
  (unless (boundp 'treesit-language-source-alist)
    (user-error "treesit not available; Emacs 29+ required"))
  (add-to-list 'treesit-language-source-alist
               '(sisu "https://git.sisudoc.org/projects"
                      :source-dir "tree-sitter-sisu/src"))
  (treesit-install-language-grammar 'sisu))

;; ---------------------------------------------------------------------
;; Major mode
;; ---------------------------------------------------------------------

;;;###autoload
(define-derived-mode sisu-spine-ts-mode text-mode "SiSU-Spine[ts]"
  "Major mode for SiSU spine markup, backed by tree-sitter."
  (unless (and (fboundp 'treesit-ready-p) (treesit-ready-p 'sisu))
    (user-error
     "tree-sitter-sisu parser not installed; run M-x sisu-spine-ts-install-grammar"))
  (treesit-parser-create 'sisu)

  ;; Comments
  (setq-local comment-start "% "
              comment-end   ""
              comment-start-skip "%[ \t]+")

  ;; Font-lock
  (setq-local treesit-font-lock-settings sisu-spine-ts--font-lock-settings)
  (setq-local treesit-font-lock-feature-list
              '((comment header heading)
                (block inline note link index)
                (misc)
                ()))

  ;; Imenu / navigation
  (setq-local treesit-simple-imenu-settings sisu-spine-ts--imenu-settings)
  (setq-local treesit-thing-settings sisu-spine-ts--thing-settings)
  (setq-local treesit-defun-type-regexp "\\`heading_\\(part\\|segment\\)\\'")
  (setq-local treesit-defun-name-function
              (lambda (node)
                (let ((c (treesit-node-child-by-field-name node "content")))
                  (and c (treesit-node-text c t)))))

  (treesit-major-mode-setup))

;;;###autoload
(when (fboundp 'treesit-ready-p)
  (dolist (ext '("\\.sst\\'" "\\.ssm\\'" "\\.ssi\\'"))
    ;; Prefer the ts mode iff the parser is installed; otherwise fall
    ;; back to `sisu-spine-mode'.
    (add-to-list 'auto-mode-alist
                 (cons ext
                       (lambda ()
                         (if (treesit-ready-p 'sisu t)
                             (sisu-spine-ts-mode)
                           (sisu-spine-mode)))))))

(provide 'sisu-spine-ts-mode)

;;; sisu-spine-ts-mode.el ends here
#+END_SRC