🐛 (whatsapp) Fix inline variable serializing
This commit is contained in:
@@ -21,7 +21,7 @@ export default function serialize(
|
||||
opts: Options = {
|
||||
nodeTypes: defaultNodeTypes,
|
||||
}
|
||||
) {
|
||||
): string | undefined {
|
||||
const {
|
||||
nodeTypes: userNodeTypes = defaultNodeTypes,
|
||||
ignoreParagraphNewline = false,
|
||||
@@ -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
|
||||
@@ -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`
|
||||
|
||||
Reference in New Issue
Block a user