@oxide/react-asciidoc 2.0.0 → 2.1.0-canary.792ad4d

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.
@@ -3,8 +3,10 @@ import RenderInline, { type InlineOverrides, inlineHtml } from './RenderInline';
3
3
  import * as Inline from './inline';
4
4
  import { Admonition, Audio, CoList, DList, Document, Example, FloatingTitle, Image, Listing, Literal, OList, Open, PageBreak, Paragraph, Pass, Preamble, Quote, Section, Sidebar, Stem, Table, TableOfContents, ThematicBreak, UList, Verse, Video } from './templates';
5
5
  import { Title } from './templates/util';
6
+ import { findSection } from './utils/findSection';
7
+ import { plainText } from './utils/plainText';
6
8
  import { isOption, prepareDocument, processDocument } from './utils/prepareDocument';
7
- import type { AdmonitionBlock, AudioBlock, Block, CoListBlock, DListBlock, DocumentBlock, DocumentSection, ImageBlock, ListBlock, LiteralBlock, ParagraphBlock, SectionBlock, TableBlock, VideoBlock } from './utils/prepareDocument';
9
+ import type { AdmonitionBlock, AudioBlock, Block, Cell, CoListBlock, DListBlock, DocumentBlock, DocumentSection, ImageBlock, ListBlock, ListItemBlock, LiteralBlock, ParagraphBlock, SectionBlock, TableBlock, VideoBlock } from './utils/prepareDocument';
8
10
  type Overrides = {
9
11
  admonition?: typeof Admonition;
10
12
  audio?: typeof Audio;
@@ -56,7 +58,7 @@ export declare const useConverterContext: () => Options & {
56
58
  sections?: DocumentSection[];
57
59
  };
58
60
  };
59
- export { Asciidoc, Content, prepareDocument, Title, parse, processDocument, isOption, RenderInline, inlineHtml, Inline, };
61
+ export { Asciidoc, Content, prepareDocument, Title, parse, processDocument, isOption, findSection, plainText, RenderInline, inlineHtml, Inline, };
60
62
  export type { InlineOverrides };
61
- export type { AdmonitionBlock, AudioBlock, Block, CoListBlock, DListBlock, DocumentBlock, DocumentSection, ImageBlock, ListBlock, LiteralBlock, ParagraphBlock, SectionBlock, TableBlock, VideoBlock, };
63
+ export type { AdmonitionBlock, AudioBlock, Block, Cell, CoListBlock, DListBlock, DocumentBlock, DocumentSection, ImageBlock, ListBlock, ListItemBlock, LiteralBlock, ParagraphBlock, SectionBlock, TableBlock, VideoBlock, };
62
64
  export * from './templates';
@@ -1,4 +1,4 @@
1
1
  export { parseInline, subSpecialchars, subCallouts, subCalloutsRaw } from './parser';
2
2
  export type { ParseOptions, ParseState } from './parser';
3
- export { renderInline, renderInlineAsString } from './renderer';
3
+ export { renderInline, renderInlineAsString, renderInlineAsText } from './renderer';
4
4
  export * from './types';
@@ -1,3 +1,22 @@
1
1
  import { InlineNode } from './types';
2
2
  export declare function renderInline(nodes: InlineNode[], iconsFont?: boolean): string;
3
3
  export declare function renderInlineAsString(nodes: InlineNode[], iconsFont?: boolean): string;
4
+ /**
5
+ * Render an inline AST back to PLAIN TEXT — the substituted source with no HTML
6
+ * markup. This is the verbatim-source counterpart to `renderInlineAsString`: it
7
+ * resolves text-level subs (notably `attributes`) but emits the bare code a
8
+ * syntax highlighter should tokenize rather than HTML5 elements.
9
+ *
10
+ * - `text` nodes: emitted as-is, with `specialcharacters` entities decoded back
11
+ * to literal `< > &` when `decodeEntities` is set (verbatim blocks include
12
+ * `specialcharacters` by default, so normally `true`). `raw` passthrough
13
+ * nodes (`pass:[]` / `+++`) are already-final author HTML — emitted verbatim,
14
+ * never decoded.
15
+ * - `quoted` / `anchor` / `footnote` / `button`: flattened to their inner text.
16
+ * A highlighter wants the code, not `<em>` / `<a>`; these only appear when the
17
+ * author opted into `+quotes` / `+macros` on the block.
18
+ * - `callout`: preserved raw as `<N>` — the highlighter resolves callouts itself.
19
+ * - `break`: a newline.
20
+ * - `image` / `kbd` / `menu` / `indexterm`: no meaningful verbatim text — skipped.
21
+ */
22
+ export declare function renderInlineAsText(nodes: InlineNode[], decodeEntities?: boolean): string;
@@ -0,0 +1,7 @@
1
+ import type { Block } from './prepareDocument';
2
+ /**
3
+ * First block whose `id` matches, depth-first. Descends through child blocks,
4
+ * list items, and table cells, so any anchored block — not just sections — is
5
+ * reachable by id.
6
+ */
7
+ export declare const findSection: (blocks: Block[], id: string) => Block | undefined;
@@ -0,0 +1,9 @@
1
+ import type { InlineNode } from '../inline';
2
+ /**
3
+ * Flatten an inline AST to its visible plain text, entity-decoded. The parser
4
+ * leaves numeric entities (`&#8217;`) in text nodes for React to round-trip, so
5
+ * plain text is where they must be resolved — the library owns both the walk
6
+ * (coupled to `InlineNode`) and the decode. For tooltips, `alt`/`title`, search
7
+ * indexing — anywhere a string is needed instead of a React tree.
8
+ */
9
+ export declare const plainText: (nodes: InlineNode[] | undefined) => string;
@@ -21,7 +21,7 @@ export type BaseBlock = {
21
21
  title?: string | undefined;
22
22
  level: number;
23
23
  };
24
- export type Block = BaseBlock | ParagraphBlock | AdmonitionBlock | CoListBlock | ImageBlock | LiteralBlock | SectionBlock | TableBlock | AudioBlock | VideoBlock;
24
+ export type Block = BaseBlock | ParagraphBlock | AdmonitionBlock | ListBlock | CoListBlock | DListBlock | ListItemBlock | ImageBlock | LiteralBlock | SectionBlock | TableBlock | Cell | AudioBlock | VideoBlock;
25
25
  export type DocumentSection = {
26
26
  id: string;
27
27
  title: string;
@@ -99,6 +99,13 @@ export interface LiteralBlock extends BaseBlock {
99
99
  type: 'listing';
100
100
  source: string;
101
101
  language: string | undefined;
102
+ /** `source` with the block's resolved text-level substitutions applied
103
+ * (notably `attributes`), un-escaped and un-highlighted — the plain code a
104
+ * syntax highlighter should tokenize. Equals `source` when the block's subs
105
+ * make no text-level change. Callout markers are preserved in raw `<N>` form
106
+ * (resolve them with `subCalloutsRaw`). Quote/macro subs, if enabled, are
107
+ * flattened to their text. */
108
+ subbedSource: string;
102
109
  }
103
110
  export interface SectionBlock extends BaseBlock {
104
111
  type: 'section';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxide/react-asciidoc",
3
- "version": "2.0.0",
3
+ "version": "2.1.0-canary.792ad4d",
4
4
  "files": [
5
5
  "dist"
6
6
  ],