@t8/docsgen 0.2.34 → 0.2.35
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 +6 -3
- package/package.json +1 -1
- package/src/bin/getConfig.ts +1 -1
- package/src/bin/stripHTML.ts +7 -2
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
|
|
145
|
-
|
|
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(/ +/, " ");
|
|
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
package/src/bin/getConfig.ts
CHANGED
|
@@ -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
|
|
package/src/bin/stripHTML.ts
CHANGED
|
@@ -2,8 +2,13 @@ import { JSDOM } from "jsdom";
|
|
|
2
2
|
|
|
3
3
|
export function stripHTML(content: string, replaceNbsp = false) {
|
|
4
4
|
try {
|
|
5
|
-
let
|
|
5
|
+
let t = content.replaceAll("<sup>", " (").replaceAll("</sup>", ")");
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
let s = new JSDOM(t).window.document.body.textContent;
|
|
8
|
+
|
|
9
|
+
if (replaceNbsp) s = s.replaceAll("\xa0", " ");
|
|
10
|
+
s = s.replace(/ +/, " ");
|
|
11
|
+
|
|
12
|
+
return s;
|
|
8
13
|
} catch {}
|
|
9
14
|
}
|