diff --git a/.github/manual_lint.js b/.github/manual_lint.js new file mode 100644 index 000000000..fcf057f --- /dev/null +++ b/.github/manual_lint.js @@ -0,0 +1,56 @@ +// fetch all .md files. +// Check it's content. +// Console.LogError for errors. + + +const glob = require("glob"); +const fs = require("fs"); +var path = require('path'); + + +var getDirectories = function (src, callback) { + glob(src + '../../dishes/**/*.md', callback); + }; + +getDirectories(__dirname, function (err, res) { + res.forEach(filePath => { + // console.log("Linting file: " + filePath + " ..."); + + fs.readFile(filePath, 'utf8' , (err, data) => { + data = data.replace('\r\n', '\n'); + data = data.replace('\r', '\n'); + + dataLines = data.split('\n'); + var filename = path.parse(filePath).base.replace(".md",""); + + titles = dataLines.filter(t => t.startsWith('#')); + secondTitles = titles + .filter(t => t.startsWith('## ')); + + if (titles[0].trim() != "# " + filename + "的做法") { + console.error(`File ${filePath} is invalid! It's title should be: ${"# " + filename + "的做法"}! It was ${titles[0].trim()}!`); + return; + } + if (secondTitles.length != 4) { + console.error(`File ${filePath} is invalid! It doesn't has 4 second titles!`); + return; + } + if (secondTitles[0].trim() != "## 必备原料和工具") { + console.error(`File ${filePath} is invalid! The first title is NOT 必备原料和工具! It was ${secondTitles[0]}!`); + return; + } + if (secondTitles[1].trim() != "## 计算") { + console.error(`File ${filePath} is invalid! The second title is NOT 计算!`); + return; + } + if (secondTitles[2].trim() != "## 操作") { + console.error(`File ${filePath} is invalid! The thrid title is NOT 操作!`); + return; + } + if (secondTitles[3].trim() != "## 附加内容") { + console.error(`File ${filePath} is invalid! The fourth title is NOT 附加内容!`); + return; + } + }); + }); +}); \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 910c407..2898f2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,10 @@ jobs: markdown-lint: runs-on: ubuntu-latest steps: + - uses: actions/setup-node@v2 + with: + node-version: '16' + cache: 'npm' - uses: actions/checkout@v2 - name: Install packages run: sudo gem install mdl @@ -15,5 +19,7 @@ jobs: run: mdl . -r ~MD036,~MD024,~MD004,~MD029 - run: pip install -r requirements.txt - run: mkdocs build --strict + - run: npm install + - run: node .github/manual_lint.js # Suppress 036 Emphasis used instead of a header # Suppress 024 Multiple headers with the same content diff --git a/dishes/aquatic/红烧鱼头.md b/dishes/aquatic/红烧鱼头.md index 86c22c9..66f30f7 100644 --- a/dishes/aquatic/红烧鱼头.md +++ b/dishes/aquatic/红烧鱼头.md @@ -4,7 +4,7 @@ - 如果你没有使用过菜刀剁过肉类食物,那么我并不推荐你使用该菜单!!! - 在操作中,锋利的菜刀可能会划伤你的手指,请一定要小心。 -## 必备原料与工具 +## 必备原料和工具 - 注:如果有可能,尽量另准备一把菜刀,超市或市场上均有廉价且刀片更厚的菜刀,刀片厚度在 5-7mm 为最佳。 - 大葱、姜、大蒜、香菜、美人椒 @@ -38,7 +38,7 @@ * 将美人椒切为厚度为 3mm 左右的辣椒圈。 * 干辣椒切四段。 -## 腌制鱼头 +### 腌制鱼头 * 注:下文所述的鱼身是购买鱼头时所附带的鱼肉。 * 将鱼头去鳞,清洗鱼头处未被清理干净的内脏。 diff --git a/dishes/aquatic/红烧鲤鱼.md b/dishes/aquatic/红烧鲤鱼.md index 15c1c9f..06f9386 100644 --- a/dishes/aquatic/红烧鲤鱼.md +++ b/dishes/aquatic/红烧鲤鱼.md @@ -1,6 +1,6 @@ # 红烧鲤鱼的做法 -## 必备原料与工具 +## 必备原料和工具 - 大葱、姜、大蒜、干辣椒 - 油、盐、生抽、老抽、陈醋、蚝油、料酒、白糖 diff --git a/dishes/meat_dish/红烧肉/南派红烧肉.md b/dishes/meat_dish/红烧肉/南派红烧肉.md index 9591699..f897ab9 100644 --- a/dishes/meat_dish/红烧肉/南派红烧肉.md +++ b/dishes/meat_dish/红烧肉/南派红烧肉.md @@ -2,7 +2,7 @@ 这份红烧肉教程是一道新手不败的菜谱。配着米饭好吃的停不下来,香糯无敌棒色泽诱人肥而不腻 -## 必备原料与工具 +## 必备原料和工具 * 注:如果有可能,请尽量把刀磨的锋利一些。 * 工具:`锅`(砂锅为宜,铝锅其次,高压锅也可以,最好不要铁锅、铜锅)、`勺`、`碗` diff --git a/dishes/meat_dish/红烧肉/简易红烧肉.md b/dishes/meat_dish/红烧肉/简易红烧肉.md index 3cb26ee..6710b3f 100644 --- a/dishes/meat_dish/红烧肉/简易红烧肉.md +++ b/dishes/meat_dish/红烧肉/简易红烧肉.md @@ -6,7 +6,7 @@ ![红烧肉成品](./001.jpg) -## 必备原料与工具 +## 必备原料和工具 - 注:如果有可能,请尽量把刀磨的锋利一些。 - 主料:`大肉`、`鸡蛋`(可选)、`豆皮`(可选) diff --git a/dishes/staple/炒馍.md b/dishes/staple/炒馍.md index 2db12c3..a72f30e 100644 --- a/dishes/staple/炒馍.md +++ b/dishes/staple/炒馍.md @@ -23,14 +23,11 @@ 使用上述条件,计算出计划使用的原材料比例。 -## 准备原料 +## 操作 * 将馒头切成小块或小片。 * 选有鸡蛋的话将鸡蛋打进碗里,打散(可加盐和五香粉各 1g 或不加,等炒的过程中加)。 * 鸡蛋浇在馒头上,拌匀,鸡蛋不宜过多。 - -## 操作 - * 大火热锅,倒入食用油(不锈钢锅怕伤锅的话可以先倒油,烧至油热也可也可) * 将馍丁放进去翻炒,翻炒均匀。 * 将火调小,炒至馍丁呈金黄色。 diff --git a/dishes/staple/烙饼/烙饼.md b/dishes/staple/烙饼/烙饼.md index 8d9c152..6c0b80a 100644 --- a/dishes/staple/烙饼/烙饼.md +++ b/dishes/staple/烙饼/烙饼.md @@ -1,6 +1,6 @@ # 烙饼的做法 -## 必备原料与工具 +## 必备原料和工具 * 油 * 面粉 diff --git a/dishes/staple/米饭/煮锅蒸米饭.md b/dishes/staple/米饭/煮锅蒸米饭.md index 9b81ee4..c44ac43 100644 --- a/dishes/staple/米饭/煮锅蒸米饭.md +++ b/dishes/staple/米饭/煮锅蒸米饭.md @@ -1,7 +1,7 @@ # 煮锅蒸米饭的做法 -## 必备的原料和工具 +## 必备原料和工具 - 北方大米 - 水 diff --git a/dishes/staple/麻油拌面.md b/dishes/staple/麻油拌面.md index 4ebe41a..6026195 100644 --- a/dishes/staple/麻油拌面.md +++ b/dishes/staple/麻油拌面.md @@ -1,7 +1,7 @@ -# 省吃俭用懒人麻油拌面的做法 +# 麻油拌面的做法 -想必大家都会有节约开销的时刻吧,附上个人耐吃又省钱的食谱。不需要太多的步骤简单的煮,捞,吃。 +省吃俭用懒人的菜:麻油拌面:想必大家都会有节约开销的时刻吧,附上个人耐吃又省钱的食谱。不需要太多的步骤简单的煮,捞,吃。 - 单身的朋友懒惰出门,又不想花钱,简简单单就一餐。 - 非单身的朋友想存钱,让女友花钱,简简单单就一餐。 diff --git a/dishes/vegetable_dish/上汤娃娃菜/上汤娃娃菜.md b/dishes/vegetable_dish/上汤娃娃菜/上汤娃娃菜.md index 238fee1..09d1261 100644 --- a/dishes/vegetable_dish/上汤娃娃菜/上汤娃娃菜.md +++ b/dishes/vegetable_dish/上汤娃娃菜/上汤娃娃菜.md @@ -1,4 +1,6 @@ -# 上汤娃娃菜的做法 (素菜|减肥餐) +# 上汤娃娃菜的做法 + +上汤娃娃菜的做法 (素菜|减肥餐) ## 必备原料和工具 diff --git a/dishes/vegetable_dish/椒盐玉米/椒盐玉米.md b/dishes/vegetable_dish/椒盐玉米/椒盐玉米.md index 35b26dc..7341103 100644 --- a/dishes/vegetable_dish/椒盐玉米/椒盐玉米.md +++ b/dishes/vegetable_dish/椒盐玉米/椒盐玉米.md @@ -1,7 +1,7 @@ # 椒盐玉米的做法 -## 必备的原料和工具 +## 必备原料和工具 - 玉米粒 - 椒盐 @@ -19,7 +19,7 @@ - 淀粉 适量 - 椒盐粉 半勺(备用) -## 做法 +## 操作 - 玉米粒都是剥好的,直接解冻即可,温水泡 15 分钟或者灶上开水煮 5 分钟。 - 拿出一个簸箕我们将其假设为 BoxA,垫上吸油纸,倒进解冻好的玉米粒。 diff --git a/dishes/vegetable_dish/红烧茄子.md b/dishes/vegetable_dish/红烧茄子.md index 743a1e6..1ac3955 100644 --- a/dishes/vegetable_dish/红烧茄子.md +++ b/dishes/vegetable_dish/红烧茄子.md @@ -1,6 +1,6 @@ # 红烧茄子的做法 -## 原料与工具 +## 必备原料和工具 - 大蒜 - 大葱 diff --git a/dishes/vegetable_dish/蒲烧茄子.md b/dishes/vegetable_dish/蒲烧茄子.md index d8dc521..f99188e 100644 --- a/dishes/vegetable_dish/蒲烧茄子.md +++ b/dishes/vegetable_dish/蒲烧茄子.md @@ -1,9 +1,20 @@ -# 蒲烧茄子🍆的做法 +# 蒲烧茄子的做法 众所皆知,茄子🍆和土豆🥔是两种荤菜。这一道蒲烧茄子,从外观上之于鳗鱼正如`土豆炖.*`中的生姜之于土豆。 ## 必备原料和工具 +- 茄子 +- 蒲烧汁 +- 蜂蜜 +- 白糖 +- 生抽 +- 老抽 +- 料酒 +- 水 + +## 计算 + - 根据锅的类型适量的油(不粘锅:油汇聚成滴后要散布在茄子的面积 || 铁锅:摊开后油可以刚好覆盖锅底) - 1 个长的上小下大的茄子(注意不要使用浙茄和圆茄) - 1 份蒲烧汁 diff --git a/dishes/vegetable_dish/虎皮青椒/虎皮青椒.md b/dishes/vegetable_dish/虎皮青椒/虎皮青椒.md index e827d72..6607d0b 100644 --- a/dishes/vegetable_dish/虎皮青椒/虎皮青椒.md +++ b/dishes/vegetable_dish/虎皮青椒/虎皮青椒.md @@ -1,7 +1,7 @@ # 虎皮青椒的做法 -## 必备的原料和工具 +## 必备原料和工具 青椒若干,大蒜 2 瓣,香醋 15ml,白糖 15g,生抽 5ml,油 15ml,盐少许。 diff --git a/dishes/vegetable_dish/西红柿炒鸡蛋.md b/dishes/vegetable_dish/西红柿炒鸡蛋.md index 7d50b50..5e0af08 100644 --- a/dishes/vegetable_dish/西红柿炒鸡蛋.md +++ b/dishes/vegetable_dish/西红柿炒鸡蛋.md @@ -1,4 +1,4 @@ -# 西红柿鸡蛋的做法 +# 西红柿炒鸡蛋的做法 西红柿炒蛋是中国家常几乎最常见的一道菜肴。它的原材料易于搜集,制作步骤也较为简单,所以非常适合新厨师上手,是很多人学习做菜时做的第一道菜。 diff --git a/package-lock.json b/package-lock.json index d24ed50..63e09ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,9 @@ "textlint-rule-ja-space-between-half-and-full-width": "^2.2.0", "textlint-rule-zh-half-and-full-width-bracket": "^1.1.0" }, - "devDependencies": {} + "devDependencies": { + "glob": "^7.2.0" + } }, "node_modules/@azu/format-text": { "version": "1.0.1", diff --git a/package.json b/package.json index 69f1ad5..55fba55 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,6 @@ "name": "how-to-cook", "description": "程序员在家做饭方法指南。Programmer's guide about how to cook at home (Chinese).", "version": "1.0.0", - "devDependencies": {}, "repository": { "type": "git", "url": "git+https://github.com/Anduin2017/HowToCook.git" @@ -24,5 +23,8 @@ "textlint": "^12.1.0", "textlint-rule-ja-space-between-half-and-full-width": "^2.2.0", "textlint-rule-zh-half-and-full-width-bracket": "^1.1.0" + }, + "devDependencies": { + "glob": "^7.2.0" } }