| 649 | |
| 650 | //Demo for main and individual readmes |
| 651 | function demos({colspan = null, wrap = false, examples = {}} = {}) { |
| 652 | if (("default1" in examples) && ("default2" in examples)) { |
| 653 | return [ |
| 654 | wrap ? '<td colspan="2"><table><tr>' : "", |
| 655 | '<td align="center">', |
| 656 | `<img src="${examples.default1}" alt=""></img>`, |
| 657 | "</td>", |
| 658 | '<td align="center">', |
| 659 | `<img src="${examples.default2}" alt=""></img>`, |
| 660 | "</td>", |
| 661 | wrap ? "</tr></table></td>" : "", |
| 662 | ].filter(v => v).join("\n") |
| 663 | } |
| 664 | return [ |
| 665 | ` <td ${colspan ? `colspan="${colspan}"` : ""} align="center">`, |
| 666 | `${ |
| 667 | Object.entries(examples).map(([text, link]) => { |
| 668 | let img = `<img src="${link}" alt=""></img>` |
| 669 | if (text !== "default") { |
| 670 | const open = text.charAt(0) === "+" ? " open" : "" |
| 671 | text = open ? text.substring(1) : text |
| 672 | text = `${text.charAt(0).toLocaleUpperCase()}${text.substring(1)}` |
| 673 | img = `<details${open}><summary>${text}</summary>${img}</details>` |
| 674 | } |
| 675 | return ` ${img}` |
| 676 | }).join("\n") |
| 677 | }`, |
| 678 | ' <img width="900" height="1" alt="">', |
| 679 | " </td>", |
| 680 | ].filter(v => v).join("\n") |
| 681 | } |