3 Commits

Author SHA1 Message Date
Anduin Xue
656b420a06 Add cooking difficulty validation to manual linting script 2025-04-24 06:29:54 +00:00
github-actions[bot]
1ec2a5a398 [ci skip] Automatic file changes/fix 2025-04-24 05:48:50 +00:00
Anduin Xue
9b774c4f16 Update readme_template.md 2025-04-24 05:48:21 +00:00
3 changed files with 36 additions and 0 deletions

View File

@@ -96,6 +96,34 @@ async function main() {
errors.push(`文件 ${filePath} 不符合仓库的规范!它的大标题应该是: ${"# " + filename + "的做法"}! 而它现在是 ${titles[0].trim()}!`);
continue;
}
// 检查烹饪难度
const mainTitleIndex = dataLines.indexOf(titles[0].trim());
const firstSecondTitleIndex = dataLines.indexOf(secondTitles[0].trim());
if (mainTitleIndex >= 0 && firstSecondTitleIndex >= 0) {
// 检查大标题和第一个二级标题之间是否有预估烹饪难度
let hasDifficulty = false;
const difficultyPattern = /^预估烹饪难度:★{1,5}$/;
for (let i = mainTitleIndex + 1; i < firstSecondTitleIndex; i++) {
if (difficultyPattern.test(dataLines[i])) {
hasDifficulty = true;
// 检查星星数量是否在1-5之间
const starCount = (dataLines[i].match(/★/g) || []).length;
if (starCount < 1 || starCount > 5) {
errors.push(`文件 ${filePath} 不符合仓库的规范烹饪难度的星星数量必须在1-5颗之间`);
}
break;
}
}
if (!hasDifficulty) {
errors.push(`文件 ${filePath} 不符合仓库的规范!在大标题和第一个二级标题之间必须包含"预估烹饪难度:★★"格式的难度评级星星数量必须在1-5颗之间`);
}
}
if (secondTitles.length != 4) {
errors.push(`文件 ${filePath} 不符合仓库的规范!它并不是四个标题的格式。请从示例菜模板中创建菜谱!请不要破坏模板的格式!`);
continue;

View File

@@ -45,3 +45,7 @@ docker run -d -p 5000:5000 ghcr.io/anduin2017/how-to-cook:latest
如果你已经做了许多上面的菜,对于厨艺已经入门,并且想学习更加高深的烹饪技巧,请继续阅读下面的内容:
{{after}}
## 衍生作品推荐
- [HowToCook-mcp 让 AI 助手变身私人大厨,为你的一日三餐出谋划策](https://github.com/worryzyy/HowToCook-mcp)

View File

@@ -399,3 +399,7 @@ docker run -d -p 5000:5000 ghcr.io/anduin2017/how-to-cook:latest
- [辅料技巧](tips/advanced/辅料技巧.md)
- [高级专业术语](tips/advanced/高级专业术语.md)
- [油温判断技巧](tips/advanced/油温判断技巧.md)
## 衍生作品推荐
- [HowToCook-mcp 让 AI 助手变身私人大厨,为你的一日三餐出谋划策](https://github.com/worryzyy/HowToCook-mcp)