testomatio-editor-blocks 0.4.37 → 0.4.39
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.
|
@@ -22,7 +22,7 @@ const headingPrefixes = {
|
|
|
22
22
|
5: "#####",
|
|
23
23
|
6: "######",
|
|
24
24
|
};
|
|
25
|
-
const SPECIAL_CHAR_REGEX = /([*_`~\[\]()
|
|
25
|
+
const SPECIAL_CHAR_REGEX = /([*_`~\[\]()<\\])/g;
|
|
26
26
|
const HTML_SPAN_REGEX = /<\/?span[^>]*>/g;
|
|
27
27
|
const HTML_UNDERLINE_REGEX = /<\/?u>/g;
|
|
28
28
|
const EXPECTED_LABEL_REGEX = /^(?:[*_`]*\s*)?(expected(?:\s+result)?)\s*(?:[*_`]*\s*)?\s*[:\-–—]\s*/i;
|
|
@@ -77,7 +77,7 @@ function stripLeadingFormatting(text) {
|
|
|
77
77
|
return result;
|
|
78
78
|
}
|
|
79
79
|
function unescapeMarkdown(text) {
|
|
80
|
-
return stripHtmlWrappers(text).replace(/\\([*_`~\[\]()<>\\])/g, "$1");
|
|
80
|
+
return stripHtmlWrappers(text).replace(/\\([*_`~\[\]()<>\\])/g, "$1").replace(/\\>/g, ">");
|
|
81
81
|
}
|
|
82
82
|
function applyTextStyles(text, styles) {
|
|
83
83
|
if (!styles) {
|
|
@@ -1016,7 +1016,7 @@ function parseQuote(lines, index) {
|
|
|
1016
1016
|
if (!trimmed.startsWith(">")) {
|
|
1017
1017
|
break;
|
|
1018
1018
|
}
|
|
1019
|
-
collected.push(trimmed.replace(
|
|
1019
|
+
collected.push(trimmed.replace(/^(?:>\s?)+/, ""));
|
|
1020
1020
|
next += 1;
|
|
1021
1021
|
}
|
|
1022
1022
|
return {
|
package/package.json
CHANGED
|
@@ -389,6 +389,26 @@ describe("blocksToMarkdown", () => {
|
|
|
389
389
|
);
|
|
390
390
|
});
|
|
391
391
|
|
|
392
|
+
it("serializes a blockquote", () => {
|
|
393
|
+
const blocks: CustomEditorBlock[] = [
|
|
394
|
+
{
|
|
395
|
+
id: "q1",
|
|
396
|
+
type: "quote",
|
|
397
|
+
props: { textColor: "default", backgroundColor: "default", textAlignment: "left" },
|
|
398
|
+
content: [{ type: "text", text: "Hello world", styles: {} }],
|
|
399
|
+
children: [],
|
|
400
|
+
},
|
|
401
|
+
];
|
|
402
|
+
|
|
403
|
+
expect(blocksToMarkdown(blocks)).toBe("> Hello world");
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
it("round-trips a blockquote without escaping > in content", () => {
|
|
407
|
+
const markdown = "> Some quoted text";
|
|
408
|
+
const blocks = markdownToBlocks(markdown);
|
|
409
|
+
expect(blocksToMarkdown(blocks as any)).toBe("> Some quoted text");
|
|
410
|
+
});
|
|
411
|
+
|
|
392
412
|
it("serializes table cells containing newlines as <br/>", () => {
|
|
393
413
|
const blocks: CustomEditorBlock[] = [
|
|
394
414
|
{
|
|
@@ -573,6 +593,48 @@ describe("blocksToMarkdown", () => {
|
|
|
573
593
|
});
|
|
574
594
|
|
|
575
595
|
describe("markdownToBlocks", () => {
|
|
596
|
+
it("parses nested blockquote by flattening to single-level quote", () => {
|
|
597
|
+
const markdown = ">> The Witch bade her clean the pots.";
|
|
598
|
+
const blocks = markdownToBlocks(markdown);
|
|
599
|
+
expect(blocks).toEqual([
|
|
600
|
+
{
|
|
601
|
+
type: "quote",
|
|
602
|
+
props: { textColor: "default", backgroundColor: "default", textAlignment: "left" },
|
|
603
|
+
content: [{ type: "text", text: "The Witch bade her clean the pots.", styles: {} }],
|
|
604
|
+
children: [],
|
|
605
|
+
},
|
|
606
|
+
]);
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
it("parses spaced nested blockquote > > text", () => {
|
|
610
|
+
const markdown = "> > The Witch bade her clean the pots.";
|
|
611
|
+
const blocks = markdownToBlocks(markdown);
|
|
612
|
+
expect(blocks).toEqual([
|
|
613
|
+
{
|
|
614
|
+
type: "quote",
|
|
615
|
+
props: { textColor: "default", backgroundColor: "default", textAlignment: "left" },
|
|
616
|
+
content: [{ type: "text", text: "The Witch bade her clean the pots.", styles: {} }],
|
|
617
|
+
children: [],
|
|
618
|
+
},
|
|
619
|
+
]);
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
it("round-trips nested blockquote without \\> escaping", () => {
|
|
623
|
+
const markdown = [
|
|
624
|
+
"> Dorothy followed her through many of the beautiful rooms in her castle.",
|
|
625
|
+
">> The Witch bade her clean the pots.",
|
|
626
|
+
].join("\n");
|
|
627
|
+
|
|
628
|
+
const blocks = markdownToBlocks(markdown);
|
|
629
|
+
const result = blocksToMarkdown(blocks as any);
|
|
630
|
+
expect(result).toBe(
|
|
631
|
+
[
|
|
632
|
+
"> Dorothy followed her through many of the beautiful rooms in her castle.",
|
|
633
|
+
"> The Witch bade her clean the pots.",
|
|
634
|
+
].join("\n"),
|
|
635
|
+
);
|
|
636
|
+
});
|
|
637
|
+
|
|
576
638
|
it("parses test steps and test cases", () => {
|
|
577
639
|
const markdown = [
|
|
578
640
|
"* Open the Login page.",
|
|
@@ -60,7 +60,7 @@ const headingPrefixes: Record<number, string> = {
|
|
|
60
60
|
6: "######",
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
const SPECIAL_CHAR_REGEX = /([*_`~\[\]()
|
|
63
|
+
const SPECIAL_CHAR_REGEX = /([*_`~\[\]()<\\])/g;
|
|
64
64
|
const HTML_SPAN_REGEX = /<\/?span[^>]*>/g;
|
|
65
65
|
const HTML_UNDERLINE_REGEX = /<\/?u>/g;
|
|
66
66
|
const EXPECTED_LABEL_REGEX = /^(?:[*_`]*\s*)?(expected(?:\s+result)?)\s*(?:[*_`]*\s*)?\s*[:\-–—]\s*/i;
|
|
@@ -125,7 +125,7 @@ function stripLeadingFormatting(text: string): string {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
function unescapeMarkdown(text: string): string {
|
|
128
|
-
return stripHtmlWrappers(text).replace(/\\([*_`~\[\]()<>\\])/g, "$1");
|
|
128
|
+
return stripHtmlWrappers(text).replace(/\\([*_`~\[\]()<>\\])/g, "$1").replace(/\\>/g, ">");
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
function applyTextStyles(text: string, styles: EditorStyles | undefined): string {
|
|
@@ -1214,7 +1214,7 @@ function parseQuote(lines: string[], index: number): { block: CustomPartialBlock
|
|
|
1214
1214
|
if (!trimmed.startsWith(">")) {
|
|
1215
1215
|
break;
|
|
1216
1216
|
}
|
|
1217
|
-
collected.push(trimmed.replace(
|
|
1217
|
+
collected.push(trimmed.replace(/^(?:>\s?)+/, ""));
|
|
1218
1218
|
next += 1;
|
|
1219
1219
|
}
|
|
1220
1220
|
|