Skip to content

Commit

Permalink
🐛 (whatsapp) Fix inline variable serializing
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jan 10, 2024
1 parent 006b9d6 commit 9b5b277
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/lib/serializer/convertRichTextToMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const convertRichTextToMarkdown = (
let extraNewLinesCount = 0
const test = richText
.reduce<string[]>((acc, node) => {
if (node.type === 'variable' || node.type === 'inline-variable') {
if (node.type === 'variable') {
return [
...acc,
...node.children.map(
Expand Down
22 changes: 21 additions & 1 deletion packages/lib/serializer/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function serialize(
opts: Options = {
nodeTypes: defaultNodeTypes,
}
) {
): string | undefined {
const {
nodeTypes: userNodeTypes = defaultNodeTypes,
ignoreParagraphNewline = false,
Expand All @@ -40,6 +40,19 @@ export default function serialize(
},
}

if ('type' in chunk && chunk.type === nodeTypes['inline-variable'])
return chunk.children
.map((child) =>
serialize(
{
...child,
parentType: nodeTypes['inline-variable'],
},
opts
)
)
.join('')

const LIST_TYPES = [nodeTypes.ul_list, nodeTypes.ol_list]

let children = text
Expand Down Expand Up @@ -169,6 +182,13 @@ export default function serialize(
}
}

if (chunk.parentType === nodeTypes['inline-variable']) {
if (opts.flavour === 'whatsapp') {
return children
}
return escapeHtml(children)
}

switch (type) {
case nodeTypes.heading[1]:
return `# ${children}\n`
Expand Down

1 comment on commit 9b5b277

@vercel
Copy link

@vercel vercel bot commented on 9b5b277 Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-typebot-io.vercel.app
builder-v2-git-main-typebot-io.vercel.app
app.typebot.io

Please sign in to comment.