(filePath, extensions)
| 19883 | * Adds an HTML codeblock to the summary buffer |
| 19884 | * |
| 19885 | * @param {string} code content to render within fenced code block |
| 19886 | * @param {string} lang (optional) language to syntax highlight code |
| 19887 | * |
| 19888 | * @returns {Summary} summary instance |
| 19889 | */ |
| 19890 | addCodeBlock(code, lang) { |
| 19891 | const attrs = Object.assign({}, lang && { lang }); |
| 19892 | const element = this.wrap("pre", this.wrap("code", code), attrs); |
| 19893 | return this.addRaw(element).addEOL(); |
| 19894 | } |
| 19895 | /** |
| 19896 | * Adds an HTML list to the summary buffer |
| 19897 | * |
| 19898 | * @param {string[]} items list of items to render |
| 19899 | * @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false) |
| 19900 | * |
| 19901 | * @returns {Summary} summary instance |
| 19902 | */ |
| 19903 | addList(items, ordered = false) { |
| 19904 | const tag = ordered ? "ol" : "ul"; |
| 19905 | const listItems = items.map((item) => this.wrap("li", item)).join(""); |
| 19906 | const element = this.wrap(tag, listItems); |
| 19907 | return this.addRaw(element).addEOL(); |
| 19908 | } |
| 19909 | /** |
| 19910 | * Adds an HTML table to the summary buffer |
| 19911 | * |
| 19912 | * @param {SummaryTableCell[]} rows table rows |
| 19913 | * |
| 19914 | * @returns {Summary} summary instance |
| 19915 | */ |
| 19916 | addTable(rows) { |
| 19917 | const tableBody = rows.map((row) => { |
| 19918 | const cells = row.map((cell) => { |
| 19919 | if (typeof cell === "string") { |
| 19920 | return this.wrap("td", cell); |
| 19921 | } |
| 19922 | const { header, data, colspan, rowspan } = cell; |
| 19923 | const tag = header ? "th" : "td"; |
| 19924 | const attrs = Object.assign(Object.assign({}, colspan && { colspan }), rowspan && { rowspan }); |
| 19925 | return this.wrap(tag, data, attrs); |
| 19926 | }).join(""); |
| 19927 | return this.wrap("tr", cells); |
| 19928 | }).join(""); |
| 19929 | const element = this.wrap("table", tableBody); |
| 19930 | return this.addRaw(element).addEOL(); |
| 19931 | } |
| 19932 | /** |
| 19933 | * Adds a collapsable HTML details element to the summary buffer |
| 19934 | * |
| 19935 | * @param {string} label text for the closed state |
| 19936 | * @param {string} content collapsable content |
| 19937 | * |
| 19938 | * @returns {Summary} summary instance |
| 19939 | */ |
| 19940 | addDetails(label, content) { |
| 19941 | const element = this.wrap("details", this.wrap("summary", label) + content); |
| 19942 | return this.addRaw(element).addEOL(); |
no test coverage detected