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.
- package/dist/build/index.js +1 -1
- package/dist/utils/markdown.d.ts +1 -0
- package/dist/utils/markdown.js +15 -6
- package/package.json +1 -1
package/dist/build/index.js
CHANGED
package/dist/utils/markdown.d.ts
CHANGED
|
@@ -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;
|
package/dist/utils/markdown.js
CHANGED
|
@@ -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
|
|
199
|
-
|
|
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
|
|
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">
|