-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmacros.js
More file actions
41 lines (37 loc) · 1.38 KB
/
Copy pathmacros.js
File metadata and controls
41 lines (37 loc) · 1.38 KB
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
function quote(input) {
return `<div class="quote">${input}</div>`;
}
function split(input) {
return `<div style="display: flex; gap: 1rem;">${input}</div>`;
}
function details(input, args) {
return `
<details style="margin-left: 1rem;">
<summary style="font-weight: bold; cursor: pointer;">${args[0]}</summary>
<div style="margin-left: 1rem;">${input}</div>
</details>
`;
}
function scaleDiv(nabla, args) {
const [scalePercentage, heightPercentage] = args;
return `<div style="width:${scalePercentage}%; height: ${heightPercentage ?? 100}%; margin-left: auto; margin-right: auto;">${nabla}</div>`;
}
// read links in the format [title](url) and return a div with buttons for each link
function linkButtons(links, _) {
const linksArray = links.split("\n");
const regex = /\[(.+)\]\((.+)\)/;
const buttonsStrings = [];
linksArray.map(link => {
const match = link.match(regex);
if (match) {
const [_, text, url] = match;
buttonsStrings.push(`
<a href="${url}" target="_blank" style="align-self: center; margin: 20px">
<button class="button"><p>${text}</p></button>
</a>`
);
}
});
return `<div style="display: flex; flex-direction: column;">${buttonsStrings.join("")}</div>`;
}
MACROS = { quote, split, details, scaleDiv, linkButtons };