@t8/docsgen 0.4.20 → 0.4.21

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.
package/dist/bin.js CHANGED
@@ -445,11 +445,17 @@ function getSectionPostprocess(linkMap) {
445
445
  for (let a of document.querySelectorAll("a")) {
446
446
  let href = a.getAttribute("href");
447
447
  if (href === null) continue;
448
- if (isPreviewURL(href) && a.parentElement) {
448
+ if (isPreviewURL(href)) {
449
449
  let preview = document.createElement("fieldset");
450
450
  preview.innerHTML = getPreviewContent(href, a.innerHTML);
451
- a.parentElement.insertBefore(preview, a);
452
- a.remove();
451
+ let p = a.closest("p");
452
+ if (p?.parentElement) {
453
+ p.parentElement.insertBefore(preview, p);
454
+ if (a.nextElementSibling?.matches("br"))
455
+ a.nextElementSibling.remove();
456
+ a.remove();
457
+ if (p.innerHTML.trim() === "") p.remove();
458
+ }
453
459
  } else {
454
460
  let nextHref = linkMap[href] ?? href;
455
461
  a.setAttribute("href", nextHref);
@@ -252,6 +252,7 @@ main h2:first-child {
252
252
  }
253
253
  main fieldset {
254
254
  border: 0.05em solid var(--secondary-color);
255
+ margin: var(--block-margin-y) 0;
255
256
  }
256
257
  main fieldset legend {
257
258
  font-size: 0.8em;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t8/docsgen",
3
- "version": "0.4.20",
3
+ "version": "0.4.21",
4
4
  "description": "",
5
5
  "main": "dist/bin.js",
6
6
  "type": "module",
@@ -32,13 +32,23 @@ export function getSectionPostprocess(
32
32
 
33
33
  if (href === null) continue;
34
34
 
35
- if (isPreviewURL(href) && a.parentElement) {
35
+ if (isPreviewURL(href)) {
36
36
  let preview = document.createElement("fieldset");
37
37
 
38
38
  preview.innerHTML = getPreviewContent(href, a.innerHTML);
39
39
 
40
- a.parentElement.insertBefore(preview, a);
41
- a.remove();
40
+ let p = a.closest("p");
41
+
42
+ if (p?.parentElement) {
43
+ p.parentElement.insertBefore(preview, p);
44
+
45
+ if (a.nextElementSibling?.matches("br"))
46
+ a.nextElementSibling.remove();
47
+
48
+ a.remove();
49
+
50
+ if (p.innerHTML.trim() === "") p.remove();
51
+ }
42
52
  } else {
43
53
  let nextHref = linkMap[href] ?? href;
44
54
 
@@ -252,6 +252,7 @@ main h2:first-child {
252
252
  }
253
253
  main fieldset {
254
254
  border: 0.05em solid var(--secondary-color);
255
+ margin: var(--block-margin-y) 0;
255
256
  }
256
257
  main fieldset legend {
257
258
  font-size: 0.8em;