Skip to content

Commit

Permalink
chore: more robust emoji id logic
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Mar 9, 2023
1 parent 09403a0 commit fa123d4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions composables/content-parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,10 @@ export function treeToText(input: Node): string {
body = (input.children as Node[]).map(n => treeToText(n)).join('')

if (input.name === 'img' || input.name === 'picture') {
if (input.attributes.class?.includes('custom-emoji'))
return `:${input.attributes['data-emoji-id'] ?? input.attributes.title ?? input.attributes.alt?.slice(1, -1)}:`
if (input.attributes.class?.includes('custom-emoji')) {
const id = input.attributes['data-emoji-id'] ?? input.attributes.title ?? input.attributes.alt ?? 'unknown'
return id[0] !== ':' ? `:${id}:` : id
}
if (input.attributes.class?.includes('iconify-emoji'))
return input.attributes.alt
}
Expand Down

0 comments on commit fa123d4

Please sign in to comment.