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
|
module doc_reform.output.xmls;
template outputXHTMLs() {
import doc_reform.output;
import
std.digest.sha,
std.file,
std.outbuffer,
std.zip,
std.conv : to;
import
doc_reform.output.create_zip_file,
doc_reform.output.xmls,
doc_reform.output.xmls_css;
mixin DocReformOutputRgxInit;
struct outputXHTMLs {
static auto rgx = Rgx();
string div_delimit(
string part,
return ref string previous_part
){
string delimit = "";
string delimit_ = "";
if (part != previous_part) {
switch (part) {
case "head":
delimit_ ~= "\n<div class=\"doc_title\">\n" ;
break;
case "toc_seg":
delimit_ ~= "\n<div class=\"doc_toc\">\n" ;
break;
case "toc_scroll":
delimit_ ~= "\n<div class=\"doc_toc\">\n" ;
break;
case "bookindex_seg":
delimit_ ~= "\n<div class=\"doc_bookindex\">\n" ;
break;
case "bookindex_scroll":
delimit_ ~= "\n<div class=\"doc_bookindex\">\n" ;
break;
default:
delimit_ ~= "\n<div class=\"doc_" ~ part ~ "\">\n" ;
break;
}
if (previous_part.length > 0) {
delimit ~= "\n</div>";
}
previous_part = part;
delimit ~= delimit_;
}
// you also need to close the last div, introduce a footer?
return delimit;
}
string special_characters(O)(
const O obj,
string _txt
){
_txt = (_txt)
.replaceAll(rgx.xhtml_ampersand, "&")
.replaceAll(rgx.xhtml_quotation, """)
.replaceAll(rgx.xhtml_less_than, "<")
.replaceAll(rgx.xhtml_greater_than, ">")
.replaceAll(rgx.nbsp_char, " ");
if (!(obj.metainfo.is_a == "code")) {
_txt = (_txt)
.replaceAll(rgx.xhtml_line_break, "<br />");
}
return _txt;
}
string special_characters_text(string _txt){
_txt = (_txt)
.replaceAll(rgx.xhtml_ampersand, "&")
.replaceAll(rgx.xhtml_quotation, """)
.replaceAll(rgx.xhtml_less_than, "<")
.replaceAll(rgx.xhtml_greater_than, ">")
.replaceAll(rgx.nbsp_char, " ");
return _txt;
}
string font_face(string _txt){
_txt = (_txt)
.replaceAll(rgx.inline_emphasis, ("<em>$1</em>"))
.replaceAll(rgx.inline_bold, ("<b>$1</b>"))
.replaceAll(rgx.inline_underscore, ("<u>$1</u>"))
.replaceAll(rgx.inline_italics, ("<i>$1</i>"))
.replaceAll(rgx.inline_superscript, ("<sup>$1</sup>"))
.replaceAll(rgx.inline_subscript, ("<sub>$1</sub>"))
.replaceAll(rgx.inline_strike, ("<del>$1</del>"))
.replaceAll(rgx.inline_insert, ("<ins>$1</ins>"))
.replaceAll(rgx.inline_mono, ("<tt>$1</tt>"))
.replaceAll(rgx.inline_cite, ("<cite>$1</cite>"));
return _txt;
}
string _xhtml_anchor_tags(O)(O obj) {
const(string[]) anchor_tags = obj.tags.anchor_tags;
string tags="";
if (anchor_tags.length > 0) {
foreach (tag; anchor_tags) {
if (!(tag.empty)) {
tags ~= "<a name=\"" ~ tag ~ "\"></a>";
}
}
}
return tags;
}
auto header_metadata(M)(
M doc_matters,
) {
string _title="Title";
string _author="Author";
string _publisher="Publisher";
string _date="Date";
string _date_created="Date";
string _date_issued="Date";
string _date_available="Date";
string _date_valid="Date";
string _date_modified="Date";
string _language="en";
string _rights="Copyright: Copyright (C) year holder";
string _generator="doc_reform [DocReform 7.1.8 of 2016w08/5 (2016-02-26)] (n*x and D)";
string _generator_home="http://www.sisudoc.org";
string o;
o = format(q"¶<!-- DocReform header metadata -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="dc.title" content="%s" />
<meta name="dc.author" content="%s" />
<meta name="dc.publisher" content="%s" />
<meta name="dc.date" content="%s" />
<meta name="dc.date.created" content="%s" />
<meta name="dc.date.issued" content="%syear" />
<meta name="dc.date.available" content="%syear" />
<meta name="dc.date.valid" content="%syear" />
<meta name="dc.date.modified" content="%syear" />
<meta name="dc.language" content="%s" />
<meta name="dc.rights" content="%s" />
<meta name="generator" content="%s" />
<link rel="generator" href="%s" />
<!-- DocReform header metadata -->¶",
_title,
_author,
_publisher,
_date,
_date_created,
_date_issued,
_date_available,
_date_valid,
_date_modified,
_language,
_rights,
_generator,
_generator_home,
);
return o;
}
auto site_info_button(M)(
M doc_matters,
) {
string _locations;
if (doc_matters.conf_make_meta.make.home_button_text.length > 0) {
_locations = (doc_matters.conf_make_meta.make.home_button_text)
.replaceAll(
rgx.inline_link,
("<p class=\"tiny_left\"><a href=\"$2\">$1</a></p>"))
.replaceAll(
rgx.br_line, "")
.replaceAll(
rgx.br_nl, "");
} else {
_locations = "<p class=\"tiny_left\"><a href=\"http://www.sisudoc.org\">DocReform</a></p>\n<p class=\"tiny_left\"><a href=\"http://www.sisudoc.org\">www.sisudoc.org</a></p>\n<p class=\"tiny_left\"><a href=\"http://git.sisudoc.org/gitweb/\">sources / git</a></p>";
}
string o;
o = format(q"¶<div class="flex-menu-option">
%s
</div>¶",
_locations,
);
return o;
}
auto inline_search_form(M)(
M doc_matters,
) {
string _action="http://www.sisudoc.org/cgi-bin/search.cgi";
string _db="DocReform.7a.manual";
string o;
o = format(q"¶<div class="flex-menu-option">
<a name="search"></a>
<form method="get" action="%s" target="_top">
<font size="2">
<input type="text" name="s1" size="24" maxlength="255" />
<input type="hidden" name="db" value="%s" />
<input type="hidden" name="ltd" value="1000" />
<input type="hidden" name="off" value="0" />
<input type="hidden" name="doc" value="live-manual" /><br />
<input type="submit" name="search" value="search doc" />
<input type="submit" name="search" value="search db" />
</font></form>
</div>¶",
_action,
_db,
);
return o;
}
auto html_head(M)(
M doc_matters,
string type,
) {
string o;
o = format(q"¶<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>
%s%s
</title>
<!-- metadata -->
%s
<!-- metadata -->
<link rel="generator" href="http://www.sisudoc.org/" />
<link rel="shortcut icon" href="%s" />
<link href="%s" rel="stylesheet" />
</head>
<body lang="%s">
<a name="top" id="top"></a>
<div class='delimit headband'>
<div class="flex-menu-bar">
%s
<div class="flex-menu-option">
<a href="../../manifest/sisu.en.html" target="_top">
<font face="verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman" size="2">
[ document manifest ]
</font>
</a>
</div>
%s%s¶",
doc_matters.conf_make_meta.meta.title_full,
(doc_matters.conf_make_meta.meta.creator_author.empty) ? ""
: ", " ~ doc_matters.conf_make_meta.meta.creator_author,
header_metadata(doc_matters),
((type == "seg") ? "../../../" : "../../") ~ "image/rb7.ico",
((type == "seg")
? "../../../css/html_seg.css"
: "../../css/html_scroll.css"),
doc_matters.src.language,
site_info_button(doc_matters),
inline_search_form(doc_matters),
((type == "seg") ? "" : "\n</div>"),
);
return o;
}
auto epub3_seg_head(M)(
M doc_matters,
) {
string html_base = format(q"¶<!DOCTYPE html>
<html>¶",
);
string html_simple = format(q"¶<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:epub="http://www.idpf.org/2007/ops"
lang="%s" xml:lang="%s">¶",
doc_matters.src.language,
doc_matters.src.language,
);
string html_strict = format(q"¶<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:epub="http://www.idpf.org/2007/ops"
lang="%s" xml:lang="%s">¶",
doc_matters.src.language,
doc_matters.src.language,
);
string o;
o = format(q"¶%s
<head>
<title>
%s%s
</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="dc.title" content="%s" />
<meta name="dc.author" content="%s" />
<meta name="dc.publisher" content="DocReform http://www.jus.uio.no/sisu (this copy)" />
<meta name="dc.date" content="year" />
<meta name="dc.date.created" content="year" />
<meta name="dc.date.issued" content="year" />
<meta name="dc.date.available" content="year" />
<meta name="dc.date.valid" content="year" />
<meta name="dc.date.modified" content="year" />
<meta name="dc.language" content="US" />
<meta name="dc.rights" content="Copyright: Copyright (C) year holder" />
<meta name="generator" content="doc_reform [DocReform 7.1.8 of 2016w08/5 (2016-02-26)] (n*x and D)" />
<link rel="generator" href="http://www.sisudoc.org/" />
<link rel="shortcut icon" href="../_sisu/image/rb7.ico" />
<link rel="stylesheet" href="css/epub.css" type="text/css" id="main-css" />
</head>
<body lang="%s">
<a name="top" id="top"></a>¶",
html_simple,
doc_matters.conf_make_meta.meta.title_full,
(doc_matters.conf_make_meta.meta.creator_author.empty) ? ""
: ", " ~ doc_matters.conf_make_meta.meta.creator_author,
doc_matters.conf_make_meta.meta.title_full,
(doc_matters.conf_make_meta.meta.creator_author.empty) ? ""
: ", " ~ doc_matters.conf_make_meta.meta.creator_author,
doc_matters.src.language,
);
return o;
}
auto tail() {
string o;
o = format(q"¶ </div>
<a name="bottom" id="bottom"></a>
<a name="end" id="end"></a>
</body>
</html>¶");
return o;
}
auto inline_images(M,O)(
M doc_matters,
const O obj,
string _txt,
string _suffix = ".html",
string _xml_type = "seg",
) {
string _img_pth;
if (_xml_type == "epub") {
_img_pth = "image/";
} else if (_xml_type == "scroll") {
_img_pth = "../../image/";
} else if (_xml_type == "seg") {
_img_pth = "../../../image/";
}
if (_txt.match(rgx.inline_image)) {
_txt = _txt.replaceAll(
rgx.inline_image,
("$1<img src=\""
~ _img_pth
~ "$3\" width=\"$4\" height=\"$5\" naturalsizeflag=\"0\" align=\"bottom\" border=\"0\" /> $6"));
}
return _txt;
}
auto inline_links(M,O)(
M doc_matters,
const O obj,
string _txt,
string _suffix = ".html",
string _xml_type = "seg",
) {
if (obj.has.inline_links) {
if ((_txt.match(rgx.mark_internal_site_lnk))
&& (_xml_type == "scroll")) { // conditions reversed to avoid: gdc compiled program run segfault
_txt = (_txt).replaceAll(
rgx.inline_seg_link,
"$1");
}
if (_xml_type == "seg" || _xml_type == "epub") {
if (auto m = _txt.match(rgx.inline_link_hash)) {
if (m.captures[3] in doc_matters.xml.tag_associations) {
if (m.captures[3] == doc_matters.xml.tag_associations[(m.captures[3])][0]) {
_txt = _txt.replaceFirst(
rgx.inline_link_hash,
"┥$1┝┤$3" ~ _suffix ~ "├"
);
} else {
_txt = _txt.replaceFirst(
rgx.inline_link_hash,
"┥$1┝┤"
~ doc_matters.xml.tag_associations[(m.captures[3])][0]
~ _suffix
~ "#" ~ "$3"
~ "├"
);
}
} else {
writeln(
"WARNING on internal document links, anchor to link not found in document, "
~ "anchor: " ~ m.captures[3]
~ " document: " ~ doc_matters.src.filename
);
}
}
}
_txt = (_txt)
.replaceAll(
rgx.inline_link_fn_suffix,
("$1" ~ _suffix))
.replaceAll(
rgx.inline_link,
("<a href=\"$2\">$1</a>"))
.replaceAll(
rgx.mark_internal_site_lnk,
"");
}
debug(markup_links) {
if (_txt.match(rgx.inline_link)) {
writeln(__LINE__,
" (missed) markup link identified (",
obj.has.inline_links,
"): ", obj.metainfo.is_a, ": ",
obj.text
);
}
}
debug(markup) {
if (_txt.match(rgx.inline_link)) {
writeln(__LINE__,
" (missed) markup link identified (",
obj.has.inline_links,
"): ", obj.metainfo.is_a, ": ",
obj.text
);
}
}
return _txt;
}
auto inline_notes_scroll(M,O)(
M doc_matters,
const O obj,
string _txt,
) {
if (obj.has.inline_notes_reg) {
_txt = font_face(_txt);
_txt = (_txt).replaceAll(
rgx.inline_notes_delimiter_al_regular_number_note,
("<a href=\"#note_$1\"><note id=\"noteref_$1\"> <sup>$1</sup> </note></a>")
);
}
debug(markup_endnotes) {
if (_txt.match(rgx.inline_notes_delimiter_al_regular_number_note)) {
writeln(__LINE__, " (missed) markup endnote: ", obj.metainfo.is_a, ": ", obj.text);
}
}
debug(markup) {
if (_txt.match(rgx.inline_notes_delimiter_al_regular_number_note)) {
writeln(__LINE__, " (missed) markup endnote: ", obj.metainfo.is_a, ": ", obj.text);
}
}
return _txt;
}
auto inline_notes_seg(M,O)(
M doc_matters,
const O obj,
string _txt,
) {
string[] _endnotes;
if (obj.has.inline_notes_reg) {
_txt = font_face(_txt);
/+ need markup for text, and separated footnote +/
foreach(m; _txt.matchAll(rgx.inline_notes_delimiter_al_regular_number_note)) {
_endnotes ~= format(
"%s%s%s%s\n %s%s%s%s%s\n %s\n%s",
"<p class=\"endnote\">",
"<a href=\"#noteref_",
m.captures[1],
"\">",
"<note id=\"note_",
m.captures[1],
"\"> <sup>",
m.captures[1],
".</sup></note></a>",
m.captures[2],
"</p>"
);
}
_txt = (_txt).replaceAll(
rgx.inline_notes_delimiter_al_regular_number_note,
("<a href=\"#note_$1\"><note id=\"noteref_$1\"> <sup>$1</sup> </note></a>")
);
} else if (_txt.match(rgx.inline_notes_delimiter_al_regular_number_note)) {
debug(markup) {
writeln(__LINE__, " endnote: ", obj.metainfo.is_a, ": ", obj.text);
}
}
auto t = tuple(
_txt,
_endnotes,
);
return t;
}
auto inline_markup_scroll(M,O)(
M doc_matters,
const O obj,
string _txt,
string _suffix = ".html",
) {
_txt = inline_images(doc_matters, obj, _txt, _suffix, "scroll");
_txt = inline_links(doc_matters, obj, _txt, _suffix, "scroll");
_txt = inline_notes_scroll(doc_matters, obj, _txt);
return _txt;
}
auto inline_markup_seg(M,O)(
M doc_matters,
const O obj,
string _txt,
string _suffix = ".html",
string _xml_type = "seg",
) {
_txt = inline_images(doc_matters, obj, _txt, _suffix, _xml_type); // TODO
_txt = inline_links(doc_matters, obj, _txt, _suffix, _xml_type); // TODO
auto t = inline_notes_seg(doc_matters, obj, _txt);
return t;
}
string lev4_heading_subtoc(M,O)(
M doc_matters,
const O obj,
) {
char[] lev4_subtoc;
lev4_subtoc ~= " <div class=\"nav\">\n";
foreach (subtoc; obj.tags.lev4_subtoc) {
if (auto m = subtoc.match(rgx.inline_link_subtoc)) {
auto indent = m.captures[1].to!string;
auto text = m.captures[2].to!string;
text = font_face(text);
auto link = m.captures[3].to!string;
lev4_subtoc ~= subtoc.replaceFirst(rgx.inline_link_subtoc,
format(q"¶ <p class="minitoc" indent="h%si%s">
<a href="%s">%s</a>
</p>
¶",
indent,
indent,
link,
text,
));
}
}
lev4_subtoc ~= " </div>\n";
return lev4_subtoc.to!string;
}
auto nav_pre_next_svg(M,O)(
M doc_matters,
const O obj,
) {
string prev, next, toc;
if (obj.tags.segment_anchor_tag == "toc") {
toc = "";
prev = "";
} else {
toc = format(q"¶<a href="toc.html" target="_top">
<div class="toc-button menu">
<svg viewbox="0 0 100 100">
<path d="M4,10h24c1.104,0,2-0.896,2-2s-0.896-2-2-2H4C2.896,6,2,6.896,2,8S2.896,10,4,10z M28,14H4c-1.104,0-2,0.896-2,2 s0.896,2,2,2h24c1.104,0,2-0.896,2-2S29.104,14,28,14z M28,22H4c-1.104,0-2,0.896-2,2s0.896,2,2,2h24c1.104,0,2-0.896,2-2 S29.104,22,28,22z"/>
</svg>
</div>
</a>¶",
);
}
if (obj.tags.segname_prev == "") {
prev = "";
} else {
prev = format(q"¶<a href="%s.html" target="_top">
<div class="prev-next-button previous">
<svg viewbox="0 0 100 100">
<path class="arrow" d="M 50,0 L 60,10 L 20,50 L 60,90 L 50,100 L 0,50 Z" transform=" translate(15,0)">
</svg>
</div>
</a>¶",
obj.tags.segname_prev,
);
}
if (obj.tags.segname_next == "") {
next = "";
} else {
next = format(q"¶<a href="%s.html" target="_top">
<div class="prev-next-button next">
<svg viewbox="0 0 100 100">
<path class="arrow" d="M 50,0 L 60,10 L 20,50 L 60,90 L 50,100 L 0,50 Z "transform="translate(85,100) rotate(180) ">
</svg>
</div>
</a>¶",
obj.tags.segname_next,
);
}
string _toc_pre_next = format(q"¶ <div class="flex-menu-option">
<div class="nav-bar">
%s
%s
%s
</div>
</div>
</div>
</div>¶",
toc,
prev,
next,
);
string _pre_next = format(q"¶ <div class="flex-menu-option">
<div class="nav-bar">
%s
%s
</div>
</div>
</div>
</div>¶",
prev,
next,
);
struct bar {
string toc_pre_next() {
return _toc_pre_next;
}
string pre_next() {
return _pre_next;
}
}
return bar();
}
auto heading(M,O)(
M doc_matters,
const O obj,
string _txt,
string _xml_type = "html",
) {
auto tags = _xhtml_anchor_tags(obj);
string seg_anchor_tag;
string heading_lev_anchor_tag;
string _horizontal_rule = "<hr />";
if ((_xml_type != "html")
|| (obj.metainfo.heading_lev_markup == 0 || obj.metainfo.heading_lev_markup > 4)) {
_horizontal_rule = "";
}
_txt = font_face(_txt);
string o;
seg_anchor_tag = (obj.tags.segment_anchor_tag.empty)
? ""
: "<a name=\"" ~ obj.tags.segment_anchor_tag ~ "\"></a>";
heading_lev_anchor_tag = (obj.tags.heading_lev_anchor_tag.empty)
? ""
: "<a name=\"" ~ obj.tags.heading_lev_anchor_tag ~ "\"></a>";
if (obj.metainfo.object_number.empty) {
o = format(q"¶%s
<div class="substance">
<h%s class="%s">%s%s
%s
</h%s>
</div>¶",
_horizontal_rule,
obj.metainfo.heading_lev_markup,
obj.metainfo.is_a,
tags,
heading_lev_anchor_tag,
_txt,
obj.metainfo.heading_lev_markup,
);
} else {
o = format(q"¶%s
<div class="substance">
<label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
<h%s class="%s" id="%s"><a name="%s"></a>%s%s
%s
</h%s>
</div>¶",
_horizontal_rule,
obj.metainfo.object_number,
obj.metainfo.object_number,
obj.metainfo.heading_lev_markup,
obj.metainfo.is_a,
obj.metainfo.object_number,
obj.metainfo.object_number,
tags,
heading_lev_anchor_tag,
_txt,
obj.metainfo.heading_lev_markup,
);
}
return o;
}
auto heading_scroll(M,O)(
M doc_matters,
const O obj,
string _txt,
string _suffix = ".html",
) {
auto tags = _xhtml_anchor_tags(obj);
_txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix);
string o = heading(doc_matters, obj, _txt);
return o;
}
auto heading_seg(M,O)(
M doc_matters,
const O obj,
string _txt,
string _suffix = ".html",
string _xml_type = "html"
) {
auto t = inline_markup_seg(doc_matters, obj, _txt, _suffix, _xml_type);
_txt = t[0];
string[] _endnotes = t[1];
string o = heading(doc_matters, obj, _txt, _xml_type);
auto u = tuple(
o,
_endnotes,
);
return u;
}
auto para(M,O)(
M doc_matters,
const O obj,
string _txt,
) {
auto tags = _xhtml_anchor_tags(obj);
_txt = font_face(_txt);
string o;
_txt = (obj.attrib.bullet) ? ("●  " ~ _txt) : _txt;
if (obj.metainfo.object_number.empty) {
o = format(q"¶ <div class="substance">
<p class="%s" indent="h%si%s">%s
%s
</p>
</div>¶",
obj.metainfo.is_a,
obj.attrib.indent_hang,
obj.attrib.indent_base,
tags,
_txt
);
} else {
o = format(q"¶ <div class="substance">
<label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
<p class="%s" indent="h%si%s" id="%s">%s
%s
</p>
</div>¶",
obj.metainfo.object_number,
obj.metainfo.object_number,
obj.metainfo.is_a,
obj.attrib.indent_hang,
obj.attrib.indent_base,
obj.metainfo.object_number,
tags,
_txt
);
}
return o;
}
auto para_scroll(M,O)(
M doc_matters,
const O obj,
string _txt,
string _suffix = ".html",
) {
auto tags = _xhtml_anchor_tags(obj);
_txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix);
string o = para(doc_matters, obj, _txt);
return o;
}
auto para_seg(M,O)(
M doc_matters,
const O obj,
string _txt,
string _suffix = ".html",
string _xml_type = "html",
) {
auto t = inline_markup_seg(doc_matters, obj, _txt, _suffix, _xml_type);
_txt = t[0].to!string;
string[] _endnotes = t[1];
string o = para(doc_matters, obj, _txt);
auto u = tuple(
o,
_endnotes,
);
return u;
}
auto quote(M,O)(
M doc_matters,
const O obj,
string _txt,
) {
_txt = font_face(_txt);
string o;
if (obj.metainfo.object_number.empty) {
o = format(q"¶ <div class="substance">
<p class="%s">
%s
</p>
</div>¶",
obj.metainfo.is_a,
_txt
);
} else {
o = format(q"¶ <div class="substance">
<label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
<p class="%s" id="%s">
%s
</p>
</div>¶",
obj.metainfo.object_number,
obj.metainfo.object_number,
obj.metainfo.is_a,
obj.metainfo.object_number,
_txt
);
}
return o;
}
auto quote_scroll(M,O)(
M doc_matters,
const O obj,
string _txt,
string _suffix = ".html",
) {
auto tags = _xhtml_anchor_tags(obj);
_txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix);
string o = quote(doc_matters, obj, _txt);
return o;
}
auto quote_seg(M,O)(
M doc_matters,
const O obj,
string _txt,
string _suffix = ".html",
string _xml_type = "html",
) {
auto t = inline_markup_seg(doc_matters, obj, _txt, _suffix, _xml_type);
_txt = t[0].to!string;
string[] _endnotes = t[1];
string o = quote(doc_matters, obj, _txt);
auto u = tuple(
o,
_endnotes,
);
return u;
}
auto group(M,O)(
M doc_matters,
const O obj,
string _txt,
) {
_txt = font_face(_txt);
string o;
if (obj.metainfo.object_number.empty) {
o = format(q"¶ <div class="substance">
<p class="%s">
%s
</p>
</div>¶",
obj.metainfo.is_a,
_txt
);
} else {
o = format(q"¶ <div class="substance">
<label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
<p class="%s" id="%s">
%s
</p>
</div>¶",
obj.metainfo.object_number,
obj.metainfo.object_number,
obj.metainfo.is_a,
obj.metainfo.object_number,
_txt
);
}
return o;
}
auto group_scroll(M,O)(
M doc_matters,
const O obj,
string _txt,
string _suffix = ".html",
string _xml_type = "html",
) {
auto tags = _xhtml_anchor_tags(obj);
_txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix);
string o = group(doc_matters, obj, _txt);
return o;
}
auto group_seg(M,O)(
M doc_matters,
const O obj,
string _txt,
string _suffix = ".html",
string _xml_type = "html",
) {
auto t = inline_markup_seg(doc_matters, obj, _txt, _suffix, _xml_type);
_txt = t[0].to!string;
string[] _endnotes = t[1];
string o = group(doc_matters, obj, _txt);
auto u = tuple(
o,
_endnotes,
);
return u;
}
auto block(M,O)(
M doc_matters,
const O obj,
string _txt,
) {
_txt = font_face(_txt);
string o;
if (obj.metainfo.object_number.empty) {
o = format(q"¶ <div class="substance">
<p class="%s">%s</p>
</div>¶",
obj.metainfo.is_a,
_txt.stripRight
);
} else {
o = format(q"¶ <div class="substance">
<label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
<p class="%s" id="%s">%s</p>
</div>¶",
obj.metainfo.object_number,
obj.metainfo.object_number,
obj.metainfo.is_a,
obj.metainfo.object_number,
_txt.stripRight
);
}
return o;
}
auto block_scroll(M,O)(
M doc_matters,
const O obj,
string _txt,
string _suffix = ".html",
string _xml_type = "html",
) {
auto tags = _xhtml_anchor_tags(obj);
_txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix);
string o = block(doc_matters, obj, _txt);
return o;
}
auto block_seg(M,O)(
M doc_matters,
const O obj,
string _txt,
string _suffix = ".html",
string _xml_type = "html",
) {
auto t = inline_markup_seg(doc_matters, obj, _txt, _suffix, _xml_type);
_txt = t[0].to!string;
string[] _endnotes = t[1];
string o = block(doc_matters, obj, _txt);
auto u = tuple(
o,
_endnotes,
);
return u;
}
auto verse(M,O)(
M doc_matters,
const O obj,
string _txt,
) {
_txt = font_face(_txt);
string o;
if (obj.metainfo.object_number.empty) {
o = format(q"¶ <div class="substance">
<p class="%s">%s</p>
</div>¶",
obj.metainfo.is_a,
_txt
);
} else {
o = format(q"¶ <div class="substance">
<label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
<p class="%s" id="%s">%s</p>
</div>¶",
obj.metainfo.object_number,
obj.metainfo.object_number,
obj.metainfo.is_a,
obj.metainfo.object_number,
_txt
);
}
return o;
}
auto verse_scroll(M,O)(
M doc_matters,
const O obj,
string _txt,
string _suffix = ".html",
string _xml_type = "html",
) {
auto tags = _xhtml_anchor_tags(obj);
_txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix);
string o = verse(doc_matters, obj, _txt);
return o;
}
auto verse_seg(M,O)(
M doc_matters,
const O obj,
string _txt,
string _suffix = ".html",
string _xml_type = "html",
) {
auto t = inline_markup_seg(doc_matters, obj, _txt, _suffix, _xml_type);
_txt = t[0].to!string;
string[] _endnotes = t[1];
string o = verse(doc_matters, obj, _txt);
auto u = tuple(
o,
_endnotes,
);
return u;
}
auto tablarize(M,O)(
M doc_matters,
const O obj,
string _txt,
) {
string[] _table_rows = (_txt).split(rgx.table_delimiter_row);
string[] _table_cols;
string _table;
string _tablenote;
foreach(row_idx, row; _table_rows) {
_table_cols = row.split(rgx.table_delimiter_col);
_table ~= "<tr>";
foreach(col_idx, cell; _table_cols) {
if ((_table_cols.length == 1)
&& (_table_rows.length <= row_idx+2)) {
_tablenote ~= cell;
} else {
string _col_is = (row_idx == 0 && obj.table.heading) ? "th" : "td";
string _align = ("style=\"text-align:"
~ ((obj.table.column_aligns[col_idx] == "l")
? "left\"" : "right\""));
_table ~= "<" ~ _col_is ~ " width=\"" ~ obj.table.column_widths[col_idx].to!string ~ "%\" " ~ _align ~ ">";
_table ~= cell;
_table ~= "</" ~ _col_is ~ ">";
}
}
_table ~= "</tr>";
}
auto t = tuple(
_table,
_tablenote,
);
return t;
}
auto table(M,O)(
M doc_matters,
const O obj,
string _txt,
) {
auto tags = _xhtml_anchor_tags(obj);
_txt = font_face(_txt);
auto t = tablarize(doc_matters, obj, _txt);
_txt = t[0];
string _note = t[1];
string o;
o = format(q"¶ <div class="substance">
<label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
<p class="%s" id="%s">%s
<table summary="normal text css" width="95%%" border="0" bgcolor="white" cellpadding="2" align="center">
%s
</table>
%s
</p>
</div>¶",
obj.metainfo.object_number,
obj.metainfo.object_number,
obj.metainfo.is_a,
obj.metainfo.object_number,
tags,
_txt,
_note
);
return o;
}
auto endnote(M,O)(
M doc_matters,
const O obj,
string _txt,
) {
string o;
o = format(q"¶ <p class="%s" indent="h%si%s">
%s
</p>¶",
obj.metainfo.is_a,
obj.attrib.indent_hang,
obj.attrib.indent_base,
_txt
);
return o;
}
auto code(M,O)(
M doc_matters,
const O obj,
string _txt,
) {
string o;
if (obj.metainfo.object_number.empty) {
o = format(q"¶ <div class="substance">
<p class="%s">%s</p>
</div>¶",
obj.metainfo.is_a,
_txt
);
} else {
o = format(q"¶ <div class="substance">
<label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
<p class="%s" id="%s">%s</p>
</div>¶",
obj.metainfo.object_number,
obj.metainfo.object_number,
obj.metainfo.is_a,
obj.metainfo.object_number,
_txt
);
}
return o;
}
}
}
|