@ndla/article-converter 2.2.3 → 2.3.0

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.
@@ -0,0 +1,23 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ /**
8
+ * Copyright (c) 2023-present, NDLA.
9
+ *
10
+ * This source code is licensed under the GPLv3 license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ *
13
+ */
14
+
15
+ import { DefinitionDescription } from '@ndla/ui';
16
+ import { attributesToProps, domToReact } from 'html-react-parser';
17
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
18
+ export var ddPlugin = function ddPlugin(node, opts) {
19
+ var props = attributesToProps(node.attribs);
20
+ return _jsx(DefinitionDescription, _objectSpread(_objectSpread({}, props), {}, {
21
+ children: domToReact(node.children, opts)
22
+ }));
23
+ };
@@ -0,0 +1,23 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ /**
8
+ * Copyright (c) 2023-present, NDLA.
9
+ *
10
+ * This source code is licensed under the GPLv3 license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ *
13
+ */
14
+
15
+ import { DefinitionTerm } from '@ndla/ui';
16
+ import { attributesToProps, domToReact } from 'html-react-parser';
17
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
18
+ export var dtPlugin = function dtPlugin(node, opts) {
19
+ var props = attributesToProps(node.attribs);
20
+ return _jsx(DefinitionTerm, _objectSpread(_objectSpread({}, props), {}, {
21
+ children: domToReact(node.children, opts)
22
+ }));
23
+ };
@@ -23,6 +23,8 @@ import { divPlugin } from './divPlugin';
23
23
  import { tablePlugin } from './tablePlugin';
24
24
  import { asidePlugin } from './asidePlugin';
25
25
  import { ulPlugin } from './ulPlugin';
26
+ import { ddPlugin } from './ddPlugin';
27
+ import { dtPlugin } from './dtPlugin';
26
28
  export var basePlugins = {
27
29
  h2: copyParagraphPlugin,
28
30
  h3: h3Plugin,
@@ -33,7 +35,9 @@ export var basePlugins = {
33
35
  div: divPlugin,
34
36
  table: tablePlugin,
35
37
  aside: asidePlugin,
36
- ul: ulPlugin
38
+ ul: ulPlugin,
39
+ dd: ddPlugin,
40
+ dt: dtPlugin
37
41
  };
38
42
  export var oembedPlugins = _objectSpread(_objectSpread({}, basePlugins), {}, {
39
43
  a: anchorPlugin
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import { PluginType } from './types';
9
+ export declare const ddPlugin: PluginType;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ddPlugin = void 0;
7
+ var _ui = require("@ndla/ui");
8
+ var _htmlReactParser = require("html-react-parser");
9
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
11
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
13
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
15
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /**
16
+ * Copyright (c) 2023-present, NDLA.
17
+ *
18
+ * This source code is licensed under the GPLv3 license found in the
19
+ * LICENSE file in the root directory of this source tree.
20
+ *
21
+ */
22
+ var ddPlugin = function ddPlugin(node, opts) {
23
+ var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
24
+ return (0, _jsxRuntime.jsx)(_ui.DefinitionDescription, _objectSpread(_objectSpread({}, props), {}, {
25
+ children: (0, _htmlReactParser.domToReact)(node.children, opts)
26
+ }));
27
+ };
28
+ exports.ddPlugin = ddPlugin;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import { PluginType } from './types';
9
+ export declare const dtPlugin: PluginType;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.dtPlugin = void 0;
7
+ var _ui = require("@ndla/ui");
8
+ var _htmlReactParser = require("html-react-parser");
9
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
11
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
13
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
15
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /**
16
+ * Copyright (c) 2023-present, NDLA.
17
+ *
18
+ * This source code is licensed under the GPLv3 license found in the
19
+ * LICENSE file in the root directory of this source tree.
20
+ *
21
+ */
22
+ var dtPlugin = function dtPlugin(node, opts) {
23
+ var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
24
+ return (0, _jsxRuntime.jsx)(_ui.DefinitionTerm, _objectSpread(_objectSpread({}, props), {}, {
25
+ children: (0, _htmlReactParser.domToReact)(node.children, opts)
26
+ }));
27
+ };
28
+ exports.dtPlugin = dtPlugin;
@@ -15,6 +15,8 @@ var _divPlugin = require("./divPlugin");
15
15
  var _tablePlugin = require("./tablePlugin");
16
16
  var _asidePlugin = require("./asidePlugin");
17
17
  var _ulPlugin = require("./ulPlugin");
18
+ var _ddPlugin = require("./ddPlugin");
19
+ var _dtPlugin = require("./dtPlugin");
18
20
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
19
21
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
20
22
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -37,7 +39,9 @@ var basePlugins = {
37
39
  div: _divPlugin.divPlugin,
38
40
  table: _tablePlugin.tablePlugin,
39
41
  aside: _asidePlugin.asidePlugin,
40
- ul: _ulPlugin.ulPlugin
42
+ ul: _ulPlugin.ulPlugin,
43
+ dd: _ddPlugin.ddPlugin,
44
+ dt: _dtPlugin.dtPlugin
41
45
  };
42
46
  exports.basePlugins = basePlugins;
43
47
  var oembedPlugins = _objectSpread(_objectSpread({}, basePlugins), {}, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/article-converter",
3
- "version": "2.2.3",
3
+ "version": "2.3.0",
4
4
  "description": "Transforms NDLA articles into extended html versions",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -30,8 +30,8 @@
30
30
  "@ndla/types-embed": "^2.0.3"
31
31
  },
32
32
  "dependencies": {
33
- "@ndla/code": "^2.2.8",
34
- "@ndla/ui": "^39.0.3",
33
+ "@ndla/code": "^2.2.9",
34
+ "@ndla/ui": "^39.0.4",
35
35
  "html-react-parser": "^3.0.8",
36
36
  "lodash": "^4.17.20"
37
37
  },
@@ -44,5 +44,5 @@
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  },
47
- "gitHead": "b71ad26162a2a50f29bc6f5a77dba795acbac7f4"
47
+ "gitHead": "885332544d3bef48783a1d9f0b15213d9485b447"
48
48
  }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { DefinitionDescription } from '@ndla/ui';
10
+ import { attributesToProps, domToReact } from 'html-react-parser';
11
+ import { PluginType } from './types';
12
+
13
+ export const ddPlugin: PluginType = (node, opts) => {
14
+ const props = attributesToProps(node.attribs);
15
+
16
+ return <DefinitionDescription {...props}>{domToReact(node.children, opts)}</DefinitionDescription>;
17
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { DefinitionTerm } from '@ndla/ui';
10
+ import { attributesToProps, domToReact } from 'html-react-parser';
11
+ import { PluginType } from './types';
12
+
13
+ export const dtPlugin: PluginType = (node, opts) => {
14
+ const props = attributesToProps(node.attribs);
15
+
16
+ return <DefinitionTerm {...props}>{domToReact(node.children, opts)}</DefinitionTerm>;
17
+ };
@@ -18,6 +18,8 @@ import { divPlugin } from './divPlugin';
18
18
  import { tablePlugin } from './tablePlugin';
19
19
  import { asidePlugin } from './asidePlugin';
20
20
  import { ulPlugin } from './ulPlugin';
21
+ import { ddPlugin } from './ddPlugin';
22
+ import { dtPlugin } from './dtPlugin';
21
23
 
22
24
  export const basePlugins: Record<string, PluginType> = {
23
25
  h2: copyParagraphPlugin,
@@ -30,6 +32,8 @@ export const basePlugins: Record<string, PluginType> = {
30
32
  table: tablePlugin,
31
33
  aside: asidePlugin,
32
34
  ul: ulPlugin,
35
+ dd: ddPlugin,
36
+ dt: dtPlugin,
33
37
  };
34
38
 
35
39
  export const oembedPlugins: Record<string, PluginType> = {