mirror of
https://activitypub.software/TransFem-org/sfm-js
synced 2024-11-27 16:33:03 +00:00
normalise emoji text
also, tests
This commit is contained in:
parent
7b6749fc35
commit
f5359d4656
2 changed files with 25 additions and 1 deletions
|
@ -629,7 +629,7 @@ export const language = P.createLanguage({
|
|||
P.regexp(/[\p{Letter}\p{Number}\p{Mark}_+-]+/iu),
|
||||
mark,
|
||||
P.alt([P.lineEnd, side]),
|
||||
], 2).map(name => M.EMOJI_CODE(name as string));
|
||||
], 2).map(name => M.EMOJI_CODE((name as string).normalize('NFC')));
|
||||
},
|
||||
|
||||
link: r => {
|
||||
|
|
|
@ -338,6 +338,30 @@ hoge`;
|
|||
const output = [EMOJI_CODE('abc')];
|
||||
assert.deepStrictEqual(mfm.parse(input), output);
|
||||
});
|
||||
|
||||
test('non-ASCII', () => {
|
||||
const input = ':taneŝima_ĝojas:, :मार्जारः:, :鹅:, :taneŝima_malsanas:, :แมว:, and :लक्षणा:';
|
||||
const output = [
|
||||
EMOJI_CODE('taneŝima_ĝojas'),
|
||||
TEXT(', '),
|
||||
EMOJI_CODE('मार्जारः'),
|
||||
TEXT(', '),
|
||||
EMOJI_CODE('鹅'),
|
||||
TEXT(', '),
|
||||
EMOJI_CODE('taneŝima_malsanas'),
|
||||
TEXT(', '),
|
||||
EMOJI_CODE('แมว'),
|
||||
TEXT(', and '),
|
||||
EMOJI_CODE('लक्षणा'),
|
||||
];
|
||||
assert.deepStrictEqual(mfm.parse(input), output);
|
||||
});
|
||||
|
||||
test('non-ASCII normalization', () => {
|
||||
const input = ":fo\u{0308}o:";
|
||||
const output = [EMOJI_CODE("f\u{00F6}o")];
|
||||
assert.deepStrictEqual(mfm.parse(input), output);
|
||||
});
|
||||
});
|
||||
|
||||
describe('unicode emoji', () => {
|
||||
|
|
Loading…
Reference in a new issue