Rewrite Hyperaudio JSON export as flat words/paragraphs/sections#297
Merged
Conversation
The previous JSON shape mirrored the editor's HTML
(article.section.paragraphs[].spans[]), which round-tripped
but was awkward for downstream consumers. Replace with three
flat arrays:
words[] — { start, end, text } in seconds, in document
order.
paragraphs[] — { speaker, start, end } speaker turns. A
paragraph without an explicit speaker tag in
the HTML inherits the previous paragraph's
speaker.
sections[] — { start, end, mediaUrl }, one per <section>
in the transcript. mediaUrl comes from the
current #hyperplayer src.
jsonToHtml accepts the new shape and rebuilds the editor HTML,
emitting speaker tags only on speaker change (matching the
editor's convention). Legacy exports (with jsonData.article)
still import via a legacyJsonToHtml fallback. The top-level
jsonData.url field is no longer written but is still read on
import for back-compat.
Closes #296.
This was referenced May 27, 2026
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.
Summary
Replaces the nested
article.section.paragraphs[].spans[]export shape with three flat arrays that are easier for downstream consumers to read, slice, and stream:{ "words": [ { "start": 34.76, "end": 35.4, "text": "Test" } ], "paragraphs": [ { "speaker": "SPEAKER_S1", "start": 34.76, "end": 44.68 } ], "sections": [ { "start": 0, "end": 239.02, "mediaUrl": "https://example.com/audio.mp3" } ] }startandend.start.sections[]captures the source-media context.mediaUrlwas previously a top-leveljsonData.urlfield; it's now per-section.Implementation notes
htmlToJsonwalks<section>→<p>→<span data-m>, splits speaker spans (class="speaker") out intoparagraph.speakerwith brackets stripped, and inherits speaker across paragraphs that have no explicit tag (matching the editor's convention).jsonToHtmlrebuilds the editor HTML using a two-pointer walk to bucket paragraphs into sections and words into paragraphs (sorted bystart, handles boundary equality cleanly). Speaker tags are emitted only on speaker change.jsonData.articlepresent) still import via alegacyJsonToHtmlfallback so older saved files keep working.exportJson()no longer writes the top-leveljsonData.url.importJson()reads fromsections[0].mediaUrl, falling back to legacyjsonData.urlif present.Closes #296.
Test plan