-
Notifications
You must be signed in to change notification settings - Fork 1
/
cols_macro.js
97 lines (73 loc) · 2.08 KB
/
cols_macro.js
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
// creates equal-width column headers with css class multicolhead for styling
// ...titles is a comma-separated list a values to determine number and contents of columns
remark.macros.col_header = function (...titles) {
var num_items = titles.length;
var width = Math.floor(100/num_items) - 2*0.5;
var code =
'<center>'+
'<div class="multicolrow"' +
'style="font-weight:bold; text-align:center; vertical-align: middle; display: flex;">';
for(let i = 0; i < num_items; i++)
code =
code +
'<div class="multicolhead wordwrap"'+
'style="'+
'float:left;'+
//'align-items: stretch;'+
'padding: 1% 0.25% 1% 0.25%;'+
'font-size: 80%;' +
'margin: 1% 0.25% 1% 0.25%;' +
'width: ' + width + '%;">' +
titles[i] +
'</div>';
code = code +
'</div>' +
'</center>';
return code;
};
// creates row of equal-width column list elements
// ...bodies is a comma-separated list a values to determine number and contents of columns
remark.macros.col_list = function (...bodies) {
var num_items = bodies.length;
var width = Math.floor(100/num_items) - 0.5;
var code =
'<center>'+
'<div class="multicolrow" style="text-align:left;">' ;
for(let i = 0; i<num_items; i++)
code =
code +
'<div class="multicolcol" style="'+
'float:left;'+
'font-size: 80%;' +
'margin: 0% 0.25% 0% 0.25%;' +
'width:' + width + '%;"> <li>' +
bodies[i] +
'</li> </div>';
code = code +
'</div>' +
'</center>';
return code;
};
// creates row of equal-width column contents
// ...bodies is a comma-separated list a values to determine number and contents of columns
remark.macros.col_row = function (...bodies) {
var num_items = bodies.length;
var width = Math.floor(100/num_items) - 0.5;
var code =
'<center>'+
'<div class="multicolrow" style="text-align:left;">' ;
for(let i = 0; i<bodies.length; i++)
code =
code +
'<div class="multicolcol" style="'+
'float:left;'+
'font-size: 80%;' +
'margin: 0% 0.25% 0% 0.25%;' +
'width:' + width + '%;">' +
bodies[i] +
'</div>';
code = code +
'</div>' +
'</center>';
return code;
};