caption.js 2.2.0: sentence and paragraph rules as options - #289
Merged
Merged
Conversation
A caption was closed at every word ending in a full stop, so an
abbreviation cut a sentence in two ("We spoke to Dr." / "Smith about
it.") and a run of short sentences came out one to a caption ("Yes." /
"No." / "Maybe."). init() takes an optional eighth argument:
- detectAbbreviations: a dotted abbreviation (e.g., U.S., p.m.) ends a
sentence only when a capital follows; a lone initial never does.
- abbreviations: words that never end a sentence, such as titles. They
are language-specific, so the caller supplies them.
- joinSentences: a short sentence shares the caption before it when the
whole sentence fits there. A sentence is never split to fill a
caption, and nothing is joined across a speaker label or a pause
longer than maxJoinGap (default 1s).
- paragraphBreaks: a new paragraph always starts a new caption, also
where the paragraph ended without punctuation.
With no options the output is unchanged.
Refs hyperaudio/hyperaudio-lite-editor#661, hyperaudio/hyperaudio-lite-editor#662
This was referenced Sep 21, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
caption.jscloses a caption at every word ending in a full stop. Two consequences, both measured in the editor:We spoke to Dr.·Smith about it.init()takes an optional eighth argument of rules. With no options the output is unchanged, and a test pins that.detectAbbreviationse.g.,U.S.,p.m.,Ph.D.) ends a sentence only when the next word starts with a capital, so "We left at 5 p.m. Then it rained." still breaks. A lone initial (J.) never ends one;I.is a word and does.abbreviationsDr.orProf., which no rule can tell from a sentence end because a capital follows them too. An array or Set; case and the trailing full stop are ignored. Language-specific, so the caller supplies them and the library ships no list.joinSentencesmaxJoinGap.maxJoinGapparagraphBreaks?,!,。,؟and an ellipsis behave as before. Joining measures the pause from where the previous caption's speech really ends, not from a stop time the timing safeguards may later extend.caption.d.tsgainsCaptionOptions, and the README documents the argument. 15 new tests; the caption suite is 28/28 and the whole suite 89/89.The version header moves to 2.2.0.
changelog.mdand the package version are left for the release commit.Refs hyperaudio/hyperaudio-lite-editor#661, hyperaudio/hyperaudio-lite-editor#662