diff --git a/packages/markdown-cicero/jest.config.js b/packages/markdown-cicero/jest.config.js
index 1d19886a..d8da3d7c 100644
--- a/packages/markdown-cicero/jest.config.js
+++ b/packages/markdown-cicero/jest.config.js
@@ -51,7 +51,8 @@ module.exports = {
coverageReporters: [
'json',
'text',
- 'lcov'
+ 'lcov',
+ 'html'
],
// An object that configures minimum threshold enforcement for coverage results
diff --git a/packages/markdown-cli/lib/Commands.js b/packages/markdown-cli/lib/Commands.js
index f8ceb8af..67220c8c 100644
--- a/packages/markdown-cli/lib/Commands.js
+++ b/packages/markdown-cli/lib/Commands.js
@@ -43,19 +43,7 @@ class Commands {
}
let argExists = true;
- if (Array.isArray(argv[argName])) {
- // All files should exist
- for (let i = 0; i < argv[argName].length; i++) {
- if (Fs.existsSync(argv[argName][i]) && argExists) {
- argExists = true;
- } else {
- argExists = false;
- }
- }
- } else {
- // This file should exist
- argExists = Fs.existsSync(argv[argName]);
- }
+ argExists = Fs.existsSync(argv[argName]);
if (!argExists){
throw new Error(`A ${argDefaultName} file is required. Try the --${argName} flag or create a ${argDefaultName}.`);
@@ -108,33 +96,33 @@ class Commands {
const markdownText = Fs.readFileSync(samplePath, 'utf8');
let result = commonMark.fromMarkdown(markdownText, 'json');
if(verbose) {
- console.log('=== CommonMark ===');
- console.log(JSON.stringify(result, null, 4));
+ Logger.info('=== CommonMark ===');
+ Logger.info(JSON.stringify(result, null, 4));
}
if (cicero) {
result = ciceroMark.fromCommonMark(result, 'json');
if(verbose) {
- console.log('=== CiceroMark ===');
- console.log(JSON.stringify(result, null, 4));
+ Logger.info('=== CiceroMark ===');
+ Logger.info(JSON.stringify(result, null, 4));
}
}
else if (slate) {
result = ciceroMark.fromCommonMark(result, 'json');
if(verbose) {
- console.log('=== CiceroMark ===');
- console.log(JSON.stringify(result, null, 4));
+ Logger.info('=== CiceroMark ===');
+ Logger.info(JSON.stringify(result, null, 4));
}
result = slateMark.fromCiceroMark(result);
if(verbose) {
- console.log('=== Slate DOM ===');
- console.log(JSON.stringify(result, null, 4));
+ Logger.info('=== Slate DOM ===');
+ Logger.info(JSON.stringify(result, null, 4));
}
} else if (html) {
result = ciceroMark.fromCommonMark(result, 'json');
if(verbose) {
- console.log('=== CiceroMark ===');
- console.log(JSON.stringify(result, null, 4));
+ Logger.info('=== CiceroMark ===');
+ Logger.info(JSON.stringify(result, null, 4));
}
result = htmlMark.toHtml(result);
}
@@ -194,21 +182,21 @@ class Commands {
ciceroOptions.wrapVariables = noWrap ? false : true;
result = ciceroMark.toCommonMark(result, ciceroOptions);
if(verbose) {
- console.log('=== CommonMark ===');
- console.log(JSON.stringify(result, null, 4));
+ Logger.info('=== CommonMark ===');
+ Logger.info(JSON.stringify(result, null, 4));
}
} else if (slate) {
result = slateMark.toCiceroMark(result, 'json');
if(verbose) {
- console.log('=== CiceroMark ===');
- console.log(JSON.stringify(result, null, 4));
+ Logger.info('=== CiceroMark ===');
+ Logger.info(JSON.stringify(result, null, 4));
}
const ciceroOptions = {};
ciceroOptions.wrapVariables = noWrap ? false : true;
result = ciceroMark.toCommonMark(result, ciceroOptions);
if(verbose) {
- console.log('=== CommonMark ===');
- console.log(JSON.stringify(result, null, 4));
+ Logger.info('=== CommonMark ===');
+ Logger.info(JSON.stringify(result, null, 4));
}
} else if (html) {
throw new Error('Cannot roundtrip from HTML');
@@ -264,27 +252,27 @@ class Commands {
const markdownText = Fs.readFileSync(samplePath, 'utf8');
let result = commonMark.fromMarkdown(markdownText, 'json');
if(verbose) {
- console.log('=== CommonMark ===');
- console.log(JSON.stringify(result, null, 4));
+ Logger.info('=== CommonMark ===');
+ Logger.info(JSON.stringify(result, null, 4));
}
if (cicero) {
result = ciceroMark.fromCommonMark(result, 'json');
if(verbose) {
- console.log('=== CiceroMark ===');
- console.log(JSON.stringify(result, null, 4));
+ Logger.info('=== CiceroMark ===');
+ Logger.info(JSON.stringify(result, null, 4));
}
}
else if (slate) {
result = ciceroMark.fromCommonMark(result, 'json');
if(verbose) {
- console.log('=== CiceroMark ===');
- console.log(JSON.stringify(result, null, 4));
+ Logger.info('=== CiceroMark ===');
+ Logger.info(JSON.stringify(result, null, 4));
}
result = slateMark.fromCiceroMark(result);
if(verbose) {
- console.log('=== Slate DOM ===');
- console.log(JSON.stringify(result, null, 4));
+ Logger.info('=== Slate DOM ===');
+ Logger.info(JSON.stringify(result, null, 4));
}
}
@@ -293,21 +281,21 @@ class Commands {
ciceroOptions.wrapVariables = noWrap ? false : true;
result = ciceroMark.toCommonMark(result, ciceroOptions);
if(verbose) {
- console.log('=== CommonMark ===');
- console.log(JSON.stringify(result, null, 4));
+ Logger.info('=== CommonMark ===');
+ Logger.info(JSON.stringify(result, null, 4));
}
} else if (slate) {
result = slateMark.toCiceroMark(result, 'json');
if(verbose) {
- console.log('=== CiceroMark ===');
- console.log(JSON.stringify(result, null, 4));
+ Logger.info('=== CiceroMark ===');
+ Logger.info(JSON.stringify(result, null, 4));
}
const ciceroOptions = {};
ciceroOptions.wrapVariables = noWrap ? false : true;
result = ciceroMark.toCommonMark(result, ciceroOptions);
if(verbose) {
- console.log('=== CommonMark ===');
- console.log(JSON.stringify(result, null, 4));
+ Logger.info('=== CommonMark ===');
+ Logger.info(JSON.stringify(result, null, 4));
}
} else if (html) {
throw new Error('Cannot roundtrip from HTML');
diff --git a/packages/markdown-cli/test/cli.js b/packages/markdown-cli/test/cli.js
index 4d8e71f8..929d4d1a 100644
--- a/packages/markdown-cli/test/cli.js
+++ b/packages/markdown-cli/test/cli.js
@@ -35,6 +35,40 @@ function normalizeNLs(input) {
return text;
}
+describe('#validateParseArgs', () => {
+ it('no args specified', () => {
+ process.chdir(path.resolve(__dirname, 'data/'));
+ const args = Commands.validateParseArgs({
+ _: ['parse'],
+ });
+ args.sample.should.match(/sample.md$/);
+ });
+ it('no args specified (verbose)', () => {
+ process.chdir(path.resolve(__dirname, 'data/'));
+ const args = Commands.validateParseArgs({
+ _: ['parse'],
+ verbose: true
+ });
+ args.sample.should.match(/sample.md$/);
+ });
+ it('all args specified', () => {
+ process.chdir(path.resolve(__dirname, 'data/'));
+ const args = Commands.validateParseArgs({
+ _: ['parse'],
+ template: './',
+ sample: 'sample.md'
+ });
+ args.sample.should.match(/sample.md$/);
+ });
+ it('bad sample.md', () => {
+ process.chdir(path.resolve(__dirname, 'data/'));
+ (() => Commands.validateParseArgs({
+ _: ['parse'],
+ sample: 'sample_en.md'
+ })).should.throw('A sample.md file is required. Try the --sample flag or create a sample.md.');
+ });
+});
+
describe('markdown-cli', () => {
const sample = path.resolve(__dirname, 'data', 'acceptance.md');
const sampleExpected = path.resolve(__dirname, 'data', 'acceptance.json');
@@ -55,6 +89,16 @@ describe('markdown-cli', () => {
JSON.stringify(JSON.parse(result)).should.eql(JSON.stringify(sampleExpectedJson));
});
+ it('should parse a markdown file to CommonMark (verbose)', async () => {
+ const options = {};
+ options.cicero = false;
+ options.slate = false;
+ options.noWrap = true;
+ options.verbose = true;
+ const result = await Commands.parse(sample, null, options);
+ JSON.stringify(JSON.parse(result)).should.eql(JSON.stringify(sampleExpectedJson));
+ });
+
it('should parse a markdown file to CiceroMark', async () => {
const options = {};
options.cicero = true;
@@ -64,6 +108,16 @@ describe('markdown-cli', () => {
JSON.stringify(JSON.parse(result)).should.eql(JSON.stringify(sampleExpectedCiceroMarkJson));
});
+ it('should parse a markdown file to CiceroMark (verbose)', async () => {
+ const options = {};
+ options.cicero = true;
+ options.slate = false;
+ options.noWrap = true;
+ options.verbose = true;
+ const result = await Commands.parse(sample, null, options);
+ JSON.stringify(JSON.parse(result)).should.eql(JSON.stringify(sampleExpectedCiceroMarkJson));
+ });
+
it('should parse a markdown file to Slate', async () => {
const options = {};
options.cicero = false;
@@ -72,6 +126,16 @@ describe('markdown-cli', () => {
const result = await Commands.parse(sample, null, options);
JSON.stringify(JSON.parse(result)).should.eql(JSON.stringify(sampleExpectedSlateJson));
});
+
+ it('should parse a markdown file to Slate (verbose)', async () => {
+ const options = {};
+ options.cicero = false;
+ options.slate = true;
+ options.noWrap = true;
+ options.verbose = true;
+ const result = await Commands.parse(sample, null, options);
+ JSON.stringify(JSON.parse(result)).should.eql(JSON.stringify(sampleExpectedSlateJson));
+ });
});
describe('#draft', () => {
diff --git a/packages/markdown-cli/test/data/sample.md b/packages/markdown-cli/test/data/sample.md
new file mode 100644
index 00000000..985bcd06
--- /dev/null
+++ b/packages/markdown-cli/test/data/sample.md
@@ -0,0 +1,11 @@
+# Heading
+
+And below is a **clause**.
+
+```
+Acceptance of Delivery. will be deemed to have completed its delivery obligations if in 's opinion, the satisfies the Acceptance Criteria, and notifies in writing that it is accepting the .
+
+Inspection and Notice. will have Business Days' to inspect and evaluate the on the delivery date before notifying that it is either accepting or rejecting the .
+
+Acceptance Criteria. The "Acceptance Criteria" are the specifications the must meet for the to comply with its requirements and obligations under this agreement, detailed in , attached to this agreement.
+```
\ No newline at end of file
diff --git a/packages/markdown-common/jest.config.js b/packages/markdown-common/jest.config.js
index 1d19886a..d8da3d7c 100644
--- a/packages/markdown-common/jest.config.js
+++ b/packages/markdown-common/jest.config.js
@@ -51,7 +51,8 @@ module.exports = {
coverageReporters: [
'json',
'text',
- 'lcov'
+ 'lcov',
+ 'html'
],
// An object that configures minimum threshold enforcement for coverage results
diff --git a/packages/markdown-html/jest.config.js b/packages/markdown-html/jest.config.js
index 1d19886a..d8da3d7c 100644
--- a/packages/markdown-html/jest.config.js
+++ b/packages/markdown-html/jest.config.js
@@ -51,7 +51,8 @@ module.exports = {
coverageReporters: [
'json',
'text',
- 'lcov'
+ 'lcov',
+ 'html'
],
// An object that configures minimum threshold enforcement for coverage results
diff --git a/packages/markdown-slate/jest.config.js b/packages/markdown-slate/jest.config.js
index 1d19886a..d8da3d7c 100644
--- a/packages/markdown-slate/jest.config.js
+++ b/packages/markdown-slate/jest.config.js
@@ -51,7 +51,8 @@ module.exports = {
coverageReporters: [
'json',
'text',
- 'lcov'
+ 'lcov',
+ 'html'
],
// An object that configures minimum threshold enforcement for coverage results