aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/ao_abstract_doc_source.d
blob: 8b1d4cf560689310701da62053b7136fb867222d (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
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
/++
  document abstraction:
  abstraction of sisu markup for downstream processing
  ao_abstract_doc_source.d
+/
template SiSUdocAbstraction() {
  private:
  struct SiSUdocAbstraction {
    /+ ↓ abstraction imports +/
    import
      ao_defaults,                  // sdp/ao_defaults.d
      ao_object_setter,             // sdp/ao_object_setter.d
      ao_rgx;                       // sdp/ao_rgx.d
    /+ ↓ abstraction mixins +/
    mixin ObjectSetter;
    mixin InternalMarkup;
    /+ ↓ abstraction struct init +/
    /+ initialize +/
    auto rgx = Rgx();
    ObjGenericComposite[][string] the_table_of_contents_section;
    ObjGenericComposite[] the_document_head_section, the_document_body_section, the_bibliography_section, the_glossary_section, the_blurb_section;
    ObjGenericComposite[] the_dom_tail_section;
    string[string] an_object, processing;
    string an_object_key;
    string[] anchor_tags;
    string anchor_tag_;
    string segment_anchor_tag_that_object_belongs_to;
    string segment_anchor_tag_that_object_belongs_to_uri;
    auto note_section = NotesSection();
    /+ enum +/
    enum State { off, on }
    enum TriState { off, on, closing } // make aware, possibility of third state
    enum DocStructMarkupHeading {
      h_sect_A,
      h_sect_B,
      h_sect_C,
      h_sect_D,
      h_text_1,
      h_text_2,
      h_text_3,
      h_text_4,
      h_text_5, // extra level, drop
      content_non_header
    } // header section A-D; header text 1-4
    enum DocStructCollapsedHeading { lv0, lv1, lv2, lv3, lv4, lv5, lv6, lv7 }
    /+ biblio variables +/
    string biblio_tag_name, biblio_tag_entry, st;
    string[] biblio_arr_json;
    string biblio_entry_str_json;
    JSONValue[] bib_arr_json;
    int bib_entry;
    /+ counters +/
    int cntr, previous_count, previous_length;
    int[string] line_occur;
    string[] html_segnames=["toc"];
    int html_segnames_ptr=0;
    int html_segnames_ptr_cntr=0;
    int verse_line, heading_ptr;
    /+ paragraph attributes +/
    int[string] indent;
    bool bullet = true;
    string content_non_header = "8";
    auto obj_im = ObjInlineMarkup();
    auto obj_att = ObjAttributes();
    /+ ocn +/
    int obj_cite_number, obj_cite_number_;
    auto object_citation_number = OCNemitter();
    int[] dom_markedup = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,];
    int[] dom_markedup_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,];
    int[] dom_collapsed = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,];
    int[] dom_collapsed_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,];
    enum DomTags { none, open, close, close_and_open, open_still, }
    void heading_ancestors(O)(
      auto ref O         obj,
      ref string[]       lv_ancestors,
    ) {
      switch (obj.heading_lev_markup) {
      case 0:
        lv_ancestors[0] = to!string(obj.text);
        foreach(k; 1..8) {
          lv_ancestors[k] = "";
        }
        goto default;
      case 1:
        lv_ancestors[1] = to!string(obj.text);
        foreach(k; 2..8) {
          lv_ancestors[k] = "";
        }
        goto default;
      case 2:
        lv_ancestors[2] = to!string(obj.text);
        foreach(k; 3..8) {
          lv_ancestors[k] = "";
        }
        goto default;
      case 3:
        lv_ancestors[3] = to!string(obj.text);
        foreach(k; 4..8) {
          lv_ancestors[k] = "";
        }
        goto default;
      case 4:
        lv_ancestors[4] = to!string(obj.text);
        foreach(k; 5..8) {
          lv_ancestors[k] = "";
        }
        goto default;
      case 5:
        lv_ancestors[5] = to!string(obj.text);
        foreach(k; 6..8) {
          lv_ancestors[k] = "";
        }
        goto default;
      case 6:
        lv_ancestors[6] = to!string(obj.text);
        lv_ancestors[7] = "";
        goto default;
      case 7:
        lv_ancestors[7] = to!string(obj.text);
        goto default;
      default:
        obj.heading_ancestors_text = lv_ancestors.dup;
      }
    }
    auto dom_set_markup_tags(int[] dom, int lev) {
      foreach (i; 0 .. 8) {
        if (i < lev) {
          if (dom[i] == DomTags.open
             || dom[i] == DomTags.close_and_open
          ) {
            dom[i] = DomTags.open_still;
          } else if (dom[i] == DomTags.close) {
            dom[i] = DomTags.none;
          }
        } else if (i == lev) {
          if (lev  == 0
            && dom[i] == DomTags.open_still
          ) {
            dom[i] = DomTags.close;
          } else if (dom[i] == DomTags.open
            || dom[i] == DomTags.open_still
            || dom[i] == DomTags.close_and_open
          ) {
            dom[i] = DomTags.close_and_open;
          } else {
            dom[i] = DomTags.open;
          }
        } else if (i > lev) {
          if (dom[i] == DomTags.close) {
            dom[i] = DomTags.none;
          } else if (dom[i] == DomTags.open
            || dom[i] == DomTags.open_still
            || dom[i] == DomTags.close_and_open
          ) {
            dom[i] = DomTags.close;
          }
        }
      }
      debug(dom) {
        writeln(lev, ": ", dom);
      }
      return dom;
    }
    auto dom_set_collapsed_tags(int[] dom, int lev) {
      foreach (i; 0 .. 8) {
        if (i < lev) {
          if (dom[i] == DomTags.open
             || dom[i] == DomTags.close_and_open
          ) {
            dom[i] = DomTags.open_still;
          } else if (dom[i] == DomTags.close) {
            dom[i] = DomTags.none;
          }
        } else if (i == lev) {
          if (lev  == 0
            && dom[i] == DomTags.open_still
          ) {
            dom[i] = DomTags.close;
          } else if (dom[i] == DomTags.open
            || dom[i] == DomTags.open_still
            || dom[i] == DomTags.close_and_open
          ) {
            dom[i] = DomTags.close_and_open;
          } else {
            dom[i] = DomTags.open;
          }
        } else if (i > lev) {
          if (dom[i] == DomTags.close) {
            dom[i] = DomTags.none;
          } else if (dom[i] == DomTags.open
            || dom[i] == DomTags.open_still
            || dom[i] == DomTags.close_and_open
          ) {
            dom[i] = DomTags.close;
          }
        }
      }
      debug(dom) {
        writeln(lev, ": ", dom);
      }
      return dom;
    }
    int ocn_emit(int ocn_status_flag) {
      return object_citation_number.ocn_emitter(ocn_status_flag);
    }
    /+ book index variables +/
    string book_idx_tmp;
    string[][string][string] bookindex_unordered_hashes;
    auto bookindex_extract_hash = BookIndexNuggetHash();
    string[][string][string] bkidx_hash(
      string bookindex_section,
      int    obj_cite_number
    ) {
      return bookindex_extract_hash.bookindex_nugget_hash(bookindex_section, obj_cite_number);
    }
    /+ node +/
    ObjGenericComposite comp_obj_heading, comp_obj_location, comp_obj_block, comp_obj_code, comp_obj_poem_ocn, comp_obj_comment;
    auto node_construct = NodeStructureMetadata();
    /+ ↓ abstract marked up document +/
    auto SiSUdocAbstraction(Src,Make,Meta,Opt)(
      Src                  markup_sourcefile_content,
      Make                 dochead_make_aa,
      Meta                 dochead_meta_aa,
      Opt                  opt_action_bool,
    ) {
      debug(asserts){
        static assert(is(typeof(markup_sourcefile_content) == char[][]));
        static assert(is(typeof(dochead_make_aa) == string[string][string]));
        static assert(is(typeof(dochead_meta_aa) == string[string][string]));
        static assert(is(typeof(opt_action_bool) == bool[string]));
      }
      /+ ↓ abstraction init +/
      scope(success) {
      }
      scope(failure) {
      }
      scope(exit) {
        destroy(the_document_head_section);
        destroy(the_table_of_contents_section);
        destroy(the_document_body_section);
        destroy(the_bibliography_section);
        destroy(an_object);
        destroy(processing);
        destroy(biblio_arr_json);
      }
      auto node_para_int_    = node_metadata_para_int;
      auto node_para_str_    = node_metadata_para_str;
      ObjGenericComposite comp_obj_heading_, comp_obj_para, comp_obj_toc;
      line_occur = [
        "heading"  : 0,
        "para"     : 0,
        "glossary" : 0,
        "blurb"    : 0,
      ];
      auto type = flags_type_init;
      string[string] obj_cite_number_poem = [
        "start" : "",
        "end"   : ""
      ];
      string[] lv_ancestors = [ "", "", "", "", "", "", "", "", ];
      int[string] lv = [
        "lv" : State.off,
        "h0" : State.off,
        "h1" : State.off,
        "h2" : State.off,
        "h3" : State.off,
        "h4" : State.off,
        "h5" : State.off,
        "h6" : State.off,
        "h7" : State.off,
        "lev_int_collapsed" : 0,
      ];
      int[string] collapsed_lev = [
        "h0" : State.off,
        "h1" : State.off,
        "h2" : State.off,
        "h3" : State.off,
        "h4" : State.off,
        "h5" : State.off,
        "h6" : State.off,
        "h7" : State.off
      ];
      string[string] heading_match_str = [
        "h_A": "^(none)",
        "h_B": "^(none)",
        "h_C": "^(none)",
        "h_D": "^(none)",
        "h_1": "^(none)",
        "h_2": "^(none)",
        "h_3": "^(none)",
        "h_4": "^(none)"
      ];
      auto heading_match_rgx = [
        "h_A": regex(r"^(none)"),
        "h_B": regex(r"^(none)"),
        "h_C": regex(r"^(none)"),
        "h_D": regex(r"^(none)"),
        "h_1": regex(r"^(none)"),
        "h_2": regex(r"^(none)"),
        "h_3": regex(r"^(none)"),
        "h_4": regex(r"^(none)")
      ];
      string _anchor_tag;
      string toc_txt_;
      an_object["glossary_nugget"] = "";
      an_object["blurb_nugget"] = "";
      comp_obj_heading_                       = comp_obj_heading_.init;
      comp_obj_heading_.use                   = "frontmatter";
      comp_obj_heading_.is_of                 = "para";
      comp_obj_heading_.is_a                  = "heading";
      comp_obj_heading_.text                  = "Table of Contents";
      comp_obj_heading_.ocn                   = 0;
      comp_obj_heading_.obj_cite_number       = "";
      comp_obj_heading_.segment_anchor_tag    = "toc";
      comp_obj_heading_.marked_up_level       = "1";
      comp_obj_heading_.heading_lev_markup    = 4;
      comp_obj_heading_.heading_lev_collapsed = 1;
      comp_obj_heading_.parent_ocn            = 1;
      comp_obj_heading_.parent_lev_markup     = 0;
      comp_obj_heading_.ptr_html_segnames     = html_segnames_ptr;
      comp_obj_heading_.anchor_tags           = ["toc"];
      auto toc_head                           = comp_obj_heading_;
      html_segnames_ptr_cntr++;
      the_table_of_contents_section = [
        "seg": [toc_head],
        "scroll": [toc_head],
      ];
      auto mkup = InlineMarkup();
      auto munge = ObjInlineMarkupMunge();
      string[][string] lev4_subtoc;
      /+ abstraction init ↑ +/
      /+ ↓ loop markup document/text line by line +/
      srcDocLoop:
      foreach (line; markup_sourcefile_content) {
        /+ ↓ markup document/text line by line +/
        /+ scope +/
        scope(exit) {
        }
        scope(failure) {
          stderr.writefln(
            "%s\n%s\n%s:%s failed here:\n  line: %s",
            __MODULE__, __FUNCTION__,
            __FILE__, __LINE__,
            line,
          );
        }
        line = replaceAll(line, rgx.true_dollar, "$$$$");
          // dollar represented as $$ needed to stop submatching on $
          // (substitutions using ${identifiers} must take into account (i.e. happen earlier))
        debug(source) {                                  // source lines
          writeln(line);
        }
        debug(srclines) {
          if (!line.empty) {                             // source lines, not empty
            writefln(
              "* %s",
              line
            );
          }
        }
        if (!line.empty) {
          _check_ocn_status_(line, type);
        }
        if (type["code"] == TriState.on) {
          /+ block object: code +/
          _code_block_(line, an_object, type);
          continue;
        } else if (!matchFirst(line, rgx.skip_from_regular_parse)) {
          /+ object other than "code block" object
             (includes regular text paragraph, headings & blocks other than code) +/
          if ((matchFirst(line, rgx.heading_biblio)
          || (type["biblio_section"] == State.on
          && (!matchFirst(line, rgx.heading_blurb_glossary))))
          && (!matchFirst(line, rgx.heading))
          && (!matchFirst(line, rgx.comment))) {
            /+ within section (block object): biblio +/
            type["glossary_section"] = State.off;
            type["biblio_section"] = State.on;
            type["blurb_section"] = State.off;
            if (opt_action_bool["backmatter"] && opt_action_bool["section_biblio"]) {
              _biblio_block_(line, type, bib_entry, biblio_entry_str_json, biblio_arr_json); //
              debug(bibliobuild) {
                writeln("-  ", biblio_entry_str_json);
                writeln("-> ", biblio_arr_json.length);
              }
            }
            continue;
          } else if ((matchFirst(line, rgx.heading_glossary)
          || (type["glossary_section"] == State.on
          && (!matchFirst(line, rgx.heading_biblio_blurb))))
          && (!matchFirst(line, rgx.heading))
          && (!matchFirst(line, rgx.comment))) {
            /+ within section (block object): glossary +/
            debug(glossary) {
              writeln(__LINE__);
              writeln(line);
            }
            // _glossary_block_(line, type);
            type["glossary_section"] = State.on;
            type["biblio_section"] = State.off;
            type["blurb_section"] = State.off;
            if (opt_action_bool["backmatter"] && opt_action_bool["section_glossary"]) {
              indent=[
                "hang_position" : 0,
                "base_position" : 0,
              ];
              bullet = false;
              type["para"] = State.on;
              line_occur["para"] = State.off;
              an_object_key="glossary_nugget"; //
              if (matchFirst(line, rgx.heading_glossary)) {
                comp_obj_heading_                       = comp_obj_heading_.init;
                comp_obj_heading_.use                   = "backmatter";
                comp_obj_heading_.is_of                 = "para";
                comp_obj_heading_.is_a                  = "heading";
                comp_obj_heading_.text                  = "Glossary";
                comp_obj_heading_.ocn                   = 0;
                comp_obj_heading_.obj_cite_number       = "";
                comp_obj_heading_.marked_up_level       = "B";
                comp_obj_heading_.heading_lev_markup    = 1;
                comp_obj_heading_.heading_lev_collapsed = 1;
                comp_obj_heading_.parent_ocn            = 1;
                comp_obj_heading_.parent_lev_markup     = 0;
                the_glossary_section                    ~= comp_obj_heading_;
                comp_obj_heading_                       = comp_obj_heading_.init;
                comp_obj_heading_.use                   = "backmatter";
                comp_obj_heading_.is_of                 = "para";
                comp_obj_heading_.is_a                  = "heading";
                comp_obj_heading_.text                  = "Glossary";
                comp_obj_heading_.ocn                   = 0;
                comp_obj_heading_.obj_cite_number       = "";
                comp_obj_heading_.segment_anchor_tag    = "glossary";
                comp_obj_heading_.marked_up_level       = "1";
                comp_obj_heading_.heading_lev_markup    = 4;
                comp_obj_heading_.heading_lev_collapsed = 2;
                comp_obj_heading_.parent_ocn            = 1;
                comp_obj_heading_.parent_lev_markup     = 0;
                comp_obj_heading_.anchor_tags           = ["glossary"];
                the_glossary_section                    ~= comp_obj_heading_;
              // } else if (matchFirst(line, rgx.heading)) {
              //   _heading_matched_(line, line_occur, an_object, an_object_key, lv, collapsed_lev, type, dochead_meta_aa); // levels?
              } else {
                _para_match_(line, an_object, an_object_key, indent, bullet, type, line_occur);
                comp_obj_para                       = comp_obj_para.init;
                comp_obj_para.use                   = "backmatter";
                comp_obj_para.is_of                 = "para";
                comp_obj_para.is_a                  = "glossary";
                comp_obj_para.text                  = to!string(line).strip;
                comp_obj_para.ocn                   = 0;
                comp_obj_para.obj_cite_number       = "";
                comp_obj_para.indent_hang           = indent["hang_position"];
                comp_obj_para.indent_base           = indent["base_position"];
                comp_obj_para.bullet                = bullet;
                the_glossary_section                ~= comp_obj_para;
              }
              type["ocn_status"] = TriState.off;
            }
            continue;
          } else if ((matchFirst(line, rgx.heading_blurb)
          || (type["blurb_section"] == State.on
          && (!matchFirst(line, rgx.heading_biblio_glossary))))
          && (!matchFirst(line, rgx.heading))
          && (!matchFirst(line, rgx.comment))) {
            /+ within section (block object): blurb +/
            debug(blurb) {
              writeln(__LINE__);
              writeln(line);
            }
            // _blurb_block_(line, type);
            type["glossary_section"] = State.off;
            type["biblio_section"] = State.off;
            type["blurb_section"] = State.on;
            if (opt_action_bool["backmatter"] && opt_action_bool["section_blurb"]) {
              indent=[
                "hang_position" : 0,
                "base_position" : 0,
              ];
              bullet = false;
              type["para"] = State.on;
              line_occur["para"] = State.off;
              an_object_key="blurb_nugget";
              if (matchFirst(line, rgx.heading_blurb)) {
                comp_obj_heading_                       = comp_obj_heading_.init;
                comp_obj_heading_.use                   = "backmatter";
                comp_obj_heading_.is_of                 = "para";
                comp_obj_heading_.is_a                  = "heading";
                comp_obj_heading_.text                  = "Blurb";
                comp_obj_heading_.ocn                   = 0;
                comp_obj_heading_.obj_cite_number       = "";
                comp_obj_heading_.marked_up_level       = "B";
                comp_obj_heading_.heading_lev_markup    = 1;
                comp_obj_heading_.heading_lev_collapsed = 1;
                comp_obj_heading_.parent_ocn            = 1;
                comp_obj_heading_.parent_lev_markup     = 0;
                the_blurb_section                       ~= comp_obj_heading_;
                comp_obj_heading_                       = comp_obj_heading_.init;
                comp_obj_heading_.use                   = "backmatter";
                comp_obj_heading_.is_of                 = "para";
                comp_obj_heading_.is_a                  = "heading";
                comp_obj_heading_.text                  = "Blurb";
                comp_obj_heading_.ocn                   = 0;
                comp_obj_heading_.obj_cite_number       = "";
                comp_obj_heading_.segment_anchor_tag    = "blurb";
                comp_obj_heading_.marked_up_level       = "1";
                comp_obj_heading_.heading_lev_markup    = 4;
                comp_obj_heading_.heading_lev_collapsed = 2;
                comp_obj_heading_.parent_ocn            = 1;
                comp_obj_heading_.parent_lev_markup     = 0;
                comp_obj_heading_.anchor_tags           = ["blurb"];
                the_blurb_section                       ~= comp_obj_heading_;
              } else if ((matchFirst(line, rgx.heading))
              && (opt_action_bool["backmatter"] && opt_action_bool["section_blurb"])) {
                comp_obj_heading_                       = comp_obj_heading_.init;
                comp_obj_heading_.use                   = "backmatter";
                comp_obj_heading_.is_of                 = "para";
                comp_obj_heading_.is_a                  = "heading";
                comp_obj_heading_.text                  = to!string(line);
                comp_obj_heading_.ocn                   = 0;
                comp_obj_heading_.obj_cite_number       = "";
                comp_obj_heading_.segment_anchor_tag    = "blurb";
                comp_obj_heading_.marked_up_level       = to!string(an_object["lev"]);
                comp_obj_heading_.heading_lev_markup    = to!int(an_object["lev_markup_number"]);    // make int, remove need to conv
                comp_obj_heading_.heading_lev_collapsed = to!int(an_object["lev_collapsed_number"]); // make int, remove need to conv
                comp_obj_heading_.parent_ocn            = 1;
                comp_obj_heading_.parent_lev_markup     = 0;
                the_blurb_section                   ~= comp_obj_heading_;
              } else {
                _para_match_(line, an_object, an_object_key, indent, bullet, type, line_occur);
                comp_obj_para                       = comp_obj_para.init;
                comp_obj_para.use                   = "backmatter";
                comp_obj_para.is_of                 = "para";
                comp_obj_para.is_a                  = "blurb";
                comp_obj_para.text                  = to!string(line).strip;
                comp_obj_para.ocn                   = 0;
                comp_obj_para.obj_cite_number       = "";
                comp_obj_para.indent_hang           = indent["hang_position"];
                comp_obj_para.indent_base           = indent["base_position"];
                comp_obj_para.bullet                = bullet;
                the_blurb_section                   ~= comp_obj_para;
              }
              type["ocn_status"] = TriState.off;
            }
            continue;
          } else if (type["poem"] == TriState.on) {
            /+ within block object: poem +/
            _poem_block_(line, an_object, type, cntr, obj_cite_number_poem, dochead_make_aa);
            continue;
          /+ within block object: group +/
          } else if (type["group"] == TriState.on) {
            /+ within block object: group +/
            _group_block_(line, an_object, type);
            continue;
          } else if (type["block"] == TriState.on) {
            /+ within block object: block +/
            _block_block_(line, an_object, type);
            continue;
          } else if (type["quote"] == TriState.on) {
            /+ within block object: quote +/
            _quote_block_(line, an_object, type);
            continue;
          } else if (type["table"] == TriState.on) {
            /+ within block object: table +/
            _table_block_(line, an_object, type);
            continue;
          } else {
            /+ not within a block group +/
            assert(
              (type["blocks"] == TriState.off)
              || (type["blocks"] == TriState.closing),
              "block status: none or closed"
            );
            assertions_flag_types_block_status_none_or_closed(type);
            if (matchFirst(line, rgx.block_open)) {
              if (matchFirst(line, (rgx.block_poem_open))) {
                /+ poem to verse exceptions! +/
                object_reset(an_object);
                processing.remove("verse");
                obj_cite_number_poem["start"] = to!string(obj_cite_number);
              }
              _start_block_(line, type, obj_cite_number_poem);
              continue;
            } else if (!line.empty) {
              /+ line not empty +/
              /+ non blocks (headings, paragraphs) & closed blocks +/
              assert(
                !line.empty,
                "line tested, line not empty surely"
              );
              assert(
                (type["blocks"] == TriState.off)
                || (type["blocks"] == TriState.closing),
                "code block status: none or closed"
              );
              if (type["blocks"] == TriState.closing) {
                // blocks closed, unless followed by book index
                debug(check) {                           // block
                  writeln(__LINE__);
                  writeln(line);
                }
                assert(
                  matchFirst(line, rgx.book_index)
                  || matchFirst(line, rgx.book_index_open)
                  || type["book_index"] == State.on
                );
              }
              if ((matchFirst(line, rgx.book_index))
              || (matchFirst(line, rgx.book_index_open))
              || (type["book_index"] == State.on ))  {
                /+ book_index +/
                _book_index_(line, book_idx_tmp, an_object, type, opt_action_bool);
              } else {
                /+ not book_index +/
                an_object_key="body_nugget";
                if (auto m = matchFirst(line, rgx.comment)) {
                  /+ matched comment +/
                  debug(comment) {
                    writeln(line);
                  }
                  an_object[an_object_key] ~= line ~= "\n";
                  comp_obj_comment                   = comp_obj_comment.init;
                  comp_obj_comment.use               = "comment";
                  comp_obj_comment.is_of             = "comment";
                  comp_obj_comment.is_a              = "comment";
                  comp_obj_comment.text              = an_object[an_object_key].strip;
                  the_document_body_section          ~= comp_obj_comment;
                  _common_reset_(line_occur, an_object, type);
                  processing.remove("verse");
                  ++cntr;
                } else if (((line_occur["para"] == State.off)
                && (line_occur["heading"] == State.off))
                && ((type["para"] == State.off)
                && (type["heading"] == State.off))) {
                  /+ heading or para but neither flag nor line exists +/
                  if ((dochead_make_aa["make"]["headings"].length > 2)
                  && (type["make_headings"] == State.off)) {
                    /+ heading found +/
                    _heading_found_(line, dochead_make_aa["make"]["headings"], heading_match_str, heading_match_rgx, type);
                  }
                  if ((type["make_headings"] == State.on)
                  && ((line_occur["para"] == State.off)
                  && (line_occur["heading"] == State.off))
                  && ((type["para"] == State.off)
                  && (type["heading"] == State.off))) {
                    /+ heading make set +/
                    _heading_make_set_(line, line_occur, heading_match_rgx, type);
                  }
                  /+ TODO node info: all headings identified at this point,
                     - extract node info here??
                     - how long can it wait?
                     - should be incorporated in composite objects
                     - should happen before endnote links set (they need to be moved down?)
                    // node_construct.node_emitter_heading segment anchor tag
                  +/
                  if (matchFirst(line, rgx.heading)) {
                    /+ heading match +/
                    _heading_matched_(line, line_occur, an_object, an_object_key, lv, collapsed_lev, type, dochead_meta_aa);
                  } else if (line_occur["para"] == State.off) {
                    /+ para match +/
                    an_object_key="body_nugget";
                    _para_match_(line, an_object, an_object_key, indent, bullet, type, line_occur);
                  }
                } else if (line_occur["heading"] > State.off) {
                  /+ heading +/
                  debug(heading) {                         // heading
                    writeln(line);
                  }
                  an_object[an_object_key] ~= line ~= "\n";
                  ++line_occur["heading"];
                } else if (line_occur["para"] > State.off) {
                  /+ paragraph +/
                  debug(para) {
                    writeln(line);
                  }
                  an_object[an_object_key] ~= " " ~ line;
                  ++line_occur["para"];
                }
              }
            } else if (type["blocks"] == TriState.closing) {
              /+ line empty, with blocks flag +/
              _block_flag_line_empty_(
                line,
                an_object,
                the_document_body_section,
                bookindex_unordered_hashes,
                obj_cite_number,
                comp_obj_heading,
                cntr,
                type,
                obj_cite_number_poem,
                dochead_make_aa
              );
            } else {
              /+ line.empty, post contents, empty variables: +/
              assert(
                line.empty,
                "line should be empty"
              );
              assert(
                (type["blocks"] == State.off),
                "code block status: none"
              );
              if ((type["heading"] == State.on)
              && (line_occur["heading"] > State.off)) {
                /+ heading object (current line empty) +/
                obj_cite_number = (to!int(an_object["lev_markup_number"]) == 0)
                ? (ocn_emit(3))
                : (obj_cite_number = ocn_emit(type["ocn_status"]));
                an_object["bookindex_nugget"] =
                  ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : "";
                bookindex_unordered_hashes =
                  bkidx_hash(an_object["bookindex_nugget"], obj_cite_number);
                an_object["is"] = "heading";
                an_object_key="body_nugget";
                auto substantive_object_and_anchor_tags_tuple =
                  obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa); // tuple this with anchor tags?
                an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0];
                anchor_tags = substantive_object_and_anchor_tags_tuple[1];
                if (to!int(an_object["lev_markup_number"]) == 4) {
                  segment_anchor_tag_that_object_belongs_to = anchor_tags[0];
                  segment_anchor_tag_that_object_belongs_to_uri = anchor_tags[0] ~ ".fnSuffix";
                  anchor_tag_ = anchor_tags[0];
                } else if (to!int(an_object["lev_markup_number"]) > 4) {
                  segment_anchor_tag_that_object_belongs_to = anchor_tag_;
                  segment_anchor_tag_that_object_belongs_to_uri = anchor_tag_ ~ ".fnSuffix#" ~ to!string(obj_cite_number);
                } else if (to!int(an_object["lev_markup_number"]) < 4) {
                  segment_anchor_tag_that_object_belongs_to = "";
                  segment_anchor_tag_that_object_belongs_to_uri = "";
                }
                /+ (incrementally build toc) table of contents here! +/
                _anchor_tag=to!string(obj_cite_number);
                the_table_of_contents_section = obj_im.table_of_contents_gather_headings(
                  an_object,
                  dochead_make_aa,
                  segment_anchor_tag_that_object_belongs_to,
                  _anchor_tag,
                  lev4_subtoc,
                  the_table_of_contents_section,
                );
                if (an_object["lev_markup_number"] == "4") {
                  html_segnames ~= segment_anchor_tag_that_object_belongs_to;
                  html_segnames_ptr = html_segnames_ptr_cntr;
                  html_segnames_ptr_cntr++;
                }
                auto comp_obj_heading =
                  node_construct.node_emitter_heading(
                    an_object["substantive"],                     // string
                    an_object["lev"],                             // string
                    an_object["lev_markup_number"],               // string
                    an_object["lev_collapsed_number"],            // string
                    segment_anchor_tag_that_object_belongs_to,    // string
                    obj_cite_number,                              // int
                    cntr,                                         // int
                    heading_ptr,                                  // int
                    lv_ancestors,                                 // string[]
                    an_object["is"],                              // string
                    html_segnames_ptr,                            // int
                  );
                ++heading_ptr;
                debug(segments) {
                  writeln(an_object["lev_markup_number"]);
                  writeln(segment_anchor_tag_that_object_belongs_to);
                }
                the_document_body_section ~= comp_obj_heading;
                // track previous heading and make assertions
                debug(objectrelated1) { // check
                  writeln(line);
                }
                _common_reset_(line_occur, an_object, type);
                an_object.remove("lev");
                an_object.remove("lev_markup_number");
                processing.remove("verse");
                ++cntr;
              } else if ((type["para"] == State.on) && (line_occur["para"] > State.off)) {
                /+ paragraph object (current line empty) +/
                obj_cite_number = ocn_emit(type["ocn_status"]);
                an_object["bookindex_nugget"] =
                  ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : "";
                bookindex_unordered_hashes =
                  bkidx_hash(an_object["bookindex_nugget"], obj_cite_number);
                an_object["is"] = "para";
                auto comp_obj_heading =
                  node_construct.node_location_emitter(
                    content_non_header,
                    segment_anchor_tag_that_object_belongs_to,
                    obj_cite_number,
                    cntr,
                    heading_ptr-1,
                    an_object["is"],
                  );
                auto substantive_object_and_anchor_tags_tuple =
                  obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa); // ...
                an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0];
                anchor_tags = substantive_object_and_anchor_tags_tuple[1];
                comp_obj_para                       = comp_obj_para.init;
                comp_obj_para.use                   = "body";
                comp_obj_para.is_of                 = "para";
                comp_obj_para.is_a                  = "para";
                comp_obj_para.text                  = to!string(an_object["substantive"]).strip;
                comp_obj_para.ocn                   = obj_cite_number;
                comp_obj_para.obj_cite_number       = (obj_cite_number==0) ? "" : to!string(obj_cite_number);
                comp_obj_para.indent_hang           = indent["hang_position"];
                comp_obj_para.indent_base           = indent["base_position"];
                comp_obj_para.bullet                = bullet;
                comp_obj_para.anchor_tags           = anchor_tags;
                the_document_body_section           ~= comp_obj_para;
                _common_reset_(line_occur, an_object, type);
                indent=[
                  "hang_position" : 0,
                  "base_position" : 0,
                ];
                bullet = false;
                processing.remove("verse");
                ++cntr;
              } else {
                assert(
                  line == null,
                  "line variable should be empty, should not occur"
                );
                // check what happens when paragraph separated by 2 newlines
              }
            } // close else for line empty
          } // close else for not the above
        } // close after non code, other blocks or regular text
        /+ unless (the_document_body_section.length == 0) ? +/
        if (the_document_body_section.length > 0) {
          if (((the_document_body_section[$-1].is_a == "para")
          || (the_document_body_section[$-1].is_a == "heading")
          || (the_document_body_section[$-1].is_a == "group"))
          && (the_document_body_section.length > previous_length)
        ) {
            if ((the_document_body_section[$-1].is_a == "heading")
            && (the_document_body_section[$-1].heading_lev_markup < 5)) {
              type["biblio_section"] = State.off;
              type["glossary_section"] = State.off;
              type["blurb_section"] = State.off;
            }
            previous_length = to!int(the_document_body_section.length);
            if (
              match(the_document_body_section[$-1].text,
              rgx.inline_notes_delimiter_al_regular_number_note)
            ) {
              previous_count=to!int(the_document_body_section.length -1);
              note_section.gather_notes_for_endnote_section(
                the_document_body_section,
                segment_anchor_tag_that_object_belongs_to,
                to!int(the_document_body_section.length-1),
              );
            }
          }
        }
      } /+ ← closed: loop markup document/text line by line +/
      /+ ↓ post loop markup document/text +/
      debug(objectrelated2) { // check
        writeln(line);
      }
      /+
        Backmatter:
        - endnotes
        - glossary
        - bibliography / references
        - book index
        - blurb
      +/
      // TODO FIGURE OUT, you need this possibility
      // obj_im.obj_inline_markup_and_anchor_tags("doc_end_reset", an_object_key, "", dochead_make_aa);
      auto en_tuple =
        note_section.endnote_objects(obj_cite_number, opt_action_bool);
      static assert(!isTypeTuple!(en_tuple));
      auto the_endnotes_section = en_tuple[0];
      obj_cite_number = en_tuple[1];
      debug(endnotes) {
        writefln(
          "%s %s",
          __LINE__,
          the_endnotes_section.length
        );
        foreach (o; the_endnotes_section) {
          writeln(o);
        }
      }
      if (an_object["glossary_nugget"].length == 0) {
        comp_obj_heading_                       = comp_obj_heading_.init;
        comp_obj_heading_.use                   = "empty";
        comp_obj_heading_.is_of                 = "para";
        comp_obj_heading_.is_a                  = "heading";
        comp_obj_heading_.text                  = "(skip) there is no Glossary section";
        comp_obj_heading_.ocn                   = 0;
        comp_obj_heading_.obj_cite_number       = "";
        comp_obj_heading_.marked_up_level       = "B";
        comp_obj_heading_.heading_lev_markup    = 1;
        comp_obj_heading_.heading_lev_collapsed = 1;
        comp_obj_heading_.parent_ocn            = 1;
        comp_obj_heading_.parent_lev_markup     = 0;
        the_glossary_section                    ~= comp_obj_heading_;
      } else {
        writeln("gloss");
      }
      debug(glossary) {
        foreach (gloss; the_glossary_section) {
          writeln(gloss.text);
        }
      }
      auto biblio_unsorted_incomplete = biblio_arr_json.dup;
      // destroy(biblio_arr_json);
      auto biblio = Bibliography();
      auto biblio_ordered =
        biblio._bibliography_(biblio_unsorted_incomplete, bib_arr_json);
      if (biblio_ordered.length > 0) {
        comp_obj_heading_                       = comp_obj_heading_.init;
        comp_obj_heading_.use                   = "backmatter";
        comp_obj_heading_.is_of                 = "para";
        comp_obj_heading_.is_a                  = "heading";
        comp_obj_heading_.text                  = "Bibliography";
        comp_obj_heading_.ocn                   = 0;
        comp_obj_heading_.obj_cite_number       = "";
        comp_obj_heading_.marked_up_level       = "B";
        comp_obj_heading_.heading_lev_markup    = 1;
        comp_obj_heading_.heading_lev_collapsed = 1;
        comp_obj_heading_.parent_ocn            = 1;
        comp_obj_heading_.parent_lev_markup     = 0;
        the_bibliography_section                ~= comp_obj_heading_;
        // ---
        comp_obj_heading_                       = comp_obj_heading_.init;
        comp_obj_heading_.use                   = "backmatter";
        comp_obj_heading_.is_of                 = "para";
        comp_obj_heading_.is_a                  = "heading";
        comp_obj_heading_.text                  = "Bibliography";
        comp_obj_heading_.ocn                   = 0;
        comp_obj_heading_.obj_cite_number       = "";
        comp_obj_heading_.segment_anchor_tag    = "bibliography";
        comp_obj_heading_.marked_up_level       = "1";
        comp_obj_heading_.heading_lev_markup    = 4;
        comp_obj_heading_.heading_lev_collapsed = 2;
        comp_obj_heading_.parent_ocn            = 1;
        comp_obj_heading_.parent_lev_markup     = 0;
        comp_obj_heading_.anchor_tags           = ["bibliography"];
        the_bibliography_section                ~= comp_obj_heading_;
      } else {
        comp_obj_heading_                       = comp_obj_heading_.init;
        comp_obj_heading_.use                   = "empty";
        comp_obj_heading_.is_of                 = "para";
        comp_obj_heading_.is_a                  = "heading";
        comp_obj_heading_.text                  = "(skip) there is no Bibliography";
        comp_obj_heading_.ocn                   = 0;
        comp_obj_heading_.obj_cite_number       = "";
        comp_obj_heading_.marked_up_level       = "B";
        comp_obj_heading_.heading_lev_markup    = 1;
        comp_obj_heading_.heading_lev_collapsed = 1;
        comp_obj_heading_.parent_ocn            = 1;
        comp_obj_heading_.parent_lev_markup     = 0;
        the_bibliography_section                ~= comp_obj_heading_;
      }
      string out_;
      foreach (entry; biblio_ordered) {
        out_ = format(
          "%s \"%s\"%s%s%s%s%s%s%s%s%s.",
          ((entry["author"].str.empty) ? entry["editor"].str : entry["author"].str),
          entry["fulltitle"].str,
          ((entry["journal"].str.empty) ? "" : ", /{" ~ entry["journal"].str ~ "}/"),
          ((entry["volume"].str.empty) ? "" : ", " ~ entry["volume"].str),
          ((entry["in"].str.empty) ? "" : ", " ~ entry["in"].str),
          ((!(entry["author"].str.empty) && (!(entry["editor"].str.empty))) ? entry["editor"].str : ""),
          ", " ~ entry["year"].str,
          ((entry["pages"].str.empty) ? "" : ", " ~ entry["pages"].str),
          ((entry["publisher"].str.empty) ? "" : ", " ~ entry["publisher"].str),
          ((entry["place"].str.empty) ? "" : ", " ~ entry["place"].str),
          ((entry["url"].str.empty) ? "" : ", [" ~ entry["url"].str ~ "]"),
        );
        comp_obj_para                       = comp_obj_para.init;
        comp_obj_para.use                   = "backmatter";
        comp_obj_para.is_of                 = "para";
        comp_obj_para.is_a                  = "bibliography";
        comp_obj_para.text                  = to!string(out_).strip;
        comp_obj_para.ocn                   = 0;
        comp_obj_para.obj_cite_number       = "";
        comp_obj_para.indent_hang           = 0;
        comp_obj_para.indent_base           = 1;
        comp_obj_para.bullet                = bullet;
        comp_obj_para.anchor_tags           = anchor_tags;
        the_bibliography_section            ~= comp_obj_para;
      }
      debug(bibliosection) {
        foreach (o; the_bibliography_section) {
          writeln(o.text);
        }
      }
      auto bi = BookIndexReportSection();
      auto bi_tuple =
        bi.bookindex_build_abstraction_section(
          bookindex_unordered_hashes,
          obj_cite_number,
          segment_anchor_tag_that_object_belongs_to,
          opt_action_bool,
        );
      static assert(!isTypeTuple!(bi_tuple));
      auto the_bookindex_section = bi_tuple[0];
      obj_cite_number = bi_tuple[1];
      debug(bookindex) {                         // bookindex
        foreach (bi_entry; the_bookindex_section["seg"]) {
          writeln(bi_entry);
        }
      }
      if (an_object["blurb_nugget"].length == 0) {
        comp_obj_heading_                       = comp_obj_heading_.init;
        comp_obj_heading_.use                   = "empty";
        comp_obj_heading_.is_of                 = "para";
        comp_obj_heading_.is_a                  = "heading";
        comp_obj_heading_.text                  = "(skip) there is no Blurb section";
        comp_obj_heading_.ocn                   = 0;
        comp_obj_para.obj_cite_number           = "";
        comp_obj_heading_.segment_anchor_tag    = "";
        comp_obj_heading_.marked_up_level       = "B";
        comp_obj_heading_.heading_lev_markup    = 1;
        comp_obj_heading_.heading_lev_collapsed = 1;
        comp_obj_heading_.parent_ocn            = 1;
        comp_obj_heading_.parent_lev_markup     = 0;
        the_blurb_section                       ~= comp_obj_heading_;
      } else {
        writeln("blurb");
      }
      debug(blurb) {
        foreach (blurb; the_blurb_section) {
          writeln(blurb.text);
        }
      }
      indent=[
        "hang_position" : 1,
        "base_position" : 1,
      ];
      comp_obj_toc                       = comp_obj_toc.init;
      comp_obj_toc.use                   = "frontmatter";
      comp_obj_toc.is_of                 = "para";
      comp_obj_toc.is_a                  = "toc";
      comp_obj_toc.ocn                   = 0;
      comp_obj_toc.obj_cite_number       = "";
      comp_obj_toc.indent_hang           = indent["hang_position"];
      comp_obj_toc.indent_base           = indent["base_position"];
      comp_obj_toc.bullet                = false;
      if (the_endnotes_section.length > 1) {
        toc_txt_ = format(
          "{ %s }%s../%s.fnSuffix",
          "Endnotes",
          mkup.mark_internal_site_lnk,
          "endnotes",            // segment_anchor_tag_that_object_belongs_to
        );
        toc_txt_= munge.url_links(toc_txt_);
        comp_obj_toc.text                       = to!string(toc_txt_).strip;
        the_table_of_contents_section["seg"]    ~= comp_obj_toc;
      }
      if (the_glossary_section.length > 1) {
        toc_txt_ = format(
          "{ %s }%s../%s.fnSuffixs",
          "Glossary",
          mkup.mark_internal_site_lnk,
          "glossary",  // segment_anchor_tag_that_object_belongs_to
        );
        toc_txt_= munge.url_links(toc_txt_);
        comp_obj_toc.text                       = to!string(toc_txt_).strip;
        the_table_of_contents_section["seg"]    ~= comp_obj_toc;
        toc_txt_ = format(
          "{ %s }#%s",
          "Glossary",
          "glossary",            // _anchor_tag
        );
        toc_txt_= munge.url_links(toc_txt_);
        comp_obj_toc.text                       = to!string(toc_txt_).strip;
        the_table_of_contents_section["scroll"] ~= comp_obj_toc;
      }
      if (the_bibliography_section.length > 1){
        toc_txt_ = format(
          "{ %s }%s../%s.fnSuffix",
          "Bibliography",
          mkup.mark_internal_site_lnk,
          "bibliography",        // segment_anchor_tag_that_object_belongs_to
        );
        toc_txt_= munge.url_links(toc_txt_);
        comp_obj_toc.text                       = to!string(toc_txt_).strip;
        the_table_of_contents_section["seg"]    ~= comp_obj_toc;
      
        toc_txt_ = format(
          "{ %s }#%s",
          "Bibliography",
          "bibliography",          // _anchor_tag
        );
        toc_txt_= munge.url_links(toc_txt_);
        comp_obj_toc.text                       = to!string(toc_txt_).strip;
        the_table_of_contents_section["scroll"] ~= comp_obj_toc;
      }
      if (the_bookindex_section["seg"].length > 1) {
        toc_txt_ = format(
          "{ %s }%s../%s.fnSuffix",
          "Book Index",
          mkup.mark_internal_site_lnk,
          "bookindex",          // segment_anchor_tag_that_object_belongs_to
        );
        toc_txt_= munge.url_links(toc_txt_);
        comp_obj_toc.text                       = to!string(toc_txt_).strip;
        the_table_of_contents_section["seg"]    ~= comp_obj_toc;
      }
      if (the_bookindex_section["scroll"].length > 1) {
        toc_txt_ = format(
          "{ %s }#%s",
          "Book Index",
          "bookindex",            // _anchor_tag
        );
        toc_txt_= munge.url_links(toc_txt_);
        comp_obj_toc.text                       = to!string(toc_txt_).strip;
        the_table_of_contents_section["scroll"] ~= comp_obj_toc;
      }
      if (the_blurb_section.length > 1) {
        toc_txt_ = format(
          "{ %s }%s../%s.fnSuffix",
          "Blurb",
          mkup.mark_internal_site_lnk,
          "blurb",                // segment_anchor_tag_that_object_belongs_to
        );
        toc_txt_= munge.url_links(toc_txt_);
        comp_obj_toc.text                       = to!string(toc_txt_).strip;
        the_table_of_contents_section["seg"]    ~= comp_obj_toc;
        toc_txt_ = format(
          "{ %s }#%s",
          "Blurb",
          "blurb",                // _anchor_tag
        );
        toc_txt_= munge.url_links(toc_txt_);
        comp_obj_toc.text                       = to!string(toc_txt_).strip;
        the_table_of_contents_section["scroll"] ~= comp_obj_toc;
      }
      debug(toc) {
        writefln(
          "%s %s",
          __LINE__,
          the_table_of_contents_section["seg"].length
        );
        foreach (toc_linked_heading; the_table_of_contents_section["seg"]) {
          writeln(mkup.indent_by_spaces_provided(toc_linked_heading.indent_hang), toc_linked_heading.text);
        }
      }
      debug(tocscroll) {
        writefln(
          "%s %s",
          __LINE__,
          the_table_of_contents_section["seg"].length
        );
        foreach (toc_linked_heading; the_table_of_contents_section["scroll"]) {
          writeln(mkup.indent_by_spaces_provided(toc_linked_heading.indent_hang), toc_linked_heading.text);
        }
      }
      the_document_head_section ~= the_document_body_section[0];
      the_document_body_section=the_document_body_section[1..$];
      if (the_endnotes_section.length > 1) {
        html_segnames ~= "endnotes";
        html_segnames_ptr = html_segnames_ptr_cntr;
        foreach (ref section; the_endnotes_section) {
          if (section.heading_lev_markup == 4) {
            section.ptr_html_segnames = html_segnames_ptr;
            break;
          }
        }
        html_segnames_ptr_cntr++;
      }
      if (the_glossary_section.length > 1) {
        html_segnames ~= "glossary";
        html_segnames_ptr = html_segnames_ptr_cntr;
        foreach (ref section; the_glossary_section) {
          if (section.heading_lev_markup == 4) {
            section.ptr_html_segnames = html_segnames_ptr;
            break;
          }
        }
        html_segnames_ptr_cntr++;
      }
      if (the_bibliography_section.length > 1) {
        html_segnames ~= "bibliography";
        html_segnames_ptr = html_segnames_ptr_cntr;
        foreach (ref section; the_bibliography_section) {
          if (section.heading_lev_markup == 4) {
            section.ptr_html_segnames = html_segnames_ptr;
            break;
          }
        }
        html_segnames_ptr_cntr++;
      }
      if (the_bookindex_section["scroll"].length > 1) {
        html_segnames ~= "bookindex";
        html_segnames_ptr = html_segnames_ptr_cntr;
        foreach (ref section; the_bookindex_section["scroll"]) {
          if (section.heading_lev_markup == 4) {
            section.ptr_html_segnames = html_segnames_ptr;
            break;
          }
        }
        foreach (ref section; the_bookindex_section["seg"]) {
          if (section.heading_lev_markup == 4) {
            section.ptr_html_segnames = html_segnames_ptr;
            break;
          }
        }
        html_segnames_ptr_cntr++;
      }
      if (the_blurb_section.length > 1) {
        html_segnames ~= "blurb";
        html_segnames_ptr = html_segnames_ptr_cntr;
        foreach (ref section; the_blurb_section) {
          if (section.heading_lev_markup == 4) {
            section.ptr_html_segnames = html_segnames_ptr;
            break;
          }
        }
        html_segnames_ptr_cntr++;
      }
      foreach (ref obj; the_document_head_section) {
        if (obj.is_a == "heading") {
          debug(dom) {
            writeln(obj.text);
          }
          if ((opt_action_bool["html"])
          || (opt_action_bool["html_scroll"])
          || (opt_action_bool["html_seg"])
          || (opt_action_bool["epub"])) {
            obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
            obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
          }
          heading_ancestors(obj, lv_ancestors);
        }
      }
      if (the_table_of_contents_section["scroll"].length > 1) {
        dom_markedup_buffer = dom_markedup.dup;
        dom_collapsed_buffer = dom_collapsed.dup;
        foreach (ref obj; the_table_of_contents_section["scroll"]) {
          if (obj.is_a == "heading") {
            debug(dom) {
            // writeln(obj.text);
            }
            if (obj.heading_lev_markup == 4) {
              obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
              assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
            }
            if ((opt_action_bool["html"])
            || (opt_action_bool["html_scroll"])
            || (opt_action_bool["html_seg"])
            || (opt_action_bool["epub"])) {
              obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
              obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
            }
            heading_ancestors(obj, lv_ancestors);
          }
        }
        dom_markedup = dom_markedup_buffer.dup;
        dom_collapsed = dom_collapsed_buffer.dup;
        foreach (ref obj; the_table_of_contents_section["seg"]) {
          if (obj.is_a == "heading") {
            debug(dom) {
              writeln(obj.text);
            }
            if (obj.heading_lev_markup == 4) {
              obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
              assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
            }
            if ((opt_action_bool["html"])
            || (opt_action_bool["html_scroll"])
            || (opt_action_bool["html_seg"])
            || (opt_action_bool["epub"])) {
              obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
              obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
            }
            heading_ancestors(obj, lv_ancestors);
          }
        }
      }
      /+ multiple 1~ levels, loop through document body +/
      if (the_document_body_section.length > 1) {
        foreach (ref obj; the_document_body_section) {
          if (obj.is_a == "heading") {
            debug(dom) {
              writeln(obj.text);
            }
            if (obj.heading_lev_markup == 4) {
              obj.lev4_subtoc = lev4_subtoc[obj.segment_anchor_tag];
              obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
              if (html_segnames.length > obj.ptr_html_segnames + 1) {
                obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
              }
              assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
            }
            if ((opt_action_bool["html"])
            || (opt_action_bool["html_scroll"])
            || (opt_action_bool["html_seg"])
            || (opt_action_bool["epub"])) {
              obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
              obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
            }
            heading_ancestors(obj, lv_ancestors);
          }
        }
      }
      /+ optional only one 1~ level +/
      if (the_endnotes_section.length > 1) {
        dom_markedup_buffer = dom_markedup.dup;
        dom_collapsed_buffer = dom_collapsed.dup;
        dom_markedup = dom_markedup_buffer.dup;
        dom_collapsed = dom_collapsed_buffer.dup;
        foreach (ref obj; the_endnotes_section) {
          if (obj.is_a == "heading") {
            debug(dom) {
              writeln(obj.text);
            }
            if (obj.heading_lev_markup == 4) {
              obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
              if (html_segnames.length > obj.ptr_html_segnames + 1) {
                obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
              }
              assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
            }
            if ((opt_action_bool["html"])
            || (opt_action_bool["html_scroll"])
            || (opt_action_bool["html_seg"])
            || (opt_action_bool["epub"])) {
              obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
              obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
            }
            heading_ancestors(obj, lv_ancestors);
          }
        }
      }
      /+ optional only one 1~ level +/
      if (the_glossary_section.length > 1) {
        foreach (ref obj; the_glossary_section) {
          if (obj.is_a == "heading") {
            debug(dom) {
              writeln(obj.text);
            }
            if (obj.heading_lev_markup == 4) {
              obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
              if (html_segnames.length > obj.ptr_html_segnames + 1) {
                obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
              }
              assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
            }
            if ((opt_action_bool["html"])
            || (opt_action_bool["html_scroll"])
            || (opt_action_bool["html_seg"])
            || (opt_action_bool["epub"])) {
              obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
              obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
            }
            heading_ancestors(obj, lv_ancestors);
          }
        }
      }
      /+ optional only one 1~ level +/
      if (the_bibliography_section.length > 1) {
        foreach (ref obj; the_bibliography_section) {
          if (obj.is_a == "heading") {
            debug(dom) {
              writeln(obj.text);
            }
            if (obj.heading_lev_markup == 4) {
              obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
              if (html_segnames.length > obj.ptr_html_segnames + 1) {
                obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
              }
              assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
            }
            if ((opt_action_bool["html"])
            || (opt_action_bool["html_scroll"])
            || (opt_action_bool["html_seg"])
            || (opt_action_bool["epub"])) {
              obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
              obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
            }
            heading_ancestors(obj, lv_ancestors);
          }
        }
      }
      /+ optional only one 1~ level +/
      if (the_bookindex_section["scroll"].length > 1) {
        dom_markedup_buffer = dom_markedup.dup;
        dom_collapsed_buffer = dom_collapsed.dup;
        foreach (ref obj; the_bookindex_section["scroll"]) {
          if (obj.is_a == "heading") {
            debug(dom) {
            // writeln(obj.text);
            }
            if (obj.heading_lev_markup == 4) {
              obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
              if (html_segnames.length > obj.ptr_html_segnames + 1) {
                obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
              }
              assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
            }
            if ((opt_action_bool["html"])
            || (opt_action_bool["html_scroll"])
            || (opt_action_bool["html_seg"])
            || (opt_action_bool["epub"])) {
              obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
              obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
            }
            heading_ancestors(obj, lv_ancestors);
          }
        }
        dom_markedup = dom_markedup_buffer.dup;
        dom_collapsed = dom_collapsed_buffer.dup;
        foreach (ref obj; the_bookindex_section["seg"]) {
          if (obj.is_a == "heading") {
            debug(dom) {
              writeln(obj.text);
            }
            if (obj.heading_lev_markup == 4) {
              obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
              if (html_segnames.length > obj.ptr_html_segnames + 1) {
                obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
              }
              assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
            }
            if ((opt_action_bool["html"])
            || (opt_action_bool["html_scroll"])
            || (opt_action_bool["html_seg"])
            || (opt_action_bool["epub"])) {
              obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
              obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
            }
            heading_ancestors(obj, lv_ancestors);
          }
        }
      }
      /+ optional only one 1~ level +/
      if (the_blurb_section.length > 1) {
        foreach (ref obj; the_blurb_section) {
          if (obj.is_a == "heading") {
            debug(dom) {
              writeln(obj.text);
            }
            if (obj.heading_lev_markup == 4) {
              obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
              if (html_segnames.length > obj.ptr_html_segnames + 1) {
                obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
              }
              assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
            }
            if ((opt_action_bool["html"])
            || (opt_action_bool["html_scroll"])
            || (opt_action_bool["html_seg"])
            || (opt_action_bool["epub"])) {
              obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
              obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
            }
            heading_ancestors(obj, lv_ancestors);
          }
        }
        /+ TODO
          - note create/insert heading object sole purpose eof close all open tags
            sort out:
            - obj.dom_markedup = dom_markedup;
            - obj.dom_collapsed = dom_collapsed;
        +/
        dom_markedup = dom_set_markup_tags(dom_markedup, 0);
        dom_collapsed = dom_set_collapsed_tags(dom_collapsed, 0);
        comp_obj_heading_                       = comp_obj_heading_.init;
        comp_obj_heading_.use                   = "empty";
        comp_obj_heading_.is_of                 = "para";
        comp_obj_heading_.is_a                  = "heading";
        // comp_obj_heading_.text                  = "(skip) this is the DOM tail";
        comp_obj_heading_.ocn                   = 0;
        comp_obj_para.obj_cite_number           = "";
        comp_obj_heading_.segment_anchor_tag    = "";
        comp_obj_heading_.marked_up_level       = "";
        comp_obj_heading_.heading_lev_markup    = 9;
        comp_obj_heading_.heading_lev_collapsed = 9;
        comp_obj_heading_.parent_ocn            = 0;
        comp_obj_heading_.parent_lev_markup     = 0;
        comp_obj_heading_.dom_markedup          = dom_markedup.dup;
        comp_obj_heading_.dom_collapsed         = dom_collapsed.dup;
        the_dom_tail_section                    ~= comp_obj_heading_;
      }
      auto document_the = [
        "head":             the_document_head_section,
        "toc_seg":          the_table_of_contents_section["seg"],
        "toc_scroll":       the_table_of_contents_section["scroll"],
        /+ substantive/body: +/
        "body":             the_document_body_section,
        /+ backmatter: +/
        "endnotes":         the_endnotes_section,
        "glossary":         the_glossary_section,
        "bibliography":     the_bibliography_section,
        "bookindex_scroll": the_bookindex_section["scroll"],
        "bookindex_seg":    the_bookindex_section["seg"],
        "blurb":            the_blurb_section,
        /+ dom tail only +/
        "tail":             the_dom_tail_section,
      ];
      string[][string] document_section_keys_sequenced = [
        "seg":    ["head", "toc_seg", "body",],
        "scroll": ["head", "toc_scroll", "body",]
      ];
      if (document_the["endnotes"].length > 1) {
        document_section_keys_sequenced["seg"]    ~= "endnotes";
        document_section_keys_sequenced["scroll"] ~= "endnotes";
      }
      if (document_the["glossary"].length > 1) {
        document_section_keys_sequenced["seg"]    ~= "glossary";
        document_section_keys_sequenced["scroll"] ~= "glossary";
      }
      if (document_the["bibliography"].length > 1) {
        document_section_keys_sequenced["seg"]    ~= "bibliography";
        document_section_keys_sequenced["scroll"] ~= "bibliography";
      }
      if (document_the["bookindex_seg"].length > 1) {
        document_section_keys_sequenced["seg"]    ~= "bookindex_seg";
      }
      if (document_the["bookindex_scroll"].length > 1) {
        document_section_keys_sequenced["scroll"] ~= "bookindex_scroll";
      }
      if (document_the["blurb"].length > 1) {
        document_section_keys_sequenced["seg"]    ~= "blurb";
        document_section_keys_sequenced["scroll"] ~= "blurb";
      }
      if ((opt_action_bool["html"])
      || (opt_action_bool["html_scroll"])
      || (opt_action_bool["html_seg"])
      || (opt_action_bool["epub"])) {
        document_section_keys_sequenced["seg"]    ~= "tail";
        document_section_keys_sequenced["scroll"] ~= "tail";
      }
      auto t = tuple(
        document_the,
        document_section_keys_sequenced,
        html_segnames,
      );
      return t;
      /+ post loop markup document/text ↑ +/
    } /+ ← closed: abstract doc source +/
    /+ ↓ abstraction functions +/
    auto object_reset(ref string[string] an_object) {
      an_object.remove("body_nugget");
      an_object.remove("substantive");
      an_object.remove("is");
      an_object.remove("attrib");
      an_object.remove("bookindex_nugget");
    }
    auto _common_reset_(
      ref int[string]    line_occur,
      ref string[string] an_object,
      ref int[string]    type
    ) {
      line_occur["heading"] = State.off;
      line_occur["para"]    = State.off;
      type["heading"]       = State.off;
      type["para"]          = State.off;
      object_reset(an_object);
    }
    void _check_ocn_status_(
      char[]          line,
      ref int[string] type
    ) {
      if ((!line.empty) && (type["ocn_status_multi_obj"] == TriState.off)) {
        /+ not multi-line object, check whether obj_cite_number is on or turned off +/
        if (matchFirst(line, rgx.obj_cite_number_block_marks)) {
          /+ switch off obj_cite_number +/
          if (matchFirst(line, rgx.obj_cite_number_off_block)) {
            type["ocn_status_multi_obj"] = TriState.on;
            debug(ocnoff) {
              writeln(line);
            }
          }
          if (matchFirst(line, rgx.obj_cite_number_off_block_dh)) {
            type["ocn_status_multi_obj"] = TriState.closing;
            debug(ocnoff) {
              writeln(line);
            }
          }
        } else {
          if (type["ocn_status_multi_obj"] == TriState.off) {
            if (matchFirst(line, rgx.obj_cite_number_off)) {
              type["ocn_status"] = TriState.on;
            } else if (matchFirst(line, rgx.obj_cite_number_off_dh)) {
              type["ocn_status"] = TriState.closing;
            } else {
              type["ocn_status"] = TriState.off;
            }
          } else {
            type["ocn_status"] =
              type["ocn_status_multi_obj"];
          }
        }
      } else if ((!line.empty) && (type["ocn_status_multi_obj"] > TriState.off)) {
        if (matchFirst(line, rgx.obj_cite_number_off_block_close)) {
          type["ocn_status_multi_obj"] = TriState.off;
          type["ocn_status"] = TriState.off;
          debug(ocnoff) {
            writeln(line);
          }
        }
      }
    }
    void _start_block_(
      char[]          line,
      ref int[string] type,
      string[string]  obj_cite_number_poem
    ) {
      if (matchFirst(line, rgx.block_curly_code_open)) {
        /+ curly code open +/
        debug(code) {                              // code (curly) open
          writefln(
            "* [code curly] %s",
            line
          );
        }
        type["blocks"] = TriState.on;
        type["code"] = TriState.on;
        type["curly_code"] = TriState.on;
      } else if (matchFirst(line, rgx.block_curly_poem_open)) {
        /+ curly poem open +/
        debug(poem) {                              // poem (curly) open
          writefln(
            "* [poem curly] %s",
            line
          );
        }
        obj_cite_number_poem["start"] =
          to!string(obj_cite_number);
        type["blocks"] = TriState.on;
        type["verse_new"] = State.on;
        type["poem"] = TriState.on;
        type["curly_poem"] = TriState.on;
      } else if (matchFirst(line, rgx.block_curly_group_open)) {
        /+ curly group open +/
        debug(group) {                             // group (curly) open
          writefln(
            "* [group curly] %s",
            line
          );
        }
        type["blocks"] = TriState.on;
        type["group"] = TriState.on;
        type["curly_group"] = TriState.on;
      } else if (matchFirst(line, rgx.block_curly_block_open)) {
        /+ curly block open +/
        debug(block) {                             // block (curly) open
          writefln(
            "* [block curly] %s",
            line
          );
        }
        type["blocks"] = TriState.on;
        type["block"] = TriState.on;
        type["curly_block"] = TriState.on;
      } else if (matchFirst(line, rgx.block_curly_quote_open)) {
        /+ curly quote open +/
        debug(quote) {                             // quote (curly) open
          writefln(
            "* [quote curly] %s",
            line
          );
        }
        type["blocks"] = TriState.on;
        type["quote"] = TriState.on;
        type["curly_quote"] = TriState.on;
      } else if (matchFirst(line, rgx.block_curly_table_open)) {
        /+ curly table open +/
        debug(table) {                             // table (curly) open
          writefln(
            "* [table curly] %s",
            line
          );
        }
        type["blocks"] = TriState.on;
        type["table"] = TriState.on;
        type["curly_table"] = TriState.on;
      } else if (matchFirst(line, rgx.block_tic_code_open)) {
        /+ tic code open +/
        debug(code) {                              // code (tic) open
          writefln(
            "* [code tic] %s",
            line
          );
        }
        type["blocks"] = TriState.on;
        type["code"] = TriState.on;
        type["tic_code"] = TriState.on;
      } else if (matchFirst(line, rgx.block_tic_poem_open)) {
        /+ tic poem open +/
        debug(poem) {                              // poem (tic) open
          writefln(
            "* [poem tic] %s",
            line
          );
        }
        obj_cite_number_poem["start"] = to!string(obj_cite_number);
        type["blocks"] = TriState.on;
        type["verse_new"] = State.on;
        type["poem"] = TriState.on;
        type["tic_poem"] = TriState.on;
      } else if (matchFirst(line, rgx.block_tic_group_open)) {
        /+ tic group open +/
        debug(group) {                             // group (tic) open
          writefln(
            "* [group tic] %s",
            line
          );
        }
        type["blocks"] = TriState.on;
        type["group"] = TriState.on;
        type["tic_group"] = TriState.on;
      } else if (matchFirst(line, rgx.block_tic_block_open)) {
        /+ tic block open +/
        debug(block) {                             // block (tic) open
          writefln(
            "* [block tic] %s",
            line
          );
        }
        type["blocks"] = TriState.on;
        type["block"] = TriState.on;
        type["tic_block"] = TriState.on;
      } else if (matchFirst(line, rgx.block_tic_quote_open)) {
        /+ tic quote open +/
        debug(quote) {                             // quote (tic) open
          writefln(
            "* [quote tic] %s",
            line
          );
        }
        type["blocks"] = TriState.on;
        type["quote"] = TriState.on;
        type["tic_quote"] = TriState.on;
      } else if (matchFirst(line, rgx.block_tic_table_open)) {
        /+ tic table open +/
        debug(table) {                             // table (tic) open
          writefln(
            "* [table tic] %s",
            line
          );
        }
        type["blocks"] = TriState.on;
        type["table"] = TriState.on;
        type["tic_table"] = TriState.on;
      }
    }
    void _code_block_(
      char[]             line,
      ref string[string] an_object,
      ref int[string]    type
    ) {
      if (type["curly_code"] == TriState.on) {
        if (matchFirst(line, rgx.block_curly_code_close)) {
          debug(code) {                              // code (curly) close
            writeln(line);
          }
          type["blocks"] = TriState.closing;
          type["code"] = TriState.closing;
          type["curly_code"] = TriState.off;
        } else {
          debug(code) {                              // code (curly) line
            writeln(line);
          }
          an_object[an_object_key] ~= line ~= "\n";          // code (curly) line
        }
      } else if (type["tic_code"] == TriState.on) {
        if (matchFirst(line, rgx.block_tic_close)) {
          debug(code) {                              // code (tic) close
            writeln(line);
          }
          type["blocks"] = TriState.closing;
          type["code"] = TriState.closing;
          type["tic_code"] = TriState.off;
        } else {
          debug(code) {                              // code (tic) line
            writeln(line);
          }
          an_object[an_object_key] ~= line ~= "\n";          // code (tic) line
        }
      }
    }
    final string biblio_tag_map(string abr) {
      auto btm = [
        "au"                               : "author_raw",
        "ed"                               : "editor_raw",
        "ti"                               : "fulltitle",
        "lng"                              : "language",
        "jo"                               : "journal",
        "vol"                              : "volume",
        "edn"                              : "edition",
        "yr"                               : "year",
        "pl"                               : "place",
        "pb"                               : "publisher",
        "pub"                              : "publisher",
        "pg"                               : "pages",
        "pgs"                              : "pages",
        "sn"                               : "short_name"
      ];
      return btm[abr];
    }
    void _biblio_block_(
      char[] line,
      ref int[string] type,
      ref int bib_entry,
      ref string biblio_entry_str_json,
      ref string[] biblio_arr_json
    ) {
      if (matchFirst(line, rgx.heading_biblio)) {
        type["biblio_section"] = TriState.on;
        type["blurb_section"] = State.off;
        type["glossary_section"] = State.off;
      }
      if (line.empty) {
        debug {
          debug(biblioblock) {
            writeln("---");
          }
          debug(biblioblockinclude) {
            writeln(biblio_entry_str_json.length);
          }
        }
        if ((bib_entry == State.off)
        && (biblio_entry_str_json.empty)) {
          bib_entry = State.on;
          biblio_entry_str_json = biblio_entry_tags_jsonstr;
        } else if (!(biblio_entry_str_json.empty)) {
          bib_entry = State.off;
          if (!(biblio_entry_str_json == biblio_entry_tags_jsonstr)) {
            auto biblio_entry = parseJSON(biblio_entry_str_json);
            if (biblio_entry["fulltitle"].str.empty) {
              writeln("check problem entry (Title missing): ", biblio_entry_str_json);
            } else if ((biblio_entry["author_raw"].str.empty) && (biblio_entry["editor_raw"].str.empty)) {
              writeln("check problem entry (No author and no editor): ", biblio_entry_str_json);
            } else {
              biblio_arr_json ~= biblio_entry_str_json;
            }
            biblio_entry_str_json = biblio_entry_tags_jsonstr;
          }
        } else { // CHECK ERROR
          writeln("?? 2. ERROR ", biblio_entry_str_json, "??");
          biblio_entry_str_json = "";
        }
      } else if (matchFirst(line, rgx.biblio_tags)) {
        debug(biblioblock) {
          writeln(line);
        }
        auto bt = match(line, rgx.biblio_tags);
        bib_entry = State.off;
        st=to!string(bt.captures[1]);
        auto header_tag_value=to!string(bt.captures[2]);
        JSONValue j = parseJSON(biblio_entry_str_json);
        biblio_tag_name = (match(st, rgx.biblio_abbreviations))
          ? (biblio_tag_map(st))
          : st;
        j.object[biblio_tag_name] = header_tag_value;
        debug(bibliounsortedcheckduplicates) {
          writeln(biblio_tag_name, ": ", header_tag_value);
          writeln("--");
        }
        switch (biblio_tag_name) {
        case "author_raw": // author_arr author (fn sn)
          j["author_arr"] =
            split(header_tag_value, rgx.arr_delimiter);
          string tmp;
          biblioAuthorLoop:
          foreach (au; j["author_arr"].array) {
            if (auto x = match(au.str, rgx.name_delimiter)) {
              tmp ~= x.captures[2] ~ " " ~ x.captures[1] ~ ", ";
            } else {
              tmp ~= au.str;
            }
          }
          tmp = replace(tmp, rgx.trailing_comma, "");
          j["author"].str = tmp;
          goto default;
        case "editor_raw": // editor_arr editor (fn sn)
          j["editor_arr"] =
            split(header_tag_value, rgx.arr_delimiter);
          string tmp;
          biblioEditorLoop:
          foreach (ed; j["editor_arr"].array) {
            if (auto x = match(ed.str, rgx.name_delimiter)) {
              tmp ~= x.captures[2] ~ " " ~ x.captures[1] ~ ", ";
            } else {
              tmp ~= ed.str;
            }
          }
          tmp = replace(tmp, rgx.trailing_comma, "");
          j["editor"].str = tmp;
          goto default;
        case "fulltitle": // title & subtitle
          goto default;
        default:
          break;
        }
        auto s = j.toString();
        debug(biblio1) {
          writefln(
            "* %s: %s\n%s",
            biblio_tag_name,
            biblio_tag_entry,
            j[biblio_tag_name]
          );
        }
        if ((match(line, rgx.comment))) {
          writeln("ERROR", line, "COMMENT");
          writeln("ERROR", s, "%%");
        }
        if (!(match(line, rgx.comment))) {
          debug(biblioblockinclude) {
            writeln(line);
          }
          biblio_entry_str_json = s;
        } else {
          biblio_entry_str_json = "";
        }
        header_tag_value="";
      }
    }
    void _poem_block_(
      char[]                 line,
      ref string[string]     an_object,
      ref int[string]        type,
      ref int                cntr,
      string[string]         obj_cite_number_poem,
      string[string][string] dochead_make_aa,
    ) {
      if (type["curly_poem"] == TriState.on) {
        if (matchFirst(line, rgx.block_curly_poem_close)) {
          an_object[an_object_key]="verse"; // check that this is as you please
          debug(poem) {                            // poem (curly) close
            writefln(
              "* [poem curly] %s",
              line
            );
          }
          if (processing.length > 0) {
            an_object[an_object_key] = processing["verse"];
          }
          debug(poem) {                            // poem (curly) close
            writeln(__LINE__);
            writefln(
              "* %s %s",
              obj_cite_number,
              line
            );
          }
          if (an_object.length > 0) {
            debug(poem) {                            // poem (curly) close
              writeln(
                obj_cite_number,
                an_object[an_object_key]
              );
            }
            an_object["is"] = "verse";
            auto substantive_object_and_anchor_tags_tuple =
              obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa);
            an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0];
            anchor_tags = substantive_object_and_anchor_tags_tuple[1];
            comp_obj_block                            = comp_obj_block.init;
            comp_obj_block.use                        = "body";
            comp_obj_block.is_of                      = "block";
            comp_obj_block.is_a                       = "verse";
            comp_obj_block.ocn                        = obj_cite_number;
            comp_obj_block.obj_cite_number            = (obj_cite_number==0) ? "" : to!string(obj_cite_number);
            comp_obj_block.text                       = an_object["substantive"];
            the_document_body_section                 ~= comp_obj_block;
            object_reset(an_object);
            processing.remove("verse");
            ++cntr;
          }
          obj_cite_number_poem["end"] =
            to!string(obj_cite_number);
          type["blocks"] = TriState.closing;
          type["poem"] = TriState.closing;
          type["curly_poem"] = TriState.off;
        } else {
          processing["verse"] ~= line ~= "\n";
          if (type["verse_new"] == State.on) {
            obj_cite_number =
              ocn_emit(type["ocn_status"]);
            type["verse_new"] = State.off;
          } else if (matchFirst(line, rgx.newline_eol_delimiter_only)) {
            verse_line = TriState.off;
            type["verse_new"] = State.on;
          }
          if (type["verse_new"] == State.on) {
            verse_line=1;
            an_object[an_object_key] = processing["verse"];
            debug(poem) {                          // poem verse
              writefln(
                "* %s curly\n%s",
                obj_cite_number,
                an_object[an_object_key]
              );
            }
            processing.remove("verse");
            an_object["is"] = "verse";
            auto comp_obj_location = node_construct.node_location_emitter(
              content_non_header,
              segment_anchor_tag_that_object_belongs_to,
              obj_cite_number,
              cntr,
              heading_ptr-1,
              an_object["is"]
            );
            auto substantive_object_and_anchor_tags_tuple =
              obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa);
            an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0];
            anchor_tags = substantive_object_and_anchor_tags_tuple[1];
            comp_obj_block                            = comp_obj_block.init;
            comp_obj_block.use                        = "body";
            comp_obj_block.is_of                      = "block";
            comp_obj_block.is_a                       = "verse";
            comp_obj_block.ocn                        = obj_cite_number;
            comp_obj_block.obj_cite_number            = (obj_cite_number==0) ? "" : to!string(obj_cite_number);
            comp_obj_block.text                       = an_object["substantive"];
            the_document_body_section                 ~= comp_obj_block;
            object_reset(an_object);
            processing.remove("verse");
            ++cntr;
          }
        }
      } else if (type["tic_poem"] == TriState.on) {
        if (auto m = matchFirst(line, rgx.block_tic_close)) { // tic_poem_close
          an_object[an_object_key]="verse"; // check that this is as you please
          debug(poem) {                            // poem (curly) close
            writefln(
              "* [poem tic] %s",
              line
            );
          }
          if (processing.length > 0) {       // needs looking at
            an_object[an_object_key] = processing["verse"];
          }
          if (an_object.length > 0) {
            debug(poem) {                            // poem (tic) close
              writeln(__LINE__);
              writeln(obj_cite_number, line);
            }
            processing.remove("verse");
            an_object["is"] = "verse";
            auto substantive_object_and_anchor_tags_tuple =
              obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa);
            an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0];
            anchor_tags = substantive_object_and_anchor_tags_tuple[1];
            comp_obj_block                            = comp_obj_block.init;
            comp_obj_block.use                        = "body";
            comp_obj_block.is_of                      = "block";
            comp_obj_block.is_a                       = "verse";
            comp_obj_block.ocn                        = obj_cite_number;
            comp_obj_block.obj_cite_number            = (obj_cite_number==0) ? "" : to!string(obj_cite_number);
            comp_obj_block.text                       = an_object["substantive"];
            the_document_body_section                 ~= comp_obj_block;
            obj_cite_number_poem["end"] = to!string(obj_cite_number);
            object_reset(an_object);
            processing.remove("verse");
            ++cntr;
          }
          type["blocks"] = TriState.closing;
          type["poem"] = TriState.closing;
          type["tic_poem"] = TriState.off;
        } else {
          processing["verse"] ~= line ~= "\n";
          if (type["verse_new"] == State.on) {
            obj_cite_number =
              ocn_emit(type["ocn_status"]);
            type["verse_new"] = State.off;
          } else if (matchFirst(line, rgx.newline_eol_delimiter_only)) {
            type["verse_new"] = State.on;
            verse_line = TriState.off;
          }
          if (type["verse_new"] == State.on) {
            verse_line=1;
            an_object[an_object_key] = processing["verse"];
            debug(poem) {                            // poem (tic) close
              writefln(
                "* %s tic\n%s",
                obj_cite_number,
                an_object[an_object_key]
              );
            }
            processing.remove("verse");
            an_object["is"] = "verse";
            auto comp_obj_location =
              node_construct.node_location_emitter(
                content_non_header,
                segment_anchor_tag_that_object_belongs_to,
                obj_cite_number,
                cntr,
                heading_ptr-1,
                an_object["is"]
              );
            auto substantive_object_and_anchor_tags_tuple =
              obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa);
            an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0];
            anchor_tags = substantive_object_and_anchor_tags_tuple[1];
            comp_obj_block                            = comp_obj_block.init;
            comp_obj_block.use                        = "body";
            comp_obj_block.is_of                      = "block";
            comp_obj_block.is_a                       = "verse";
            comp_obj_block.ocn                        = obj_cite_number;
            comp_obj_block.obj_cite_number            = (obj_cite_number==0) ? "" : to!string(obj_cite_number);
            comp_obj_block.text                       = an_object["substantive"];
            the_document_body_section                 ~= comp_obj_block;
            object_reset(an_object);
            processing.remove("verse");
            ++cntr;
          }
        }
      }
    }
    void _group_block_(
      char[]             line,
      ref string[string] an_object,
      ref int[string]    type
    ) {
      if (type["curly_group"] == State.on) {
        if (matchFirst(line, rgx.block_curly_group_close)) {
          debug(group) {                           // group (curly) close
            writeln(line);
          }
          type["blocks"] = TriState.closing;
          type["group"] = TriState.closing;
          type["curly_group"] = TriState.off;
        } else {
          debug(group) {                           // group
            writeln(line);
          }
          an_object[an_object_key] ~= line ~= "\n";           // build group array (or string)
        }
      } else if (type["tic_group"] == TriState.on) {
        if (matchFirst(line, rgx.block_tic_close)) {
          debug(group) {                           // group (tic) close
            writeln(line);
          }
          type["blocks"] = TriState.closing;
          type["group"] = TriState.closing;
          type["tic_group"] = TriState.off;
        } else {
          debug(group) {                           // group
            writeln(line);
          }
          an_object[an_object_key] ~= line ~= "\n";           // build group array (or string)
        }
      }
    }
    void _block_block_(
      char[]             line,
      ref string[string] an_object,
      ref int[string]    type
    ) {
      if (type["curly_block"] == TriState.on) {
        if (matchFirst(line, rgx.block_curly_block_close)) {
          debug(block) {                           // block (curly) close
            writeln(line);
          }
          type["blocks"] = TriState.closing;
          type["block"] = TriState.closing;
          type["curly_block"] = TriState.off;
        } else {
          debug(block) {                           // block
            writeln(line);
          }
          an_object[an_object_key] ~= line ~= "\n";           // build block array (or string)
        }
      } else if (type["tic_block"] == TriState.on) {
        if (matchFirst(line, rgx.block_tic_close)) {
          debug(block) {                           // block (tic) close
            writeln(line);
          }
          type["blocks"] = TriState.closing;
          type["block"] = TriState.closing;
          type["tic_block"] = TriState.off;
        } else {
          debug(block) {                           // block
            writeln(line);
          }
          an_object[an_object_key] ~= line ~= "\n";           // build block array (or string)
        }
      }
    }
    void _quote_block_(
      char[]             line,
      ref string[string] an_object,
      ref int[string]    type
    ) {
      if (type["curly_quote"] == TriState.on) {
        if (matchFirst(line, rgx.block_curly_quote_close)) {
          debug(quote) {                           // quote (curly) close
            writeln(line);
          }
          type["blocks"] = TriState.closing;
          type["quote"] = TriState.closing;
          type["curly_quote"] = TriState.off;
        } else {
          debug(quote) {                           // quote
            writeln(line);
          }
          an_object[an_object_key] ~= line ~= "\n";           // build quote array (or string)
        }
      } else if (type["tic_quote"] == TriState.on) {
        if (matchFirst(line, rgx.block_tic_close)) {
          debug(quote) {                           // quote (tic) close
            writeln(line);
          }
          type["blocks"] = TriState.closing;
          type["quote"] = TriState.closing;
          type["tic_quote"] = TriState.off;
        } else {
          debug(quote) {                           // quote
            writeln(line);
          }
          an_object[an_object_key] ~= line ~= "\n";           // build quote array (or string)
        }
      }
    }
    void _table_block_(
      char[]             line,
      ref string[string] an_object,
      ref int[string]    type
    ) {
      if (type["curly_table"] == TriState.on) {
        if (matchFirst(line, rgx.block_curly_table_close)) {
          debug(table) {                           // table (curly) close
            writeln(line);
          }
          type["blocks"] = TriState.closing;
          type["table"] = TriState.closing;
          type["curly_table"] = TriState.off;
        } else {
          debug(table) {                           // table
            writeln(line);
          }
          an_object[an_object_key] ~= line ~= "\n";           // build table array (or string)
        }
      } else if (type["tic_table"] == TriState.on) {
        if (matchFirst(line, rgx.block_tic_close)) {
          debug(table) {                           // table (tic) close
            writeln(line);
          }
          type["blocks"] = TriState.closing;
          type["table"] = TriState.closing;
          type["tic_table"] = TriState.off;
        } else {
          debug(table) {                           // table
            writeln(line);
          }
          an_object[an_object_key] ~= line ~= "\n";           // build table array (or string)
        }
      }
    }
    void _block_flag_line_empty_(
      char[]                       line,
      ref string[string]           an_object,
      ref ObjGenericComposite[]    the_document_body_section,
      ref string[][string][string] bookindex_unordered_hashes,
      ref int                      obj_cite_number,
      ref ObjGenericComposite      _comp_obj_heading,
      ref int                      cntr,
      ref int[string]              type,
      string[string]               obj_cite_number_poem,
      string[string][string]       dochead_make_aa,
    ) {
      // line.empty, post contents, empty variables ---------------
      assert(
        line.empty,
        "line should be empty"
      );
      assert(
        (type["blocks"] == TriState.closing),
        "code block status: closed"
      );
      assertions_flag_types_block_status_none_or_closed(type);
      if (type["code"] == TriState.closing) {
        obj_cite_number =
          ocn_emit(type["ocn_status"]);
        an_object["bookindex_nugget"] =
          ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : "";
        bookindex_unordered_hashes =
          bkidx_hash(an_object["bookindex_nugget"], obj_cite_number);
        an_object["is"] = "code";
        auto comp_obj_location =
          node_construct.node_location_emitter(
            content_non_header,
            segment_anchor_tag_that_object_belongs_to,
            obj_cite_number,
            cntr,
            heading_ptr-1,
            an_object["is"]
          );
        auto substantive_object_and_anchor_tags_tuple =
          obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa);
        an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0];
        anchor_tags = substantive_object_and_anchor_tags_tuple[1];
        comp_obj_code                             = comp_obj_code.init;
        comp_obj_code.use                         = "body";
        comp_obj_code.is_of                       = "block";
        comp_obj_code.is_a                        = "code";
        comp_obj_code.ocn                         = obj_cite_number;
        comp_obj_code.obj_cite_number             = (obj_cite_number==0) ? "" : to!string(obj_cite_number);
        comp_obj_code.text                        = an_object["substantive"];
        the_document_body_section                 ~= comp_obj_code;
        object_reset(an_object);
        processing.remove("verse");
        ++cntr;
        type["blocks"] = TriState.off;
        type["code"] = TriState.off;
      } else if (type["poem"] == TriState.closing) {
        an_object["bookindex_nugget"] =
          ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : "";
        bookindex_unordered_hashes =
          bkidx_hash(an_object["bookindex_nugget"], obj_cite_number);
        an_object["is"] = "verse"; // check also
        auto comp_obj_location =
          node_construct.node_location_emitter(
            content_non_header,
            segment_anchor_tag_that_object_belongs_to,
            obj_cite_number,
            cntr,
            heading_ptr-1,
            an_object["is"]
          );
        comp_obj_poem_ocn                         = comp_obj_poem_ocn.init;
        comp_obj_poem_ocn.use                     = "body";
        comp_obj_poem_ocn.is_of                   = "block";
        comp_obj_poem_ocn.is_a                    = "poem";
        comp_obj_poem_ocn.ocn                     = obj_cite_number;
        comp_obj_poem_ocn.obj_cite_number         = (obj_cite_number_poem["start"], obj_cite_number_poem["end"]); // not sure about this
        comp_obj_poem_ocn.text                    = ""; // an_object["substantive"];
        the_document_body_section                 ~= comp_obj_poem_ocn;
        object_reset(an_object);
        processing.remove("verse");
        type["blocks"] = TriState.off;
        type["poem"] = TriState.off;
      } else if (type["table"] == TriState.closing) {
        obj_cite_number =
          ocn_emit(type["ocn_status"]);
        an_object["bookindex_nugget"] =
          ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : "";
        bookindex_unordered_hashes =
          bkidx_hash(an_object["bookindex_nugget"], obj_cite_number);
        an_object["is"] = "table";
        auto comp_obj_location =
          node_construct.node_location_emitter(
            content_non_header,
            segment_anchor_tag_that_object_belongs_to,
            obj_cite_number,
            cntr,
            heading_ptr-1,
            an_object["is"]
          );
        auto substantive_object_and_anchor_tags_tuple =
          obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa);
        an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0];
        anchor_tags = substantive_object_and_anchor_tags_tuple[1];
        comp_obj_block                            = comp_obj_block.init;
        comp_obj_block.use                        = "body";
        comp_obj_block.is_of                      = "block";
        comp_obj_block.is_a                       = "table";
        comp_obj_block.ocn                        = obj_cite_number;
        comp_obj_block.obj_cite_number            = (obj_cite_number==0) ? "" : to!string(obj_cite_number);
        comp_obj_block.text                       = an_object["substantive"];
        the_document_body_section                 ~= comp_obj_block;
        object_reset(an_object);
        processing.remove("verse");
        ++cntr;
        type["blocks"] = TriState.off;
        type["table"] = TriState.off;
      } else if (type["group"] == TriState.closing) {
        obj_cite_number =
          ocn_emit(type["ocn_status"]);
        an_object["bookindex_nugget"] =
          ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : "";
        bookindex_unordered_hashes =
          bkidx_hash(an_object["bookindex_nugget"], obj_cite_number);
        an_object["is"] = "group";
        auto comp_obj_location =
          node_construct.node_location_emitter(
            content_non_header,
            segment_anchor_tag_that_object_belongs_to,
            obj_cite_number,
            cntr,
            heading_ptr-1,
            an_object["is"]
          );
        auto substantive_object_and_anchor_tags_tuple =
          obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa);
        an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0];
        anchor_tags = substantive_object_and_anchor_tags_tuple[1];
        comp_obj_block                            = comp_obj_block.init;
        comp_obj_block.use                        = "body";
        comp_obj_block.is_of                      = "block";
        comp_obj_block.is_a                       = "group";
        comp_obj_block.ocn                        = obj_cite_number;
        comp_obj_block.obj_cite_number            = (obj_cite_number==0) ? "" : to!string(obj_cite_number);
        comp_obj_block.text                       = an_object["substantive"];
        the_document_body_section                 ~= comp_obj_block;
        object_reset(an_object);
        processing.remove("verse");
        ++cntr;
        type["blocks"] = TriState.off;
        type["group"] = TriState.off;
      } else if (type["block"] == TriState.closing) {
        obj_cite_number = ocn_emit(type["ocn_status"]);
        an_object["bookindex_nugget"] =
          ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : "";
        bookindex_unordered_hashes =
          bkidx_hash(an_object["bookindex_nugget"], obj_cite_number);
        an_object["is"] = "block";
        auto comp_obj_location =
          node_construct.node_location_emitter(
            content_non_header,
            segment_anchor_tag_that_object_belongs_to,
            obj_cite_number,
            cntr,
            heading_ptr-1,
            an_object["is"]
           );
        auto substantive_object_and_anchor_tags_tuple =
          obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa);
        an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0];
        anchor_tags = substantive_object_and_anchor_tags_tuple[1];
        comp_obj_block                            = comp_obj_block.init;
        comp_obj_block.use                        = "body";
        comp_obj_block.is_of                      = "block";
        comp_obj_block.is_a                       = "block";
        comp_obj_block.ocn                        = obj_cite_number;
        comp_obj_block.obj_cite_number            = (obj_cite_number==0) ? "" : to!string(obj_cite_number);
        comp_obj_block.text                       = an_object["substantive"];
        the_document_body_section                 ~= comp_obj_block;
        object_reset(an_object);
        processing.remove("verse");
        ++cntr;
        type["blocks"] = TriState.off;
        type["block"] = TriState.off;
      } else if (type["quote"] == TriState.closing) {
        obj_cite_number =
          ocn_emit(type["ocn_status"]);
        an_object["bookindex_nugget"] =
          ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : "";
        bookindex_unordered_hashes =
          bkidx_hash(an_object["bookindex_nugget"], obj_cite_number);
        an_object["is"] = "quote";
        auto comp_obj_location =
          node_construct.node_location_emitter(
            content_non_header,
            segment_anchor_tag_that_object_belongs_to,
            obj_cite_number,
            cntr,
            heading_ptr-1,
            an_object["is"]
          );
        auto substantive_object_and_anchor_tags_tuple =
          obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa);
        an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0];
        anchor_tags = substantive_object_and_anchor_tags_tuple[1];
        comp_obj_block                            = comp_obj_block.init;
        comp_obj_block.use                        = "body";
        comp_obj_block.is_of                      = "block";
        comp_obj_block.is_a                       = "quote";
        comp_obj_block.ocn                        = obj_cite_number;
        comp_obj_block.obj_cite_number            = (obj_cite_number==0) ? "" : to!string(obj_cite_number);
        comp_obj_block.text                       = an_object["substantive"];
        the_document_body_section                 ~= comp_obj_block;
        object_reset(an_object);
        processing.remove("verse");
        ++cntr;
        type["blocks"] = TriState.off;
        type["quote"] = TriState.off;
      }
    }
    auto _book_index_(
      char[]             line,
      ref string         book_idx_tmp,
      ref string[string] an_object,
      ref int[string]    type,
      bool[string]       opt_action_bool,
    ) {
      if (auto m = match(line, rgx.book_index)) {
        /+ match book_index +/
        debug(bookindexmatch) {                       // book index
          writefln(
            "* [bookindex] %s\n",
            to!string(m.captures[1]),
          );
        }
        an_object["bookindex_nugget"] = to!string(m.captures[1]);
      } else if (auto m = match(line, rgx.book_index_open))  {
        /+ match open book_index +/
        type["book_index"] = State.on;
        if (opt_action_bool["backmatter"] && opt_action_bool["section_bookindex"]) {
          book_idx_tmp = to!string(m.captures[1]);
          debug(bookindexmatch) {                       // book index
            writefln(
              "* [bookindex] %s\n",
              book_idx_tmp,
            );
          }
        }
      } else if (type["book_index"] == State.on )  {
        /+ book_index flag set +/
        if (auto m = match(line, rgx.book_index_close))  {
          type["book_index"] = State.off;
          if (opt_action_bool["backmatter"] && opt_action_bool["section_bookindex"]) {
            an_object["bookindex_nugget"] = book_idx_tmp ~ to!string(m.captures[1]);
            debug(bookindexmatch) {                     // book index
              writefln(
                "* [bookindex] %s\n",
                book_idx_tmp,
              );
            }
          }
          book_idx_tmp = "";
        } else {
          if (opt_action_bool["backmatter"] && opt_action_bool["section_bookindex"]) {
            book_idx_tmp ~= line;
          }
        }
      }
    }
    auto _heading_found_(
      char[]                   line,
      string                   dochead_make_identify_unmarked_headings,
      ref string[string]       heading_match_str,
      ref Regex!(char)[string] heading_match_rgx,
      ref int[string]          type
    ) {
      if ((dochead_make_identify_unmarked_headings.length > 2)
      && (type["make_headings"] == State.off)) {
        /+ headings found +/
        debug(headingsfound) {
          writeln(dochead_make_identify_unmarked_headings);
        }
        char[][] make_headings_spl =
          split(
            cast(char[]) dochead_make_identify_unmarked_headings,
            rgx.make_heading_delimiter);
        debug(headingsfound) {
          writeln(make_headings_spl.length);
          writeln(make_headings_spl);
        }
        switch (make_headings_spl.length) {
        case 7 :
          if (!empty(make_headings_spl[6])) {
            heading_match_str["h_4"] =
              "^(" ~ to!string(make_headings_spl[6]) ~ ")";
            heading_match_rgx["h_4"] =
              regex(heading_match_str["h_4"]);
          }
          goto case;
        case 6 :
          if (!empty(make_headings_spl[5])) {
            heading_match_str["h_3"] =
              "^(" ~ to!string(make_headings_spl[5]) ~ ")";
            heading_match_rgx["h_3"] =
              regex(heading_match_str["h_3"]);
          }
          goto case;
        case 5 :
          if (!empty(make_headings_spl[4])) {
            heading_match_str["h_2"] =
              "^(" ~ to!string(make_headings_spl[4]) ~ ")";
            heading_match_rgx["h_2"] =
              regex(heading_match_str["h_2"]);
          }
          goto case;
        case 4 :
          if (!empty(make_headings_spl[3])) {
            heading_match_str["h_1"] =
              "^(" ~ to!string(make_headings_spl[3]) ~ ")";
            heading_match_rgx["h_1"] =
              regex(heading_match_str["h_1"]);
          }
          goto case;
        case 3 :
          if (!empty(make_headings_spl[2])) {
            heading_match_str["h_D"] =
              "^(" ~ to!string(make_headings_spl[2]) ~ ")";
            heading_match_rgx["h_D"] =
              regex(heading_match_str["h_D"]);
          }
          goto case;
        case 2 :
          if (!empty(make_headings_spl[1])) {
            heading_match_str["h_C"] =
              "^(" ~ to!string(make_headings_spl[1]) ~ ")";
            heading_match_rgx["h_C"] =
              regex(heading_match_str["h_C"]);
          }
          goto case;
        case 1 :
          if (!empty(make_headings_spl[0])) {
            heading_match_str["h_B"] =
              "^(" ~ to!string(make_headings_spl[0]) ~ ")";
            heading_match_rgx["h_B"] =
              regex(heading_match_str["h_B"]);
          }
          break;
        default:
          break;
        }
        type["make_headings"] = State.on;
      }
    }
    auto _heading_make_set_(
      ref char[]               line,
      ref int[string]          line_occur,
      ref Regex!(char)[string] heading_match_rgx,
      ref int[string]          type
    ) {
      if ((type["make_headings"] == State.on)
      && ((line_occur["para"] == State.off)
      && (line_occur["heading"] == State.off))
      && ((type["para"] == State.off)
      && (type["heading"] == State.off))) {
        /+ heading make set +/
        if (matchFirst(line, heading_match_rgx["h_B"])) {
          line = "B~ " ~ line;
          debug(headingsfound) {
            writeln(line);
          }
        }
        if (matchFirst(line, heading_match_rgx["h_C"])) {
          line = "C~ " ~ line;
          debug(headingsfound) {
            writeln(line);
          }
        }
        if (matchFirst(line, heading_match_rgx["h_D"])) {
          line = "D~ " ~ line;
          debug(headingsfound) {
            writeln(line);
          }
        }
        if (matchFirst(line, heading_match_rgx["h_1"])) {
          line = "1~ " ~ line;
          debug(headingsfound) {
            writeln(line);
          }
        }
        if (matchFirst(line, heading_match_rgx["h_2"])) {
          line = "2~ " ~ line;
          debug(headingsfound) {
            writeln(line);
          }
        }
        if (matchFirst(line, heading_match_rgx["h_3"])) {
          line = "3~ " ~ line;
          debug(headingsfound) {
            writeln(line);
          }
        }
        if (matchFirst(line, heading_match_rgx["h_4"])) {
          line = "4~ " ~ line;
          debug(headingsfound) {
            writeln(line);
          }
        }
      }
    }
    auto _heading_matched_(
      char[]                     line,
      ref int[string]            line_occur,
      ref string[string]         an_object,
      ref string                 an_object_key,
      ref int[string]            lv,
      ref int[string]            collapsed_lev,
      ref int[string]            type,
      ref string[string][string] dochead_meta_aa
    ) {
      if (auto m = match(line, rgx.heading)) {
        /+ heading match +/
        type["heading"] = State.on;
        if (match(line, rgx.heading_seg_and_above)) {
          type["biblio_section"] = State.off;
          type["glossary_section"] = State.off;
          type["blurb_section"] = State.off;
        }
        type["para"] = State.off;
        ++line_occur["heading"];
        an_object[an_object_key] ~= line ~= "\n";
        an_object["lev"] ~= m.captures[1];
        assertions_doc_structure(an_object, lv); // includes most of the logic for collapsed levels
        switch (an_object["lev"]) {
        case "A":
          an_object[an_object_key]=replaceFirst(an_object[an_object_key],
            rgx.variable_doc_title, (dochead_meta_aa["title"]["full"] ~ ","));
          an_object[an_object_key]=replaceFirst(an_object[an_object_key],
            rgx.variable_doc_author, dochead_meta_aa["creator"]["author"]);
          collapsed_lev["h0"] = 0;
          an_object["lev_collapsed_number"] =
            to!string(collapsed_lev["h0"]);
          lv["lv"] = DocStructMarkupHeading.h_sect_A;
          ++lv["h0"];
          lv["h1"] = State.off;
          lv["h2"] = State.off;
          lv["h3"] = State.off;
          lv["h4"] = State.off;
          lv["h5"] = State.off;
          lv["h6"] = State.off;
          lv["h7"] = State.off;
          goto default;
        case "B":
          collapsed_lev["h1"] = collapsed_lev["h0"] + 1;
          an_object["lev_collapsed_number"] =
            to!string(collapsed_lev["h1"]);
          lv["lv"] = DocStructMarkupHeading.h_sect_B;
          ++lv["h1"];
          lv["h2"] = State.off;
          lv["h3"] = State.off;
          lv["h4"] = State.off;
          lv["h5"] = State.off;
          lv["h6"] = State.off;
          lv["h7"] = State.off;
          goto default;
        case "C":
          collapsed_lev["h2"] = collapsed_lev["h1"] + 1;
          an_object["lev_collapsed_number"] =
            to!string(collapsed_lev["h2"]);
          lv["lv"] = DocStructMarkupHeading.h_sect_C;
          ++lv["h2"];
          lv["h3"] = State.off;
          lv["h4"] = State.off;
          lv["h5"] = State.off;
          lv["h6"] = State.off;
          lv["h7"] = State.off;
          goto default;
        case "D":
          collapsed_lev["h3"] = collapsed_lev["h2"] + 1;
          an_object["lev_collapsed_number"] =
            to!string(collapsed_lev["h3"]);
          lv["lv"] = DocStructMarkupHeading.h_sect_D;
          ++lv["h3"];
          lv["h4"] = State.off;
          lv["h5"] = State.off;
          lv["h6"] = State.off;
          lv["h7"] = State.off;
          goto default;
        case "1":
          if (lv["h3"] > State.off) {
            collapsed_lev["h4"] = collapsed_lev["h3"] + 1;
          } else if (lv["h2"] > State.off) {
            collapsed_lev["h4"] = collapsed_lev["h2"] + 1;
          } else if (lv["h1"] > State.off) {
            collapsed_lev["h4"] = collapsed_lev["h1"] + 1;
          } else if (lv["h0"] > State.off) {
            collapsed_lev["h4"] = collapsed_lev["h0"] + 1;
          }
          an_object["lev_collapsed_number"] =
            to!string(collapsed_lev["h4"]);
          lv["lv"] = DocStructMarkupHeading.h_text_1;
          ++lv["h4"];
          lv["h5"] = State.off;
          lv["h6"] = State.off;
          lv["h7"] = State.off;
          goto default;
        case "2":
          if (lv["h5"] > State.off) {
            an_object["lev_collapsed_number"] =
              to!string(collapsed_lev["h5"]);
          } else if (lv["h4"] > State.off) {
            collapsed_lev["h5"] = collapsed_lev["h4"] + 1;
            an_object["lev_collapsed_number"] =
              to!string(collapsed_lev["h5"]);
          }
          lv["lv"] = DocStructMarkupHeading.h_text_2;
          ++lv["h5"];
          lv["h6"] = State.off;
          lv["h7"] = State.off;
          goto default;
        case "3":
          if (lv["h6"] > State.off) {
            an_object["lev_collapsed_number"] =
              to!string(collapsed_lev["h6"]);
          } else if (lv["h5"] > State.off) {
            collapsed_lev["h6"] = collapsed_lev["h5"] + 1;
            an_object["lev_collapsed_number"] =
              to!string(collapsed_lev["h6"]);
          }
          lv["lv"] = DocStructMarkupHeading.h_text_3;
          ++lv["h6"];
          lv["h7"] = State.off;
          goto default;
        case "4":
          if (lv["h7"] > State.off) {
            an_object["lev_collapsed_number"] =
              to!string(collapsed_lev["h7"]);
          } else if (lv["h6"] > State.off) {
            collapsed_lev["h7"] = collapsed_lev["h6"] + 1;
            an_object["lev_collapsed_number"] =
              to!string(collapsed_lev["h7"]);
          }
          lv["lv"] = DocStructMarkupHeading.h_text_4;
          ++lv["h7"];
          goto default;
        default:
          an_object["lev_markup_number"] = to!string(lv["lv"]);
        }
        debug(heading) {                         // heading
          writeln(strip(line));
        }
      }
    }
    auto _para_match_(
      char[]             line,
      ref string[string] an_object,
      ref string         an_object_key,
      ref int[string]    indent,
      ref bool           bullet,
      ref int[string]    type,
      ref int[string]    line_occur,
    ) {
      if (line_occur["para"] == State.off) {
        /+ para matches +/
        type["para"] = State.on;
        an_object[an_object_key] ~= line; // body_nugget
        indent=[
          "hang_position" : 0,
          "base_position" : 0,
        ];
        bullet = false;
        if (auto m = matchFirst(line, rgx.para_indent)) {
          debug(paraindent) {                    // para indent
            writeln(line);
          }
          indent["hang_position"] = to!int(m.captures[1]);
          indent["base_position"] = 0;
        } else if (matchFirst(line, rgx.para_bullet)) {
          debug(parabullet) {                    // para bullet
            writeln(line);
          }
          bullet = true;
        } else if (auto m = matchFirst(line, rgx.para_indent_hang)) {
          debug(paraindenthang) {                // para indent hang
            writeln(line);
          }
          indent=[
            "hang_position" : to!int(m.captures[1]),
            "base_position" : to!int(m.captures[2]),
          ];
        } else if (auto m = matchFirst(line, rgx.para_bullet_indent)) {
          debug(parabulletindent) {              // para bullet indent
            writeln(line);
          }
          indent=[
            "hang_position" : to!int(m.captures[1]),
            "base_position" : 0,
          ];
          bullet = true;
        }
        ++line_occur["para"];
      }
    }
    /+ abstraction functions ↑ +/
    /+ ↓ abstraction function emitters +/
    struct OCNemitter {
      int obj_cite_number, obj_cite_number_;
      int ocn_emitter(int ocn_status_flag)
      in { assert(ocn_status_flag <= 3); }
      body {
        if (ocn_status_flag == 3) {
          obj_cite_number = obj_cite_number_ = 1;
        } else {
          obj_cite_number=(ocn_status_flag == 0)
          ? ++obj_cite_number_
          : 0;
        }
        assert(obj_cite_number >= 0);
        return obj_cite_number;
      }
      invariant() {
      }
    }
    /+ +/
    struct ObjInlineMarkupMunge {
      string[string] obj_txt;
      int n_foot, n_foot_reg, n_foot_sp_asterisk, n_foot_sp_plus;
      string asterisks_;
      string obj_txt_out, tail, note;
      auto rgx = Rgx();
      auto mkup = InlineMarkup();
      private auto initialize_note_numbers() {
        n_foot = 0;
        n_foot_reg = 0;
        n_foot_sp_asterisk = 0;
        n_foot_sp_plus = 0;
      }
      string url_links(string obj_txt_in) {
        /+ url matched +/
        if (auto m = matchAll(obj_txt_in, rgx.inline_url)) {
          /+ link: naked url: http://url +/
          if (match(obj_txt_in, rgx.inline_link_naked_url)) {
            obj_txt_in =
              replaceAll(
                obj_txt_in,
                rgx.inline_link_naked_url,
                ("$1" ~ mkup.lnk_o ~ " $2 " ~ mkup.lnk_c ~  mkup.url_o ~ "$2" ~  mkup.url_c ~ "$3")            // ("$1{ $2 }$2$3")
              );
          }
          /+ link with helper for endnote including the url:
               {~^ link which includes url as footnote }http://url
             maps to:
               { link which includes url as footnote }http://url~{ { http://url }http://url }~
          +/
          if (match(obj_txt_in, rgx.inline_link_endnote_url_helper)) {
            obj_txt_in =
              replaceAll(
                obj_txt_in,
                rgx.inline_link_endnote_url_helper_punctuated,
                (mkup.lnk_o ~ " $1 " ~ mkup.lnk_c ~ mkup.url_o ~ "$2" ~ mkup.url_c ~ "~{ " ~ mkup.lnk_o ~ " $2 " ~ mkup.lnk_c ~ mkup.url_o ~ "$2" ~ mkup.url_c ~  " }~$3") // ("{ $1 }$2~{ { $2 }$2 }~$3")
              );
            obj_txt_in =
              replaceAll(
                obj_txt_in,
                rgx.inline_link_endnote_url_helper,
                (mkup.lnk_o ~ " $1 " ~ mkup.lnk_c ~ mkup.url_o ~ "$2" ~ mkup.url_c ~ "~{ " ~ mkup.lnk_o ~ " $2 " ~ mkup.lnk_c ~ mkup.url_o ~ "$2" ~ mkup.url_c ~  " }~")   // ("{ $1 }$2~{ { $2 }$2 }~")
              );
          }
          /+ link with regular markup:
             { linked text or image }http://url
          +/
          if (match(obj_txt_in, rgx.inline_link_markup_regular)) {
            obj_txt_in =
              replaceAll(
                obj_txt_in,
                rgx.inline_link_markup_regular,
                ("$1" ~ mkup.lnk_o ~ " $2 " ~ mkup.lnk_c ~  mkup.url_o ~ "$3" ~  mkup.url_c ~ "$4")            // ("$1{ $2 }$3$4")
              );
          }
        }
        return obj_txt_in;
      }
      string footnotes_endnotes_markup_and_number_or_stars(string obj_txt_in) {
        /+ endnotes (regular) +/
        obj_txt_in =
          replaceAll(
            obj_txt_in,
            rgx.inline_notes_curly,
            (mkup.en_a_o ~ " $1" ~ mkup.en_a_c)
          );
        if (match(obj_txt_in, rgx.inline_notes_al_gen)) {
          if (auto m = matchAll(obj_txt_in, rgx.inline_text_and_note_al_)) {
            foreach(n; m) {
              if (match(to!string(n.hit), rgx.inline_al_delimiter_open_symbol_star)) {
                ++n_foot_sp_asterisk;
                asterisks_ = "*";
                n_foot=n_foot_sp_asterisk;
                obj_txt_out ~=
                  (replaceFirst(
                    to!string(n.hit),
                    rgx.inline_al_delimiter_open_symbol_star,
                    (mkup.en_a_o ~ replicate(asterisks_, n_foot_sp_asterisk) ~ " ")
                  ) ~ "\n");
              } else if (match(to!string(n.hit), rgx.inline_al_delimiter_open_regular)) {
                ++n_foot_reg;
                n_foot=n_foot_reg;
                obj_txt_out ~=
                  (replaceFirst(
                    to!string(n.hit),
                    rgx.inline_al_delimiter_open_regular,
                    (mkup.en_a_o ~ to!string(n_foot) ~ " ")
                  ) ~ "\n");
              } else {
                obj_txt_out ~= to!string(n.hit) ~ "\n";
              }
            }
          }
        } else {
          obj_txt_out = obj_txt_in;
        }
        return obj_txt_out;
      }
      private auto object_notes_(string obj_txt_in)
      in { }
      body {
        obj_txt_out = "";
        tail = "";
        /+ special endnotes +/
        obj_txt_in = replaceAll(
          obj_txt_in,
          rgx.inline_notes_curly_sp_asterisk,
          (mkup.en_a_o ~ "*" ~ " $1" ~ mkup.en_a_c)
        );
        obj_txt_in =
          replaceAll(
            obj_txt_in,
            rgx.inline_notes_curly_sp_plus,
            (mkup.en_a_o ~ "+" ~ " $1" ~ mkup.en_a_c)
          );
        /+ url matched +/
        if (auto m = matchAll(obj_txt_in, rgx.inline_url)) {
          obj_txt_in = url_links(obj_txt_in);
        }
        obj_txt_out = footnotes_endnotes_markup_and_number_or_stars(obj_txt_in);
        debug(footnotes) {
          writeln(obj_txt_out, tail);
        }
        obj_txt_out = obj_txt_out ~ tail;
        debug(footnotesdone) {
          foreach(m; matchAll(obj_txt_out,
          (mkup.en_a_o ~ `\s*(.+?)` ~ mkup.en_a_c))) {
            writeln(m.captures[1]);
            writeln(m.hit);
          }
        }
        return obj_txt_out;
      }
      string para(string obj_txt_in)
      in { }
      body {
        auto rgx = Rgx();
        obj_txt["munge"]=obj_txt_in;
        obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.para_attribs, "");
        obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.obj_cite_number_off_all, "");
        obj_txt["munge"]=object_notes_(obj_txt["munge"]);
        debug(munge) {
          writeln(__LINE__);
          writeln(obj_txt_in);
          writeln(__LINE__);
          writeln(to!string(obj_txt["munge"]));
        }
        return obj_txt["munge"];
      }
      string heading(string obj_txt_in)
      in { }
      body {
        auto rgx = Rgx();
        obj_txt["munge"]=obj_txt_in;
        obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.heading, "");
        obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.obj_cite_number_off_all, "");
        obj_txt["munge"]=strip(obj_txt["munge"]);
        obj_txt["munge"]=object_notes_(obj_txt["munge"]);
        debug(munge) {
          writeln(__LINE__);
          writeln(obj_txt_in);
          writeln(__LINE__);
          writeln(to!string(obj_txt["munge"]));
        }
        return obj_txt["munge"];
      }
      invariant() {
      }
      /+ revisit +/
      string code(string obj_txt_in)
      in { }
      body {
        obj_txt["munge"]=obj_txt_in;
        return obj_txt["munge"];
      }
      invariant() {
      }
      string group(string obj_txt_in)
      in { }
      body {
        obj_txt["munge"]=obj_txt_in;
        obj_txt["munge"]=object_notes_(obj_txt["munge"]);
        return obj_txt["munge"];
      }
      invariant() {
      }
      string block(string obj_txt_in)
      in { }
      body {
        obj_txt["munge"]=obj_txt_in;
        obj_txt["munge"]=object_notes_(obj_txt["munge"]);
        return obj_txt["munge"];
      }
      invariant() {
      }
      string verse(string obj_txt_in)
      in { }
      body {
        obj_txt["munge"]=obj_txt_in;
        obj_txt["munge"]=object_notes_(obj_txt["munge"]);
        return obj_txt["munge"];
      }
      invariant() {
      }
      string quote(string obj_txt_in)
      in { }
      body {
        obj_txt["munge"]=obj_txt_in;
        return obj_txt["munge"];
      }
      invariant() {
      }
      string table(string obj_txt_in)
      in { }
      body {
        obj_txt["munge"]=obj_txt_in;
        return obj_txt["munge"];
      }
      invariant() {
      }
      string comment(string obj_txt_in)
      in { }
      body {
        obj_txt["munge"]=obj_txt_in;
        return obj_txt["munge"];
      }
      invariant() {
      }
    }
    struct ObjInlineMarkup {
      auto munge = ObjInlineMarkupMunge();
      string[string] obj_txt;
      auto obj_inline_markup_and_anchor_tags(
        string[string]         obj_,
        string                 obj_key_,
        string[string][string] dochead_make_aa
      )
      in { }
      body {
        obj_txt["munge"]=obj_[obj_key_].dup;
        obj_txt["munge"]=(match(obj_["is"], ctRegex!(`verse|code`)))
        ? obj_txt["munge"]
        : strip(obj_txt["munge"]);
        static __gshared string[] anchor_tags_ = [];
        switch (obj_["is"]) {
        case "heading":
          static __gshared string anchor_tag = "";
          // TODO WORK ON, you still need to ensure that level 1 anchor_tags are unique
          obj_txt["munge"]=_configured_auto_heading_numbering_and_segment_anchor_tags(obj_txt["munge"], obj_, dochead_make_aa);
          obj_txt["munge"]=_make_segment_anchor_tags_if_none_provided(obj_txt["munge"], obj_["lev"]);
          if (auto m = match(obj_txt["munge"], rgx.heading_anchor_tag)) {
            anchor_tag = m.captures[1];
            anchor_tags_ ~=anchor_tag;
          } else if (obj_["lev"] == "1") {
            writeln("heading anchor tag missing: ", obj_txt["munge"]);
          }
          obj_txt["munge"]=munge.heading(obj_txt["munge"]);
          break;
        case "para":
          obj_txt["munge"]=munge.para(obj_txt["munge"]);
          break;
        case "code":
          obj_txt["munge"]=munge.code(obj_txt["munge"]);
          break;
        case "group":
          obj_txt["munge"]=munge.group(obj_txt["munge"]);
          break;
        case "block":
          obj_txt["munge"]=munge.block(obj_txt["munge"]);
          break;
        case "verse":
          obj_txt["munge"]=munge.verse(obj_txt["munge"]);
          break;
        case "quote":
          obj_txt["munge"]=munge.quote(obj_txt["munge"]);
          break;
        case "table":
          obj_txt["munge"]=munge.table(obj_txt["munge"]);
          break;
        case "comment":
          obj_txt["munge"]=munge.comment(obj_txt["munge"]);
          break;
        case "doc_end_reset":
          munge.initialize_note_numbers();
          break;
        default:
          break;
        }
        auto t = tuple(
         obj_txt["munge"],
         anchor_tags_,
        );
        anchor_tags_=[];
        return t;
      }
      invariant() {
      }
      auto _clean_heading_toc_(
        char[] heading_toc_,
      ) {
       auto m = matchFirst(cast(char[]) heading_toc_, rgx.heading);
       heading_toc_ =
         replaceAll(
           m.post,
           rgx.inline_notes_curly_gen,
           ("")
         );
       return heading_toc_;
      };
      auto table_of_contents_gather_headings(
        string[string]                obj_,
        string[string][string]        dochead_make_aa,
        string                        segment_anchor_tag_that_object_belongs_to,
        string                        _anchor_tag,
        ref string[][string]          lev4_subtoc,
        ObjGenericComposite[][string] the_table_of_contents_section,
      )
      in { }
      body {
        ObjGenericComposite comp_obj_toc;
        mixin InternalMarkup;
        auto mkup = InlineMarkup();
        char[] heading_toc_ = to!(char[])(obj_["body_nugget"].dup.strip);
        heading_toc_ = _clean_heading_toc_(heading_toc_);
        auto attrib="";
        string toc_txt_, subtoc_txt_;
        int[string] indent;
        if (to!int(obj_["lev_markup_number"]) > 0) {
          indent=[
            "hang_position" : to!int(obj_["lev_markup_number"]),
            "base_position" : to!int(obj_["lev_markup_number"]),
          ];
          toc_txt_ = format(
            "{ %s }#%s",
            heading_toc_,
            _anchor_tag,
          );
          toc_txt_= munge.url_links(toc_txt_);
          comp_obj_toc                       = comp_obj_toc.init;
          comp_obj_toc.use                   = "frontmatter";
          comp_obj_toc.is_of                 = "para";
          comp_obj_toc.is_a                  = "toc";
          comp_obj_toc.ocn                   = 0;
          comp_obj_toc.obj_cite_number       = "";
          comp_obj_toc.indent_hang           = indent["hang_position"];
          comp_obj_toc.indent_base           = indent["base_position"];
          comp_obj_toc.bullet                = false;
          comp_obj_toc.text                  = to!string(toc_txt_).strip;
          the_table_of_contents_section["scroll"] ~= comp_obj_toc;
        } else {
          indent=[
            "hang_position" : 0,
            "base_position" : 0,
          ];
          comp_obj_toc                       = comp_obj_toc.init;
          comp_obj_toc.use                   = "frontmatter";
          comp_obj_toc.is_of                 = "para";
          comp_obj_toc.is_a                  = "toc";
          comp_obj_toc.ocn                   = 0;
          comp_obj_toc.obj_cite_number       = "";
          comp_obj_toc.indent_hang           = indent["hang_position"];
          comp_obj_toc.indent_base           = indent["base_position"];
          comp_obj_toc.bullet                = false;
          comp_obj_toc.text                  = "Table of Contents";
          the_table_of_contents_section["scroll"] ~= comp_obj_toc;
        }
        comp_obj_toc                       = comp_obj_toc.init;
        comp_obj_toc.use                   = "frontmatter";
        comp_obj_toc.is_of                 = "para";
        comp_obj_toc.is_a                  = "toc";
        comp_obj_toc.ocn                   = 0;
        comp_obj_toc.obj_cite_number       = "";
        comp_obj_toc.bullet                = false;
        switch (to!int(obj_["lev_markup_number"])) {
        case 0:
          indent=[
            "hang_position" : 0,
            "base_position" : 0,
          ];
          toc_txt_ = "{ Table of Contents }" ~ mkup.mark_internal_site_lnk ~ "../toc.fnSuffix";
          toc_txt_= munge.url_links(toc_txt_);
          comp_obj_toc.indent_hang             = indent["hang_position"];
          comp_obj_toc.indent_base             = indent["base_position"];
          comp_obj_toc.text                    = to!string(toc_txt_).strip;
          the_table_of_contents_section["seg"] ~= comp_obj_toc;
          break;
        case 1: .. case 3:
          indent=[
            "hang_position" : to!int(obj_["lev_markup_number"]),
            "base_position" : to!int(obj_["lev_markup_number"]),
          ];
          toc_txt_ = format(
            "%s",
            heading_toc_,
          );
          toc_txt_= munge.url_links(toc_txt_);
          comp_obj_toc.indent_hang             = indent["hang_position"];
          comp_obj_toc.indent_base             = indent["base_position"];
          comp_obj_toc.text                    = to!string(toc_txt_).strip;
          the_table_of_contents_section["seg"] ~= comp_obj_toc;
          break;
        case 4:
          toc_txt_ = format(
            "{ %s }%s../%s.fnSuffix",
            heading_toc_,
            mkup.mark_internal_site_lnk,
            segment_anchor_tag_that_object_belongs_to,
          );
          lev4_subtoc[segment_anchor_tag_that_object_belongs_to] = [];
          toc_txt_= munge.url_links(toc_txt_);
          indent=[
            "hang_position" : to!int(obj_["lev_markup_number"]),
            "base_position" : to!int(obj_["lev_markup_number"]),
          ];
          comp_obj_toc.indent_hang             = indent["hang_position"];
          comp_obj_toc.indent_base             = indent["base_position"];
          comp_obj_toc.text                    = to!string(toc_txt_).strip;
          the_table_of_contents_section["seg"] ~= comp_obj_toc;
          break;
        case 5: .. case 7:
          toc_txt_ = format(
            "{ %s }%s../%s.fnSuffix#%s",
            heading_toc_,
            mkup.mark_internal_site_lnk,
            segment_anchor_tag_that_object_belongs_to,
            _anchor_tag,
          );
          subtoc_txt_ = format(
            "{ %s }#%s",
            heading_toc_,
            _anchor_tag,
          );
          lev4_subtoc[segment_anchor_tag_that_object_belongs_to] ~= obj_["lev_markup_number"] ~ "~ " ~ to!string(subtoc_txt_).strip;
          toc_txt_= munge.url_links(toc_txt_);
          indent=[
            "hang_position" : to!int(obj_["lev_markup_number"]),
            "base_position" : to!int(obj_["lev_markup_number"]),
          ];
          comp_obj_toc.indent_hang             = indent["hang_position"];
          comp_obj_toc.indent_base             = indent["base_position"];
          comp_obj_toc.text                    = to!string(toc_txt_).strip;
          the_table_of_contents_section["seg"] ~= comp_obj_toc;
          break;
        default:
          break;
        }
        return the_table_of_contents_section;
      }
      invariant() {
      }
    private:
      static string _configured_auto_heading_numbering_and_segment_anchor_tags(
        string                 munge_,
        string[string]         obj_,
        string[string][string] dochead_make_aa
      ) {
        if (dochead_make_aa["make"]["num_top"].length > 0) {
          if (!(match(munge_, rgx.heading_anchor_tag))) {
            static __gshared int heading_num_top_level=9;
            static __gshared int heading_num_depth=2;
            static __gshared int heading_num_0 = 0;
            static __gshared int heading_num_1 = 0;
            static __gshared int heading_num_2 = 0;
            static __gshared int heading_num_3 = 0;
            static __gshared string heading_number_auto_composite = "";
            if (heading_num_top_level==9) {
              if (dochead_make_aa["make"]["num_depth"].length > 0) {
                heading_num_depth = to!uint(dochead_make_aa["make"]["num_depth"]);
              }
              switch (dochead_make_aa["make"]["num_top"]) {
              case "A":
                break;
              case "B":
                heading_num_top_level=1;
                break;
              case "C":
                heading_num_top_level=2;
                break;
              case "D":
                heading_num_top_level=3;
                break;
              case "1":
                heading_num_top_level=4;
                break;
              case "2":
                heading_num_top_level=5;
                break;
              case "3":
                heading_num_top_level=6;
                break;
              case "4":
                heading_num_top_level=7;
                break;
              default:
                break;
              }
            }
            /+ num_depth minimum 0 (1.) default 2 (1.1.1) max 3 (1.1.1.1) implement +/
            if (heading_num_top_level > to!uint(obj_["lev_markup_number"])) {
              heading_num_0 = 0;
              heading_num_1 = 0;
              heading_num_2 = 0;
              heading_num_3 = 0;
            } else if (heading_num_top_level == to!uint(obj_["lev_markup_number"])) {
              heading_num_0 ++;
              heading_num_1 = 0;
              heading_num_2 = 0;
              heading_num_3 = 0;
            } else if (heading_num_top_level == (to!uint(obj_["lev_markup_number"]) - 1)) {
              heading_num_1 ++;
              heading_num_2 = 0;
              heading_num_3 = 0;
            } else if (heading_num_top_level == (to!uint(obj_["lev_markup_number"]) - 2)) {
              heading_num_2 ++;
              heading_num_3 = 0;
            } else if (heading_num_top_level == (to!uint(obj_["lev_markup_number"]) - 3)) {
              heading_num_3 ++;
            }
            if (heading_num_3 > 0) {
              heading_number_auto_composite =
                (heading_num_depth == 3)
                ? ( to!string(heading_num_0) ~ "." ~
                      to!string(heading_num_1) ~ "." ~
                      to!string(heading_num_2) ~ "." ~
                      to!string(heading_num_3)
                    )
                : "";
            } else if (heading_num_2 > 0) {
              heading_number_auto_composite =
                ((heading_num_depth >= 2)
                && (heading_num_depth <= 3))
                ?  ( to!string(heading_num_0) ~ "." ~
                      to!string(heading_num_1) ~ "." ~
                      to!string(heading_num_2)
                    )
                : "";
            } else if (heading_num_1 > 0) {
              heading_number_auto_composite =
                ((heading_num_depth >= 1)
                && (heading_num_depth <= 3))
                ? ( to!string(heading_num_0) ~ "." ~
                      to!string(heading_num_1)
                    )
                : "";
            } else if (heading_num_0 > 0) {
              heading_number_auto_composite =
                ((heading_num_depth >= 0)
                && (heading_num_depth <= 3))
                ?  (to!string(heading_num_0))
                : "";
            } else {
              heading_number_auto_composite = "";
            }
            debug(heading_number_auto) {
              writeln(heading_number_auto_composite);
            }
            if (!empty(heading_number_auto_composite)) {
              munge_=replaceFirst(munge_, rgx.heading,
                "$1~$2 " ~ heading_number_auto_composite ~ ". ");
              munge_=replaceFirst(munge_, rgx.heading_marker_missing_tag,
                "$1~" ~ heading_number_auto_composite ~ " ");
            }
          }
        }
        return munge_;
      }
    
    
      static string _make_segment_anchor_tags_if_none_provided(string munge_, string lev_) {
        if (!(match(munge_, rgx.heading_anchor_tag))) { // if (anchor_tags_.length == 0) {
          if (match(munge_, rgx.heading_identify_anchor_tag)) {
            if (auto m = match(munge_, rgx.heading_extract_named_anchor_tag)) {
              munge_=replaceFirst(munge_, rgx.heading_marker_missing_tag,
                "$1~" ~ toLower(m.captures[1]) ~ "_"  ~ m.captures[2] ~ " ");
            } else if (auto m = match(munge_, rgx.heading_extract_unnamed_anchor_tag)) {
              munge_=replaceFirst(munge_, rgx.heading_marker_missing_tag,
                "$1~" ~ "s" ~ m.captures[1] ~ " ");
            }
          } else if (lev_ == "1") { // (if not successful) manufacture a unique anchor tag for lev=="1"
            static __gshared int heading_num_lev1 = 0;
            heading_num_lev1 ++;
            munge_=replaceFirst(munge_, rgx.heading_marker_missing_tag,
              "$1~" ~ "x" ~ to!string(heading_num_lev1) ~ " ");
          }
        }
        return munge_;
      }
      unittest {
        string txt_lev="1";
        string txt_in, txt_out;
    
        txt_in = "1~copyright Copyright";
        txt_out ="1~copyright Copyright";
        assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out);
    
        txt_in = "1~ 6. Writing Copyright Licenses";
        txt_out ="1~s6 6. Writing Copyright Licenses";
        assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out);
    
        txt_in= "1~ 1. Reinforcing trends";
        txt_out= "1~s1 1. Reinforcing trends";
        assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out);
    
        txt_in= "1~ 11 SCIENCE AS A COMMONS";
        txt_out= "1~s11 11 SCIENCE AS A COMMONS";
        assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out);
    
        txt_in= "1~ Chapter 1";
        txt_out="1~chapter_1 Chapter 1";
        assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out);
    
        txt_in= "1~ Chapter 1.";
        txt_out="1~chapter_1 Chapter 1.";
        assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out);
    
        txt_in= "1~ Chapter 1: Done";
        txt_out="1~chapter_1 Chapter 1: Done";
        assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out);
    
        txt_in=  "1~ Chapter 11 - The Battle Over the Institutional Ecology of the Digital Environment";
        txt_out= "1~chapter_11 Chapter 11 - The Battle Over the Institutional Ecology of the Digital Environment";
        assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out);
    
        txt_in= "1~ CHAPTER I.";
        txt_out="1~x1 CHAPTER I.";
        assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out);
    
        txt_in= "1~ CHAPTER II.";
        txt_out="1~x2 CHAPTER II.";
        assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out);
      }
    }
    /+ +/
    struct ObjAttributes {
      string[string] _obj_attrib;
      string obj_attributes(
        string              obj_is_,
        string              obj_raw,
        ObjGenericComposite _comp_obj_heading,
      )
      in { }
      body {
        scope(exit) {
          destroy(obj_is_);
          destroy(obj_raw);
          destroy(_comp_obj_heading);
        }
        _obj_attrib["json"] ="{";
        switch (obj_is_) {
        case "heading":
          _obj_attrib["json"] ~= _heading(obj_raw);
          break;
        case "para":
          _obj_attrib["json"] ~= _para_and_blocks(obj_raw)
          ~ _para(obj_raw);
          break;
        case "code":
          _obj_attrib["json"] ~= _code(obj_raw);
          break;
        case "group":
          _obj_attrib["json"] ~= _para_and_blocks(obj_raw)
          ~ _group(obj_raw);
          break;
        case "block":
          _obj_attrib["json"] ~= _para_and_blocks(obj_raw)
          ~ _block(obj_raw);
          break;
        case "verse":
          _obj_attrib["json"] ~= _verse(obj_raw);
          break;
        case "quote":
          _obj_attrib["json"] ~= _quote(obj_raw);
          break;
        case "table":
          _obj_attrib["json"] ~= _table(obj_raw);
          break;
        case "comment":
          _obj_attrib["json"] ~= _comment(obj_raw);
          break;
        default:
          _obj_attrib["json"] ~= _para(obj_raw);
          break;
        }
        _obj_attrib["json"] ~=" }";
        _obj_attrib["json"]=_set_additional_values_parse_as_json(_obj_attrib["json"], obj_is_, _comp_obj_heading); // check
        debug(structattrib) {
          if (oa_j["is"].str() == "heading") {
            writeln(_obj_attrib["json"]);
            writeln(
              "is: ", oa_j["is"].str(),
              "; obj_cite_number: ", oa_j["obj_cite_number"].integer()
            );
          }
        }
        return _obj_attrib["json"];
      }
      invariant() {
      }
      private:
      string _obj_attributes;
      string _para_and_blocks(string obj_txt_in)
      in { }
      body {
        auto rgx = Rgx();
        if (matchFirst(obj_txt_in, rgx.para_bullet)) {
          _obj_attributes =" \"bullet\": \"true\","
          ~ " \"indent_hang\": 0,"
          ~ " \"indent_base\": 0,";
        } else if (auto m = matchFirst(obj_txt_in, rgx.para_bullet_indent)) {
          _obj_attributes =" \"bullet\": \"true\","
          ~ " \"indent_hang\": " ~ to!string(m.captures[1]) ~ ","
          ~ " \"indent_base\": " ~ to!string(m.captures[1]) ~ ",";
        } else if (auto m = matchFirst(obj_txt_in, rgx.para_indent_hang)) {
          _obj_attributes =" \"bullet\": \"false\","
          ~ " \"indent_hang\": " ~ to!string(m.captures[1]) ~ ","
          ~ " \"indent_base\": " ~  to!string(m.captures[2]) ~ ",";
        } else if (auto m = matchFirst(obj_txt_in, rgx.para_indent)) {
          _obj_attributes =" \"bullet\": \"false\","
          ~ " \"indent_hang\": " ~ to!string(m.captures[1]) ~ ","
          ~ " \"indent_base\": " ~ to!string(m.captures[1]) ~ ",";
        } else {
          _obj_attributes =" \"bullet\": \"false\","
          ~ " \"indent_hang\": 0,"
          ~ " \"indent_base\": 0,";
        }
        return _obj_attributes;
      }
      string _para(string obj_txt_in)
      in { }
      body {
        _obj_attributes = " \"use\": \"content\","
        ~ " \"of\": \"para\","
        ~ " \"is\": \"para\"";
        return _obj_attributes;
      }
      invariant() {
      }
      string _heading(string obj_txt_in)
      in { }
      body {
        _obj_attributes = " \"use\": \"content\","
        ~ " \"of\": \"para\","
        ~ " \"is\": \"heading\"";
        return _obj_attributes;
      }
      invariant() {
      }
      string _code(string obj_txt_in)
      in { }
      body {
        _obj_attributes = " \"use\": \"content\","
        ~ " \"of\": \"block\","
        ~ " \"is\": \"code\"";
        return _obj_attributes;
      }
      invariant() {
      }
      string _group(string obj_txt_in)
      in { }
      body {
        _obj_attributes = " \"use\": \"content\","
        ~ " \"of\": \"block\","
        ~ " \"is\": \"group\"";
        return _obj_attributes;
      }
      invariant() {
      }
      string _block(string obj_txt_in)
      in { }
      body {
        _obj_attributes = " \"use\": \"content\","
        ~ " \"of\": \"block\","
        ~ " \"is\": \"block\"";
        return _obj_attributes;
      }
      invariant() {
      }
      string _verse(string obj_txt_in)
      in { }
      body {
        _obj_attributes = " \"use\": \"content\","
        ~ " \"of\": \"block\","
        ~ " \"is\": \"verse\"";
        return _obj_attributes;
      }
      invariant() {
      }
      string _quote(string obj_txt_in)
      in { }
      body {
        _obj_attributes = " \"use\": \"content\","
        ~ " \"of\": \"block\","
        ~ " \"is\": \"quote\"";
        return _obj_attributes;
      }
      invariant() {
      }
      string _table(string obj_txt_in)
      in { }
      body {
        _obj_attributes = " \"use\": \"content\","
        ~ " \"of\": \"block\","
        ~ " \"is\": \"table\"";
        return _obj_attributes;
      }
      invariant() {
      }
      string _comment(string obj_txt_in)
      in { }
      body {
        _obj_attributes = " \"use\": \"comment\","
        ~ " \"of\": \"comment\","
        ~ " \"is\": \"comment\"";
        return _obj_attributes;
      }
      invariant() {
      }
      string _set_additional_values_parse_as_json(
        string              _obj_attrib,
        string              obj_is_,
        ObjGenericComposite _comp_obj_heading,
      ) {                                                  //
        JSONValue oa_j = parseJSON(_obj_attrib);
        assert(
          (oa_j.type == JSON_TYPE.OBJECT)
        );
        if (obj_is_ == "heading") {
          oa_j.object["obj_cite_number"] = _comp_obj_heading.ocn;
          oa_j.object["lev_markup_number"] = _comp_obj_heading.heading_lev_markup;
          oa_j.object["lev_collapsed_number"] = _comp_obj_heading.heading_lev_collapsed;
          oa_j.object["heading_ptr"] =
            _comp_obj_heading.ptr_heading;
          oa_j.object["doc_object_ptr"] =
            _comp_obj_heading.ptr_doc_object;
        }
        oa_j.object["parent_obj_cite_number"] = _comp_obj_heading.parent_ocn;
        oa_j.object["parent_lev_markup_number"] = _comp_obj_heading.parent_lev_markup;
        _obj_attrib = oa_j.toString();
        return _obj_attrib;
      }
    }
    /+ +/
    struct BookIndexNuggetHash {
      string main_term, sub_term, sub_term_bits;
      int obj_cite_number_offset, obj_cite_number_endpoint;
      string[] obj_cite_numbers;
      string[][string][string] bi;
      string[][string][string] hash_nugget;
      string[] bi_main_terms_split_arr;
      string[][string][string] bookindex_nugget_hash(
        string bookindex_section,
        int    obj_cite_number
      )
      in {
        debug(bookindexraw) {
          if (!bookindex_section.empty) {
            writeln(
              "* [bookindex] ",
              "[", to!string(obj_cite_number), "] ", bookindex_section
            );
          }
        }
      }
      body {
        auto rgx = Rgx();
        if (!bookindex_section.empty) {
          auto bi_main_terms_split_arr =
            split(bookindex_section, rgx.bi_main_terms_split);
          foreach (bi_main_terms_content; bi_main_terms_split_arr) {
            auto bi_main_term_and_rest =
              split(bi_main_terms_content, rgx.bi_main_term_plus_rest_split);
            if (auto m = match(
              bi_main_term_and_rest[0],
              rgx.bi_term_and_obj_cite_numbers_match)
            ) {
              main_term = strip(m.captures[1]);
              obj_cite_number_offset = to!int(m.captures[2]);
              obj_cite_number_endpoint=(obj_cite_number + obj_cite_number_offset);
              obj_cite_numbers ~= (to!string(obj_cite_number) ~ "-" ~ to!string(obj_cite_number_endpoint));
            } else {
              main_term = strip(bi_main_term_and_rest[0]);
              obj_cite_numbers ~= to!string(obj_cite_number);
            }
            bi[main_term]["_a"] ~= obj_cite_numbers;
            obj_cite_numbers=null;
            if (bi_main_term_and_rest.length > 1) {
              auto bi_sub_terms_split_arr =
                split(
                  bi_main_term_and_rest[1],
                  rgx.bi_sub_terms_plus_obj_cite_number_offset_split
                );
              foreach (sub_terms_bits; bi_sub_terms_split_arr) {
                if (auto m = match(sub_terms_bits, rgx.bi_term_and_obj_cite_numbers_match)) {
                  sub_term = strip(m.captures[1]);
                  obj_cite_number_offset = to!int(m.captures[2]);
                  obj_cite_number_endpoint=(obj_cite_number + obj_cite_number_offset);
                  obj_cite_numbers ~= (to!string(obj_cite_number) ~ " - " ~ to!string(obj_cite_number_endpoint));
                } else {
                  sub_term = strip(sub_terms_bits);
                  obj_cite_numbers ~= to!string(obj_cite_number);
                }
                if (!empty(sub_term)) {
                  bi[main_term][sub_term] ~= obj_cite_numbers;
                }
                obj_cite_numbers=null;
              }
            }
          }
        }
        hash_nugget = bi;
        return hash_nugget;
      }
      invariant() {
      }
    }
    struct BookIndexReportIndent {
      int mkn, skn;
      auto bookindex_report_indented(
        string[][string][string] bookindex_unordered_hashes
      ) {
        auto mainkeys=
          bookindex_unordered_hashes.byKey.array.sort().release;
        foreach (mainkey; mainkeys) {
          debug(bookindex) {
            writeln(mainkey);
          }
          auto subkeys=
            bookindex_unordered_hashes[mainkey].byKey.array.sort().release;
          foreach (subkey; subkeys) {
            debug(bookindex) {
              writeln("  ", subkey);
              writeln("    ", to!string(
                bookindex_unordered_hashes[mainkey][subkey]
              ));
            }
            ++skn;
          }
          ++mkn;
        }
      }
    }
    struct BookIndexReportSection {
      int  mkn, skn;
      auto rgx = Rgx();
      auto munge = ObjInlineMarkupMunge();
      auto bookindex_write_section(
        string[][string][string] bookindex_unordered_hashes
      ) {
        auto mainkeys=bookindex_unordered_hashes.byKey.array.sort().release;
        foreach (mainkey; mainkeys) {
          write("_0_1 !{", mainkey, "}! ");
          foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) {
            auto go = replaceAll(ref_, rgx.book_index_go, "$1");
            write(" {", ref_, "}#", go, ", ");
          }
          writeln(" \\\\");
          bookindex_unordered_hashes[mainkey].remove("_a");
          auto subkeys=
            bookindex_unordered_hashes[mainkey].byKey.array.sort().release;
          foreach (subkey; subkeys) {
            write("  ", subkey, ", ");
            foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) {
              auto go = replaceAll(ref_, rgx.book_index_go, "$1");
              write(" {", ref_, "}#", go, ", ");
            }
            writeln(" \\\\");
            ++skn;
          }
          ++mkn;
        }
      }
      auto bookindex_build_abstraction_section(
        string[][string][string] bookindex_unordered_hashes,
        int                      obj_cite_number,
        string                   segment_anchor_tag_that_object_belongs_to,
        bool[string]             opt_action_bool,
      ) {
        mixin SiSUnode;
        mixin InternalMarkup;
        auto mkup = InlineMarkup();
        string type_is;
        string lev;
        int heading_lev_markup, heading_lev_collapsed;
        string attrib;
        int[string] indent;
        auto mainkeys =
          bookindex_unordered_hashes.byKey.array.sort().release;
        ObjGenericComposite[][string] bookindex_section;
        ObjGenericComposite comp_obj_heading_, comp_obj_para;
        auto node_para_int_ = node_metadata_para_int;
        auto node_para_str_ = node_metadata_para_str;
        if ((mainkeys.length > 0)
        && (opt_action_bool["backmatter"] && opt_action_bool["section_bookindex"])) {
          string bi_tmp_seg, bi_tmp_scroll;
          string[] bi_tmp_tags;
          comp_obj_heading_                       = comp_obj_heading_.init;
          comp_obj_heading_.use                   = "backmatter";
          comp_obj_heading_.is_of                 = "para";
          comp_obj_heading_.is_a                  = "heading";
          comp_obj_heading_.text                  = "Book Index";
          comp_obj_heading_.ocn                   = 0;
          comp_obj_heading_.obj_cite_number       = "";
          comp_obj_heading_.marked_up_level       = "B";
          comp_obj_heading_.heading_lev_markup    = 1;
          comp_obj_heading_.heading_lev_collapsed = 1;
          comp_obj_heading_.parent_ocn            = 1;
          comp_obj_heading_.parent_lev_markup     = 0;
          bookindex_section["scroll"]             ~= comp_obj_heading_;
          bookindex_section["seg"]                ~= comp_obj_heading_;
          ++obj_cite_number;
          ++mkn;
          comp_obj_heading_                       = comp_obj_heading_.init;
          comp_obj_heading_.use                   = "backmatter";
          comp_obj_heading_.is_of                 = "para";
          comp_obj_heading_.is_a                  = "heading";
          comp_obj_heading_.text                  = "Index";
          comp_obj_heading_.ocn                   = 0;
          comp_obj_heading_.obj_cite_number       = "";
          comp_obj_heading_.segment_anchor_tag    = "bookindex";
          comp_obj_heading_.marked_up_level       = "1";
          comp_obj_heading_.heading_lev_markup    = 4;
          comp_obj_heading_.heading_lev_collapsed = 2;
          comp_obj_heading_.parent_ocn            = 1;
          comp_obj_heading_.parent_lev_markup     = 0;
          comp_obj_heading_.anchor_tags           = ["bookindex"];
          bookindex_section["scroll"]             ~= comp_obj_heading_;
          bookindex_section["seg"]                ~= comp_obj_heading_;
          ++obj_cite_number;
          ++mkn;
          import std.array : appender;
          auto buffer = appender!(char[])();
          string[dchar] transTable = [' ' : "_"];
          foreach (mainkey; mainkeys) {
            bi_tmp_tags = [""];
            bi_tmp_scroll = "!{" ~ mainkey ~ "}! ";
            buffer.clear();
            bi_tmp_tags ~= translate(mainkey, transTable);
            bi_tmp_seg = "!{" ~ mainkey ~ "}! ";
            foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) {
              auto go = replaceAll(ref_, rgx.book_index_go, "$1");
              bi_tmp_scroll ~= munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", ");
              bi_tmp_seg ~= (segment_anchor_tag_that_object_belongs_to.empty)
              ? munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", ")
              : munge.url_links(" {" ~ ref_ ~ "}" ~ mkup.mark_internal_site_lnk ~ "../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fnSuffix#" ~ go ~ ", ");
            }
            bi_tmp_scroll ~= " \\\\\n    ";
            bi_tmp_seg ~= " \\\\\n    ";
            bookindex_unordered_hashes[mainkey].remove("_a");
            auto subkeys =
              bookindex_unordered_hashes[mainkey].byKey.array.sort().release;
            foreach (subkey; subkeys) {
              bi_tmp_scroll ~= subkey ~ ", ";
              buffer.clear();
              bi_tmp_tags ~= translate(subkey, transTable);
              bi_tmp_seg ~= subkey ~ ", ";
              foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) {
                auto go = replaceAll(ref_, rgx.book_index_go, "$1");
                bi_tmp_scroll ~= munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", ");
                bi_tmp_seg ~= (segment_anchor_tag_that_object_belongs_to.empty)
                ? munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", ")
                : munge.url_links(" {" ~ ref_ ~ "}" ~ mkup.mark_internal_site_lnk ~ "../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fnSuffix#" ~ go ~ ", ");
              }
              bi_tmp_scroll ~= " \\\\\n    ";
              bi_tmp_seg ~= " \\\\\n    ";
              ++skn;
            }
            bi_tmp_scroll = replaceFirst(bi_tmp_scroll, rgx.trailing_linebreak, "");
            bi_tmp_seg = replaceFirst(bi_tmp_seg, rgx.trailing_linebreak, "");
            comp_obj_para                       = comp_obj_para.init;
            comp_obj_para.use                   = "backmatter";
            comp_obj_para.is_of                 = "para";
            comp_obj_para.is_a                  = "bookindex";
            comp_obj_para.text                  = to!string(bi_tmp_scroll).strip;
            comp_obj_para.ocn                   = obj_cite_number;
            comp_obj_para.obj_cite_number       = (obj_cite_number==0) ? "" : to!string(obj_cite_number);
            comp_obj_para.anchor_tags           = bi_tmp_tags;
            comp_obj_para.indent_hang           = 0;
            comp_obj_para.indent_base           = 1;
            comp_obj_para.bullet                = false;
            bookindex_section["scroll"]         ~= comp_obj_para;
            comp_obj_para.text                  = to!string(bi_tmp_seg).strip;
            bookindex_section["seg"]            ~= comp_obj_para;
            ++obj_cite_number;
            ++mkn;
          }
        } else {                              // no book index, (figure out what to do here)
          comp_obj_heading_                       = comp_obj_heading_.init;
          comp_obj_heading_.text                  = "(skip) there is no Book Index";
          comp_obj_heading_.ocn                   = 0;
          comp_obj_heading_.obj_cite_number       = "";
          comp_obj_heading_.marked_up_level       = "B";
          comp_obj_heading_.heading_lev_markup    = 1;
          comp_obj_heading_.heading_lev_collapsed = 1;
          comp_obj_heading_.parent_ocn            = 1;
          comp_obj_heading_.parent_lev_markup     = 0;
          bookindex_section["scroll"]             ~= comp_obj_heading_;
          bookindex_section["seg"]                ~= comp_obj_heading_;
        }
        auto t = tuple(bookindex_section, obj_cite_number);
        return t;
      }
    }
    /+ +/
    struct NotesSection {
      string[string] object_notes;
      int previous_count;
      int mkn;
      auto rgx = Rgx();
      private auto gather_notes_for_endnote_section(
        ObjGenericComposite[] contents_am,
        string                segment_anchor_tag_that_object_belongs_to,
        int                   cntr,
      )
      in {
        // endnotes/ footnotes for
        // doc objects other than paragraphs & headings
        // various forms of grouped text
        assert((contents_am[cntr].is_a == "para")
        || (contents_am[cntr].is_a == "heading")
        || (contents_am[cntr].is_a == "group"));
        assert(cntr >= previous_count);
        previous_count=cntr;
        assert(
          match(contents_am[cntr].text,
          rgx.inline_notes_delimiter_al_regular_number_note)
        );
      }
      body {
        mixin InternalMarkup;
        auto mkup = InlineMarkup();
        auto munge = ObjInlineMarkupMunge();
        foreach(
          m;
          matchAll(
            contents_am[cntr].text,
            rgx.inline_notes_delimiter_al_regular_number_note
          )
        ) {
          debug(endnotes_build) {
            writeln(
              "{^{", m.captures[1], ".}^}" ~ mkup.mark_internal_site_lnk ~ "../", segment_anchor_tag_that_object_belongs_to, ".fnSuffix#noteref_\n  ", m.captures[1], " ",
              m.captures[2]); // sometimes need segment name (segmented html & epub)
          }
          // TODO NEXT you need anchor for segments at this point ->
          object_notes["anchor"] ~= "#note_" ~ m.captures[1] ~ "』";
          object_notes["notes"] ~= (segment_anchor_tag_that_object_belongs_to.empty)
          ? (munge.url_links(
              "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~
              m.captures[1]) ~ " " ~ m.captures[2] ~ "』"
            )
          : (munge.url_links(
              "{^{" ~ m.captures[1] ~ ".}^}" ~ mkup.mark_internal_site_lnk ~ "../" ~
              segment_anchor_tag_that_object_belongs_to ~ ".fnSuffix#noteref_" ~
              m.captures[1]) ~ " " ~ m.captures[2] ~ "』"
            );
        }
        return object_notes;
      }
      private auto gathered_notes()
      in {
      }
      body {
        string[][string] endnotes_;
        if (object_notes.length > 1) {
          endnotes_["notes"] = (split(object_notes["notes"], rgx.break_string))[0..$-1];
          endnotes_["anchor"] = (split(object_notes["anchor"], rgx.break_string))[0..$-1];
        } else {
          endnotes_["notes"] = [];
          endnotes_["anchor"] = [];
        }
        return endnotes_;
      }
      private auto endnote_objects(
        int            obj_cite_number,
        bool[string]   opt_action_bool,
      )
      in {
      }
      body {
        mixin SiSUnode;
        ObjGenericComposite[] the_endnotes_section;
        auto endnotes_ = gathered_notes();
        string type_is;
        string lev, lev_markup_number, lev_collapsed_number;
        string attrib;
        int[string] indent;
        ObjGenericComposite comp_obj_heading_;
        if ((endnotes_["notes"].length > 0)
        && (opt_action_bool["backmatter"] && opt_action_bool["section_endnotes"])) {
          comp_obj_heading_                       = comp_obj_heading_.init;
          comp_obj_heading_.use                   = "backmatter";
          comp_obj_heading_.is_of                 = "para";
          comp_obj_heading_.is_a                  = "heading";
          comp_obj_heading_.text                  = "Endnotes";
          comp_obj_heading_.ocn                   = 0;
          comp_obj_heading_.obj_cite_number       = "";
          comp_obj_heading_.marked_up_level       = "B";
          comp_obj_heading_.heading_lev_markup    = 1;
          comp_obj_heading_.heading_lev_collapsed = 1;
          comp_obj_heading_.parent_ocn            = 1;
          comp_obj_heading_.parent_lev_markup     = 0;
          the_endnotes_section                    ~= comp_obj_heading_;
          ++obj_cite_number;
          ++mkn;
          comp_obj_heading_                       = comp_obj_heading_.init;
          comp_obj_heading_.use                   = "backmatter";
          comp_obj_heading_.is_of                 = "para";
          comp_obj_heading_.is_a                  = "heading";
          comp_obj_heading_.text                  = "Endnotes";
          comp_obj_heading_.ocn                   = 0;
          comp_obj_heading_.obj_cite_number       = "";
          comp_obj_heading_.segment_anchor_tag    = "endnotes";
          comp_obj_heading_.marked_up_level       = "1";
          comp_obj_heading_.heading_lev_markup    = 4;
          comp_obj_heading_.heading_lev_collapsed = 2;
          comp_obj_heading_.parent_ocn            = 1;
          comp_obj_heading_.parent_lev_markup     = 0;
          comp_obj_heading_.anchor_tags           = ["endnotes"];
          the_endnotes_section                    ~= comp_obj_heading_;
          ++obj_cite_number;
          ++mkn;
        } else {
          comp_obj_heading_                       = comp_obj_heading_.init;
          comp_obj_heading_.use                   = "empty";
          comp_obj_heading_.is_of                 = "para";
          comp_obj_heading_.is_a                  = "heading";
          comp_obj_heading_.text                  = "(skip) there are no Endnotes";
          comp_obj_heading_.ocn                   = 0;
          comp_obj_heading_.obj_cite_number       = "";
          comp_obj_heading_.marked_up_level       = "B";
          comp_obj_heading_.heading_lev_markup    = 1;
          comp_obj_heading_.heading_lev_collapsed = 1;
          comp_obj_heading_.parent_ocn            = 1;
          comp_obj_heading_.parent_lev_markup     = 0;
          the_endnotes_section                    ~= comp_obj_heading_;
        }
        if (opt_action_bool["backmatter"] && opt_action_bool["section_endnotes"]) {
          ObjGenericComposite comp_obj_endnote_;
          comp_obj_endnote_                       = comp_obj_endnote_.init;
          comp_obj_endnote_.use                   = "backmatter";
          comp_obj_endnote_.is_of                 = "para";
          comp_obj_endnote_.is_a                  = "endnote";
          comp_obj_endnote_.ocn                   = 0;
          comp_obj_heading_.obj_cite_number       = "";
          comp_obj_endnote_.indent_hang           = 0;
          comp_obj_endnote_.indent_base           = 0;
          comp_obj_endnote_.bullet                = false;
          foreach (i, endnote; endnotes_["notes"]) {
            auto     m                            = (matchFirst(endnote, rgx.note_ref));
            string   notenumber                   = to!string(m.captures[1]);
            string   anchor_tag                   = "note_" ~ notenumber;
            comp_obj_endnote_.anchor_tags         ~= [ endnotes_["anchor"][i] ]; // fix
            comp_obj_endnote_.text                = endnote.strip;
            the_endnotes_section                  ~= comp_obj_endnote_;
          }
        }
        auto t = tuple(the_endnotes_section, obj_cite_number);
        return t;
      }
    }
    /+ +/
    struct Bibliography {
      public JSONValue[] _bibliography_(
        ref string[]     biblio_unsorted_incomplete,
        ref JSONValue[]  bib_arr_json
      )
      in { }
      body {
        JSONValue[] biblio_unsorted =
          _biblio_unsorted_complete_(biblio_unsorted_incomplete, bib_arr_json);
        JSONValue[] biblio_sorted__ = biblio_sort(biblio_unsorted);
        biblio_debug(biblio_sorted__);
        debug(biblio0) {
          writeln("---");
          writeln("unsorted incomplete: ", biblio_unsorted_incomplete.length);
          writeln("json:                ", bib_arr_json.length);
          writeln("unsorted:            ", biblio_unsorted.length);
          writeln("sorted:              ", biblio_sorted__.length);
          int cntr;
          int[7] x;
          while (cntr < x.length) {
            writeln(cntr, ": ", biblio_sorted__[cntr]["fulltitle"]);
            cntr++;
          }
        }
        return biblio_sorted__;
      }
      final private JSONValue[] _biblio_unsorted_complete_(
        string[]        biblio_unordered,
        ref JSONValue[] bib_arr_json
      ) {
        foreach (bibent; biblio_unordered) {
          // update bib to include deemed_author, needed for:
          // sort_bibliography_array_by_deemed_author_year_title
          // either: sort on multiple fields, or; create such sort field
          JSONValue j = parseJSON(bibent);
          if (!empty(j["fulltitle"].str)) {
            if (!empty(j["author_raw"].str)) {
              j["deemed_author"]=j["author_arr"][0];
            } else if (!empty(j["editor_raw"].str)) {
              j["deemed_author"]=j["editor_arr"][0];
            }
            j["sortby_deemed_author_year_title"] = (
              j["deemed_author"].str ~
               "; " ~
               j["year"].str ~
               "; "  ~
               j["fulltitle"].str
            );
          }
          bib_arr_json ~= j;
        }
        JSONValue[] biblio_unsorted_array_of_json_objects =
          bib_arr_json.dup;
        return biblio_unsorted_array_of_json_objects;
      }
      final private JSONValue[] biblio_sort(JSONValue[] biblio_unordered) {
        JSONValue[] biblio_sorted_;
        biblio_sorted_ =
          sort!((a, b){
            return ((a["sortby_deemed_author_year_title"].str) < (b["sortby_deemed_author_year_title"].str));
          })(biblio_unordered).array;
        debug(bibliosorted) {
          foreach (j; biblio_sorted_) {
            if (!empty(j["fulltitle"].str)) {
              writeln(j["sortby_deemed_author_year_title"]);
            }
          }
        }
        return biblio_sorted_;
      }
      void biblio_debug(JSONValue[] biblio_sorted) {
        debug(biblio0) {
          foreach (j; biblio_sorted) {
            if (!empty(j["fulltitle"].str)) {
              writeln(j["sortby_deemed_author_year_title"]);
            }
          }
        }
      }
    }
    /+ +/
    struct NodeStructureMetadata {
      int lv, lv0, lv1, lv2, lv3, lv4, lv5, lv6, lv7;
      int obj_cite_number;
      int[string] p_; // p_ parent_
      ObjGenericComposite node_location_emitter(
        string lev_markup_number,
        string segment_anchor_tag,
        int    obj_cite_number_,
        int    cntr_,
        int    ptr_,
        string is_
      )
      in {
        auto rgx = Rgx();
        assert(is_ != "heading");
        assert(to!int(obj_cite_number_) >= 0);
      }
      body {
        assert(is_ != "heading"); // should not be necessary
        assert(to!int(obj_cite_number_) >= 0); // should not be necessary
        int obj_cite_number=to!int(obj_cite_number_);
        if (lv7 > State.off) {
          p_["lev_markup_number"] = DocStructMarkupHeading.h_text_4;
          p_["obj_cite_number"] = lv7;
        } else if (lv6 > State.off) {
          p_["lev_markup_number"] = DocStructMarkupHeading.h_text_3;
          p_["obj_cite_number"] = lv6;
        } else if (lv5 > State.off) {
          p_["lev_markup_number"] = DocStructMarkupHeading.h_text_2;
          p_["obj_cite_number"] = lv5;
        } else {
          p_["lev_markup_number"] = DocStructMarkupHeading.h_text_1;
          p_["obj_cite_number"] = lv4;
        }
        ObjGenericComposite comp_obj_location;
        comp_obj_location                       = comp_obj_location.init;
        comp_obj_location.is_a                  = is_;
        comp_obj_location.ocn                   = obj_cite_number_;
        comp_obj_location.segment_anchor_tag    = to!string(segment_anchor_tag);
        comp_obj_location.parent_ocn            = p_["obj_cite_number"];
        comp_obj_location.parent_lev_markup     = p_["lev_markup_number"];
        debug(node) {
          if (match(lev_markup_number, rgx.levels_numbered_headings)) {
            writeln("x ", to!string(_node));
          } else {
            writeln("- ", to!string(_node));
          }
        }
        assert(comp_obj_location.parent_lev_markup >= 4);
        assert(comp_obj_location.parent_lev_markup <= 7);
        assert(comp_obj_location.parent_ocn >= 0);
        return comp_obj_location;
      }
      invariant() {
      }
      ObjGenericComposite node_emitter_heading(
        string _text,
        string lev,
        string lev_markup_number,
        string lev_collapsed_number,
        string segment_anchor_tag,
        int    obj_cite_number_,
        int    cntr_,
        int    ptr_,
        string[] lv_ancestors,
        string is_,
        int    html_segnames_ptr,
      )
      in {
        auto rgx = Rgx();
        assert(is_ == "heading");
        assert(to!int(obj_cite_number_) >= 0);
        assert(
          match(lev_markup_number, rgx.levels_numbered),
          ("not a valid heading level: " ~ lev_markup_number ~ " at " ~ to!string(obj_cite_number_))
        );
        if (match(lev_markup_number, rgx.levels_numbered)) {
          if (to!int(lev_markup_number) == 0) {
            assert(to!int(obj_cite_number_) == 1);
          }
        }
      }
      body {
        auto rgx = Rgx();
        int obj_cite_number = to!int(obj_cite_number_);
        switch (to!int(lev_markup_number)) { // switch (to!string(lv)) {
        case 0:
          lv = DocStructMarkupHeading.h_sect_A;
          lv0 = obj_cite_number;
          lv1=0; lv2=0; lv3=0; lv4=0; lv5=0; lv6=0; lv7=0;
          p_["lev_markup_number"] = 0;
          p_["obj_cite_number"] = 0;
          break;
        case 1:
          lv = DocStructMarkupHeading.h_sect_B;
          lv1 = obj_cite_number;
          lv2=0; lv3=0; lv4=0; lv5=0; lv6=0; lv7=0;
          p_["lev_markup_number"] =
            DocStructMarkupHeading.h_sect_A;
          p_["obj_cite_number"] = lv0;
          break;
        case 2:
          lv = DocStructMarkupHeading.h_sect_C;
          lv2 = obj_cite_number;
          lv3=0; lv4=0; lv5=0; lv6=0; lv7=0;
          p_["lev_markup_number"] =
            DocStructMarkupHeading.h_sect_B;
          p_["obj_cite_number"] = lv1;
          break;
        case 3:
          lv = DocStructMarkupHeading.h_sect_D;
          lv3=obj_cite_number;
          lv4=0; lv5=0; lv6=0; lv7=0;
          p_["lev_markup_number"] =
            DocStructMarkupHeading.h_sect_C;
          p_["obj_cite_number"] = lv2;
          break;
        case 4:
          lv = DocStructMarkupHeading.h_text_1;
          lv4 = obj_cite_number;
          lv5=0; lv6=0; lv7=0;
          if (lv3 > State.off) {
            p_["lev_markup_number"] =
              DocStructMarkupHeading.h_sect_D;
            p_["obj_cite_number"] = lv3;
          } else if (lv2 > State.off) {
            p_["lev_markup_number"] =
              DocStructMarkupHeading.h_sect_C;
            p_["obj_cite_number"] = lv2;
          } else if (lv1 > State.off) {
            p_["lev_markup_number"] =
              DocStructMarkupHeading.h_sect_B;
            p_["obj_cite_number"] = lv1;
          } else {
            p_["lev_markup_number"] =
              DocStructMarkupHeading.h_sect_A;
            p_["obj_cite_number"] = lv0;
          }
          break;
        case 5:
          lv = DocStructMarkupHeading.h_text_2;
          lv5 = obj_cite_number;
          lv6=0; lv7=0;
          p_["lev_markup_number"] =
            DocStructMarkupHeading.h_text_1;
          p_["obj_cite_number"] = lv4;
          break;
        case 6:
          lv = DocStructMarkupHeading.h_text_3;
          lv6 = obj_cite_number;
          lv7=0;
          p_["lev_markup_number"] =
            DocStructMarkupHeading.h_text_2;
          p_["obj_cite_number"] = lv5;
          break;
        case 7:
          lv = DocStructMarkupHeading.h_text_4;
          lv7 = obj_cite_number;
          p_["lev_markup_number"] =
            DocStructMarkupHeading.h_text_3;
          p_["obj_cite_number"] = lv6;
          break;
        default:
          break;
        }
        ObjGenericComposite _comp_obj_heading_;
        _comp_obj_heading_                           = _comp_obj_heading_.init;
        _comp_obj_heading_.use                       = "body";
        _comp_obj_heading_.is_of                     = "para";
        _comp_obj_heading_.is_a                      = "heading";   //    _node_heading_.is_a                = is_; // check whether needed, constant???
        _comp_obj_heading_.text                      = to!string(_text).strip;
        _comp_obj_heading_.ocn                       = obj_cite_number_;
        _comp_obj_heading_.obj_cite_number           = (obj_cite_number==0) ? "" : to!string(obj_cite_number);
        _comp_obj_heading_.segment_anchor_tag        = to!string(segment_anchor_tag);
        _comp_obj_heading_.marked_up_level           = lev;
        _comp_obj_heading_.heading_lev_markup        = (!(lev_markup_number.empty) ? to!int(lev_markup_number) : 0);
        _comp_obj_heading_.heading_lev_collapsed     = (!(lev_collapsed_number.empty) ? to!int(lev_collapsed_number) : 0);
        _comp_obj_heading_.parent_ocn                = p_["obj_cite_number"];
        _comp_obj_heading_.parent_lev_markup         = p_["lev_markup_number"];
        _comp_obj_heading_.heading_ancestors_text    = lv_ancestors;
        _comp_obj_heading_.ptr_doc_object            = cntr_;
        _comp_obj_heading_.ptr_html_segnames         = ((lev_markup_number == "4") ? html_segnames_ptr : 0);
        _comp_obj_heading_.ptr_heading               = ptr_;
        debug(node) {
          if (match(lev_markup_number, rgx.levels_numbered_headings)) {
            writeln("* ", to!string(_node));
          }
        }
        debug(nodeheading) {
          if (match(lev_markup_number, rgx.levels_numbered_headings)) {
            writeln("* ", to!string(_node));
          }
        }
        assert(_comp_obj_heading_.parent_lev_markup <= 7);
        assert(_comp_obj_heading_.parent_ocn >= 0);
        if (match(lev_markup_number, rgx.levels_numbered_headings)) {
          assert(_comp_obj_heading_.heading_lev_markup <= 7);
          assert(_comp_obj_heading_.ocn >= 0);
          if (_comp_obj_heading_.parent_lev_markup > 0) {
            assert(_comp_obj_heading_.parent_lev_markup < _comp_obj_heading_.heading_lev_markup);
            if (_comp_obj_heading_.ocn != 0) {
              assert(_comp_obj_heading_.parent_ocn < _comp_obj_heading_.ocn);
            }
          }
          if (_comp_obj_heading_.heading_lev_markup == 0) {
            assert(_comp_obj_heading_.parent_lev_markup == DocStructMarkupHeading.h_sect_A);
          } else if  (_comp_obj_heading_.heading_lev_markup == DocStructMarkupHeading.h_sect_B) {
            assert(_comp_obj_heading_.parent_lev_markup == DocStructMarkupHeading.h_sect_A);
          } else if  (_comp_obj_heading_.heading_lev_markup == DocStructMarkupHeading.h_sect_C) {
            assert(_comp_obj_heading_.parent_lev_markup == DocStructMarkupHeading.h_sect_B);
          } else if  (_comp_obj_heading_.heading_lev_markup == DocStructMarkupHeading.h_sect_D) {
            assert(_comp_obj_heading_.parent_lev_markup == DocStructMarkupHeading.h_sect_C);
          } else if  (_comp_obj_heading_.heading_lev_markup == DocStructMarkupHeading.h_text_1) {
            assert(_comp_obj_heading_.parent_lev_markup <= DocStructMarkupHeading.h_sect_D);
          } else if  (_comp_obj_heading_.heading_lev_markup == DocStructMarkupHeading.h_text_2) {
            assert(_comp_obj_heading_.parent_lev_markup == DocStructMarkupHeading.h_text_1);
          } else if  (_comp_obj_heading_.heading_lev_markup == DocStructMarkupHeading.h_text_3) {
            assert(_comp_obj_heading_.parent_lev_markup == DocStructMarkupHeading.h_text_2);
          } else if  (_comp_obj_heading_.heading_lev_markup == DocStructMarkupHeading.h_text_4) {
            assert(_comp_obj_heading_.parent_lev_markup == DocStructMarkupHeading.h_text_3);
          } else if  (_comp_obj_heading_.heading_lev_markup == DocStructMarkupHeading.h_text_5) {
          }
        }
        return _comp_obj_heading_;
      }
      invariant() {
      }
    }
    /+ abstraction functions emitters ↑ +/
    /+ ↓ abstraction functions assertions +/
    auto assertions_doc_structure(
      string[string] an_object,
      int[string]    lv
    ) {
      if (lv["h3"] > State.off) {
        assert(lv["h0"] > State.off);
        assert(lv["h1"] > State.off);
        assert(lv["h2"] > State.off);
      } else if (lv["h2"] > State.off) {
        assert(lv["h0"] > State.off);
        assert(lv["h1"] > State.off);
        assert(lv["h3"] == State.off);
      } else if (lv["h1"] > State.off) {
        assert(lv["h0"] > State.off);
        assert(lv["h2"] == State.off);
        assert(lv["h3"] == State.off);
      } else if (lv["h0"] > State.off) {
        assert(lv["h1"] == State.off);
        assert(lv["h2"] == State.off);
        assert(lv["h3"] == State.off);
      } else {
        assert(lv["h0"] == State.off);
        assert(lv["h1"] == State.off);
        assert(lv["h2"] == State.off);
        assert(lv["h3"] == State.off);
      }
      if (lv["h7"] > State.off) {
        assert(lv["h4"] > State.off);
        assert(lv["h5"] > State.off);
        assert(lv["h6"] > State.off);
      } else if (lv["h6"] > State.off) {
        assert(lv["h4"] > State.off);
        assert(lv["h5"] > State.off);
        assert(lv["h7"] == State.off);
      } else if (lv["h5"] > State.off) {
        assert(lv["h4"] > State.off);
        assert(lv["h6"] == State.off);
        assert(lv["h7"] == State.off);
      } else if (lv["h4"] > State.off) {
        assert(lv["h5"] == State.off);
        assert(lv["h6"] == State.off);
        assert(lv["h7"] == State.off);
      } else {
        assert(lv["h4"] == State.off);
        assert(lv["h5"] == State.off);
        assert(lv["h6"] == State.off);
        assert(lv["h7"] == State.off);
      }
      if (lv["h0"] == State.off) {
        assert(lv["h1"] == State.off);
        assert(lv["h2"] == State.off);
        assert(lv["h3"] == State.off);
        assert(lv["h4"] == State.off);
        assert(lv["h5"] == State.off);
        assert(lv["h6"] == State.off);
        assert(lv["h7"] == State.off);
      }
      if (lv["h1"] == State.off) {
        assert(lv["h2"] == State.off);
        assert(lv["h3"] == State.off);
      }
      if (lv["h2"] == State.off) {
        assert(lv["h3"] == State.off);
      }
      if (lv["h3"] == State.off) {
      }
      if (lv["h4"] == State.off) {
        assert(lv["h5"] == State.off);
        assert(lv["h6"] == State.off);
        assert(lv["h7"] == State.off);
      }
      if (lv["h5"] == State.off) {
        assert(lv["h6"] == State.off);
        assert(lv["h7"] == State.off);
      }
      if (lv["h6"] == State.off) {
        assert(lv["h7"] == State.off);
      }
      if (lv["h7"] == State.off) {
      }
      switch (to!string(an_object["lev"])) {
      case "A":
        if (lv["h0"] == State.off) {
          assert(lv["h1"] == State.off);
          assert(lv["h2"] == State.off);
          assert(lv["h3"] == State.off);
          assert(lv["h4"] == State.off);
          assert(lv["h5"] == State.off);
          assert(lv["h6"] == State.off);
          assert(lv["h7"] == State.off);
        } else {                       // (lv["h0"] > State.off)
          assert(lv["h0"] == State.off,"error should not enter level A a second time");
        }
        break;
      case "B":
        if (lv["h1"] == State.off) {
          assert(lv["h0"] > State.off);
          assert(lv["h2"] == State.off);
          assert(lv["h3"] == State.off);
        } else {                       // (lv["h1"] > State.off)
          assert(lv["h0"] > State.off);
          assert(lv["h1"] > State.off);
        }
        break;
      case "C":
        if (lv["h2"] == State.off) {
          assert(lv["h0"] > State.off);
          assert(lv["h1"] > State.off);
          assert(lv["h3"] == State.off);
        } else {                       // (lv["h2"] > State.off)
          assert(lv["h0"] > State.off);
          assert(lv["h1"] > State.off);
          assert(lv["h2"] > State.off);
        }
        break;
      case "D":
        if (lv["h3"] == State.off) {
          assert(lv["h0"] > State.off);
          assert(lv["h1"] > State.off);
          assert(lv["h2"] > State.off);
        } else {                      // (lv["h3"] > State.off)
          assert(lv["h0"] > State.off);
          assert(lv["h1"] > State.off);
          assert(lv["h2"] > State.off);
          assert(lv["h3"] > State.off);
        }
        break;
      case "1":
        if (lv["h4"] == State.off) {
          assert(lv["h0"] > State.off);
        } else {                      // (lv["h4"] > State.off)
          assert(lv["h0"] > State.off);
          assert(lv["h4"] > State.off);
        }
        break;
      case "2":
        if (lv["h5"] == State.off) {
          assert(lv["h0"] > State.off);
          assert(lv["h4"] > State.off);
        } else {                      // (lv["h5"] > State.off)
          assert(lv["h0"] > State.off);
          assert(lv["h4"] > State.off);
          assert(lv["h5"] > State.off);
        }
        break;
      case "3":
        if (lv["h6"] == State.off) {
          assert(lv["h0"] > State.off);
          assert(lv["h4"] > State.off);
          assert(lv["h5"] > State.off);
        } else {                      // (lv["h6"] > State.off)
          assert(lv["h0"] > State.off);
          assert(lv["h4"] > State.off);
          assert(lv["h5"] > State.off);
          assert(lv["h6"] > State.off);
        }
        break;
      case "4":
        if (lv["h7"] == State.off) {
          assert(lv["h0"] > State.off);
          assert(lv["h4"] > State.off);
          assert(lv["h5"] > State.off);
          assert(lv["h6"] > State.off);
        } else {                      // (lv["h7"] > State.off)
          assert(lv["h0"] > State.off);
          assert(lv["h4"] > State.off);
          assert(lv["h5"] > State.off);
          assert(lv["h6"] > State.off);
          assert(lv["h7"] > State.off);
        }
        break;
      default:
        break;
      }
    }
    auto assertions_flag_types_block_status_none_or_closed(int[string] type) {
      assert(
        (type["code"] == TriState.off)
        || (type["code"] == TriState.closing),
        "code block status: off or closing");
      assert(
        (type["poem"] == TriState.off)
        || (type["poem"] == TriState.closing),
        "poem status: off or closing");
      assert(
        (type["table"] == TriState.off)
        || (type["table"] == TriState.closing),
        "table status: off or closing");
      assert(
        (type["group"] == TriState.off)
        || (type["group"] == TriState.closing),
        "group block status: off or closing");
      assert(
        (type["block"] == TriState.off)
        || (type["block"] == TriState.closing),
        "block status: off or closing");
    }
    /+ abstraction functions assertions ↑ +/
  } /+ ← closed: struct Abstraction +/
} /+ ← closed: template SiSUdocAbstraction +/