diff --git a/packages/html-parser/src/html-parser.test.ts b/packages/html-parser/src/html-parser.test.ts
index 75cc64df..e6983799 100644
--- a/packages/html-parser/src/html-parser.test.ts
+++ b/packages/html-parser/src/html-parser.test.ts
@@ -501,6 +501,14 @@ describe('HtmlMessageEntityParser', () => {
)
})
+ it('should handle numbers and Longs', () => {
+ test(
+ htm`a number ${123123} and a long ${Long.fromNumber(456456)}`,
+ [],
+ 'a number 123123 and a long 456456',
+ )
+ })
+
it('should handle interpolation into attrs', () => {
test(
htm`link`,
@@ -526,7 +534,7 @@ describe('HtmlMessageEntityParser', () => {
'user',
)
test(
- htm`🚀`,
+ htm`🚀`,
[
createEntity('messageEntityCustomEmoji', 0, 2, {
documentId: Long.fromString('123123123123'),
diff --git a/packages/html-parser/src/index.ts b/packages/html-parser/src/index.ts
index 34d30af4..c6de4896 100644
--- a/packages/html-parser/src/index.ts
+++ b/packages/html-parser/src/index.ts
@@ -20,7 +20,7 @@ function escape(str: string, quote = false): string {
function parse(
strings: TemplateStringsArray | string,
- ...sub: (InputText | MessageEntity | boolean | number | undefined | null)[]
+ ...sub: (InputText | MessageEntity | Long | boolean | number | undefined | null)[]
): TextWithEntities {
const stacks: Record[]> = {}
const entities: tl.TypeMessageEntity[] = []
@@ -250,6 +250,7 @@ function parse(
if (typeof it === 'string') text = it
else if (typeof it === 'number') text = it.toString()
+ else if (Long.isLong(it)) text = it.toString(10)
else {
// obviously we can't have entities inside attributes, so just use the text
text = it.text
@@ -261,6 +262,8 @@ function parse(
if (typeof it === 'string' || typeof it === 'number') {
pendingText += it
+ } else if (Long.isLong(it)) {
+ pendingText += it.toString(10)
} else {
// TextWithEntities or MessageEntity
const text = it.text
@@ -451,7 +454,7 @@ export const html: {
*/
(
strings: TemplateStringsArray,
- ...sub: (InputText | MessageEntity | boolean | number | undefined | null)[]
+ ...sub: (InputText | MessageEntity | boolean | Long | number | undefined | null)[]
): TextWithEntities
/**
* A variant taking a plain JS string as input