samengine 1.7.5 → 1.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  // Function to get the Version
2
2
  export function version() {
3
- return "1.7.5";
3
+ return "1.7.6";
4
4
  }
@@ -36,5 +36,6 @@ export declare function parse(markdown: string, options?: ParseOptions): string;
36
36
  export declare function parseToDocument(markdown: string, options?: ParseOptions & {
37
37
  title?: string;
38
38
  css?: string;
39
+ header?: string;
39
40
  }): string;
40
41
  export declare function exportcss(): string;
@@ -193,10 +193,14 @@ function parseTable(block, opts) {
193
193
  if (rows.length < 2)
194
194
  return `<p>${renderInline(block, opts)}</p>`;
195
195
  const headerCells = rows[0]
196
- .split("|")
196
+ .split(/(?<!\\)\|/)
197
197
  .filter((_, i, a) => !(i === 0 && _ === "") && !(i === a.length - 1 && _ === ""))
198
- .map((c) => c.trim());
199
- const alignRow = rows[1].split("|").filter((c) => /[-:]/.test(c));
198
+ .map((c) => c
199
+ .trim()
200
+ .replace(/\\\|/g, "|")
201
+ .replace(/\\\[/g, "[")
202
+ .replace(/\\\]/g, "]"));
203
+ const alignRow = rows[1].split(/(?<!\\)\|/).filter((c) => /[-:]/.test(c));
200
204
  const aligns = alignRow.map((c) => {
201
205
  c = c.trim();
202
206
  if (c.startsWith(":") && c.endsWith(":"))
@@ -215,9 +219,13 @@ function parseTable(block, opts) {
215
219
  .join("\n")}\n</tr>\n</thead>`;
216
220
  const bodyRows = rows.slice(2).map((row) => {
217
221
  const cells = row
218
- .split("|")
222
+ .split(/(?<!\\)\|/)
219
223
  .filter((_, i, a) => !(i === 0 && _ === "") && !(i === a.length - 1 && _ === ""))
220
- .map((c) => c.trim());
224
+ .map((c) => c
225
+ .trim()
226
+ .replace(/\\\|/g, "|")
227
+ .replace(/\\\[/g, "[")
228
+ .replace(/\\\]/g, "]"));
221
229
  return `<tr>\n${cells
222
230
  .map((c, i) => {
223
231
  const align = aligns[i] ? ` style="text-align:${aligns[i]}"` : "";
@@ -620,7 +628,7 @@ export function parse(markdown, options = {}) {
620
628
  * Gibt ein vollständiges HTML-Dokument zurück (optional mit eigenem CSS).
621
629
  */
622
630
  export function parseToDocument(markdown, options = {}) {
623
- const { title = "Dokument", css = defaultCss, ...parseOpts } = options;
631
+ const { title = "Dokument", header = "", css = defaultCss, ...parseOpts } = options;
624
632
  const body = parse(markdown, parseOpts);
625
633
  return `<!DOCTYPE html>
626
634
  <html lang="de">
@@ -629,6 +637,7 @@ export function parseToDocument(markdown, options = {}) {
629
637
  <meta name="viewport" content="width=device-width, initial-scale=1">
630
638
  <title>${escapeHtml(title)}</title>
631
639
  <style>${css}</style>
640
+ ${header}
632
641
  </head>
633
642
  <body>
634
643
  <article class="md-body">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "samengine",
3
- "version": "1.7.5",
3
+ "version": "1.7.7",
4
4
  "description": "A TypeScript game library to make HTML Games",
5
5
  "sideEffects": false,
6
6
  "files": [