图书格式

Sections and blocks

Section files, and every block for text, lines, grammar and lesson flow.

规范正文为英文。

L is a Localized map (base-language text by locale); ? marks an optional field.

Section files

{
  "schema": 2,
  "id": "sfs-l01-learn",
  "name": "learn",
  "blocks": [
    { "kind": "heading", "id": "h1", "level": 2, "text": { "en": "Saying hello" } },
    { "kind": "text", "id": "t1", "text": { "en": "Spanish has one word for hello at any time of day." } }
  ]
}
Field Required Meaning
schema yes 2.
id yes The section id from book.json.
name yes The section name from book.json.
blocks yes The content, in reading order.

Every block has kind and id. Container blocks (box, callout, collapsible) hold more blocks in their own blocks array.

Styles. Any block may also carry style, a name for the look it should have, such as { "kind": "box", "style": "double", … }. Each kind has a default look and may offer more; a reader that does not know the name draws the default, so a new style never hides content and needs no higher formatVersion. Styles today: box has double (a double-line border; the older "variant": "double" still works), and callout takes any name defined under style.callouts in book.json, falling back to its variant. A book can also define its own named looks for any kind (Block presets, under book.json).

Block reference

L means a Localized map. ? marks an optional field. Field names are case-sensitive.

Text and structure

kind Fields Shows
heading text L, level? 1–3 A heading.
text text L, or runs A paragraph. See Rich text below.
quote text L, cite? L A quotation.
list items: [{text: L}] or [{blocks: [...]}], ordered? A bulleted or numbered list.
divider variant? A rule between parts.
box blocks, variant? A plain panel around blocks.
callout variant (note or key), blocks, title? L A highlighted panel: note for an aside, key for the point to remember.
collapsible title L, blocks, defaultOpen? A panel the reader opens.
table columns, rows A table (below).
image src, alt?, caption? L, width?, height?, bleed? A picture. bleed: true runs it edge to edge.
audio src, label? L, inline? A play button for one clip.
lessonLink chapterID?, sectionID?, title? L A link to another part of the book.
code code, language?, filename? Preformatted code.
terms items: [{term: L, def: L}] A glossary of base-language terms.
nextBook work, title L, button L, text? L A card at the end of a book pointing to the next one (work is its package name).

Rich text. Instead of text, a text block can carry runs: for each locale a list of runs, each { "t": "words", "marks": [...] }.

{ "kind": "text", "id": "t2", "runs": {
  "en": [
    { "t": "Say " },
    { "t": "hola", "marks": [{ "kind": "gloss", "target": "hola", "base": { "en": "hello" }, "pron": "OH-lah" }] },
    { "t": " to anyone. It is ", "marks": [] },
    { "t": "never", "marks": ["bold"] },
    { "t": " rude." }
  ] } }

Marks: bold, italic, underline, highlight, code, {"kind": "link", "href": "https://…"}, and {"kind": "gloss", "target", "base": L, "pron"?} (a tappable word with its meaning).

Tables. columns is a list of {id, title: L, width?, align?}; width is "auto", "flex" or a number of points; align is leading, center or trailing. rows is a list of rows, each a list of cells {text: L} or {blocks: [...]}, with audio? and span? {col, row}.

Target-language lines

kind Fields Shows
vocab entries: [{fa, pron, gloss, type, marked?, audio?, image?, imageFill?, emoji?, extra?, pitch?}] Word cards. type is the part of speech label (noun, verb …). marked is the word with vowel marks or kana reading. extra: true marks a word that is not core. pitch is a Japanese pitch-accent number. Words here feed review.
sentences items: sentence items, numbered? Example sentences with audio.
phraseList items: sentence items A phrasebook list.
practiceWords items: sentence items, highlight Words to read aloud; highlight is the letter or part to colour in each.
dialogue turns: [{fa, gloss, pron?, audio?, speaker?: L, speakerTarget?}], title? L, titleTarget? A scripted conversation.
chat turns: [{fa, gloss, pron?, audio?, speaker?: L, speakerTarget?, me?, colloquial?: {fa, pron?, audio?}}], labels?: {book: L, spoken: L} The same conversation as chat bubbles. me: true puts the turn on the reader’s side. With colloquial forms and labels, the reader can switch between the written and the spoken register.
colloquial items: [{formal: {fa, pron?, audio?}, colloquial: {fa, pron?, audio?}}], title? L, note? L Written form next to everyday spoken form.
conjTable rows: [{fa, gloss, pron?, person?}], caption? L A conjugation table.
rootCard label, text L, pron? A word root or stem with its meaning.
pronGuide items: [{glyph, ipa, hint?: L, word?, pron?, gloss?: L, note?: L}] How each sound is written and said.
readLadder rows: [{label: L, items: sentence items}], hint? L Reading practice from easy to hard.

Grammar

kind Fields Shows
note body L, label?, examples? A grammar note.
rule body L, label?, examples? A grammar rule.
legend items: [{title, body: L, examples?}], title? L A set of short explanations (title is a plain string, often target text).

An example is {fa, gloss, pron?, highlight?: {fa?, pron?}, parts?}. highlight colours the part of the line the note is about. parts labels the line by role, each {t, role}; t must appear in fa in order, and role is one of topic, subject, frequency, time, companion, place, object, predicate, verb.

Lesson flow

kind Fields Shows
lessonOpener goals: [L], title? L, letters?: [string], meta? L The start of a lesson: what the reader will be able to do, letters it introduces, time and steps (meta).
quickCheck question L, choices: [{fa} or {text: L}] (2+), answer (index from 0), explain? L One question with instant feedback. Nothing is recorded.
goalCheck goals: [L], title? L, progress? L The lesson’s goals as a checklist at the end. progress may use {done} and {total}.
exercise see 6.5 A scored exercise.