TextParseConfig
TextParseConfig (crates/show/src/parse.rs) controls how extracted text is
split into cues during import. It is serializable and can be passed to
import_pdf_show from the frontend (camelCase field names in JSON).
Fields
| Field | Type | Default | Description |
|---|---|---|---|
maxCueLength | number | 140 | Target maximum cue length in characters. Longer passages are split. |
minCueLength | number | 40 | Fragments shorter than this are merged into a neighboring cue. |
splitPunctuation | string[] | [";", ":", "—", ","] | Split points, in priority order, for over-long sentences. |
Rust constants: DEFAULT_MAX_CUE_LENGTH, DEFAULT_MIN_CUE_LENGTH,
DEFAULT_SPLIT_PUNCTUATION.
Splitting algorithm
- Sentences are split on
.,!, and?(the terminator stays with the sentence it ends). - Long sentences (over
maxCueLength) are split at the strongest nearby punctuation. The splitter searches right-to-left within the window and prefers higher-priority punctuation, so a comma is used only when no semicolon, colon, or em-dash is available. - If no punctuation is available, it splits at the last whitespace in the window, so a word is never cut in two. A sentence with no whitespace at all (one giant word) is kept whole.
- Small fragments (under
minCueLength) are merged into a neighboring cue, so imports don't contain stunted one-word cues.
These steps are implemented by split_cue_text, which composes split_sentences,
split_long, find_split_point, and merge_small_into_neighbours.
Example
import { importPdfShow } from "@/lib/tauri";
// (The frontend wrapper currently passes no config; call invoke directly to
// override the defaults.)
await invoke("import_pdf_show", {
config: {
maxCueLength: 100,
minCueLength: 30,
splitPunctuation: [";", ":", "—", ","],
},
});
Notes
- Lengths are measured in characters, not bytes, so multi-byte characters split correctly.
- Setting
minCueLengthto0disables merging. - Removing all
splitPunctuationstill yields word-boundary splitting.