Spaces:
Runtime error
Runtime error
Adrien Denat
commited on
Commit
•
cad5ba6
1
Parent(s):
f437e64
Fix line break markdown (#131)
Browse files* replace all <br> tags by \n
* fix line breaks in markdown not being transformed to <br> tags
* make sure to also match things like <Br>
src/lib/components/chat/ChatMessage.svelte
CHANGED
@@ -13,6 +13,7 @@
|
|
13 |
.replace(/<\|[a-z]+\|$/, "")
|
14 |
.replace(/<$/, "")
|
15 |
.replaceAll(/<\|[a-z]+\|>/g, " ")
|
|
|
16 |
.trim()
|
17 |
.replaceAll("&", "&")
|
18 |
.replaceAll("<", "<");
|
@@ -39,6 +40,7 @@
|
|
39 |
const options: marked.MarkedOptions = {
|
40 |
...marked.getDefaults(),
|
41 |
gfm: true,
|
|
|
42 |
renderer,
|
43 |
};
|
44 |
|
@@ -83,7 +85,7 @@
|
|
83 |
{#if token.type === "code"}
|
84 |
<CodeBlock lang={token.lang} code={unsanitizeMd(token.text)} />
|
85 |
{:else}
|
86 |
-
{@html marked
|
87 |
{/if}
|
88 |
{/each}
|
89 |
</div>
|
|
|
13 |
.replace(/<\|[a-z]+\|$/, "")
|
14 |
.replace(/<$/, "")
|
15 |
.replaceAll(/<\|[a-z]+\|>/g, " ")
|
16 |
+
.replaceAll(/<br\s?\/?>/gi, "\n")
|
17 |
.trim()
|
18 |
.replaceAll("&", "&")
|
19 |
.replaceAll("<", "<");
|
|
|
40 |
const options: marked.MarkedOptions = {
|
41 |
...marked.getDefaults(),
|
42 |
gfm: true,
|
43 |
+
breaks: true,
|
44 |
renderer,
|
45 |
};
|
46 |
|
|
|
85 |
{#if token.type === "code"}
|
86 |
<CodeBlock lang={token.lang} code={unsanitizeMd(token.text)} />
|
87 |
{:else}
|
88 |
+
{@html marked(token.raw, options)}
|
89 |
{/if}
|
90 |
{/each}
|
91 |
</div>
|