Skip to content

Commit 774420e

Browse files
committed
New lint CI. Fix some issues.
1 parent 7d90e46 commit 774420e

File tree

18 files changed

+98
-22
lines changed

18 files changed

+98
-22
lines changed

.github/manual_lint.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// fetch all .md files.
2+
// Check it's content.
3+
// Console.LogError for errors.
4+
5+
6+
const glob = require("glob");
7+
const fs = require("fs");
8+
var path = require('path');
9+
10+
11+
var getDirectories = function (src, callback) {
12+
glob(src + '../../dishes/**/*.md', callback);
13+
};
14+
15+
getDirectories(__dirname, function (err, res) {
16+
res.forEach(filePath => {
17+
// console.log("Linting file: " + filePath + " ...");
18+
19+
fs.readFile(filePath, 'utf8' , (err, data) => {
20+
data = data.replace('\r\n', '\n');
21+
data = data.replace('\r', '\n');
22+
23+
dataLines = data.split('\n');
24+
var filename = path.parse(filePath).base.replace(".md","");
25+
26+
titles = dataLines.filter(t => t.startsWith('#'));
27+
secondTitles = titles
28+
.filter(t => t.startsWith('## '));
29+
30+
if (titles[0].trim() != "# " + filename + "的做法") {
31+
console.error(`File ${filePath} is invalid! It's title should be: ${"# " + filename + "的做法"}! It was ${titles[0].trim()}!`);
32+
return;
33+
}
34+
if (secondTitles.length != 4) {
35+
console.error(`File ${filePath} is invalid! It doesn't has 4 second titles!`);
36+
return;
37+
}
38+
if (secondTitles[0].trim() != "## 必备原料和工具") {
39+
console.error(`File ${filePath} is invalid! The first title is NOT 必备原料和工具! It was ${secondTitles[0]}!`);
40+
return;
41+
}
42+
if (secondTitles[1].trim() != "## 计算") {
43+
console.error(`File ${filePath} is invalid! The second title is NOT 计算!`);
44+
return;
45+
}
46+
if (secondTitles[2].trim() != "## 操作") {
47+
console.error(`File ${filePath} is invalid! The thrid title is NOT 操作!`);
48+
return;
49+
}
50+
if (secondTitles[3].trim() != "## 附加内容") {
51+
console.error(`File ${filePath} is invalid! The fourth title is NOT 附加内容!`);
52+
return;
53+
}
54+
});
55+
});
56+
});

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ jobs:
88
markdown-lint:
99
runs-on: ubuntu-latest
1010
steps:
11+
- uses: actions/setup-node@v2
12+
with:
13+
node-version: '16'
14+
cache: 'npm'
1115
- uses: actions/checkout@v2
1216
- name: Install packages
1317
run: sudo gem install mdl
1418
- name: Lint markdown files
1519
run: mdl . -r ~MD036,~MD024,~MD004,~MD029
1620
- run: pip install -r requirements.txt
1721
- run: mkdocs build --strict
22+
- run: npm install
23+
- run: node .github/manual_lint.js
1824
# Suppress 036 Emphasis used instead of a header
1925
# Suppress 024 Multiple headers with the same content

dishes/aquatic/红烧鱼头.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
- 如果你没有使用过菜刀剁过肉类食物,那么我并不推荐你使用该菜单!!!
55
- 在操作中,锋利的菜刀可能会划伤你的手指,请一定要小心。
66

7-
## 必备原料与工具
7+
## 必备原料和工具
88

99
- 注:如果有可能,尽量另准备一把菜刀,超市或市场上均有廉价且刀片更厚的菜刀,刀片厚度在 5-7mm 为最佳。
1010
- 大葱、姜、大蒜、香菜、美人椒
@@ -38,7 +38,7 @@
3838
* 将美人椒切为厚度为 3mm 左右的辣椒圈。
3939
* 干辣椒切四段。
4040

41-
## 腌制鱼头
41+
### 腌制鱼头
4242

4343
* 注:下文所述的鱼身是购买鱼头时所附带的鱼肉。
4444
* 将鱼头去鳞,清洗鱼头处未被清理干净的内脏。

dishes/aquatic/红烧鲤鱼.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 红烧鲤鱼的做法
22

3-
## 必备原料与工具
3+
## 必备原料和工具
44

55
- 大葱、姜、大蒜、干辣椒
66
- 油、盐、生抽、老抽、陈醋、蚝油、料酒、白糖

dishes/meat_dish/红烧肉/南派红烧肉.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
这份红烧肉教程是一道新手不败的菜谱。配着米饭好吃的停不下来,香糯无敌棒色泽诱人肥而不腻
44

5-
## 必备原料与工具
5+
## 必备原料和工具
66

77
* 注:如果有可能,请尽量把刀磨的锋利一些。
88
* 工具:``(砂锅为宜,铝锅其次,高压锅也可以,最好不要铁锅、铜锅)、````

dishes/meat_dish/红烧肉/简易红烧肉.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
![红烧肉成品](./001.jpg)
88

9-
## 必备原料与工具
9+
## 必备原料和工具
1010

1111
- 注:如果有可能,请尽量把刀磨的锋利一些。
1212
- 主料:`大肉``鸡蛋`(可选)、`豆皮`(可选)

dishes/staple/炒馍.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@
2323

2424
使用上述条件,计算出计划使用的原材料比例。
2525

26-
## 准备原料
26+
## 操作
2727

2828
* 将馒头切成小块或小片。
2929
* 选有鸡蛋的话将鸡蛋打进碗里,打散(可加盐和五香粉各 1g 或不加,等炒的过程中加)。
3030
* 鸡蛋浇在馒头上,拌匀,鸡蛋不宜过多。
31-
32-
## 操作
33-
3431
* 大火热锅,倒入食用油(不锈钢锅怕伤锅的话可以先倒油,烧至油热也可也可)
3532
* 将馍丁放进去翻炒,翻炒均匀。
3633
* 将火调小,炒至馍丁呈金黄色。

dishes/staple/烙饼/烙饼.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 烙饼的做法
22

3-
## 必备原料与工具
3+
## 必备原料和工具
44

55
*
66
* 面粉

dishes/staple/米饭/煮锅蒸米饭.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# 煮锅蒸米饭的做法
33

4-
## 必备的原料和工具
4+
## 必备原料和工具
55

66
- 北方大米
77
-

dishes/staple/麻油拌面.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
# 省吃俭用懒人麻油拌面的做法
2+
# 麻油拌面的做法
33

4-
想必大家都会有节约开销的时刻吧,附上个人耐吃又省钱的食谱。不需要太多的步骤简单的煮,捞,吃。
4+
省吃俭用懒人的菜:麻油拌面:想必大家都会有节约开销的时刻吧,附上个人耐吃又省钱的食谱。不需要太多的步骤简单的煮,捞,吃。
55

66
- 单身的朋友懒惰出门,又不想花钱,简简单单就一餐。
77
- 非单身的朋友想存钱,让女友花钱,简简单单就一餐。

dishes/vegetable_dish/上汤娃娃菜/上汤娃娃菜.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# 上汤娃娃菜的做法 (素菜|减肥餐)
1+
# 上汤娃娃菜的做法
2+
3+
上汤娃娃菜的做法 (素菜|减肥餐)
24

35
## 必备原料和工具
46

dishes/vegetable_dish/椒盐玉米/椒盐玉米.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# 椒盐玉米的做法
33

4-
## 必备的原料和工具
4+
## 必备原料和工具
55

66
- 玉米粒
77
- 椒盐
@@ -19,7 +19,7 @@
1919
- 淀粉 适量
2020
- 椒盐粉 半勺(备用)
2121

22-
## 做法
22+
## 操作
2323

2424
- 玉米粒都是剥好的,直接解冻即可,温水泡 15 分钟或者灶上开水煮 5 分钟。
2525
- 拿出一个簸箕我们将其假设为 BoxA,垫上吸油纸,倒进解冻好的玉米粒。

dishes/vegetable_dish/红烧茄子.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 红烧茄子的做法
22

3-
## 原料与工具
3+
## 必备原料和工具
44

55
- 大蒜
66
- 大葱

dishes/vegetable_dish/蒲烧茄子.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1-
# 蒲烧茄子🍆的做法
1+
# 蒲烧茄子的做法
22

33
众所皆知,茄子🍆和土豆🥔是两种荤菜。这一道蒲烧茄子,从外观上之于鳗鱼正如`土豆炖.*`中的生姜之于土豆。
44

55
## 必备原料和工具
66

7+
- 茄子
8+
- 蒲烧汁
9+
- 蜂蜜
10+
- 白糖
11+
- 生抽
12+
- 老抽
13+
- 料酒
14+
-
15+
16+
## 计算
17+
718
- 根据锅的类型适量的油(不粘锅:油汇聚成滴后要散布在茄子的面积 || 铁锅:摊开后油可以刚好覆盖锅底)
819
- 1 个长的上小下大的茄子(注意不要使用浙茄和圆茄)
920
- 1 份蒲烧汁

dishes/vegetable_dish/虎皮青椒/虎皮青椒.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# 虎皮青椒的做法
33

4-
## 必备的原料和工具
4+
## 必备原料和工具
55

66
青椒若干,大蒜 2 瓣,香醋 15ml,白糖 15g,生抽 5ml,油 15ml,盐少许。
77

dishes/vegetable_dish/西红柿炒鸡蛋.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 西红柿鸡蛋的做法
1+
# 西红柿炒鸡蛋的做法
22

33
西红柿炒蛋是中国家常几乎最常见的一道菜肴。它的原材料易于搜集,制作步骤也较为简单,所以非常适合新厨师上手,是很多人学习做菜时做的第一道菜。
44

package-lock.json

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"name": "how-to-cook",
33
"description": "程序员在家做饭方法指南。Programmer's guide about how to cook at home (Chinese).",
44
"version": "1.0.0",
5-
"devDependencies": {},
65
"repository": {
76
"type": "git",
87
"url": "git+https://github.com/Anduin2017/HowToCook.git"
@@ -24,5 +23,8 @@
2423
"textlint": "^12.1.0",
2524
"textlint-rule-ja-space-between-half-and-full-width": "^2.2.0",
2625
"textlint-rule-zh-half-and-full-width-bracket": "^1.1.0"
26+
},
27+
"devDependencies": {
28+
"glob": "^7.2.0"
2729
}
2830
}

0 commit comments

Comments
 (0)