@hyperbook/markdown 0.23.1 → 0.23.2

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,9 +1,19 @@
1
1
  hyperbook.mermaid = (function () {
2
2
  const elementCode = ".directive-mermaid";
3
3
 
4
- const loadMermaid = function (theme) {
5
- window.mermaid.initialize({ theme });
6
- window.mermaid.init({ theme }, document.querySelectorAll(elementCode));
4
+ const loadMermaid = async function (theme) {
5
+ window.mermaid.initialize({ theme, startOnLoad: false });
6
+ let i = 0;
7
+ for (const el of document.querySelectorAll(elementCode)) {
8
+ if (el.getAttribute("data-processed")) return;
9
+
10
+ el.setAttribute("data-processed", true);
11
+ let id = `graph-` + Date.now() + i++;
12
+
13
+ mermaid.render(id, el.innerText).then(({ svg }) => {
14
+ el.innerHTML = svg;
15
+ });
16
+ }
7
17
  };
8
18
 
9
19
  const resetProcessed = function () {
package/dist/index.js CHANGED
@@ -63702,11 +63702,19 @@ function hash(object) {
63702
63702
  }
63703
63703
 
63704
63704
  // src/remarkDirectiveTabs.ts
63705
- var remarkDirectiveTabs_default = (ctx) => () => {
63706
- return (tree, file) => {
63707
- visit(tree, function(node3) {
63708
- if (isDirective(node3)) {
63709
- if (node3.name !== "tabs") return;
63705
+ function remarkDirectiveTabs_default(ctx) {
63706
+ return function() {
63707
+ const self2 = this;
63708
+ return async (tree, file) => {
63709
+ const tabsNodes = [];
63710
+ visit(tree, function(node3) {
63711
+ if (isDirective(node3)) {
63712
+ if (node3.name !== "tabs") return;
63713
+ tabsNodes.push(node3);
63714
+ return;
63715
+ }
63716
+ });
63717
+ for (const node3 of tabsNodes) {
63710
63718
  const data = node3.data || (node3.data = {});
63711
63719
  if (node3.name === "tabs") {
63712
63720
  expectContainerDirective(node3, file, "tabs");
@@ -63722,9 +63730,9 @@ var remarkDirectiveTabs_default = (ctx) => () => {
63722
63730
  const tabContentElements = [];
63723
63731
  const tabTitleElements = [];
63724
63732
  let first = true;
63725
- node3.children.filter(isDirective).forEach((node4) => {
63726
- expectContainerDirective(node4, file, "tab");
63727
- let { title = "", id: tabId = hash(node4) } = node4.attributes || {};
63733
+ for (const tabNode of node3.children.filter(isDirective)) {
63734
+ expectContainerDirective(tabNode, file, "tab");
63735
+ let { title = "", id: tabId = hash(tabNode) } = tabNode.attributes || {};
63728
63736
  let tree2 = remark(ctx).parse(title);
63729
63737
  remarkGemoji()(tree2);
63730
63738
  let hastTree = toHast(tree2);
@@ -63742,6 +63750,7 @@ var remarkDirectiveTabs_default = (ctx) => () => {
63742
63750
  },
63743
63751
  children: hastTree.children || []
63744
63752
  });
63753
+ const tabContent = await remark(ctx).run(tabNode);
63745
63754
  tabContentElements.push({
63746
63755
  type: "element",
63747
63756
  tagName: "div",
@@ -63750,10 +63759,10 @@ var remarkDirectiveTabs_default = (ctx) => () => {
63750
63759
  "data-tab-id": tabId,
63751
63760
  "data-tabs-id": tabsId
63752
63761
  },
63753
- children: toHast(node4)?.children
63762
+ children: [tabContent]
63754
63763
  });
63755
63764
  first = false;
63756
- });
63765
+ }
63757
63766
  data.hChildren = [
63758
63767
  {
63759
63768
  type: "element",
@@ -63768,9 +63777,9 @@ var remarkDirectiveTabs_default = (ctx) => () => {
63768
63777
  ];
63769
63778
  }
63770
63779
  }
63771
- });
63780
+ };
63772
63781
  };
63773
- };
63782
+ }
63774
63783
 
63775
63784
  // src/remarkDirectiveSqlIde.ts
63776
63785
  var remarkDirectiveSqlIde_default = (ctx) => () => {
@@ -66656,48 +66665,55 @@ var remarkDirectiveCollapsible_default = (ctx) => () => {
66656
66665
  }
66657
66666
  return [element5];
66658
66667
  };
66659
- return (tree, file) => {
66668
+ const collapsibleNodes = [];
66669
+ return async (tree, file) => {
66660
66670
  visit(tree, function(node3) {
66661
66671
  if (isDirective(node3)) {
66662
66672
  if (node3.name !== name) return;
66663
- const data = node3.data || (node3.data = {});
66664
- const { title = "", id } = node3.data.hProperties || {};
66665
- expectContainerDirective(node3, file, name);
66666
- registerDirective(file, name, [], ["style.css"]);
66667
- node3.attributes = {};
66668
- data.hName = "div";
66669
- data.hProperties = {
66670
- class: "directive-collapsible",
66671
- "data-id": id
66672
- };
66673
- const children = toHast(node3)?.children.flatMap(
66674
- transformCollapsible
66675
- );
66676
- data.hChildren = [
66677
- {
66678
- type: "element",
66679
- tagName: "button",
66680
- properties: {
66681
- class: "collapsible"
66682
- },
66683
- children: [
66684
- {
66685
- type: "text",
66686
- value: title
66687
- }
66688
- ]
66689
- },
66690
- {
66691
- type: "element",
66692
- tagName: "div",
66693
- properties: {
66694
- class: "collapsible-content"
66695
- },
66696
- children
66697
- }
66698
- ];
66673
+ collapsibleNodes.push(node3);
66674
+ return;
66699
66675
  }
66700
66676
  });
66677
+ for (const node3 of collapsibleNodes) {
66678
+ const data = node3.data || (node3.data = {});
66679
+ const { title = "", id } = node3.data.hProperties || {};
66680
+ expectContainerDirective(node3, file, name);
66681
+ registerDirective(file, name, [], ["style.css"]);
66682
+ node3.attributes = {};
66683
+ data.hName = "div";
66684
+ data.hProperties = {
66685
+ class: "directive-collapsible",
66686
+ "data-id": id
66687
+ };
66688
+ const collapsibleContent = [];
66689
+ for (const child of node3.children) {
66690
+ collapsibleContent.push(await remark(ctx).run(child));
66691
+ }
66692
+ console.log(collapsibleContent);
66693
+ data.hChildren = [
66694
+ {
66695
+ type: "element",
66696
+ tagName: "button",
66697
+ properties: {
66698
+ class: "collapsible"
66699
+ },
66700
+ children: [
66701
+ {
66702
+ type: "text",
66703
+ value: title
66704
+ }
66705
+ ]
66706
+ },
66707
+ {
66708
+ type: "element",
66709
+ tagName: "div",
66710
+ properties: {
66711
+ class: "collapsible-content"
66712
+ },
66713
+ children: collapsibleContent
66714
+ }
66715
+ ];
66716
+ }
66701
66717
  };
66702
66718
  };
66703
66719
 
@@ -73916,6 +73932,12 @@ var remark = (ctx) => {
73916
73932
  remarkCollectHeadings_default(ctx),
73917
73933
  remarkCollectSearchDocuments_default(ctx)
73918
73934
  ];
73935
+ return unified().use(remarkParse).use(remarkPlugins).use(remarkRehype, {
73936
+ allowDangerousHtml: ctx.config.allowDangerousHtml || false
73937
+ });
73938
+ };
73939
+ var process2 = (md, ctx) => {
73940
+ i18n.init(ctx.config.language || "en");
73919
73941
  const rehypePlugins = [
73920
73942
  rehypeTableOfContents_default(ctx),
73921
73943
  rehypeQrCode_default(ctx),
@@ -73939,13 +73961,7 @@ var remark = (ctx) => {
73939
73961
  ],
73940
73962
  rehypeFormat
73941
73963
  ];
73942
- return unified().use(remarkParse).use(remarkPlugins).use(remarkRehype, {
73943
- allowDangerousHtml: ctx.config.allowDangerousHtml || false
73944
- }).use(rehypePlugins);
73945
- };
73946
- var process2 = (md, ctx) => {
73947
- i18n.init(ctx.config.language || "en");
73948
- return remark(ctx).use(rehypeShell_default(ctx)).use(rehypeHtmlStructure_default(ctx)).use(rehypeStringify, {
73964
+ return remark(ctx).use(rehypePlugins).use(rehypeShell_default(ctx)).use(rehypeHtmlStructure_default(ctx)).use(rehypeStringify, {
73949
73965
  allowDangerousCharacters: true,
73950
73966
  allowDangerousHtml: ctx.config.allowDangerousHtml || false
73951
73967
  }).process(md);