Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

markdown checker #226

Draft
wants to merge 36 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
36 commits
Select commit Hold shift click to select a range
e3d07a9
added source code reader
Jul 1, 2019
527c524
moved package into the tools folder
Jul 2, 2019
5cf1533
downgraded version from 1 to 0
Jul 2, 2019
1f6afca
Update tablerow object dot notation
oyilmaztekin Jul 2, 2019
de265d5
update private property
oyilmaztekin Jul 2, 2019
cde54af
Update Object dot notation
oyilmaztekin Jul 2, 2019
b01b4a5
Update test description
oyilmaztekin Jul 2, 2019
ade9c4c
Update test description
oyilmaztekin Jul 2, 2019
5204588
Update dot notation in test
oyilmaztekin Jul 2, 2019
346b29a
Update dot notation
oyilmaztekin Jul 2, 2019
2545fe6
Update destructuring assignment
oyilmaztekin Jul 2, 2019
853044f
reduced analyzeTable function
Jul 2, 2019
421e31d
Merge branch 'ozer-check-markdown' of https://github.com/oyilmaztekin…
Jul 2, 2019
a78ac0b
eslint integration
Jul 8, 2019
0601099
added new line
Jul 8, 2019
4c96e44
Merge pull request #1 from oguzzkilic/patch-1
oyilmaztekin Jul 8, 2019
a9710f7
added tested for resolver, parser and recursive test for tokenization
oyilmaztekin Jul 28, 2019
0df11c5
Merge branch 'master' of https://github.com/tc39/proposals into ozer-…
oyilmaztekin Nov 7, 2019
5325939
added test for collectLinkDefinitions.js
oyilmaztekin Nov 7, 2019
2f5a10b
added detectTables test
oyilmaztekin Nov 10, 2019
d068b15
added tables Represantation mock
oyilmaztekin Nov 11, 2019
1d15acb
fixed grammar
oyilmaztekin Nov 12, 2019
8ba807c
Merge branch 'master' into ozer-check-markdown
Sep 3, 2021
f19f819
adds handler for table head
Sep 7, 2021
829789a
removes unused function
oyilmaztekin Sep 7, 2021
cf70ee9
adds cell handler
oyilmaztekin Sep 10, 2021
b7cce4d
fixes handlers to group array by proposals
oyilmaztekin Sep 10, 2021
84d8c3d
makes refactoring on handleTables function
oyilmaztekin Sep 10, 2021
8a433ba
Merge branch 'master' into ozer-check-markdown
oyilmaztekin Sep 10, 2021
142a78b
adds doc into index.js
oyilmaztekin Sep 10, 2021
215ea12
ignores editor files
oyilmaztekin Sep 10, 2021
a14e799
removes extra spaces
oyilmaztekin Sep 10, 2021
43683bc
removes extra spaces
oyilmaztekin Sep 10, 2021
812d0ca
removes .gitignore
oyilmaztekin Sep 10, 2021
e591bdd
creates final JSON for stage1
oyilmaztekin Sep 11, 2021
6a347ee
adds some refactoring
oyilmaztekin Sep 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tools/markdown-checker/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 1 @@
*_tests_*
21 changes: 21 additions & 0 deletions tools/markdown-checker/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 1,21 @@
{
"env": {
"node": true,
"es6": true
},
"extends": [
"airbnb-base"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"no-underscore-dangle": 0,
"import/no-extraneous-dependencies": 0,
"no-unused-vars": 0
}
}
10 changes: 5 additions & 5 deletions tools/markdown-checker/index.js
Original file line number Diff line number Diff line change
@@ -1,8 1,8 @@
const readMarkdown = require("./lib/parser/readMarkdown");
const parseToAST = require("./lib/parser/parseToAst");
const collectLinkDefinitions = require("./lib/analyzer/collectLinkDefinitions");
const tableAnalyzer = require("./lib/analyzer/analyzeTable");
const config = require("./config.json");
const readMarkdown = require('./lib/parser/readMarkdown');
const parseToAST = require('./lib/parser/parseToAst');
const collectLinkDefinitions = require('./lib/analyzer/collectLinkDefinitions');
const tableAnalyzer = require('./lib/analyzer/analyzeTable');
const config = require('./config.json');

function processStage3({ stage3 } = config) {
const markdownStage3 = readMarkdown(stage3);
Expand Down
4 changes: 2 additions & 2 deletions tools/markdown-checker/lib/analyzer/analyzeTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 4,8 @@
*
*/

const detectTables = require("./detectTables");
const detectHeader = require("./detectHeaders");
const detectTables = require('./detectTables');
const detectHeader = require('./detectHeaders');

/**
*
Expand Down
23 changes: 12 additions & 11 deletions tools/markdown-checker/lib/analyzer/collectLinkDefinitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 2,15 @@
* @param {Object} AST
* @returns {Object} - collected link definitions
*/
module.exports = function(AST) {
let definitions = {};
AST.children.forEach(node => {
if (node.type === "definition") {
let label = node.label;
definitions[label] = node.url;
}
});
return definitions;
};

function collectLinkDefinitions(AST) {
const definitions = {};
AST.children.forEach((node) => {
if (node.type === 'definition') {
const { label } = node;
definitions[label] = node.url;
}
});
return definitions;
}

module.exports = collectLinkDefinitions;
8 changes: 4 additions & 4 deletions tools/markdown-checker/lib/analyzer/detectHeaders.js
Original file line number Diff line number Diff line change
@@ -1,10 1,10 @@
const traverseChildren = require("./../transformer/traverser").traverseChildren;
const { traverseChildren } = require('./../transformer/traverser');
/**
* @param {Object} tableRow
* @returns {Object} - collected header template
* @returns {Object} - collected header template
*/
module.exports = function detectHeaders(tableRow) {
let cellSize = tableRow.align.length;
let [headerNode] = tableRow.children;
//create header template here
let [headerNode] = tableRow.children;
// create header template here
};
24 changes: 12 additions & 12 deletions tools/markdown-checker/lib/mocks/mock.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions tools/markdown-checker/lib/parser/__tests__/readMarkdown.test.js
Original file line number Diff line number Diff line change
@@ -1,14 1,14 @@
const readMarkdown = require("./../readMarkdown");
const mock = require("../../mocks/mock");
const config = require("./../../../config.json");
const readMarkdown = require('./../readMarkdown');
const mock = require('../../mocks/mock');
const config = require('./../../../config.json');

const sourceCode = readMarkdown(config.stage3);
describe("testing parser", () => {
test("is defined", () => {
describe('testing parser', () => {
test('is defined', () => {
expect(sourceCode).toBeDefined();
});

test("result is matched to given mock AST", () => {
test('result is matched to given mock AST', () => {
expect(sourceCode).toEqual(mock);
});
});
12 changes: 7 additions & 5 deletions tools/markdown-checker/lib/parser/parseToAst.js
Original file line number Diff line number Diff line change
@@ -1,12 1,14 @@
const unified = require("unified");
const markdown = require("remark-parse");
const unified = require('unified');
const markdown = require('remark-parse');

/**
* @param {string} file - file path
* @returns {Object} - returns parsed markdown file as an AST
* @returns {Object} - returns parsed markdown file as an AST
*/
module.exports = function(file) {
function parseToAst(file) {
return unified()
.use(markdown)
.parse(file);
};
}

module.exports = parseToAst;
12 changes: 7 additions & 5 deletions tools/markdown-checker/lib/parser/readMarkdown.js
Original file line number Diff line number Diff line change
@@ -1,11 1,13 @@
const fs = require("fs");
const path = require("path");
const fs = require('fs');
const path = require('path');

/**
* @param {string} markdownPath - path of the markdown file
* @returns {string} - source code of the markdown as a string
*/
module.exports = function(markdownPath) {
function readMarkdown(markdownPath) {
const resolvedPath = path.resolve(__dirname, markdownPath);
return fs.readFileSync(resolvedPath, "utf-8");
};
return fs.readFileSync(resolvedPath, 'utf-8');
}

module.exports = readMarkdown;
8 changes: 4 additions & 4 deletions tools/markdown-checker/lib/transformer/traverser.js
Original file line number Diff line number Diff line change
@@ -1,10 1,10 @@
/**
* @param {Object} Node
* @param {function} callBackLogic
* @param {Object} Node
* @param {function} callBackLogic
*/

module.exports = function traverseChildren(node, callBackLogic) {
node.forEach(n => {
module.exports = function traverseChildren(node, callBackLogic) {
node.forEach((n) => {
callBackLogic();
oyilmaztekin marked this conversation as resolved.
Show resolved Hide resolved
if (n.children) {
traverseChildren(n);
Expand Down
Loading