@ndla/article-converter 6.0.15 → 6.0.16

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.
Files changed (76) hide show
  1. package/es/extractEmbedMeta.js +6 -10
  2. package/es/plugins/anchorPlugin.js +9 -12
  3. package/es/plugins/asidePlugin.js +1 -1
  4. package/es/plugins/copyParagraphPlugin.js +3 -4
  5. package/es/plugins/ddPlugin.js +5 -10
  6. package/es/plugins/divPlugin.js +16 -34
  7. package/es/plugins/dtPlugin.js +5 -10
  8. package/es/plugins/embed/KeyFigureEmbedPlugin.js +8 -7
  9. package/es/plugins/embed/audioEmbedPlugin.js +4 -5
  10. package/es/plugins/embed/blogPostEmbedPlugin.js +15 -15
  11. package/es/plugins/embed/brightcoveEmbedPlugin.js +4 -5
  12. package/es/plugins/embed/campaignBlockPlugin.js +4 -4
  13. package/es/plugins/embed/codeEmbedPlugin.js +3 -3
  14. package/es/plugins/embed/conceptEmbedPlugin.js +4 -5
  15. package/es/plugins/embed/conceptListEmbedPlugin.js +3 -3
  16. package/es/plugins/embed/contactBlockEmbedPlugin.js +13 -13
  17. package/es/plugins/embed/contentLinkEmbedPlugin.js +6 -4
  18. package/es/plugins/embed/externalEmbedPlugin.js +3 -3
  19. package/es/plugins/embed/fileEmbedPlugin.js +9 -8
  20. package/es/plugins/embed/footnoteEmbedPlugin.js +3 -3
  21. package/es/plugins/embed/h5pEmbedPlugin.js +3 -3
  22. package/es/plugins/embed/iframeEmbedPlugin.js +3 -3
  23. package/es/plugins/embed/imageEmbedPlugin.js +6 -7
  24. package/es/plugins/embed/index.js +1 -1
  25. package/es/plugins/embed/linkBlockEmbedPlugin.js +6 -11
  26. package/es/plugins/embed/relatedContentEmbedPlugin.js +3 -3
  27. package/es/plugins/h3Plugin.js +5 -10
  28. package/es/plugins/index.js +4 -9
  29. package/es/plugins/mathPlugin.js +8 -15
  30. package/es/plugins/navPlugin.js +5 -10
  31. package/es/plugins/oembed/anchorPlugin.js +9 -12
  32. package/es/plugins/olPlugin.js +9 -17
  33. package/es/plugins/paragraphPlugin.js +9 -16
  34. package/es/plugins/spanPlugin.js +6 -12
  35. package/es/plugins/tablePlugin.js +5 -10
  36. package/es/plugins/ulPlugin.js +6 -14
  37. package/es/transform.js +6 -6
  38. package/lib/extractEmbedMeta.js +7 -12
  39. package/lib/index.js +5 -6
  40. package/lib/plugins/anchorPlugin.js +17 -18
  41. package/lib/plugins/asidePlugin.js +1 -1
  42. package/lib/plugins/copyParagraphPlugin.js +3 -4
  43. package/lib/plugins/ddPlugin.js +13 -16
  44. package/lib/plugins/divPlugin.js +25 -41
  45. package/lib/plugins/dtPlugin.js +13 -16
  46. package/lib/plugins/embed/KeyFigureEmbedPlugin.js +8 -7
  47. package/lib/plugins/embed/audioEmbedPlugin.js +4 -5
  48. package/lib/plugins/embed/blogPostEmbedPlugin.js +15 -16
  49. package/lib/plugins/embed/brightcoveEmbedPlugin.js +4 -5
  50. package/lib/plugins/embed/campaignBlockPlugin.js +4 -4
  51. package/lib/plugins/embed/codeEmbedPlugin.js +3 -3
  52. package/lib/plugins/embed/conceptEmbedPlugin.js +4 -5
  53. package/lib/plugins/embed/conceptListEmbedPlugin.js +3 -3
  54. package/lib/plugins/embed/contactBlockEmbedPlugin.js +13 -13
  55. package/lib/plugins/embed/contentLinkEmbedPlugin.js +6 -4
  56. package/lib/plugins/embed/externalEmbedPlugin.js +3 -3
  57. package/lib/plugins/embed/fileEmbedPlugin.js +9 -8
  58. package/lib/plugins/embed/footnoteEmbedPlugin.js +3 -3
  59. package/lib/plugins/embed/h5pEmbedPlugin.js +3 -3
  60. package/lib/plugins/embed/iframeEmbedPlugin.js +3 -3
  61. package/lib/plugins/embed/imageEmbedPlugin.js +6 -7
  62. package/lib/plugins/embed/index.js +2 -3
  63. package/lib/plugins/embed/linkBlockEmbedPlugin.js +14 -17
  64. package/lib/plugins/embed/relatedContentEmbedPlugin.js +3 -3
  65. package/lib/plugins/h3Plugin.js +13 -16
  66. package/lib/plugins/index.js +12 -17
  67. package/lib/plugins/mathPlugin.js +9 -15
  68. package/lib/plugins/navPlugin.js +13 -16
  69. package/lib/plugins/oembed/anchorPlugin.js +17 -18
  70. package/lib/plugins/olPlugin.js +17 -23
  71. package/lib/plugins/paragraphPlugin.js +17 -22
  72. package/lib/plugins/spanPlugin.js +14 -18
  73. package/lib/plugins/tablePlugin.js +13 -16
  74. package/lib/plugins/ulPlugin.js +14 -20
  75. package/lib/transform.js +7 -8
  76. package/package.json +3 -3
@@ -19,19 +19,15 @@ var _ddPlugin = require("./ddPlugin");
19
19
  var _dtPlugin = require("./dtPlugin");
20
20
  var _navPlugin = require("./navPlugin");
21
21
  var _anchorPlugin2 = require("./anchorPlugin");
22
- 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); }
23
- 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; }
24
- 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; }
25
- 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; }
26
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
27
- 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); } /**
28
- * Copyright (c) 2023-present, NDLA.
29
- *
30
- * This source code is licensed under the GPLv3 license found in the
31
- * LICENSE file in the root directory of this source tree.
32
- *
33
- */
34
- var basePlugins = {
22
+ /**
23
+ * Copyright (c) 2023-present, NDLA.
24
+ *
25
+ * This source code is licensed under the GPLv3 license found in the
26
+ * LICENSE file in the root directory of this source tree.
27
+ *
28
+ */
29
+
30
+ const basePlugins = exports.basePlugins = {
35
31
  h2: _copyParagraphPlugin.copyParagraphPlugin,
36
32
  h3: _h3Plugin.h3Plugin,
37
33
  ol: _olPlugin.olPlugin,
@@ -47,8 +43,7 @@ var basePlugins = {
47
43
  nav: _navPlugin.navPlugin,
48
44
  a: _anchorPlugin2.anchorPlugin
49
45
  };
50
- exports.basePlugins = basePlugins;
51
- var oembedPlugins = _objectSpread(_objectSpread({}, basePlugins), {}, {
46
+ const oembedPlugins = exports.oembedPlugins = {
47
+ ...basePlugins,
52
48
  a: _anchorPlugin.anchorPlugin
53
- });
54
- exports.oembedPlugins = oembedPlugins;
49
+ };
@@ -1,13 +1,11 @@
1
1
  "use strict";
2
2
 
3
- 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); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.mathPlugin = void 0;
8
7
  var _htmlReactParser = require("html-react-parser");
9
8
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
- var _excluded = ["data-math"];
11
9
  /**
12
10
  * Copyright (c) 2023-present, NDLA.
13
11
  *
@@ -15,22 +13,18 @@ var _excluded = ["data-math"];
15
13
  * LICENSE file in the root directory of this source tree.
16
14
  *
17
15
  */
18
- 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; }
19
- 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; }
20
- 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; }
21
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
22
- 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); }
23
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
24
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
25
- var mathPlugin = function mathPlugin(node) {
26
- var _attributesToProps = (0, _htmlReactParser.attributesToProps)(node.attribs),
27
- mathContent = _attributesToProps['data-math'],
28
- props = _objectWithoutProperties(_attributesToProps, _excluded);
16
+
17
+ const mathPlugin = node => {
18
+ const {
19
+ 'data-math': mathContent,
20
+ ...props
21
+ } = (0, _htmlReactParser.attributesToProps)(node.attribs);
29
22
  // @ts-ignore
30
- return (0, _jsxRuntime.jsx)("math", _objectSpread(_objectSpread({}, props), {}, {
23
+ return (0, _jsxRuntime.jsx)("math", {
24
+ ...props,
31
25
  dangerouslySetInnerHTML: {
32
26
  __html: mathContent
33
27
  }
34
- }));
28
+ });
35
29
  };
36
30
  exports.mathPlugin = mathPlugin;
@@ -7,24 +7,21 @@ exports.navPlugin = void 0;
7
7
  var _htmlReactParser = require("html-react-parser");
8
8
  var _ui = require("@ndla/ui");
9
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 navPlugin = function navPlugin(node, opts) {
10
+ /**
11
+ * Copyright (c) 2023-present, NDLA.
12
+ *
13
+ * This source code is licensed under the GPLv3 license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ *
16
+ */
17
+
18
+ const navPlugin = (node, opts) => {
23
19
  if (node.attribs['data-type'] === 'link-block-list') {
24
- var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
25
- return (0, _jsxRuntime.jsx)(_ui.LinkBlockSection, _objectSpread(_objectSpread({}, props), {}, {
20
+ const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
21
+ return (0, _jsxRuntime.jsx)(_ui.LinkBlockSection, {
22
+ ...props,
26
23
  children: (0, _htmlReactParser.domToReact)(node.children, opts)
27
- }));
24
+ });
28
25
  }
29
26
  return null;
30
27
  };
@@ -9,27 +9,26 @@ var _ui = require("@ndla/ui");
9
9
  var _safelink = _interopRequireDefault(require("@ndla/safelink"));
10
10
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- 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); }
13
- 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; }
14
- 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; }
15
- 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; }
16
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
17
- 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); } /**
18
- * Copyright (c) 2023-present, NDLA.
19
- *
20
- * This source code is licensed under the GPLv3 license found in the
21
- * LICENSE file in the root directory of this source tree.
22
- *
23
- */
24
- var anchorPlugin = function anchorPlugin(node, options, _ref) {
25
- var path = _ref.path;
26
- var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
27
- var href = (0, _ui.getPossiblyRelativeUrl)(props.href, path);
28
- return (0, _jsxRuntime.jsx)(_safelink.default, _objectSpread(_objectSpread({}, props), {}, {
12
+ /**
13
+ * Copyright (c) 2023-present, NDLA.
14
+ *
15
+ * This source code is licensed under the GPLv3 license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ *
18
+ */
19
+
20
+ const anchorPlugin = (node, options, _ref) => {
21
+ let {
22
+ path
23
+ } = _ref;
24
+ const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
25
+ const href = (0, _ui.getPossiblyRelativeUrl)(props.href, path);
26
+ return (0, _jsxRuntime.jsx)(_safelink.default, {
27
+ ...props,
29
28
  target: "_blank",
30
29
  to: href,
31
30
  rel: "noreferrer",
32
31
  children: (0, _htmlReactParser.domToReact)(node.children, options)
33
- }));
32
+ });
34
33
  };
35
34
  exports.anchorPlugin = anchorPlugin;
@@ -7,31 +7,25 @@ exports.olPlugin = void 0;
7
7
  var _ui = require("@ndla/ui");
8
8
  var _htmlReactParser = require("html-react-parser");
9
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 olPlugin = function olPlugin(node, converterOpts, opts) {
23
- var _node$attribs$class;
24
- var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
25
- var letterClass = node.attribs['data-type'] === 'letters' ? 'ol-list--roman' : false;
26
- var num = node.attribs['start'];
27
- var numClass = num ? "ol-reset-".concat(num) : false;
28
- var classes = [(_node$attribs$class = node.attribs.class) !== null && _node$attribs$class !== void 0 ? _node$attribs$class : false, letterClass, numClass].filter(function (c) {
29
- return !!c;
30
- }).join(' ');
31
- return (0, _jsxRuntime.jsx)(_ui.OrderedList, _objectSpread(_objectSpread({}, props), {}, {
10
+ /**
11
+ * Copyright (c) 2023-present, NDLA.
12
+ *
13
+ * This source code is licensed under the GPLv3 license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ *
16
+ */
17
+
18
+ const olPlugin = (node, converterOpts, opts) => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
20
+ const letterClass = node.attribs['data-type'] === 'letters' ? 'ol-list--roman' : false;
21
+ const num = node.attribs['start'];
22
+ const numClass = num ? `ol-reset-${num}` : false;
23
+ const classes = [node.attribs.class ?? false, letterClass, numClass].filter(c => !!c).join(' ');
24
+ return (0, _jsxRuntime.jsx)(_ui.OrderedList, {
25
+ ...props,
32
26
  className: classes.length ? classes : undefined,
33
27
  lang: opts.articleLanguage,
34
28
  children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
35
- }));
29
+ });
36
30
  };
37
31
  exports.olPlugin = olPlugin;
@@ -6,35 +6,30 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.paragraphPlugin = void 0;
7
7
  var _htmlReactParser = require("html-react-parser");
8
8
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
9
- 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); }
10
- 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; }
11
- 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; }
12
- 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; }
13
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
14
- 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); } /**
15
- * Copyright (c) 2023-present, NDLA.
16
- *
17
- * This source code is licensed under the GPLv3 license found in the
18
- * LICENSE file in the root directory of this source tree.
19
- *
20
- */
21
- var paragraphPlugin = function paragraphPlugin(node, converterOpts, opts) {
22
- var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
9
+ /**
10
+ * Copyright (c) 2023-present, NDLA.
11
+ *
12
+ * This source code is licensed under the GPLv3 license found in the
13
+ * LICENSE file in the root directory of this source tree.
14
+ *
15
+ */
16
+
17
+ const paragraphPlugin = (node, converterOpts, opts) => {
18
+ const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
23
19
  if (node.attribs['data-align'] === 'center') {
24
- var _node$attribs$class;
25
- var classes = [(_node$attribs$class = node.attribs.class) !== null && _node$attribs$class !== void 0 ? _node$attribs$class : '', 'u-text-center'].filter(function (c) {
26
- return !!c;
27
- }).join(' ');
28
- return (0, _jsxRuntime.jsx)("p", _objectSpread(_objectSpread({}, props), {}, {
20
+ const classes = [node.attribs.class ?? '', 'u-text-center'].filter(c => !!c).join(' ');
21
+ return (0, _jsxRuntime.jsx)("p", {
22
+ ...props,
29
23
  lang: opts.articleLanguage,
30
24
  "data-align": undefined,
31
25
  className: classes,
32
26
  children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
33
- }));
27
+ });
34
28
  }
35
- return (0, _jsxRuntime.jsx)("p", _objectSpread(_objectSpread({}, props), {}, {
29
+ return (0, _jsxRuntime.jsx)("p", {
30
+ ...props,
36
31
  lang: opts.articleLanguage,
37
32
  children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
38
- }));
33
+ });
39
34
  };
40
35
  exports.paragraphPlugin = paragraphPlugin;
@@ -6,27 +6,23 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.spanPlugin = void 0;
7
7
  var _htmlReactParser = require("html-react-parser");
8
8
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
9
- 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); }
10
- 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; }
11
- 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; }
12
- 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; }
13
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
14
- 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); } /**
15
- * Copyright (c) 2023-present, NDLA.
16
- *
17
- * This source code is licensed under the GPLv3 license found in the
18
- * LICENSE file in the root directory of this source tree.
19
- *
20
- */
21
- var spanPlugin = function spanPlugin(node, opts) {
9
+ /**
10
+ * Copyright (c) 2023-present, NDLA.
11
+ *
12
+ * This source code is licensed under the GPLv3 license found in the
13
+ * LICENSE file in the root directory of this source tree.
14
+ *
15
+ */
16
+
17
+ const spanPlugin = (node, opts) => {
22
18
  if (node.attribs['data-size'] === 'large') {
23
- var _node$attribs$class;
24
- var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
25
- return (0, _jsxRuntime.jsx)("span", _objectSpread(_objectSpread({}, props), {}, {
19
+ const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
20
+ return (0, _jsxRuntime.jsx)("span", {
21
+ ...props,
26
22
  "data-size": undefined,
27
- className: "".concat((_node$attribs$class = node.attribs.class) !== null && _node$attribs$class !== void 0 ? _node$attribs$class : '', " u-large-body-text"),
23
+ className: `${node.attribs.class ?? ''} u-large-body-text`,
28
24
  children: (0, _htmlReactParser.domToReact)(node.children, opts)
29
- }));
25
+ });
30
26
  }
31
27
  return null;
32
28
  };
@@ -7,23 +7,20 @@ exports.tablePlugin = void 0;
7
7
  var _ui = require("@ndla/ui");
8
8
  var _htmlReactParser = require("html-react-parser");
9
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 tablePlugin = function tablePlugin(node, converterOpts, opts) {
23
- var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
24
- return (0, _jsxRuntime.jsx)(_ui.Table, _objectSpread(_objectSpread({}, props), {}, {
10
+ /**
11
+ * Copyright (c) 2023-present, NDLA.
12
+ *
13
+ * This source code is licensed under the GPLv3 license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ *
16
+ */
17
+
18
+ const tablePlugin = (node, converterOpts, opts) => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
20
+ return (0, _jsxRuntime.jsx)(_ui.Table, {
21
+ ...props,
25
22
  lang: opts.articleLanguage,
26
23
  children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
27
- }));
24
+ });
28
25
  };
29
26
  exports.tablePlugin = tablePlugin;
@@ -7,28 +7,22 @@ exports.ulPlugin = void 0;
7
7
  var _ui = require("@ndla/ui");
8
8
  var _htmlReactParser = require("html-react-parser");
9
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 ulPlugin = function ulPlugin(node, converterOpts, opts) {
23
- var _node$attribs$class;
24
- var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
25
- var classes = [(_node$attribs$class = node.attribs.class) !== null && _node$attribs$class !== void 0 ? _node$attribs$class : '', node.attribs['data-type'] === 'two-column' ? 'o-list--two-columns' : ''].filter(function (c) {
26
- return !!c;
27
- }).join(' ');
28
- return (0, _jsxRuntime.jsx)(_ui.UnOrderedList, _objectSpread(_objectSpread({}, props), {}, {
10
+ /**
11
+ * Copyright (c) 2023-present, NDLA.
12
+ *
13
+ * This source code is licensed under the GPLv3 license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ *
16
+ */
17
+
18
+ const ulPlugin = (node, converterOpts, opts) => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
20
+ const classes = [node.attribs.class ?? '', node.attribs['data-type'] === 'two-column' ? 'o-list--two-columns' : ''].filter(c => !!c).join(' ');
21
+ return (0, _jsxRuntime.jsx)(_ui.UnOrderedList, {
22
+ ...props,
29
23
  className: classes,
30
24
  lang: opts.articleLanguage,
31
25
  children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
32
- }));
26
+ });
33
27
  };
34
28
  exports.ulPlugin = ulPlugin;
package/lib/transform.js CHANGED
@@ -18,10 +18,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
18
18
  *
19
19
  */
20
20
 
21
- var transform = function transform(content, opts) {
22
- var plugins = opts !== null && opts !== void 0 && opts.isOembed ? _plugins.oembedPlugins : _plugins.basePlugins;
23
- var options = {
24
- replace: function replace(node) {
21
+ const transform = (content, opts) => {
22
+ const plugins = opts?.isOembed ? _plugins.oembedPlugins : _plugins.basePlugins;
23
+ const options = {
24
+ replace: node => {
25
25
  if (!('attribs' in node)) {
26
26
  return;
27
27
  }
@@ -32,7 +32,7 @@ var transform = function transform(content, opts) {
32
32
  if (_embed.embedPlugins[node.attribs['data-resource']]) {
33
33
  return _embed.embedPlugins[node.attribs['data-resource']](node, options, opts);
34
34
  } else {
35
- var embed = JSON.parse(node.attribs['data-json']);
35
+ const embed = JSON.parse(node.attribs['data-json']);
36
36
  return (0, _jsxRuntime.jsx)(_ui.UnknownEmbed, {
37
37
  embed: embed
38
38
  });
@@ -40,8 +40,7 @@ var transform = function transform(content, opts) {
40
40
  }
41
41
  }
42
42
  };
43
- var replaced = (0, _htmlReactParser.default)(content, options);
43
+ const replaced = (0, _htmlReactParser.default)(content, options);
44
44
  return replaced;
45
45
  };
46
- var _default = transform;
47
- exports.default = _default;
46
+ var _default = exports.default = transform;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/article-converter",
3
- "version": "6.0.15",
3
+ "version": "6.0.16",
4
4
  "description": "Transforms NDLA articles into extended html versions",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@ndla/code": "^5.0.18",
35
- "@ndla/ui": "^50.1.1",
35
+ "@ndla/ui": "^50.1.2",
36
36
  "html-react-parser": "^4.2.2",
37
37
  "lodash": "^4.17.20"
38
38
  },
@@ -48,5 +48,5 @@
48
48
  "publishConfig": {
49
49
  "access": "public"
50
50
  },
51
- "gitHead": "4ef777000ee1a3e080e03e7ef32521abf6d7d0fd"
51
+ "gitHead": "a3aad57d56edabe22d550adb5fda8af5ab6c8b6f"
52
52
  }