fix(html-parser)!: keep whitespaces in interpolated strings
might be breaking as someone could be relying on this despite being a bug. to fix existing code wrap the string in `html(...)`
This commit is contained in:
parent
868082260e
commit
fefc8d38a7
2 changed files with 12 additions and 2 deletions
|
@ -361,6 +361,14 @@ describe('HtmlMessageEntityParser', () => {
|
||||||
test(htm`hewwo ${htm`<br>`} world`, [], 'hewwo \nworld')
|
test(htm`hewwo ${htm`<br>`} world`, [], 'hewwo \nworld')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should keep whitespaces in raw strings', () => {
|
||||||
|
const dot = ' ∙ '
|
||||||
|
const lf = '\n'
|
||||||
|
test(htm`this is${dot}some text${lf}xd`, [], 'this is ∙ some text\nxd')
|
||||||
|
|
||||||
|
test(htm`hewwo ${htm`<br>`} world`, [], 'hewwo \nworld')
|
||||||
|
})
|
||||||
|
|
||||||
it('should not ignore newlines and indentation in pre', () => {
|
it('should not ignore newlines and indentation in pre', () => {
|
||||||
test(
|
test(
|
||||||
htm`<pre>this is some text\n\nwith newlines</pre>`,
|
htm`<pre>this is some text\n\nwith newlines</pre>`,
|
||||||
|
|
|
@ -262,9 +262,11 @@ function parse(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof it === 'string' || typeof it === 'number') {
|
if (typeof it === 'string') {
|
||||||
|
processPendingText()
|
||||||
pendingText += it
|
pendingText += it
|
||||||
} else if (Long.isLong(it)) {
|
processPendingText(false, true)
|
||||||
|
} else if (Long.isLong(it) || typeof it === 'number') {
|
||||||
pendingText += it.toString(10)
|
pendingText += it.toString(10)
|
||||||
} else {
|
} else {
|
||||||
// TextWithEntities or MessageEntity
|
// TextWithEntities or MessageEntity
|
||||||
|
|
Loading…
Reference in a new issue