diff --git a/packages/html-parser/src/index.ts b/packages/html-parser/src/index.ts
index cba150c2..f9d59770 100644
--- a/packages/html-parser/src/index.ts
+++ b/packages/html-parser/src/index.ts
@@ -20,10 +20,12 @@ const MENTION_REGEX =
*/
export function html(
strings: TemplateStringsArray,
- ...sub: (string | FormattedString<'html'>)[]
+ ...sub: (string | FormattedString<'html'> | boolean | undefined | null)[]
): FormattedString<'html'> {
let str = ''
sub.forEach((it, idx) => {
+ if (typeof it === 'boolean' || !it) return
+
if (typeof it === 'string') it = HtmlMessageEntityParser.escape(it)
else {
if (it.mode && it.mode !== 'html')
diff --git a/packages/markdown-parser/src/index.ts b/packages/markdown-parser/src/index.ts
index 4c25ac14..7ccda574 100644
--- a/packages/markdown-parser/src/index.ts
+++ b/packages/markdown-parser/src/index.ts
@@ -26,12 +26,18 @@ const TO_BE_ESCAPED = /[*_\-~`[\\\]|]/g
*/
export function md(
strings: TemplateStringsArray,
- ...sub: (string | FormattedString<'markdown'>)[]
+ ...sub: (
+ | string
+ | FormattedString<'markdown'>
+ | boolean
+ | undefined
+ | null
+ )[]
): FormattedString<'markdown'> {
let str = ''
sub.forEach((it, idx) => {
- if (typeof it === 'string')
- it = MarkdownMessageEntityParser.escape(it as string)
+ if (typeof it === 'boolean' || !it) return
+ if (typeof it === 'string') it = MarkdownMessageEntityParser.escape(it)
else {
if (it.mode && it.mode !== 'markdown')
throw new Error(`Incompatible parse mode: ${it.mode}`)
@@ -249,8 +255,13 @@ export class MarkdownMessageEntityParser implements IMessageEntityParser {
if (c === text[pos + 1]) {
// maybe (?) start or end of an entity
- let type: 'Italic' | 'Bold' | 'Underline' | 'Strike' | 'Spoiler' | null =
- null
+ let type:
+ | 'Italic'
+ | 'Bold'
+ | 'Underline'
+ | 'Strike'
+ | 'Spoiler'
+ | null = null
switch (c) {
case '_':
type = 'Italic'