From eefc25de1a1667f5de0ff8efe3a4a9837e5116ce Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Thu, 25 Mar 2021 15:20:55 +0800 Subject: [PATCH] Use String.prototype.matchAll --- scripts/tags/tabs.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/tags/tabs.js b/scripts/tags/tabs.js index 7b15feb..d54da50 100644 --- a/scripts/tags/tabs.js +++ b/scripts/tags/tabs.js @@ -4,21 +4,21 @@ 'use strict'; -module.exports = ctx => function(args, content) { +module.exports = ctx => function(args, content = '') { const tabBlock = /\n([\w\W\s\S]*?)/g; args = args.join(' ').split(','); const tabName = args[0]; const tabActive = Number(args[1]) || 0; - let match; let tabId = 0; let tabNav = ''; let tabContent = ''; if (!tabName) ctx.log.warn('Tabs block must have unique name!'); + const matches = content.matchAll(tabBlock); - while ((match = tabBlock.exec(content)) !== null) { + for (const match of matches) { let [caption = '', icon = ''] = match[1].split('@'); let postContent = match[2];