/** * @fileoverview Turns Markdown into text a speech synthesizer can read. * * Markdown handed straight to a TTS engine is read literally: "hash hash Getting * started", "star star important star star". This module parses the document * instead and emits only the words, keeping the *structure* the marks encoded — * a heading becomes its own spoken segment ending in a full stop so the * synthesizer pauses, a list item becomes one sentence, a fenced code block is * announced rather than spelled out. * * It is deliberately dependency-free and runs in the browser as well as Node, so * `ReadAloudController` and the CLI can share it. */ /** Kind of block the converter recognised. */ export type SpeechSegmentType = "heading" | "paragraph" | "list-item" | "quote" | "code" | "table-row"; export interface SpeechSegment { type: SpeechSegmentType; /** Spoken text of the block, with every Markdown mark already removed. */ text: string; /** Heading level 1-6. Only set on `heading` segments. */ level?: number; } export interface MarkdownToSpeechOptions { /** * How headings are spoken. `text` (default) reads the heading words on their * own so they land between pauses; `announce` prefixes them with "Heading:"; * `skip` drops them entirely. */ headings?: "text" | "announce" | "skip"; /** * What to do with fenced code blocks. `announce` (default) replaces the block * with a short spoken note, `read` reads the code verbatim, `skip` drops it. */ codeBlocks?: "announce" | "read" | "skip"; /** `text` (default) speaks the link text and drops the URL; `text-and-url` reads both. */ links?: "text" | "text-and-url"; /** `alt` (default) speaks the image's alt text; `skip` drops images. */ images?: "alt" | "skip"; /** Read the YAML front matter block. Off by default. */ frontMatter?: boolean; /** `rows` (default) reads table rows as comma-separated cells; `skip` drops tables. */ tables?: "rows" | "skip"; /** * Append a full stop to blocks that do not end in punctuation, so the * synthesizer pauses between them instead of running them together. * Default true. */ addTerminalPunctuation?: boolean; } /** * Strips the inline marks — emphasis, code spans, links, images, raw HTML — from * a single line, leaving the words behind. */ export declare function stripInlineMarkdown(input: string, options?: MarkdownToSpeechOptions): string; /** * Parses Markdown into the blocks that should be spoken, in reading order. * * Use this when the caller wants the structure — to highlight the current * heading, say, or to skip to a section. Callers that only need something to * feed a synthesizer want {@link markdownToSpeech}. */ export declare function markdownToSpeechSegments(markdown: string, options?: MarkdownToSpeechOptions): SpeechSegment[]; /** * Converts Markdown to plain text ready for a speech synthesizer. * * Blocks are separated by blank lines so downstream chunkers (`splitTextSmart`) * break on them; runs of list items and table rows stay in one block so a list * is not chopped into one request per bullet. */ export declare function markdownToSpeech(markdown: string, options?: MarkdownToSpeechOptions): string; /** * Guesses whether a blob of text is Markdown, for callers with no filename to go * on (piped stdin, a paste). Errs towards `false`: prose read as Markdown is * mostly unchanged anyway, so only reasonably clear signals count. */ export declare function looksLikeMarkdown(text: string): boolean;