server(export): export Markdown using ATX heading syntax (closes #1251)

This commit is contained in:
Elian Doran
2025-02-22 12:45:21 +02:00
parent a1bfc6aae7
commit 411e3dfa0e
3 changed files with 60 additions and 1 deletions

View File

@@ -1,3 +1,35 @@
/**
* Reads the level of indentation of the first line and trims the identation for all the text by that amount.
*
* For example, for:
*
* ```json
* {
* "hello": "world"
* }
* ```
*
* it results in:
*
* ```json
* {
* "hello": "world"
* }
* ```
*
* This is meant to be used as a template string, where it allows the indentation of the template without affecting whitespace changes.
*
* @example const html = trimIndentation`\
* <h1>Heading 1</h1>
* <h2>Heading 2</h2>
* <h3>Heading 3</h3>
* <h4>Heading 4</h4>
* <h5>Heading 5</h5>
* <h6>Heading 6</h6>
* `;
* @param strings
* @returns
*/
export function trimIndentation(strings: TemplateStringsArray) {
const str = strings.toString();