@t8/docsgen 0.2.34 → 0.2.36

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
@@ -141,8 +141,11 @@ function getLocation(ctx, path, preferredLocation) {
141
141
  var import_jsdom = require("jsdom");
142
142
  function stripHTML(content, replaceNbsp = false) {
143
143
  try {
144
- let s = new import_jsdom.JSDOM(content).window.document.body.textContent;
145
- return replaceNbsp ? s.replaceAll("\xA0", " ") : s;
144
+ let t = content.replaceAll("<sup>", " (").replaceAll("</sup>", ")");
145
+ let s = new import_jsdom.JSDOM(t).window.document.body.textContent;
146
+ if (replaceNbsp) s = s.replaceAll("\xA0", " ");
147
+ s = s.replace(/ +/g, " ");
148
+ return s;
146
149
  } catch {
147
150
  }
148
151
  }
@@ -188,7 +191,7 @@ async function addMetadata(config2) {
188
191
  }
189
192
  function deriveProps(config2) {
190
193
  let { dir, assetsDir, root, title, htmlTitle } = config2;
191
- if (htmlTitle && !title) title = stripHTML(htmlTitle);
194
+ if (htmlTitle && !title) title = stripHTML(htmlTitle, true);
192
195
  if (dir && !root) root = `/${dir}/`;
193
196
  if (!root?.endsWith("/")) root = `${root ?? ""}/`;
194
197
  if (dir && assetsDir?.includes("{{dir}}"))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t8/docsgen",
3
- "version": "0.2.34",
3
+ "version": "0.2.36",
4
4
  "description": "",
5
5
  "main": "dist/bin.js",
6
6
  "bin": {
@@ -24,7 +24,7 @@ async function addMetadata(config: EntryConfig) {
24
24
  function deriveProps(config: EntryConfig) {
25
25
  let { dir, assetsDir, root, title, htmlTitle } = config;
26
26
 
27
- if (htmlTitle && !title) title = stripHTML(htmlTitle);
27
+ if (htmlTitle && !title) title = stripHTML(htmlTitle, true);
28
28
  if (dir && !root) root = `/${dir}/`;
29
29
  if (!root?.endsWith("/")) root = `${root ?? ""}/`;
30
30
 
@@ -2,8 +2,13 @@ import { JSDOM } from "jsdom";
2
2
 
3
3
  export function stripHTML(content: string, replaceNbsp = false) {
4
4
  try {
5
- let s = new JSDOM(content).window.document.body.textContent;
5
+ let t = content.replaceAll("<sup>", " (").replaceAll("</sup>", ")");
6
6
 
7
- return replaceNbsp ? s.replaceAll("\xa0", " ") : s;
7
+ let s = new JSDOM(t).window.document.body.textContent;
8
+
9
+ if (replaceNbsp) s = s.replaceAll("\xa0", " ");
10
+ s = s.replace(/ +/g, " ");
11
+
12
+ return s;
8
13
  } catch {}
9
14
  }