@rightkit/doc-render 0.1.0 → 0.1.1

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/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.1.1 — 2026-10-07
4
+
5
+ - `buildBlocks(nodes, { hintPrefixes })` limits which `<!-- PREFIX: KIND -->` comments count as explicit hints (default `["doc", "viewright"]`). ViewRight passes `["viewright"]` for exact parity.
@@ -12,6 +12,10 @@ export type Block = {
12
12
  kind: "plain";
13
13
  nodes: RootContent[];
14
14
  };
15
+ export interface BuildBlocksOptions {
16
+ /** Comment prefixes accepted for explicit hints (`<!-- PREFIX: KIND -->`). Default `["doc", "viewright"]`. */
17
+ hintPrefixes?: readonly string[];
18
+ }
15
19
  /**
16
20
  * The confidence gate. Walks top-level nodes, runs detectors, and decides per block:
17
21
  * - hit at/above threshold (or forced by a hint) → semantic component
@@ -19,4 +23,4 @@ export type Block = {
19
23
  * - no hit → plain markdown
20
24
  * Returns a flat block list the renderer maps to React.
21
25
  */
22
- export declare function buildBlocks(nodes: RootContent[]): Block[];
26
+ export declare function buildBlocks(nodes: RootContent[], options?: BuildBlocksOptions): Block[];
@@ -17,11 +17,17 @@ const DETECTORS = [
17
17
  comparisonDetector,
18
18
  stepperDetector,
19
19
  ];
20
- const HINT_RE = /<!--\s*(?:doc|viewright):\s*(frontmatter|callout|stepper|comparison|faq|richTable|descriptionList)\s*-->/i;
21
- function parseHint(node) {
20
+ const HINT_KINDS = "frontmatter|callout|stepper|comparison|faq|richTable|descriptionList";
21
+ const DEFAULT_HINT_PREFIXES = ["doc", "viewright"];
22
+ function hintPattern(prefixes) {
23
+ const names = prefixes.map((p) => p.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
24
+ return new RegExp(`<!--\\s*(?:${names}):\\s*(${HINT_KINDS})\\s*-->`, "i");
25
+ }
26
+ const DEFAULT_HINT_RE = hintPattern(DEFAULT_HINT_PREFIXES);
27
+ function parseHint(node, re) {
22
28
  if (node.type !== "html")
23
29
  return null;
24
- const m = HINT_RE.exec(node.value ?? "");
30
+ const m = re.exec(node.value ?? "");
25
31
  return m ? m[1] : null;
26
32
  }
27
33
  /**
@@ -31,7 +37,8 @@ function parseHint(node) {
31
37
  * - no hit → plain markdown
32
38
  * Returns a flat block list the renderer maps to React.
33
39
  */
34
- export function buildBlocks(nodes) {
40
+ export function buildBlocks(nodes, options = {}) {
41
+ const hintRe = options.hintPrefixes ? hintPattern(options.hintPrefixes) : DEFAULT_HINT_RE;
35
42
  const blocks = [];
36
43
  let pendingHint = null;
37
44
  let plainRun = [];
@@ -44,7 +51,7 @@ export function buildBlocks(nodes) {
44
51
  let i = 0;
45
52
  while (i < nodes.length) {
46
53
  const node = nodes[i];
47
- const hint = parseHint(node);
54
+ const hint = parseHint(node, hintRe);
48
55
  if (hint) {
49
56
  pendingHint = hint;
50
57
  i += 1; // the hint comment itself never renders
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ export { collectFootnotes } from "./footnotes.js";
7
7
  export { formatCitation, formatBibliographyEntry, formatNames, formatYear, buildBibliographyMap } from "./citations/formatter.js";
8
8
  export type { CslEntry, CslName, BibliographyEntry, CitationMatch } from "./citations/types.js";
9
9
  export { buildBlocks } from "./detectors/index.js";
10
- export type { Block } from "./detectors/index.js";
10
+ export type { Block, BuildBlocksOptions } from "./detectors/index.js";
11
11
  export type { Detector, DetectorHit, SemanticKind } from "./detectors/types.js";
12
12
  export { remarkCitations } from "./remarkCitations.js";
13
13
  export { remarkDefListAbbr } from "./remarkDefListAbbr.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rightkit/doc-render",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Brand-neutral, read-only document renderer (Markdown, sanitized HTML, safe email frame) for Right Suite readers.",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "type": "module",
@@ -18,7 +18,8 @@
18
18
  "styles.css",
19
19
  "README.md",
20
20
  "LICENSE-MIT",
21
- "LICENSE-APACHE"
21
+ "LICENSE-APACHE",
22
+ "CHANGELOG.md"
22
23
  ],
23
24
  "sideEffects": [
24
25
  "*.css"