@adobe/helix-markdown-support 2.0.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  version: 2.1
2
2
  executors:
3
- node12:
3
+ node14:
4
4
  docker:
5
- - image: circleci/node:12
5
+ - image: circleci/node:14
6
6
  environment:
7
7
  NPM_CONFIG_PREFIX: ~/.npm-global
8
8
 
@@ -29,7 +29,7 @@ commands:
29
29
 
30
30
  jobs:
31
31
  build:
32
- executor: node12
32
+ executor: node14
33
33
 
34
34
  steps:
35
35
  - setup
package/.eslintrc.cjs ADDED
@@ -0,0 +1,27 @@
1
+ /*
2
+ * Copyright 2019 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ module.exports = {
14
+ root: true,
15
+ extends: '@adobe/helix',
16
+ env: {
17
+ node: true,
18
+ es6: true,
19
+ },
20
+ parserOptions: {
21
+ sourceType: 'module',
22
+ ecmaVersion: 2020,
23
+ },
24
+ rules: {
25
+ 'import/extensions': 0,
26
+ },
27
+ };
@@ -10,10 +10,10 @@ jobs:
10
10
  if: "!contains(github.event.head_commit.message, '[skip ci]')"
11
11
  steps:
12
12
  - uses: actions/checkout@v2
13
- - name: Use Node.js 12.x
13
+ - name: Use Node.js 14.x
14
14
  uses: actions/setup-node@v2
15
15
  with:
16
- node-version: '12.x'
16
+ node-version: '14.x'
17
17
  - run: npm install
18
18
  - run: npm test
19
19
  - run: npm run semantic-release
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npx lint-staged
@@ -0,0 +1,6 @@
1
+ {
2
+ "reporterEnabled": "spec,xunit",
3
+ "xunitReporterOptions": {
4
+ "output": "junit/test-results.xml"
5
+ }
6
+ }
package/.releaserc.cjs ADDED
@@ -0,0 +1,16 @@
1
+ module.exports = {
2
+ plugins: [
3
+ "@semantic-release/commit-analyzer",
4
+ "@semantic-release/release-notes-generator",
5
+ ["@semantic-release/changelog", {
6
+ "changelogFile": "CHANGELOG.md",
7
+ }],
8
+ "@semantic-release/npm",
9
+ ["@semantic-release/git", {
10
+ "assets": ["package.json", "CHANGELOG.md"],
11
+ "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
12
+ }],
13
+ ["@semantic-release/github", {}]
14
+ ],
15
+ branches: [ 'main' ],
16
+ };
package/CHANGELOG.md CHANGED
@@ -1,3 +1,36 @@
1
+ ## [3.1.1](https://github.com/adobe/helix-markdown-support/compare/v3.1.0...v3.1.1) (2022-01-15)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update external fixes ([791a84b](https://github.com/adobe/helix-markdown-support/commit/791a84b8c3ac94b745522668ffac59e10b98a4c2))
7
+
8
+ # [3.1.0](https://github.com/adobe/helix-markdown-support/compare/v3.0.0...v3.1.0) (2022-01-14)
9
+
10
+
11
+ ### Features
12
+
13
+ * improve sanitize-headings to move leading images before heading ([292dc72](https://github.com/adobe/helix-markdown-support/commit/292dc72dbe43def0d97e8f1c528eeb065b3bff12)), closes [#83](https://github.com/adobe/helix-markdown-support/issues/83)
14
+
15
+ # [3.0.0](https://github.com/adobe/helix-markdown-support/compare/v2.0.1...v3.0.0) (2021-12-07)
16
+
17
+
18
+ ### Features
19
+
20
+ * convert to esm ([0b5e09b](https://github.com/adobe/helix-markdown-support/commit/0b5e09bac1e7e26128d7af8f25c85eadc82ff56c))
21
+
22
+
23
+ ### BREAKING CHANGES
24
+
25
+ * only esm supported
26
+
27
+ ## [2.0.1](https://github.com/adobe/helix-markdown-support/compare/v2.0.0...v2.0.1) (2021-07-23)
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * allow html in table cells ([9afe468](https://github.com/adobe/helix-markdown-support/commit/9afe468057101b28d17ae218f45666e1ec9829c6))
33
+
1
34
  # [2.0.0](https://github.com/adobe/helix-markdown-support/compare/v1.5.0...v2.0.0) (2021-06-09)
2
35
 
3
36
 
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "@adobe/helix-markdown-support",
3
- "version": "2.0.0",
3
+ "version": "3.1.1",
4
4
  "description": "Helix Markdown Support",
5
+ "type": "module",
5
6
  "scripts": {
6
- "test": " nyc mocha",
7
- "test-ci": "nyc mocha --reporter xunit --reporter-options output=./junit/test-results.xml && codecov",
7
+ "test": " c8 mocha",
8
+ "test-ci": "c8 mocha && codecov",
8
9
  "lint": "eslint .",
9
- "semantic-release": "semantic-release"
10
+ "semantic-release": "semantic-release",
11
+ "prepare": "husky install"
10
12
  },
11
13
  "repository": {
12
14
  "type": "git",
@@ -20,47 +22,44 @@
20
22
  "homepage": "https://github.com/adobe/helix-markdown-support#readme",
21
23
  "main": "src/index.js",
22
24
  "dependencies": {
23
- "hast-util-to-html": "7.1.3",
25
+ "hast-util-to-html": "8.0.3",
24
26
  "js-yaml": "4.1.0",
25
- "mdast-util-to-hast": "10.2.0",
27
+ "mdast-util-to-hast": "12.1.0",
26
28
  "unist-util-find": "1.0.2",
27
- "unist-util-visit": "2.0.3"
29
+ "unist-util-visit": "4.1.0"
30
+ },
31
+ "mocha": {
32
+ "spec": "test/**/*.test.js",
33
+ "recursive": "true",
34
+ "reporter": "mocha-multi-reporters",
35
+ "reporter-options": "configFile=.mocha-multi.json"
28
36
  },
29
37
  "peerDependencies": {
30
- "unified": "9.x"
38
+ "unified": "10.x"
31
39
  },
32
40
  "devDependencies": {
33
- "@adobe/eslint-config-helix": "1.1.5",
34
- "@semantic-release/changelog": "5.0.1",
35
- "@semantic-release/git": "9.0.0",
36
- "@semantic-release/npm": "7.1.3",
37
- "ajv": "8.5.0",
38
- "codecov": "3.8.2",
39
- "commitizen": "4.2.4",
40
- "cz-conventional-changelog": "3.3.0",
41
- "eslint": "7.28.0",
41
+ "@adobe/eslint-config-helix": "1.3.2",
42
+ "@semantic-release/changelog": "6.0.1",
43
+ "@semantic-release/git": "10.0.1",
44
+ "c8": "7.11.0",
45
+ "codecov": "3.8.3",
46
+ "eslint": "8.6.0",
42
47
  "eslint-plugin-header": "3.1.1",
43
- "eslint-plugin-import": "2.23.4",
44
- "fs-extra": "10.0.0",
45
- "ghooks": "2.0.4",
48
+ "eslint-plugin-import": "2.25.4",
49
+ "husky": "7.0.4",
46
50
  "junit-report-builder": "3.0.0",
47
- "lint-staged": "11.0.0",
51
+ "lint-staged": "12.1.7",
48
52
  "mdast-builder": "1.1.1",
49
- "mocha": "9.0.0",
50
- "nyc": "15.1.0",
51
- "remark-gfm": "1.0.0",
52
- "remark-parse": "9.0.0",
53
- "remark-stringify": "9.0.1",
54
- "semantic-release": "17.4.3",
55
- "unified": "9.2.1",
56
- "unist-util-inspect": "6.0.1"
53
+ "mocha": "9.1.4",
54
+ "mocha-multi-reporters": "1.5.1",
55
+ "remark-gfm": "3.0.1",
56
+ "remark-parse": "10.0.1",
57
+ "remark-stringify": "10.0.2",
58
+ "semantic-release": "18.0.1",
59
+ "unified": "10.1.1",
60
+ "unist-util-inspect": "7.0.0"
57
61
  },
58
62
  "lint-staged": {
59
63
  "*.js": "eslint"
60
- },
61
- "config": {
62
- "ghooks": {
63
- "pre-commit": "npx lint-staged"
64
- }
65
64
  }
66
65
  }
package/src/index.js CHANGED
@@ -10,24 +10,12 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- const remarkMatter = require('./remark-matter');
14
- const robustTables = require('./mdast-robust-tables.js');
15
- const breaksAsSpaces = require('./remark-breaks-as-spaces.js');
16
- const sanitizeHeading = require('./mdast-sanitize-heading.js');
17
- const suppressSpaceCode = require('./mdast-suppress-spacecode.js');
18
- const sanitizeFormats = require('./mdast-sanitize-formats.js');
19
- const fixCodeFlow = require('./mdast-fix-code-flow.js');
20
- const sanitizeLinks = require('./mdast-sanitize-links.js');
21
- const sanitizeText = require('./mdast-sanitize-text.js');
22
-
23
- module.exports = {
24
- remarkMatter,
25
- robustTables,
26
- breaksAsSpaces,
27
- sanitizeHeading,
28
- suppressSpaceCode,
29
- sanitizeFormats,
30
- fixCodeFlow,
31
- sanitizeLinks,
32
- sanitizeText,
33
- };
13
+ export { default as remarkMatter } from './remark-matter/index.js';
14
+ export { default as robustTables } from './mdast-robust-tables.js';
15
+ export { default as breaksAsSpaces } from './remark-breaks-as-spaces.js';
16
+ export { default as sanitizeHeading } from './mdast-sanitize-heading.js';
17
+ export { default as suppressSpaceCode } from './mdast-suppress-spacecode.js';
18
+ export { default as sanitizeFormats } from './mdast-sanitize-formats.js';
19
+ export { default as fixCodeFlow } from './mdast-fix-code-flow.js';
20
+ export { default as sanitizeLinks } from './mdast-sanitize-links.js';
21
+ export { default as sanitizeText } from './mdast-sanitize-text.js';
@@ -10,7 +10,7 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
  /* eslint-disable no-param-reassign */
13
- const visit = require('unist-util-visit');
13
+ import { visit, CONTINUE } from 'unist-util-visit';
14
14
 
15
15
  /**
16
16
  * ensures that `code` is at a flow level. i.e. outside a paragraph
@@ -18,7 +18,7 @@ const visit = require('unist-util-visit');
18
18
  * @param {object} tree
19
19
  * @returns {object} The modified (original) tree.
20
20
  */
21
- function fixCodeFlow(tree) {
21
+ export default function fixCodeFlow(tree) {
22
22
  visit(tree, (node, index, parent) => {
23
23
  if (node.type === 'paragraph' && node.children) {
24
24
  for (let i = 0; i < node.children.length; i += 1) {
@@ -50,9 +50,7 @@ function fixCodeFlow(tree) {
50
50
  }
51
51
  }
52
52
  // return index;
53
- return visit.CONTINUE;
53
+ return CONTINUE;
54
54
  });
55
55
  return tree;
56
56
  }
57
-
58
- module.exports = fixCodeFlow;
@@ -10,9 +10,9 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
  /* eslint-disable no-param-reassign */
13
- const md2hast = require('mdast-util-to-hast');
14
- const hast2html = require('hast-util-to-html');
15
- const visit = require('unist-util-visit');
13
+ import { toHast as md2hast } from 'mdast-util-to-hast';
14
+ import { toHtml as hast2html } from 'hast-util-to-html';
15
+ import { visit, CONTINUE } from 'unist-util-visit';
16
16
 
17
17
  /**
18
18
  * Converts tables to HTML
@@ -20,17 +20,15 @@ const visit = require('unist-util-visit');
20
20
  * @param {object} tree
21
21
  * @returns {object} The modified (original) tree.
22
22
  */
23
- function robustTables(tree) {
23
+ export default function robustTables(tree) {
24
24
  visit(tree, (node) => {
25
25
  if (node.type !== 'table') {
26
- return visit.CONTINUE;
26
+ return CONTINUE;
27
27
  }
28
28
  let html = '<table>\n';
29
- /* istanbul ignore next */
30
- (node.children || []).forEach((row) => {
29
+ (node.children /* c8 ignore next */ || []).forEach((row) => {
31
30
  html += ' <tr>\n';
32
- /* istanbul ignore next */
33
- (row.children || []).forEach((cell) => {
31
+ (row.children /* c8 ignore next */ || []).forEach((cell) => {
34
32
  let align = '';
35
33
  if (cell.align === 'right') {
36
34
  align = ' align="right"';
@@ -52,14 +50,17 @@ function robustTables(tree) {
52
50
  children = children[0].children;
53
51
  }
54
52
 
55
- /* istanbul ignore next */
56
- (children || []).forEach((child) => {
57
- const cellHtml = hast2html(md2hast(child));
58
- if (child.type === 'code') {
59
- // code needs special treatment, otherwise the newlines disappear.
60
- html += cellHtml.replace(/\r?\n/g, '<br>');
53
+ (children /* c8 ignore next */ || []).forEach((child) => {
54
+ if (child.type === 'html') {
55
+ html += child.value;
61
56
  } else {
62
- html += cellHtml.replace(/\r?\n/g, ' ');
57
+ const cellHtml = hast2html(md2hast(child));
58
+ if (child.type === 'code') {
59
+ // code needs special treatment, otherwise the newlines disappear.
60
+ html += cellHtml.replace(/\r?\n/g, '<br>');
61
+ } else {
62
+ html += cellHtml.replace(/\r?\n/g, ' ');
63
+ }
63
64
  }
64
65
  });
65
66
  html += '</td>\n';
@@ -70,9 +71,7 @@ function robustTables(tree) {
70
71
  node.type = 'html';
71
72
  node.value = html;
72
73
  delete node.children;
73
- return visit.CONTINUE;
74
+ return CONTINUE;
74
75
  });
75
76
  return tree;
76
77
  }
77
-
78
- module.exports = robustTables;
@@ -9,7 +9,7 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- const visit = require('unist-util-visit');
12
+ import { visit, CONTINUE } from 'unist-util-visit';
13
13
 
14
14
  /**
15
15
  * Sanitizes text:
@@ -19,7 +19,7 @@ const visit = require('unist-util-visit');
19
19
  * @param {object} tree
20
20
  * @returns {object} The modified (original) tree.
21
21
  */
22
- function sanitizeFormats(tree) {
22
+ export default function sanitizeFormats(tree) {
23
23
  visit(tree, (node, index, parent) => {
24
24
  const { children: siblings = [] } = parent || {};
25
25
  const { children } = node;
@@ -43,9 +43,7 @@ function sanitizeFormats(tree) {
43
43
  }
44
44
  }
45
45
  }
46
- return visit.CONTINUE;
46
+ return CONTINUE;
47
47
  });
48
48
  return tree;
49
49
  }
50
-
51
- module.exports = sanitizeFormats;
@@ -9,42 +9,53 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- const visit = require('unist-util-visit');
12
+ import { visit } from 'unist-util-visit';
13
13
 
14
14
  /**
15
15
  * Sanitizes headings:
16
- * - (re)move images
16
+ * - (re)move images ('before', 'both', 'after')
17
17
  *
18
18
  * @param {object} tree
19
+ * @param {object} [opts] options
20
+ * @param {string} [opts.imageHandling] specifies how images are handled. defaults to 'after'.
19
21
  * @returns {object} The modified (original) tree.
20
22
  */
21
- function sanitizeHeading(tree) {
23
+ export default function sanitizeHeading(tree, opts = {}) {
24
+ const { imageHandling = 'after' } = opts;
22
25
  visit(tree, (node, index, parent) => {
23
26
  const { children: siblings = [] } = parent || {};
24
27
  const { children = [] } = node;
28
+ let after = index + 1;
25
29
  if (node.type === 'heading') {
26
30
  for (let i = 0; i < children.length; i += 1) {
27
31
  const child = children[i];
28
32
  if (child.type === 'image') {
29
- // move after heading
30
- children.splice(i, 1);
31
- i -= 1;
32
33
  const para = {
33
34
  type: 'paragraph',
34
35
  children: [child],
35
36
  };
36
- siblings.splice(index + 1, 0, para);
37
+ children.splice(i, 1);
38
+ i -= 1;
39
+ if ((i < 0 && imageHandling !== 'after') || imageHandling === 'before') {
40
+ // move before heading
41
+ siblings.splice(index, 0, para);
42
+ // eslint-disable-next-line no-param-reassign
43
+ index += 1;
44
+ after = index + 1;
45
+ } else {
46
+ // move after heading
47
+ siblings.splice(after, 0, para);
48
+ after += 1;
49
+ }
37
50
  }
38
51
  }
39
52
  // remove empty headings
40
53
  if (!children.length) {
41
54
  siblings.splice(index, 1);
42
- return index;
55
+ after -= 1;
43
56
  }
44
57
  }
45
- return visit.CONTINUE;
58
+ return after;
46
59
  });
47
60
  return tree;
48
61
  }
49
-
50
- module.exports = sanitizeHeading;
@@ -9,8 +9,8 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- const visit = require('unist-util-visit');
13
- const find = require('unist-util-find');
12
+ import { visit, CONTINUE } from 'unist-util-visit';
13
+ import find from 'unist-util-find';
14
14
 
15
15
  /**
16
16
  * Sanitizes links:
@@ -19,7 +19,7 @@ const find = require('unist-util-find');
19
19
  * @param {object} tree
20
20
  * @returns {object} The modified (original) tree.
21
21
  */
22
- function sanitizeLinks(tree) {
22
+ export default function sanitizeLinks(tree) {
23
23
  visit(tree, (node, index, parent) => {
24
24
  const { children = [] } = node;
25
25
  if (node.type === 'link' && children.length === 1) {
@@ -61,9 +61,7 @@ function sanitizeLinks(tree) {
61
61
  }
62
62
  }
63
63
  }
64
- return visit.CONTINUE;
64
+ return CONTINUE;
65
65
  });
66
66
  return tree;
67
67
  }
68
-
69
- module.exports = sanitizeLinks;
@@ -9,7 +9,7 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- const visit = require('unist-util-visit');
12
+ import { visit, CONTINUE } from 'unist-util-visit';
13
13
 
14
14
  /**
15
15
  * Sanitizes text:
@@ -22,7 +22,7 @@ const visit = require('unist-util-visit');
22
22
  * @param {object} tree
23
23
  * @returns {object} The modified (original) tree.
24
24
  */
25
- function sanitizeText(tree) {
25
+ export default function sanitizeText(tree) {
26
26
  visit(tree, (node, index, parent) => {
27
27
  const { children: siblings = [] } = parent || {};
28
28
  const { children = [] } = node;
@@ -107,9 +107,7 @@ function sanitizeText(tree) {
107
107
  }
108
108
  }
109
109
  }
110
- return visit.CONTINUE;
110
+ return CONTINUE;
111
111
  });
112
112
  return tree;
113
113
  }
114
-
115
- module.exports = sanitizeText;
@@ -9,7 +9,7 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- const visit = require('unist-util-visit');
12
+ import { visit, CONTINUE } from 'unist-util-visit';
13
13
 
14
14
  /**
15
15
  * Looks for text starting with 4 spaces. As this would render as code in some markdown,
@@ -18,7 +18,7 @@ const visit = require('unist-util-visit');
18
18
  * @param {object} tree
19
19
  * @returns {object} The modified (original) tree.
20
20
  */
21
- function suppressSpaceCode(tree) {
21
+ export default function suppressSpaceCode(tree) {
22
22
  visit(tree, (child, index, parent) => {
23
23
  const { children } = parent || {};
24
24
  if (child.type === 'text'
@@ -27,9 +27,7 @@ function suppressSpaceCode(tree) {
27
27
  // eslint-disable-next-line no-param-reassign
28
28
  child.value = child.value.replace(/^\s+/, ' ');
29
29
  }
30
- return visit.CONTINUE;
30
+ return CONTINUE;
31
31
  });
32
32
  return tree;
33
33
  }
34
-
35
- module.exports = suppressSpaceCode;
@@ -13,7 +13,7 @@
13
13
  /**
14
14
  * Remark extension that handles soft-breaks correctly.
15
15
  */
16
- function softBreak() {
16
+ export default function softBreak() {
17
17
  function handleBreak(node, _, context) {
18
18
  if (context.stack.indexOf('tableCell') !== -1) {
19
19
  return ' ';
@@ -31,5 +31,3 @@ function softBreak() {
31
31
  },
32
32
  });
33
33
  }
34
-
35
- module.exports = softBreak;
@@ -9,7 +9,7 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- const jsYaml = require('js-yaml');
12
+ import jsYaml from 'js-yaml';
13
13
 
14
14
  function open(token) {
15
15
  this.enter({ type: 'yaml', value: '', payload: {} }, token);
@@ -38,7 +38,7 @@ function value(token) {
38
38
  }
39
39
 
40
40
  // eslint-disable-next-line no-unused-vars
41
- function fromMarkdown(options = {}) {
41
+ export default function fromMarkdown(options = {}) {
42
42
  return {
43
43
  enter: {
44
44
  yaml: open,
@@ -49,5 +49,3 @@ function fromMarkdown(options = {}) {
49
49
  },
50
50
  };
51
51
  }
52
-
53
- module.exports = fromMarkdown;
@@ -9,9 +9,9 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- const fromMarkdown = require('./from-markdown.js');
13
- const toMarkdown = require('./to-markdown.js');
14
- const syntax = require('./syntax.js');
12
+ import fromMarkdown from './from-markdown.js';
13
+ import toMarkdown from './to-markdown.js';
14
+ import syntax from './syntax.js';
15
15
 
16
16
  /**
17
17
  * Front- and mid-matter remark plugin.
@@ -83,11 +83,11 @@ const syntax = require('./syntax.js');
83
83
  * @param {object} options Plugin options
84
84
  * @param {Function} options.errorHandler Function that is invoked on yaml parsing errors.
85
85
  */
86
- function matterPlugin(options) {
86
+ export default function matterPlugin(options) {
87
87
  const data = this.data();
88
88
 
89
89
  function add(field, value) {
90
- /* istanbul ignore next */
90
+ /* c8 ignore next 2 */
91
91
  if (data[field]) {
92
92
  data[field].push(value);
93
93
  } else {
@@ -99,5 +99,3 @@ function matterPlugin(options) {
99
99
  add('fromMarkdownExtensions', fromMarkdown(options));
100
100
  add('toMarkdownExtensions', toMarkdown(options));
101
101
  }
102
-
103
- module.exports = matterPlugin;
@@ -10,7 +10,7 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
  /* eslint-disable no-use-before-define */
13
- const jsYaml = require('js-yaml');
13
+ import jsYaml from 'js-yaml';
14
14
 
15
15
  const type = (v) => ((v !== undefined && v !== null) ? v.constructor : v);
16
16
 
@@ -33,11 +33,9 @@ function validYaml(str, errorHandler) {
33
33
  if (Array.isArray(payload)) {
34
34
  payloadType = 'Array';
35
35
  }
36
- errorHandler(
37
- 'Found ambiguous frontmatter block: Block contains valid yaml, but '
36
+ errorHandler('Found ambiguous frontmatter block: Block contains valid yaml, but '
38
37
  + `it's data type is "${payloadType}" instead of Object. `
39
- + 'Make sure your yaml blocks contain only key-value pairs at the root level!', str,
40
- );
38
+ + 'Make sure your yaml blocks contain only key-value pairs at the root level!', str);
41
39
  }
42
40
  return false;
43
41
  }
@@ -265,12 +263,10 @@ function parse(options) {
265
263
  }
266
264
  }
267
265
 
268
- function create(options = {}) {
266
+ export default function create(options = {}) {
269
267
  return {
270
268
  flow: {
271
269
  [CODE_DASH]: [parse(options)],
272
270
  },
273
271
  };
274
272
  }
275
-
276
- module.exports = create;
@@ -9,12 +9,10 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- function toMarkdown() {
12
+ export default function toMarkdown() {
13
13
  return {
14
14
  handlers: {
15
15
  yaml: (node) => `---\n${node.value.trim()}\n---`,
16
16
  },
17
17
  };
18
18
  }
19
-
20
- module.exports = toMarkdown;