@oxide/react-asciidoc 2.0.0 → 2.1.0

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';
@@ -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 (`’`) 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;
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",
4
4
  "files": [
5
5
  "dist"
6
6
  ],