@ndla/article-converter 10.0.133-alpha.0 → 10.0.135-alpha.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.
@@ -1,16 +1,17 @@
1
- import { attributesToProps } from "html-react-parser";
1
+ import { attributesToProps, domToReact } from "html-react-parser";
2
2
  import { ConceptEmbed } from "@ndla/ui";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
 
5
5
  //#region src/plugins/embed/conceptEmbedPlugin.tsx
6
- const conceptEmbedPlugin = (element, _, opts) => {
6
+ const conceptEmbedPlugin = (element, parserOpts, transformOpts) => {
7
7
  const props = attributesToProps(element.attribs);
8
8
  const data = JSON.parse(props["data-json"]);
9
9
  return /* @__PURE__ */ jsx(ConceptEmbed, {
10
10
  embed: data,
11
- lang: opts.articleLanguage,
12
- renderContext: opts.renderContext,
13
- previewAlt: opts.previewAlt
11
+ lang: transformOpts.articleLanguage,
12
+ renderContext: transformOpts.renderContext,
13
+ previewAlt: transformOpts.previewAlt,
14
+ children: domToReact(element.children, parserOpts)
14
15
  });
15
16
  };
16
17
 
@@ -1 +1 @@
1
- {"version":3,"file":"conceptEmbedPlugin.js","names":["conceptEmbedPlugin: PluginType"],"sources":["../../../src/plugins/embed/conceptEmbedPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { attributesToProps } from \"html-react-parser\";\nimport { type ConceptMetaData } from \"@ndla/types-embed\";\nimport { ConceptEmbed } from \"@ndla/ui\";\nimport { type PluginType } from \"../types\";\n\nexport const conceptEmbedPlugin: PluginType = (element, _, opts) => {\n const props = attributesToProps(element.attribs);\n const data = JSON.parse(props[\"data-json\"] as string) as ConceptMetaData;\n return (\n <ConceptEmbed\n embed={data}\n lang={opts.articleLanguage}\n renderContext={opts.renderContext}\n previewAlt={opts.previewAlt}\n />\n );\n};\n"],"mappings":";;;;;AAaA,MAAaA,qBAAiC,CAAC,SAAS,GAAG,SAAS;CAClE,MAAM,QAAQ,kBAAkB,QAAQ,QAAQ;CAChD,MAAM,OAAO,KAAK,MAAM,MAAM,aAAuB;AACrD,wBACE,IAAC;EACC,OAAO;EACP,MAAM,KAAK;EACX,eAAe,KAAK;EACpB,YAAY,KAAK;GACjB;AAEL"}
1
+ {"version":3,"file":"conceptEmbedPlugin.js","names":["conceptEmbedPlugin: PluginType"],"sources":["../../../src/plugins/embed/conceptEmbedPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { attributesToProps, domToReact, type DOMNode } from \"html-react-parser\";\nimport { type ConceptMetaData } from \"@ndla/types-embed\";\nimport { ConceptEmbed } from \"@ndla/ui\";\nimport { type PluginType } from \"../types\";\n\nexport const conceptEmbedPlugin: PluginType = (element, parserOpts, transformOpts) => {\n const props = attributesToProps(element.attribs);\n const data = JSON.parse(props[\"data-json\"] as string) as ConceptMetaData;\n return (\n <ConceptEmbed\n embed={data}\n lang={transformOpts.articleLanguage}\n renderContext={transformOpts.renderContext}\n previewAlt={transformOpts.previewAlt}\n >\n {domToReact(element.children as DOMNode[], parserOpts)}\n </ConceptEmbed>\n );\n};\n"],"mappings":";;;;;AAaA,MAAaA,qBAAiC,CAAC,SAAS,YAAY,kBAAkB;CACpF,MAAM,QAAQ,kBAAkB,QAAQ,QAAQ;CAChD,MAAM,OAAO,KAAK,MAAM,MAAM,aAAuB;AACrD,wBACE,IAAC;EACC,OAAO;EACP,MAAM,cAAc;EACpB,eAAe,cAAc;EAC7B,YAAY,cAAc;YAEzB,WAAW,QAAQ,UAAuB,WAAW;GACzC;AAElB"}
@@ -5,6 +5,7 @@ import { jsx } from "react/jsx-runtime";
5
5
  const mathPlugin = (node) => {
6
6
  const { "data-math": mathContent,...props } = attributesToProps(node.attribs);
7
7
  return /* @__PURE__ */ jsx("math", {
8
+ xmlns: "http://www.w3.org/1998/Math/MathML",
8
9
  ...props,
9
10
  dangerouslySetInnerHTML: { __html: mathContent }
10
11
  });
@@ -1 +1 @@
1
- {"version":3,"file":"mathPlugin.js","names":["mathPlugin: PluginType"],"sources":["../../src/plugins/mathPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { attributesToProps } from \"html-react-parser\";\nimport { type PluginType } from \"./types\";\nexport const mathPlugin: PluginType = (node) => {\n const { \"data-math\": mathContent, ...props } = attributesToProps(node.attribs);\n // @ts-expect-error - math is a valid tag\n return <math {...props} dangerouslySetInnerHTML={{ __html: mathContent }} />;\n};\n"],"mappings":";;;;AAUA,MAAaA,aAAyB,CAAC,SAAS;CAC9C,MAAM,EAAE,aAAa,YAAa,GAAG,OAAO,GAAG,kBAAkB,KAAK,QAAQ;AAE9E,wBAAO,IAAC;EAAK,GAAI;EAAO,yBAAyB,EAAE,QAAQ,YAAa;GAAI;AAC7E"}
1
+ {"version":3,"file":"mathPlugin.js","names":["mathPlugin: PluginType"],"sources":["../../src/plugins/mathPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { attributesToProps } from \"html-react-parser\";\nimport { type PluginType } from \"./types\";\nexport const mathPlugin: PluginType = (node) => {\n const { \"data-math\": mathContent, ...props } = attributesToProps(node.attribs);\n return (\n // @ts-expect-error - math is a valid tag\n <math xmlns=\"http://www.w3.org/1998/Math/MathML\" {...props} dangerouslySetInnerHTML={{ __html: mathContent }} />\n );\n};\n"],"mappings":";;;;AAUA,MAAaA,aAAyB,CAAC,SAAS;CAC9C,MAAM,EAAE,aAAa,YAAa,GAAG,OAAO,GAAG,kBAAkB,KAAK,QAAQ;AAC9E,wBAEE,IAAC;EAAK,OAAM;EAAqC,GAAI;EAAO,yBAAyB,EAAE,QAAQ,YAAa;GAAI;AAEnH"}
@@ -4,14 +4,15 @@ const __ndla_ui = require_rolldown_runtime.__toESM(require("@ndla/ui"));
4
4
  const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
5
5
 
6
6
  //#region src/plugins/embed/conceptEmbedPlugin.tsx
7
- const conceptEmbedPlugin = (element, _, opts) => {
7
+ const conceptEmbedPlugin = (element, parserOpts, transformOpts) => {
8
8
  const props = (0, html_react_parser.attributesToProps)(element.attribs);
9
9
  const data = JSON.parse(props["data-json"]);
10
10
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_ui.ConceptEmbed, {
11
11
  embed: data,
12
- lang: opts.articleLanguage,
13
- renderContext: opts.renderContext,
14
- previewAlt: opts.previewAlt
12
+ lang: transformOpts.articleLanguage,
13
+ renderContext: transformOpts.renderContext,
14
+ previewAlt: transformOpts.previewAlt,
15
+ children: (0, html_react_parser.domToReact)(element.children, parserOpts)
15
16
  });
16
17
  };
17
18
 
@@ -1 +1 @@
1
- {"version":3,"file":"conceptEmbedPlugin.js","names":["conceptEmbedPlugin: PluginType","ConceptEmbed"],"sources":["../../../src/plugins/embed/conceptEmbedPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { attributesToProps } from \"html-react-parser\";\nimport { type ConceptMetaData } from \"@ndla/types-embed\";\nimport { ConceptEmbed } from \"@ndla/ui\";\nimport { type PluginType } from \"../types\";\n\nexport const conceptEmbedPlugin: PluginType = (element, _, opts) => {\n const props = attributesToProps(element.attribs);\n const data = JSON.parse(props[\"data-json\"] as string) as ConceptMetaData;\n return (\n <ConceptEmbed\n embed={data}\n lang={opts.articleLanguage}\n renderContext={opts.renderContext}\n previewAlt={opts.previewAlt}\n />\n );\n};\n"],"mappings":";;;;;;AAaA,MAAaA,qBAAiC,CAAC,SAAS,GAAG,SAAS;CAClE,MAAM,QAAQ,yCAAkB,QAAQ,QAAQ;CAChD,MAAM,OAAO,KAAK,MAAM,MAAM,aAAuB;AACrD,wBACE,2BAACC;EACC,OAAO;EACP,MAAM,KAAK;EACX,eAAe,KAAK;EACpB,YAAY,KAAK;GACjB;AAEL"}
1
+ {"version":3,"file":"conceptEmbedPlugin.js","names":["conceptEmbedPlugin: PluginType","ConceptEmbed"],"sources":["../../../src/plugins/embed/conceptEmbedPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { attributesToProps, domToReact, type DOMNode } from \"html-react-parser\";\nimport { type ConceptMetaData } from \"@ndla/types-embed\";\nimport { ConceptEmbed } from \"@ndla/ui\";\nimport { type PluginType } from \"../types\";\n\nexport const conceptEmbedPlugin: PluginType = (element, parserOpts, transformOpts) => {\n const props = attributesToProps(element.attribs);\n const data = JSON.parse(props[\"data-json\"] as string) as ConceptMetaData;\n return (\n <ConceptEmbed\n embed={data}\n lang={transformOpts.articleLanguage}\n renderContext={transformOpts.renderContext}\n previewAlt={transformOpts.previewAlt}\n >\n {domToReact(element.children as DOMNode[], parserOpts)}\n </ConceptEmbed>\n );\n};\n"],"mappings":";;;;;;AAaA,MAAaA,qBAAiC,CAAC,SAAS,YAAY,kBAAkB;CACpF,MAAM,QAAQ,yCAAkB,QAAQ,QAAQ;CAChD,MAAM,OAAO,KAAK,MAAM,MAAM,aAAuB;AACrD,wBACE,2BAACC;EACC,OAAO;EACP,MAAM,cAAc;EACpB,eAAe,cAAc;EAC7B,YAAY,cAAc;YAEzB,kCAAW,QAAQ,UAAuB,WAAW;GACzC;AAElB"}
@@ -6,6 +6,7 @@ const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-ru
6
6
  const mathPlugin = (node) => {
7
7
  const { "data-math": mathContent,...props } = (0, html_react_parser.attributesToProps)(node.attribs);
8
8
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("math", {
9
+ xmlns: "http://www.w3.org/1998/Math/MathML",
9
10
  ...props,
10
11
  dangerouslySetInnerHTML: { __html: mathContent }
11
12
  });
@@ -1 +1 @@
1
- {"version":3,"file":"mathPlugin.js","names":["mathPlugin: PluginType"],"sources":["../../src/plugins/mathPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { attributesToProps } from \"html-react-parser\";\nimport { type PluginType } from \"./types\";\nexport const mathPlugin: PluginType = (node) => {\n const { \"data-math\": mathContent, ...props } = attributesToProps(node.attribs);\n // @ts-expect-error - math is a valid tag\n return <math {...props} dangerouslySetInnerHTML={{ __html: mathContent }} />;\n};\n"],"mappings":";;;;;AAUA,MAAaA,aAAyB,CAAC,SAAS;CAC9C,MAAM,EAAE,aAAa,YAAa,GAAG,OAAO,GAAG,yCAAkB,KAAK,QAAQ;AAE9E,wBAAO,2BAAC;EAAK,GAAI;EAAO,yBAAyB,EAAE,QAAQ,YAAa;GAAI;AAC7E"}
1
+ {"version":3,"file":"mathPlugin.js","names":["mathPlugin: PluginType"],"sources":["../../src/plugins/mathPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { attributesToProps } from \"html-react-parser\";\nimport { type PluginType } from \"./types\";\nexport const mathPlugin: PluginType = (node) => {\n const { \"data-math\": mathContent, ...props } = attributesToProps(node.attribs);\n return (\n // @ts-expect-error - math is a valid tag\n <math xmlns=\"http://www.w3.org/1998/Math/MathML\" {...props} dangerouslySetInnerHTML={{ __html: mathContent }} />\n );\n};\n"],"mappings":";;;;;AAUA,MAAaA,aAAyB,CAAC,SAAS;CAC9C,MAAM,EAAE,aAAa,YAAa,GAAG,OAAO,GAAG,yCAAkB,KAAK,QAAQ;AAC9E,wBAEE,2BAAC;EAAK,OAAM;EAAqC,GAAI;EAAO,yBAAyB,EAAE,QAAQ,YAAa;GAAI;AAEnH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/article-converter",
3
- "version": "10.0.133-alpha.0",
3
+ "version": "10.0.135-alpha.0",
4
4
  "description": "Transforms NDLA articles into extended html versions",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -29,12 +29,12 @@
29
29
  ],
30
30
  "devDependencies": {
31
31
  "@ndla/types-backend": "^1.0.50",
32
- "@ndla/types-embed": "^5.0.15-alpha.0"
32
+ "@ndla/types-embed": "^5.0.16-alpha.0"
33
33
  },
34
34
  "dependencies": {
35
35
  "@ndla/primitives": "^1.0.93-alpha.0",
36
36
  "@ndla/safelink": "^7.0.95-alpha.0",
37
- "@ndla/ui": "^56.0.130-alpha.0",
37
+ "@ndla/ui": "^56.0.132-alpha.0",
38
38
  "html-react-parser": "^5.1.19"
39
39
  },
40
40
  "peerDependencies": {
@@ -47,5 +47,5 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  },
50
- "gitHead": "7ce19c361e51c5ed4460cf952a7764b9f017f41e"
50
+ "gitHead": "acbf5abd6a95cb34bc345df93895ac4e37b0b88e"
51
51
  }
@@ -6,20 +6,22 @@
6
6
  *
7
7
  */
8
8
 
9
- import { attributesToProps } from "html-react-parser";
9
+ import { attributesToProps, domToReact, type DOMNode } from "html-react-parser";
10
10
  import { type ConceptMetaData } from "@ndla/types-embed";
11
11
  import { ConceptEmbed } from "@ndla/ui";
12
12
  import { type PluginType } from "../types";
13
13
 
14
- export const conceptEmbedPlugin: PluginType = (element, _, opts) => {
14
+ export const conceptEmbedPlugin: PluginType = (element, parserOpts, transformOpts) => {
15
15
  const props = attributesToProps(element.attribs);
16
16
  const data = JSON.parse(props["data-json"] as string) as ConceptMetaData;
17
17
  return (
18
18
  <ConceptEmbed
19
19
  embed={data}
20
- lang={opts.articleLanguage}
21
- renderContext={opts.renderContext}
22
- previewAlt={opts.previewAlt}
23
- />
20
+ lang={transformOpts.articleLanguage}
21
+ renderContext={transformOpts.renderContext}
22
+ previewAlt={transformOpts.previewAlt}
23
+ >
24
+ {domToReact(element.children as DOMNode[], parserOpts)}
25
+ </ConceptEmbed>
24
26
  );
25
27
  };
@@ -10,6 +10,8 @@ import { attributesToProps } from "html-react-parser";
10
10
  import { type PluginType } from "./types";
11
11
  export const mathPlugin: PluginType = (node) => {
12
12
  const { "data-math": mathContent, ...props } = attributesToProps(node.attribs);
13
- // @ts-expect-error - math is a valid tag
14
- return <math {...props} dangerouslySetInnerHTML={{ __html: mathContent }} />;
13
+ return (
14
+ // @ts-expect-error - math is a valid tag
15
+ <math xmlns="http://www.w3.org/1998/Math/MathML" {...props} dangerouslySetInnerHTML={{ __html: mathContent }} />
16
+ );
15
17
  };