@meistrari/chat-nuxt 4.6.0-rc.8 → 4.6.0-rc.9

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/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meistrari/chat-nuxt",
3
3
  "configKey": "chatNuxt",
4
- "version": "4.6.0-rc.8",
4
+ "version": "4.6.0-rc.9",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -3,6 +3,7 @@ import MarkdownRender, { removeCustomComponents, setCustomComponents } from "mar
3
3
  import { wrapCustomMarkdownComponents } from "../markdown/custom-components";
4
4
  import { STREAMING_TEXT_FADE_MS } from "../markdown/streaming-text-segments";
5
5
  import { escapeSingleDollarSigns } from "../markdown/escape-dollar-signs";
6
+ import { normalizeCustomTagJson } from "../markdown/normalize-custom-tag-json";
6
7
  import StreamingTextNode from "../markdown/streaming-text-node.vue";
7
8
  const props = defineProps({
8
9
  content: { type: [String, null], required: false, default: "" },
@@ -15,7 +16,7 @@ const props = defineProps({
15
16
  const attrs = useAttrs();
16
17
  const instance = getCurrentInstance();
17
18
  const scopeId = `app-markdown-render-${instance?.uid ?? Math.random().toString(36).slice(2)}`;
18
- const escapedContent = computed(() => escapeSingleDollarSigns(props.content ?? ""));
19
+ const escapedContent = computed(() => escapeSingleDollarSigns(normalizeCustomTagJson(props.content ?? "", props.customHtmlTags)));
19
20
  const customMarkdownComponents = computed(() => wrapCustomMarkdownComponents(props.customComponents));
20
21
  const streamingTextActive = ref(props.typewriter);
21
22
  let streamingTextTimer;
@@ -0,0 +1 @@
1
+ export declare function normalizeCustomTagJson(text: string, customHtmlTags: readonly string[]): string;
@@ -0,0 +1,15 @@
1
+ export function normalizeCustomTagJson(text, customHtmlTags) {
2
+ if (!customHtmlTags.length)
3
+ return text;
4
+ return text.replace(/(^[ \t]{0,3}(`{3,}|~{3,})[^\n]*\n[\s\S]*?(?:\n[ \t]{0,3}(?=\2)(?:`+|~+)[ \t]*(?=\n|$)|(?![\s\S]))|(`+)[\s\S]*?\3)|^([ \t]{0,3}<([a-z][\w-]*)(?:\s+[\w-]+=(?:"[^"\n]*"|'[^'\n]*'))*\s+[\w-]+=')([\[{][^\n]*[\]}])([ \t]*\/>)[ \t]*(?=\n|$)/gm, (match, code, _fence, _inline, prefix, tag, json, closing) => {
5
+ if (code || !customHtmlTags.includes(tag))
6
+ return match;
7
+ try {
8
+ JSON.parse(json);
9
+ } catch {
10
+ return match;
11
+ }
12
+ const escaped = json.replace(/&/g, "\\u0026").replace(/'/g, "\\u0027").replace(/</g, "\\u003c").replace(/>/g, "\\u003e");
13
+ return `${prefix}${escaped}'${closing}`;
14
+ });
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/chat-nuxt",
3
- "version": "4.6.0-rc.8",
3
+ "version": "4.6.0-rc.9",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {