Adrien Denat coyotte508 HF staff commited on
Commit
c3aa4e3
1 Parent(s): 91e621a

add basic markdown parsing using Marked (#18)

Browse files

Co-authored-by: Eliott C <coyotte508@gmail.com>

package-lock.json CHANGED
@@ -11,6 +11,7 @@
11
  "@huggingface/inference": "^2.0.0-rc2",
12
  "autoprefixer": "^10.4.14",
13
  "date-fns": "^2.29.3",
 
14
  "mongodb": "^5.3.0",
15
  "postcss": "^8.4.21",
16
  "tailwind-scrollbar": "^3.0.0",
@@ -19,6 +20,7 @@
19
  "devDependencies": {
20
  "@sveltejs/adapter-node": "^1.2.0",
21
  "@sveltejs/kit": "^1.5.0",
 
22
  "@typescript-eslint/eslint-plugin": "^5.45.0",
23
  "@typescript-eslint/parser": "^5.45.0",
24
  "eslint": "^8.28.0",
@@ -723,25 +725,25 @@
723
  }
724
  },
725
  "node_modules/@sveltejs/kit": {
726
- "version": "1.15.7",
727
- "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-1.15.7.tgz",
728
- "integrity": "sha512-dgdKExsMJ16X3q8tEcuDlv+QIWAlJcf7IqCU2HWV13nmtTzwSA2n4VtEx9Gy5OGhH0SUAGNIupmlf0TdFSMXbw==",
729
  "dev": true,
730
  "hasInstallScript": true,
731
  "dependencies": {
732
  "@sveltejs/vite-plugin-svelte": "^2.0.0",
733
  "@types/cookie": "^0.5.1",
734
  "cookie": "^0.5.0",
735
- "devalue": "^4.3.0",
736
  "esm-env": "^1.0.0",
737
  "kleur": "^4.1.5",
738
- "magic-string": "^0.30.0",
739
  "mime": "^3.0.0",
740
  "sade": "^1.8.1",
741
  "set-cookie-parser": "^2.5.1",
742
  "sirv": "^2.0.2",
743
  "tiny-glob": "^0.2.9",
744
- "undici": "5.20.0"
745
  },
746
  "bin": {
747
  "svelte-kit": "svelte-kit.js"
@@ -805,6 +807,12 @@
805
  "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
806
  "dev": true
807
  },
 
 
 
 
 
 
808
  "node_modules/@types/node": {
809
  "version": "18.13.0",
810
  "resolved": "https://registry.npmjs.org/@types/node/-/node-18.13.0.tgz",
@@ -2023,18 +2031,6 @@
2023
  "url": "https://github.com/sponsors/sindresorhus"
2024
  }
2025
  },
2026
- "node_modules/globals/node_modules/type-fest": {
2027
- "version": "0.20.2",
2028
- "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz",
2029
- "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==",
2030
- "dev": true,
2031
- "engines": {
2032
- "node": ">=10"
2033
- },
2034
- "funding": {
2035
- "url": "https://github.com/sponsors/sindresorhus"
2036
- }
2037
- },
2038
  "node_modules/globalyzer": {
2039
  "version": "0.1.0",
2040
  "resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.0.tgz",
@@ -2357,9 +2353,9 @@
2357
  }
2358
  },
2359
  "node_modules/magic-string": {
2360
- "version": "0.30.0",
2361
- "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.0.tgz",
2362
- "integrity": "sha512-LA+31JYDJLs82r2ScLrlz1GjSgu66ZV518eyWT+S8VhyQn/JL0u9MeBOvQMGYiPk1DBiSN9DDMOcXvigJZaViQ==",
2363
  "dev": true,
2364
  "dependencies": {
2365
  "@jridgewell/sourcemap-codec": "^1.4.13"
@@ -2368,6 +2364,17 @@
2368
  "node": ">=12"
2369
  }
2370
  },
 
 
 
 
 
 
 
 
 
 
 
2371
  "node_modules/memory-pager": {
2372
  "version": "1.5.0",
2373
  "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz",
@@ -3586,6 +3593,18 @@
3586
  "node": ">= 0.8.0"
3587
  }
3588
  },
 
 
 
 
 
 
 
 
 
 
 
 
3589
  "node_modules/typescript": {
3590
  "version": "4.9.5",
3591
  "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
@@ -3600,9 +3619,9 @@
3600
  }
3601
  },
3602
  "node_modules/undici": {
3603
- "version": "5.20.0",
3604
- "resolved": "https://registry.npmjs.org/undici/-/undici-5.20.0.tgz",
3605
- "integrity": "sha512-J3j60dYzuo6Eevbawwp1sdg16k5Tf768bxYK4TUJRH7cBM4kFCbf3mOnM/0E3vQYXvpxITbbWmBafaDbxLDz3g==",
3606
  "dev": true,
3607
  "dependencies": {
3608
  "busboy": "^1.6.0"
 
11
  "@huggingface/inference": "^2.0.0-rc2",
12
  "autoprefixer": "^10.4.14",
13
  "date-fns": "^2.29.3",
14
+ "marked": "^4.3.0",
15
  "mongodb": "^5.3.0",
16
  "postcss": "^8.4.21",
17
  "tailwind-scrollbar": "^3.0.0",
 
20
  "devDependencies": {
21
  "@sveltejs/adapter-node": "^1.2.0",
22
  "@sveltejs/kit": "^1.5.0",
23
+ "@types/marked": "^4.0.8",
24
  "@typescript-eslint/eslint-plugin": "^5.45.0",
25
  "@typescript-eslint/parser": "^5.45.0",
26
  "eslint": "^8.28.0",
 
725
  }
726
  },
727
  "node_modules/@sveltejs/kit": {
728
+ "version": "1.7.1",
729
+ "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-1.7.1.tgz",
730
+ "integrity": "sha512-epaQCaZ/D3Qr/SgrRKHv+MpM6rz8JdaXSjOjas8t7PbDJl88KpqYWUvsmyuJQn/yNNGar23kENyy4NueNnjIKQ==",
731
  "dev": true,
732
  "hasInstallScript": true,
733
  "dependencies": {
734
  "@sveltejs/vite-plugin-svelte": "^2.0.0",
735
  "@types/cookie": "^0.5.1",
736
  "cookie": "^0.5.0",
737
+ "devalue": "^4.2.3",
738
  "esm-env": "^1.0.0",
739
  "kleur": "^4.1.5",
740
+ "magic-string": "^0.29.0",
741
  "mime": "^3.0.0",
742
  "sade": "^1.8.1",
743
  "set-cookie-parser": "^2.5.1",
744
  "sirv": "^2.0.2",
745
  "tiny-glob": "^0.2.9",
746
+ "undici": "5.19.1"
747
  },
748
  "bin": {
749
  "svelte-kit": "svelte-kit.js"
 
807
  "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
808
  "dev": true
809
  },
810
+ "node_modules/@types/marked": {
811
+ "version": "4.0.8",
812
+ "resolved": "https://registry.npmjs.org/@types/marked/-/marked-4.0.8.tgz",
813
+ "integrity": "sha512-HVNzMT5QlWCOdeuBsgXP8EZzKUf0+AXzN+sLmjvaB3ZlLqO+e4u0uXrdw9ub69wBKFs+c6/pA4r9sy6cCDvImw==",
814
+ "dev": true
815
+ },
816
  "node_modules/@types/node": {
817
  "version": "18.13.0",
818
  "resolved": "https://registry.npmjs.org/@types/node/-/node-18.13.0.tgz",
 
2031
  "url": "https://github.com/sponsors/sindresorhus"
2032
  }
2033
  },
 
 
 
 
 
 
 
 
 
 
 
 
2034
  "node_modules/globalyzer": {
2035
  "version": "0.1.0",
2036
  "resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.0.tgz",
 
2353
  }
2354
  },
2355
  "node_modules/magic-string": {
2356
+ "version": "0.29.0",
2357
+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.29.0.tgz",
2358
+ "integrity": "sha512-WcfidHrDjMY+eLjlU+8OvwREqHwpgCeKVBUpQ3OhYYuvfaYCUgcbuBzappNzZvg/v8onU3oQj+BYpkOJe9Iw4Q==",
2359
  "dev": true,
2360
  "dependencies": {
2361
  "@jridgewell/sourcemap-codec": "^1.4.13"
 
2364
  "node": ">=12"
2365
  }
2366
  },
2367
+ "node_modules/marked": {
2368
+ "version": "4.3.0",
2369
+ "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz",
2370
+ "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==",
2371
+ "bin": {
2372
+ "marked": "bin/marked.js"
2373
+ },
2374
+ "engines": {
2375
+ "node": ">= 12"
2376
+ }
2377
+ },
2378
  "node_modules/memory-pager": {
2379
  "version": "1.5.0",
2380
  "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz",
 
3593
  "node": ">= 0.8.0"
3594
  }
3595
  },
3596
+ "node_modules/type-fest": {
3597
+ "version": "0.20.2",
3598
+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz",
3599
+ "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==",
3600
+ "dev": true,
3601
+ "engines": {
3602
+ "node": ">=10"
3603
+ },
3604
+ "funding": {
3605
+ "url": "https://github.com/sponsors/sindresorhus"
3606
+ }
3607
+ },
3608
  "node_modules/typescript": {
3609
  "version": "4.9.5",
3610
  "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
 
3619
  }
3620
  },
3621
  "node_modules/undici": {
3622
+ "version": "5.19.1",
3623
+ "resolved": "https://registry.npmjs.org/undici/-/undici-5.19.1.tgz",
3624
+ "integrity": "sha512-YiZ61LPIgY73E7syxCDxxa3LV2yl3sN8spnIuTct60boiiRaE1J8mNWHO8Im2Zi/sFrPusjLlmRPrsyraSqX6A==",
3625
  "dev": true,
3626
  "dependencies": {
3627
  "busboy": "^1.6.0"
package.json CHANGED
@@ -14,6 +14,7 @@
14
  "devDependencies": {
15
  "@sveltejs/adapter-node": "^1.2.0",
16
  "@sveltejs/kit": "^1.5.0",
 
17
  "@typescript-eslint/eslint-plugin": "^5.45.0",
18
  "@typescript-eslint/parser": "^5.45.0",
19
  "eslint": "^8.28.0",
@@ -32,6 +33,7 @@
32
  "@huggingface/inference": "^2.0.0-rc2",
33
  "autoprefixer": "^10.4.14",
34
  "date-fns": "^2.29.3",
 
35
  "mongodb": "^5.3.0",
36
  "postcss": "^8.4.21",
37
  "tailwind-scrollbar": "^3.0.0",
 
14
  "devDependencies": {
15
  "@sveltejs/adapter-node": "^1.2.0",
16
  "@sveltejs/kit": "^1.5.0",
17
+ "@types/marked": "^4.0.8",
18
  "@typescript-eslint/eslint-plugin": "^5.45.0",
19
  "@typescript-eslint/parser": "^5.45.0",
20
  "eslint": "^8.28.0",
 
33
  "@huggingface/inference": "^2.0.0-rc2",
34
  "autoprefixer": "^10.4.14",
35
  "date-fns": "^2.29.3",
36
+ "marked": "^4.3.0",
37
  "mongodb": "^5.3.0",
38
  "postcss": "^8.4.21",
39
  "tailwind-scrollbar": "^3.0.0",
src/lib/components/chat/ChatMessage.svelte CHANGED
@@ -1,4 +1,5 @@
1
  <script lang="ts">
 
2
  import type { Message } from '$lib/types/Message';
3
 
4
  export let message: Message;
@@ -14,7 +15,7 @@
14
  <div
15
  class="group relative rounded-2xl px-5 py-3.5 border border-gray-100 bg-gradient-to-br from-gray-50 dark:from-gray-800/40 dark:border-gray-800"
16
  >
17
- {message.content}
18
  </div>
19
  </div>
20
  {/if}
 
1
  <script lang="ts">
2
+ import { marked } from 'marked';
3
  import type { Message } from '$lib/types/Message';
4
 
5
  export let message: Message;
 
15
  <div
16
  class="group relative rounded-2xl px-5 py-3.5 border border-gray-100 bg-gradient-to-br from-gray-50 dark:from-gray-800/40 dark:border-gray-800"
17
  >
18
+ {@html marked(message.content, { gfm: true })}
19
  </div>
20
  </div>
21
  {/if}