소스 검색

修改歌词解析的标签检测逻辑:只有在[]中的标签才忽略

onecold 11 달 전
부모
커밋
6d017b67c4
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 1
      lib/src/main/ets/parse/LyricParser.ts

+ 5 - 1
lib/src/main/ets/parse/LyricParser.ts

@@ -40,7 +40,11 @@ export class LyricParser implements IParser {
             }
 
             // 检查是否是需要忽略的标签
-            const shouldIgnore = ignoredTags.some(tag  => line.indexOf(tag)  > 0);
+            // 修改后的标签检测逻辑:只有在[]中的标签才忽略
+            const shouldIgnore = ignoredTags.some(tag  => {
+                const tagPattern = new RegExp(`\\[${tag}[^\\]]*\\]`, 'i'); // 匹配[tag...]格式,忽略大小写
+                return tagPattern.test(line);
+            });
             if (shouldIgnore) {
                 printW(`the lyric line contains ignored tag, line index= ${i}`);
                 continue;