Skip to content

Commit 3070792

Browse files
committed
chore(test): add mdast parse
1 parent 44f8849 commit 3070792

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"eslint": "^1.3.0",
4040
"eslint-plugin-markdown": "git://github.com/eslint/eslint-plugin-markdown.git",
4141
"espower-babel": "^3.3.0",
42-
"gitbook-cli": "^1.0.0",
42+
"gitbook-cli": "^0.3.6",
4343
"gitbook-plugin-edit-link": "^1.4.1",
4444
"gitbook-plugin-ga": "^0.2.1",
4545
"gitbook-plugin-github-buttons": "^1.2.2",
@@ -48,6 +48,7 @@
4848
"gitbook-plugin-richquotes": "0.0.5",
4949
"gitbook-summary-to-path": "^1.0.1",
5050
"jsdom": "^6.3.0",
51+
"mdast": "^2.1.0",
5152
"mocha": "^2.2.5",
5253
"node-fetch": "^1.3.2",
5354
"npm-run-all": "^1.2.8",
@@ -57,6 +58,7 @@
5758
"textlint-rule-max-ten": "^1.1.0",
5859
"textlint-rule-no-mix-dearu-desumasu": "^1.1.0",
5960
"textlint-rule-no-start-duplicated-conjunction": "^1.0.3",
61+
"unist-util-select": "^1.0.0",
6062
"textlint-rule-prh": "^2.0.0",
6163
"textlint-rule-spellcheck-tech-word": "^4.0.1"
6264
},
@@ -65,6 +67,7 @@
6567
"estraverse": "^4.1.0",
6668
"gulp": "^3.9.0",
6769
"gulp-util": "^3.0.6",
68-
"jquery": "^2.1.4"
70+
"jquery": "^2.1.4",
71+
"stemming-x-keywords": "^1.0.3"
6972
}
7073
}

test/keywords-test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
import {getFilePathListAsync} from "gitbook-summary-to-path";
44
import path from "path";
55
import fs from "fs";
6+
import mdast from "mdast";
7+
var select = require('unist-util-select');
68
const rootDir = path.join(__dirname, "..");
79
const keywordInfo = require("./keywords.json");
8-
10+
const Org = fs.readFileSync(__dirname + "/../ORGANIZATION.md","utf-8");
911
function getKeywords(matchPath) {
1012
return getFilePathListAsync(__dirname + "/../SUMMARY.md").then(fileList => {
1113
let filteredList = fileList.filter(filePath => {
@@ -32,6 +34,8 @@ function isNotContain(content, keywords) {
3234
// キーワードが書くコンテンツに含まれているかをテストする
3335
describe("keywords", function () {
3436
it("Each chapter contain the keyword", function (done) {
37+
let ast = mdast.parse(Org);
38+
let headingPrs = select(ast, "heading, heading + paragraph");
3539
let promises = Object.keys(keywordInfo).map(key => {
3640
return getKeywords(key).then(({filePath, content, keywords}) => {
3741
let unusedKeywords = isNotContain(content, keywords);

0 commit comments

Comments
 (0)