File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,34 @@ async function main() {
9696 errors . push ( `文件 ${ filePath } 不符合仓库的规范!它的大标题应该是: ${ "# " + filename + "的做法" } ! 而它现在是 ${ titles [ 0 ] . trim ( ) } !` ) ;
9797 continue ;
9898 }
99+
100+ // 检查烹饪难度
101+ const mainTitleIndex = dataLines . indexOf ( titles [ 0 ] . trim ( ) ) ;
102+ const firstSecondTitleIndex = dataLines . indexOf ( secondTitles [ 0 ] . trim ( ) ) ;
103+
104+ if ( mainTitleIndex >= 0 && firstSecondTitleIndex >= 0 ) {
105+ // 检查大标题和第一个二级标题之间是否有预估烹饪难度
106+ let hasDifficulty = false ;
107+ const difficultyPattern = / ^ 预 估 烹 饪 难 度 : ★ { 1 , 5 } $ / ;
108+
109+ for ( let i = mainTitleIndex + 1 ; i < firstSecondTitleIndex ; i ++ ) {
110+ if ( difficultyPattern . test ( dataLines [ i ] ) ) {
111+ hasDifficulty = true ;
112+ // 检查星星数量是否在1-5之间
113+ const starCount = ( dataLines [ i ] . match ( / ★ / g) || [ ] ) . length ;
114+ if ( starCount < 1 || starCount > 5 ) {
115+ errors . push ( `文件 ${ filePath } 不符合仓库的规范!烹饪难度的星星数量必须在1-5颗之间!` ) ;
116+ }
117+ break ;
118+ }
119+ }
120+
121+ if ( ! hasDifficulty ) {
122+ errors . push ( `文件 ${ filePath } 不符合仓库的规范!在大标题和第一个二级标题之间必须包含"预估烹饪难度:★★"格式的难度评级,星星数量必须在1-5颗之间!` ) ;
123+ }
124+ }
125+
126+
99127 if ( secondTitles . length != 4 ) {
100128 errors . push ( `文件 ${ filePath } 不符合仓库的规范!它并不是四个标题的格式。请从示例菜模板中创建菜谱!请不要破坏模板的格式!` ) ;
101129 continue ;
You can’t perform that action at this time.
0 commit comments