MapComplete/src/Utils/MarkdownUtils.ts

24 lines
685 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-07-16 19:31:00 +02:00
if(strings.length === 0){
return ""
}
return "\n\n"+strings.map((item) => " - " + item).join("\n")+"\n\n"
}
}