@emdaer/core
Advanced tools
Comparing version 1.6.19 to 1.6.20
@@ -6,2 +6,10 @@ # Change Log | ||
<a name="1.6.20"></a> | ||
## [1.6.20](https://github.com/emdaer/emdaer/compare/v1.6.19...v1.6.20) (2017-12-09) | ||
**Note:** Version bump only for package @emdaer/core | ||
<a name="1.6.19"></a> | ||
@@ -8,0 +16,0 @@ ## [1.6.19](https://github.com/emdaer/emdaer/compare/v1.6.18...v1.6.19) (2017-11-27) |
@@ -5,8 +5,15 @@ /* */ | ||
const EmdaerFeatureFlags = { | ||
// Experimental AST parsing of Markdown files: | ||
enableASTParsing: false, | ||
// Experimental single comment type: | ||
enableCommonComment: false, | ||
// Experimental AST parsing of Markdown files and common comment type: | ||
enableASTAndCommonComment: false, | ||
}; | ||
Object.defineProperty(EmdaerFeatureFlags, 'override', { | ||
enumerable: false, | ||
writable: false, | ||
configurable: false, | ||
value(key, value) { | ||
this[key] = value; | ||
}, | ||
}); | ||
module.exports = EmdaerFeatureFlags; |
/* */ | ||
const unified = require('unified'); | ||
const parseHtml = require('rehype-parse'); | ||
const parseMarkdown = require('remark-parse'); | ||
const convertMarkdownToHtml = require('remark-rehype'); | ||
const minifyHtml = require('rehype-preset-minify'); | ||
const outputHtml = require('rehype-stringify'); | ||
const EmdaerFeatureFlags = require('./EmdaerFeatureFlags'); | ||
const addStamp = require('./util/addStamp'); | ||
@@ -10,13 +19,28 @@ const executePlugins = require('./util/executePlugins'); | ||
const transforms = await identifyTransforms(content); | ||
const contentWithPluginsExecuted = await executePlugins(content); | ||
const contentWithTransformsApplied = await applyTransforms( | ||
contentWithPluginsExecuted, | ||
transforms | ||
); | ||
const text = stamp | ||
? await addStamp(contentWithTransformsApplied, origin) | ||
: contentWithTransformsApplied; | ||
return text; | ||
let output; | ||
output = await executePlugins(content); | ||
if (EmdaerFeatureFlags.enableASTAndCommonComment) { | ||
output = await unified() | ||
.use(parseHtml) | ||
.use(parseMarkdown) | ||
.use(convertMarkdownToHtml) | ||
.use(minifyHtml) | ||
.use(outputHtml) | ||
.process(output) | ||
.then(String) | ||
.then(string => `${string}\n`); | ||
} | ||
output = await applyTransforms(output, transforms); | ||
if (stamp) { | ||
output = await addStamp(output, origin); | ||
} | ||
return output; | ||
} | ||
module.exports = emdaer; |
{ | ||
"name": "@emdaer/core", | ||
"description": "emdaer core", | ||
"version": "1.6.19", | ||
"version": "1.6.20", | ||
"repository": "emdaer/emdaer", | ||
@@ -16,3 +16,9 @@ "homepage": "https://emdaer.me/", | ||
"dependencies": { | ||
"js-yaml": "3.8.4" | ||
"js-yaml": "3.8.4", | ||
"rehype-parse": "4.0.0", | ||
"rehype-preset-minify": "2.0.0", | ||
"rehype-stringify": "3.0.0", | ||
"remark-parse": "4.0.0", | ||
"remark-rehype": "2.0.1", | ||
"unified": "6.1.5" | ||
}, | ||
@@ -19,0 +25,0 @@ "publishConfig": { |
/* @flow */ | ||
type FeatureFlags = {| | ||
enableASTParsing: boolean, | ||
enableCommonComment: boolean, | ||
export type FeatureFlags = {| | ||
override?: (string, boolean) => void, | ||
enableASTAndCommonComment: boolean, | ||
|}; | ||
const EmdaerFeatureFlags: FeatureFlags = { | ||
// Experimental AST parsing of Markdown files: | ||
enableASTParsing: false, | ||
// Experimental single comment type: | ||
enableCommonComment: false, | ||
// Experimental AST parsing of Markdown files and common comment type: | ||
enableASTAndCommonComment: false, | ||
}; | ||
Object.defineProperty(EmdaerFeatureFlags, 'override', { | ||
enumerable: false, | ||
writable: false, | ||
configurable: false, | ||
value(key, value) { | ||
this[key] = value; | ||
}, | ||
}); | ||
module.exports = EmdaerFeatureFlags; |
/* @flow */ | ||
const unified = require('unified'); | ||
const parseHtml = require('rehype-parse'); | ||
const parseMarkdown = require('remark-parse'); | ||
const convertMarkdownToHtml = require('remark-rehype'); | ||
const minifyHtml = require('rehype-preset-minify'); | ||
const outputHtml = require('rehype-stringify'); | ||
const EmdaerFeatureFlags = require('./EmdaerFeatureFlags'); | ||
const addStamp = require('./util/addStamp'); | ||
@@ -10,13 +19,28 @@ const executePlugins = require('./util/executePlugins'); | ||
const transforms = await identifyTransforms(content); | ||
const contentWithPluginsExecuted = await executePlugins(content); | ||
const contentWithTransformsApplied = await applyTransforms( | ||
contentWithPluginsExecuted, | ||
transforms | ||
); | ||
const text = stamp | ||
? await addStamp(contentWithTransformsApplied, origin) | ||
: contentWithTransformsApplied; | ||
return text; | ||
let output; | ||
output = await executePlugins(content); | ||
if (EmdaerFeatureFlags.enableASTAndCommonComment) { | ||
output = await unified() | ||
.use(parseHtml) | ||
.use(parseMarkdown) | ||
.use(convertMarkdownToHtml) | ||
.use(minifyHtml) | ||
.use(outputHtml) | ||
.process(output) | ||
.then(String) | ||
.then(string => `${string}\n`); | ||
} | ||
output = await applyTransforms(output, transforms); | ||
if (stamp) { | ||
output = await addStamp(output, origin); | ||
} | ||
return output; | ||
} | ||
module.exports = emdaer; |
@@ -15,6 +15,10 @@ /* eslint-disable import/no-unresolved, import/no-extraneous-dependencies */ | ||
jest.mock('./EmdaerFeatureFlags'); | ||
const emdaer = require('./'); | ||
const EmdaerFeatureFlags = require('./EmdaerFeatureFlags'); | ||
describe('@emdaer/core', () => { | ||
it('processes an .emdaer.md file', async () => { | ||
EmdaerFeatureFlags.enableASTAndCommonComment = false; | ||
expect( | ||
@@ -47,2 +51,3 @@ await emdaer( | ||
it('processes an .emdaer.md file without a stamp', async () => { | ||
EmdaerFeatureFlags.enableASTAndCommonComment = false; | ||
expect( | ||
@@ -69,2 +74,51 @@ await emdaer( | ||
}); | ||
describe('AST + CC', () => { | ||
it('processes an .emdaer.md file', async () => { | ||
EmdaerFeatureFlags.enableASTAndCommonComment = true; | ||
expect( | ||
await emdaer( | ||
'./.emdaer/README.emdaer.md', | ||
`# <!--emdaer-p | ||
- '@emdaer/plugin-foo' | ||
- a: 0 | ||
b: 1 | ||
c: 2 | ||
--> | ||
<!--emdaer-t | ||
- '@emdaer/transform-bar' | ||
--> | ||
` | ||
) | ||
).toBe(`<!-- | ||
This file was generated by emdaer | ||
Its template can be found at ./.emdaer/README.emdaer.md | ||
--> | ||
<h1>Hello, World!</h1> | ||
`); | ||
}); | ||
it('processes an .emdaer.md file without a stamp', async () => { | ||
EmdaerFeatureFlags.enableASTAndCommonComment = true; | ||
expect( | ||
await emdaer( | ||
'./.emdaer/README.emdaer.md', | ||
`# <!--emdaer-p | ||
- '@emdaer/plugin-foo' | ||
- a: 0 | ||
b: 1 | ||
c: 2 | ||
--> | ||
<!--emdaer-t | ||
- '@emdaer/transform-bar' | ||
--> | ||
`, | ||
false | ||
) | ||
).toBe(`<h1>Hello, World!</h1> | ||
`); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39268
41
776
7
287
+ Addedrehype-parse@4.0.0
+ Addedrehype-preset-minify@2.0.0
+ Addedrehype-stringify@3.0.0
+ Addedremark-parse@4.0.0
+ Addedremark-rehype@2.0.1
+ Addedunified@6.1.5
+ Added@types/node@22.9.0(transitive)
+ Addedarray-iterate@1.1.4(transitive)
+ Addedbail@1.0.5(transitive)
+ Addedcamelcase@3.0.0(transitive)
+ Addedccount@1.1.0(transitive)
+ Addedcharacter-entities@1.2.4(transitive)
+ Addedcharacter-entities-html4@1.1.4(transitive)
+ Addedcharacter-entities-legacy@1.1.4(transitive)
+ Addedcharacter-reference-invalid@1.1.4(transitive)
+ Addedclean-css@4.2.4(transitive)
+ Addedcollapse-white-space@1.0.6(transitive)
+ Addedcomma-separated-tokens@1.0.8(transitive)
+ Addeddetab@2.0.4(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedflatmap@0.0.3(transitive)
+ Addedhast-util-embedded@1.0.6(transitive)
+ Addedhast-util-from-parse5@2.1.0(transitive)
+ Addedhast-util-from-string@1.0.4(transitive)
+ Addedhast-util-has-property@1.0.4(transitive)
+ Addedhast-util-is-body-ok-link@1.0.4(transitive)
+ Addedhast-util-is-conditional-comment@1.0.4(transitive)
+ Addedhast-util-is-css-link@1.0.5(transitive)
+ Addedhast-util-is-css-style@1.0.5(transitive)
+ Addedhast-util-is-element@1.1.0(transitive)
+ Addedhast-util-is-event-handler@1.0.4(transitive)
+ Addedhast-util-is-javascript@1.0.5(transitive)
+ Addedhast-util-parse-selector@2.2.5(transitive)
+ Addedhast-util-to-html@3.1.0(transitive)
+ Addedhast-util-to-string@1.0.4(transitive)
+ Addedhast-util-whitespace@1.0.4(transitive)
+ Addedhastscript@3.1.0(transitive)
+ Addedhtml-url-attributes@1.0.3(transitive)
+ Addedhtml-void-elements@1.0.5(transitive)
+ Addedhtml-whitespace-sensitive-tag-names@1.0.3(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-alphabetical@1.0.4(transitive)
+ Addedis-alphanumerical@1.0.4(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-decimal@1.0.4(transitive)
+ Addedis-hexadecimal@1.0.4(transitive)
+ Addedis-plain-obj@1.1.0(transitive)
+ Addedis-whitespace-character@1.0.4(transitive)
+ Addedis-word-character@1.0.4(transitive)
+ Addedkebab-case@1.0.2(transitive)
+ Addedmarkdown-escapes@1.0.4(transitive)
+ Addedmdast-util-definitions@1.2.5(transitive)
+ Addedmdast-util-to-hast@2.5.0(transitive)
+ Addedmdurl@1.0.1(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedparse-entities@1.2.2(transitive)
+ Addedparse5@3.0.3(transitive)
+ Addedproperty-information@3.2.0(transitive)
+ Addedrehype-minify-attribute-whitespace@1.0.2(transitive)
+ Addedrehype-minify-css-style@1.1.1(transitive)
+ Addedrehype-minify-enumerated-attribute@1.0.1(transitive)
+ Addedrehype-minify-event-handler@1.1.1(transitive)
+ Addedrehype-minify-javascript-script@1.1.0(transitive)
+ Addedrehype-minify-javascript-url@1.1.0(transitive)
+ Addedrehype-minify-json-script@1.0.1(transitive)
+ Addedrehype-minify-media-attribute@1.1.1(transitive)
+ Addedrehype-minify-meta-color@1.1.1(transitive)
+ Addedrehype-minify-meta-content@1.0.2(transitive)
+ Addedrehype-minify-style-attribute@1.1.1(transitive)
+ Addedrehype-minify-whitespace@2.0.4(transitive)
+ Addedrehype-normalize-attribute-value-case@1.0.2(transitive)
+ Addedrehype-parse@4.0.0(transitive)
+ Addedrehype-preset-minify@2.0.0(transitive)
+ Addedrehype-remove-comments@2.0.2(transitive)
+ Addedrehype-remove-duplicate-attribute-values@1.0.2(transitive)
+ Addedrehype-remove-empty-attribute@1.0.2(transitive)
+ Addedrehype-remove-external-script-content@1.0.1(transitive)
+ Addedrehype-remove-meta-http-equiv@1.0.1(transitive)
+ Addedrehype-remove-script-type-javascript@1.0.1(transitive)
+ Addedrehype-remove-style-type-css@1.0.1(transitive)
+ Addedrehype-sort-attribute-values@1.0.1(transitive)
+ Addedrehype-sort-attributes@1.0.1(transitive)
+ Addedrehype-stringify@3.0.0(transitive)
+ Addedremark-parse@4.0.0(transitive)
+ Addedremark-rehype@2.0.1(transitive)
+ Addedrepeat-string@1.6.1(transitive)
+ Addedreplace-ext@1.0.0(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedspace-separated-tokens@1.1.5(transitive)
+ Addedstate-toggle@1.0.3(transitive)
+ Addedstringify-entities@1.3.2(transitive)
+ Addedtrim@0.0.11.0.01.0.1(transitive)
+ Addedtrim-lines@1.1.3(transitive)
+ Addedtrim-trailing-lines@1.1.4(transitive)
+ Addedtrough@1.0.5(transitive)
+ Addeduglify-js@3.19.3(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addedunherit@1.1.3(transitive)
+ Addedunified@6.1.5(transitive)
+ Addeduniq@1.0.1(transitive)
+ Addedunist-builder@1.0.4(transitive)
+ Addedunist-util-filter@1.0.2(transitive)
+ Addedunist-util-generated@1.1.6(transitive)
+ Addedunist-util-is@2.1.33.0.0(transitive)
+ Addedunist-util-modify-children@1.1.6(transitive)
+ Addedunist-util-position@3.1.0(transitive)
+ Addedunist-util-remove-position@1.1.4(transitive)
+ Addedunist-util-stringify-position@1.1.2(transitive)
+ Addedunist-util-visit@1.4.1(transitive)
+ Addedunist-util-visit-parents@2.1.2(transitive)
+ Addedvfile@2.3.0(transitive)
+ Addedvfile-location@2.0.6(transitive)
+ Addedvfile-message@1.1.1(transitive)
+ Addedx-is-array@0.1.0(transitive)
+ Addedx-is-function@1.0.4(transitive)
+ Addedx-is-string@0.1.0(transitive)
+ Addedxtend@4.0.2(transitive)