@norskvideo/ctl-dev-kit 0.2.59 → 0.2.60
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/doc-guide/doc-guide.d.ts +4 -2
- package/doc-guide/doc-guide.js +10 -2
- package/package.json +1 -1
package/doc-guide/doc-guide.d.ts
CHANGED
|
@@ -28,11 +28,13 @@ export declare function docsRoot(): string;
|
|
|
28
28
|
* at about 2.5 words/s: 35 words is 14 s on one still, 50 is 20 s, and the
|
|
29
29
|
* renderer's own lint warns at 35. This is the hard stop. */
|
|
30
30
|
export declare const DEFAULT_CAPTION_WORDS = 50;
|
|
31
|
+
/** The part of a step's text that is narrated: everything but its fenced blocks. */
|
|
32
|
+
export declare function spokenText(text: string): string;
|
|
31
33
|
/** Why a step's text cannot be narrated as written, or null when it can. Pure,
|
|
32
34
|
* so the wording is pinned without a browser. Checks the budget first: an
|
|
33
35
|
* over-long caption gets rewritten anyway, and the rewrite is where the
|
|
34
|
-
* phrasing gets fixed. */
|
|
35
|
-
export declare function captionFault(
|
|
36
|
+
* phrasing gets fixed. Only the spoken part is held to either. */
|
|
37
|
+
export declare function captionFault(caption: string, budget: number): string | null;
|
|
36
38
|
/** Device scale factor for a capture: 2 in a DOCS_GENERATE run, 1 otherwise.
|
|
37
39
|
* The video spike found the manual's component crops 383 to 778 px wide; in
|
|
38
40
|
* a 1080p frame they are soft, and no renderer recovers detail that was never
|
package/doc-guide/doc-guide.js
CHANGED
|
@@ -17,11 +17,19 @@ export const DEFAULT_CAPTION_WORDS = 50;
|
|
|
17
17
|
const SPOKEN_WORD = /[\p{L}\p{N}]/u;
|
|
18
18
|
const RAW_URL = /https?:\/\/\S+/;
|
|
19
19
|
const SLASH_BETWEEN_WORDS = /\S+\/\S+/;
|
|
20
|
+
/** A fenced block (``` or ~~~, closed or running to the end as markdown has
|
|
21
|
+
* it) is a transcript or a file to copy: the page shows it, nobody speaks it. */
|
|
22
|
+
const FENCED_BLOCK = /^(`{3,}|~{3,})[^\n]*$[\s\S]*?(?:^\1[ \t]*$|(?![\s\S]))/gm;
|
|
23
|
+
/** The part of a step's text that is narrated: everything but its fenced blocks. */
|
|
24
|
+
export function spokenText(text) {
|
|
25
|
+
return text.replace(FENCED_BLOCK, "");
|
|
26
|
+
}
|
|
20
27
|
/** Why a step's text cannot be narrated as written, or null when it can. Pure,
|
|
21
28
|
* so the wording is pinned without a browser. Checks the budget first: an
|
|
22
29
|
* over-long caption gets rewritten anyway, and the rewrite is where the
|
|
23
|
-
* phrasing gets fixed. */
|
|
24
|
-
export function captionFault(
|
|
30
|
+
* phrasing gets fixed. Only the spoken part is held to either. */
|
|
31
|
+
export function captionFault(caption, budget) {
|
|
32
|
+
const text = spokenText(caption);
|
|
25
33
|
const count = text.split(/\s+/).filter((token) => SPOKEN_WORD.test(token)).length;
|
|
26
34
|
if (count > budget)
|
|
27
35
|
return `${count} words; the spoken budget is ${budget}`;
|