@hyperbook/markdown 0.10.0 → 0.11.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.
@@ -4,7 +4,7 @@ var hyperbook = (function () {
4
4
  const calcMaxHeight = (elem) => {
5
5
  const content = elem.nextElementSibling;
6
6
  if (content) {
7
- if (elem.classList.contains("active")) {
7
+ if (elem.classList.contains("expanded")) {
8
8
  content.style.maxHeight = content.scrollHeight + "px";
9
9
  } else {
10
10
  content.style.maxHeight = "0";
@@ -20,9 +20,13 @@ var hyperbook = (function () {
20
20
  };
21
21
  for (let collapsible of collapsibles) {
22
22
  collapsible.addEventListener("click", () => {
23
- collapsible.classList.toggle("active");
23
+ collapsible.classList.toggle("expanded");
24
24
  calcMaxHeight(collapsible);
25
25
  });
26
+
27
+ if (collapsible.classList.contains("expanded")) {
28
+ calcMaxHeight(collapsible);
29
+ }
26
30
  }
27
31
 
28
32
  function tocToggle() {
@@ -11,7 +11,7 @@
11
11
  margin-bottom: 10px;
12
12
  }
13
13
 
14
- .directive-collapsible button.active {
14
+ .directive-collapsible button.expanded {
15
15
  border-bottom-left-radius: 0px;
16
16
  border-bottom-right-radius: 0px;
17
17
  margin-bottom: 0px;
@@ -25,7 +25,7 @@
25
25
  margin-left: 5px;
26
26
  }
27
27
 
28
- .directive-collapsible button.active:after {
28
+ .directive-collapsible button.expanded:after {
29
29
  content: "\2796";
30
30
  /* Unicode character for "minus" sign (-) */
31
31
  }
@@ -39,7 +39,7 @@
39
39
  display: none;
40
40
  }
41
41
 
42
- .directive-collapsible button.active+.collapsible-content {
42
+ .directive-collapsible button.expanded+.collapsible-content {
43
43
  display: block;
44
44
  border-style: solid;
45
45
  border-width: 1px;
File without changes
@@ -615,11 +615,11 @@ nav li+li {
615
615
  margin-left: 5px;
616
616
  }
617
617
 
618
- .collapsible.active:after {
618
+ .collapsible.expanded:after {
619
619
  content: "\2212";
620
620
  }
621
621
 
622
- .collapsible.active+.collapsible-content {
622
+ .collapsible.expanded+.collapsible-content {
623
623
  max-height: 9999px;
624
624
  }
625
625
 
package/dist/index.js CHANGED
@@ -62910,7 +62910,7 @@ var remarkDirectiveVideo_default = (ctx) => () => {
62910
62910
  };
62911
62911
 
62912
62912
  // src/remarkDirectiveYoutube.ts
62913
- var remarkDirectiveYoutube_default = (_) => () => {
62913
+ var remarkDirectiveYoutube_default = (ctx) => () => {
62914
62914
  const name = "youtube";
62915
62915
  return (tree, file) => {
62916
62916
  visit(tree, function(node2) {
@@ -62921,7 +62921,10 @@ var remarkDirectiveYoutube_default = (_) => () => {
62921
62921
  const { id } = attributes5;
62922
62922
  expectLeafDirective(node2, file, name);
62923
62923
  if (id == null) {
62924
- file.fail(`Missing id, use ::youtube{#iasd}`, node2);
62924
+ file.fail(
62925
+ `[youtube] Missing id, use ::youtube{#iasd} (${ctx.navigation.current?.href})`,
62926
+ node2
62927
+ );
62925
62928
  }
62926
62929
  registerDirective(file, name, [], ["style.css"]);
62927
62930
  data.hName = "div";
@@ -62970,9 +62973,11 @@ var remarkDirectiveTiles_default = (ctx) => () => {
62970
62973
  const { title, size = "M", icon, href } = node3.attributes || {};
62971
62974
  expectLeafDirective(node3, file, "tile");
62972
62975
  if (!title) {
62973
- file.fail("A title is required", node3);
62976
+ file.fail(
62977
+ `[tiles] A title is required (${ctx.navigation.current?.href})`,
62978
+ node3
62979
+ );
62974
62980
  }
62975
- registerDirective(file, "tile");
62976
62981
  const tileChildren = [
62977
62982
  {
62978
62983
  type: "element",
@@ -64459,8 +64464,9 @@ var makeNavigationPageElement = (ctx, page) => {
64459
64464
  };
64460
64465
  };
64461
64466
  var makeNavigationSectionElement = (ctx, section) => {
64462
- const { virtual, isEmpty, href, name, pages, sections } = section;
64467
+ const { virtual, isEmpty, href, name, pages, sections, expanded } = section;
64463
64468
  const children = [];
64469
+ let isExpanded = ctx.navigation.current?.href?.startsWith(href || "") || expanded;
64464
64470
  if (!virtual && isEmpty) {
64465
64471
  children.push({
64466
64472
  type: "element",
@@ -64470,7 +64476,8 @@ var makeNavigationSectionElement = (ctx, section) => {
64470
64476
  "collapsible",
64471
64477
  "name",
64472
64478
  "empty",
64473
- ctx.navigation.current?.href?.includes(href || "") ? "active" : ""
64479
+ ctx.navigation.current?.href === href ? "active" : "",
64480
+ isExpanded ? "expanded" : ""
64474
64481
  ].join(" ")
64475
64482
  },
64476
64483
  children: [
@@ -64497,7 +64504,8 @@ var makeNavigationSectionElement = (ctx, section) => {
64497
64504
  class: [
64498
64505
  "collapsible",
64499
64506
  "name",
64500
- ctx.navigation.current?.href === section.href ? "active" : ""
64507
+ ctx.navigation.current?.href === href ? "active" : "",
64508
+ isExpanded ? "expanded" : ""
64501
64509
  ].join(" ")
64502
64510
  },
64503
64511
  children: [
@@ -64586,10 +64594,14 @@ var makeMetaElements = (ctx) => {
64586
64594
  });
64587
64595
  }
64588
64596
  const copyrightChildren = [];
64589
- copyrightChildren.push({
64590
- type: "raw",
64591
- value: ctx.config.license ? linkLicense(ctx) : `\xA9 Copyright ${(/* @__PURE__ */ new Date()).getFullYear()}`
64592
- });
64597
+ if (ctx.config.license) {
64598
+ copyrightChildren.push(linkLicense(ctx));
64599
+ } else {
64600
+ copyrightChildren.push({
64601
+ type: "text",
64602
+ value: `\xA9 Copyright ${(/* @__PURE__ */ new Date()).getFullYear()}`
64603
+ });
64604
+ }
64593
64605
  if (ctx.config.author) {
64594
64606
  copyrightChildren.push({
64595
64607
  type: "text",
@@ -64630,7 +64642,7 @@ var makeMetaElements = (ctx) => {
64630
64642
  };
64631
64643
  var linkLicense = (ctx) => {
64632
64644
  const license = ctx.config.license;
64633
- if (!license) return "";
64645
+ if (!license) return { type: "text", value: "" };
64634
64646
  let href = null;
64635
64647
  let label4 = "";
64636
64648
  switch (license.toLowerCase()) {
@@ -64671,9 +64683,24 @@ var linkLicense = (ctx) => {
64671
64683
  }
64672
64684
  }
64673
64685
  if (href) {
64674
- return `<a href="${href}">${label4}</a>`;
64686
+ return {
64687
+ type: "element",
64688
+ tagName: "a",
64689
+ properties: {
64690
+ href
64691
+ },
64692
+ children: [
64693
+ {
64694
+ type: "text",
64695
+ value: label4
64696
+ }
64697
+ ]
64698
+ };
64675
64699
  }
64676
- return license;
64700
+ return {
64701
+ type: "raw",
64702
+ value: license
64703
+ };
64677
64704
  };
64678
64705
  var makeHeaderElements = (ctx) => {
64679
64706
  const { config: config2 } = ctx;
@@ -71759,7 +71786,7 @@ var remarkDirectiveTerm_default = (ctx) => () => {
71759
71786
  expectTextDirective(node2, file, "term");
71760
71787
  if (node2.children[0]?.type !== "text") {
71761
71788
  file.fail(
71762
- "Only plain text is supported, use :term[my text]{#my-id}",
71789
+ `[term] Only plain text is supported, use :term[my text]{#my-id} (${ctx.navigation.current?.href})`,
71763
71790
  node2
71764
71791
  );
71765
71792
  }