MapComplete/src/Utils/MarkdownUtils.ts

21 lines
605 B
TypeScript
Raw Normal View History

export default class MarkdownUtils {
2024-06-16 16:06:26 +02:00
public static table(header: string[], contents: string[][]) {
let result = ""
2024-06-16 16:06:26 +02:00
result += "\n\n| " + header.join(" | ") + " |\n"
result += header.map(() => "-----").join("|") + " |\n"
for (const line of contents) {
2024-06-16 16:06:26 +02:00
if (!line) {
continue
}
2024-06-16 16:06:26 +02:00
result += "| " + line.map((x) => x ?? "").join(" | ") + " |\n"
}
result += "\n\n"
return result
}
static list(strings: string[]): string {
2024-06-16 16:06:26 +02:00
return strings.map((item) => " - " + item).join("\n")
}
}