@truedat/core 8.8.0 → 8.8.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/core",
3
- "version": "8.8.0",
3
+ "version": "8.8.1",
4
4
  "description": "Truedat Web Core",
5
5
  "sideEffects": [
6
6
  "**/*.css",
@@ -54,7 +54,7 @@
54
54
  "@testing-library/jest-dom": "^6.6.3",
55
55
  "@testing-library/react": "^16.3.0",
56
56
  "@testing-library/user-event": "^14.6.1",
57
- "@truedat/test": "8.8.0",
57
+ "@truedat/test": "8.8.1",
58
58
  "identity-obj-proxy": "^3.0.0",
59
59
  "jest": "^29.7.0",
60
60
  "redux-saga-test-plan": "^4.0.6"
@@ -95,5 +95,5 @@
95
95
  "swr": "^2.3.3",
96
96
  "turndown": "^7.2.2"
97
97
  },
98
- "gitHead": "006b9cd6486cd37976d4dc06ede1a48e37175f30"
98
+ "gitHead": "22fb2c1d668ac5fabbc23372a1234297d32ff407"
99
99
  }
@@ -7,11 +7,20 @@ import Link from "@tiptap/extension-link";
7
7
  import Heading from "@tiptap/extension-heading";
8
8
  import { Menu, Icon } from "semantic-ui-react";
9
9
  import { FormattedMessage } from "react-intl";
10
- import { marked } from "marked";
10
+ import { Marked } from "marked";
11
11
  import DOMPurify from "dompurify";
12
12
  import TurndownService from "turndown";
13
13
  import TextPromptModal from "./TextPromptModal";
14
14
 
15
+ const markdownParser = new Marked();
16
+ markdownParser.use({
17
+ tokenizer: {
18
+ code() {
19
+ return undefined;
20
+ },
21
+ },
22
+ });
23
+
15
24
  const turndownService = new TurndownService({ headingStyle: "atx" });
16
25
  turndownService.addRule("underline", {
17
26
  filter: ["u"],
@@ -91,7 +100,7 @@ function markdownToHtml(markdown) {
91
100
 
92
101
  const cleaned = stripOuterCodeFence(markdown);
93
102
 
94
- const withLinks = marked
103
+ const withLinks = markdownParser
95
104
  .parse(cleaned, { async: false })
96
105
  .replace(
97
106
  /<a (?=[^>]*href=)/gi,
@@ -21,6 +21,29 @@ describe("markdownToHtml", () => {
21
21
  expect(markdownToHtml("## Title")).toContain("<h2>");
22
22
  });
23
23
 
24
+ it("renders leading-space indented prose as paragraphs, not code blocks", () => {
25
+ const legacy = [
26
+ "Son agentes de seguros las personas físicas o jurídicas.",
27
+ "",
28
+ " Generalmente, los agentes pertenecen a una determinada delegación.",
29
+ ].join("\n");
30
+
31
+ const html = markdownToHtml(legacy);
32
+
33
+ expect(html).not.toContain("<pre>");
34
+ expect(html).not.toContain("<code>");
35
+ // leading spaces are preserved in the markup, not turned into a code block
36
+ expect(html).toContain("<p> Generalmente");
37
+ });
38
+
39
+ it("still renders fenced code blocks as code", () => {
40
+ const html = markdownToHtml("Texto normal\n\n```js\nconst x = 1;\n```");
41
+
42
+ expect(html).toContain("<pre>");
43
+ expect(html).toContain("<code");
44
+ expect(html).toContain("const x = 1;");
45
+ });
46
+
24
47
  it("generates a correct <a> element for markdown links", () => {
25
48
  const html = markdownToHtml("[Example link](https://example.com/path)");
26
49
  const parser = new DOMParser();
@@ -115,6 +138,16 @@ describe("<MarkdownReader />", () => {
115
138
  expect(rendered.container).toMatchSnapshot();
116
139
  });
117
140
 
141
+ it("matches the latest snapshot with leading-space indented prose", () => {
142
+ const content = [
143
+ "Son agentes de seguros las personas físicas o jurídicas.",
144
+ "",
145
+ " Generalmente, los agentes pertenecen a una determinada delegación.",
146
+ ].join("\n");
147
+ const rendered = render(<MarkdownReader content={content} />);
148
+ expect(rendered.container).toMatchSnapshot();
149
+ });
150
+
118
151
  it("renders MarkdownReader headings and links", () => {
119
152
  const content = "## Title\n\n[link](https://example.com)";
120
153
  const { container } = render(<MarkdownReader content={content} />);
@@ -224,3 +224,22 @@ exports[`<MarkdownReader /> matches the latest snapshot with content 1`] = `
224
224
  </div>
225
225
  </div>
226
226
  `;
227
+
228
+ exports[`<MarkdownReader /> matches the latest snapshot with leading-space indented prose 1`] = `
229
+ <div>
230
+ <div
231
+ class="markdown-reader"
232
+ >
233
+ <p>
234
+ Son agentes de seguros las personas físicas o jurídicas.
235
+ </p>
236
+
237
+
238
+ <p>
239
+ Generalmente, los agentes pertenecen a una determinada delegación.
240
+ </p>
241
+
242
+
243
+ </div>
244
+ </div>
245
+ `;