Files
ai.interactive.fiction/MARKUP_GUIDELINES.md
T

10 KiB

Markup Guidelines

This file documents author-facing Ink tag conventions. The active parser normalizes tags into structured StoryTag objects before they reach the UI.

Eibenreith Ink Architecture

WritingWithInk.md is the official Ink language reference and must not be edited for project conventions. This file is the author-facing project guide.

All Ink source and UI localization files must be UTF-8 and use real German characters directly: ä, ö, ü, Ä, Ö, Ü, ß, „…“. Do not replace them with ae, oe, ue, ss, or ASCII quotation marks as an encoding workaround.

Eibenreith uses a bucket architecture. This is mandatory for authored content, not a suggestion. The active choice surface is collected in this priority order:

  1. Moment bucket
  2. Room entry or room look
  3. Room exits
  4. Episode bucket
  5. Game bucket

Every room is declared through enter_room(location, entry, look, exits, bucket). The room entry knot contains the one-time first description. The look knot contains the repeat look action. The exits knot contains traversal choices. The bucket contains complete conditioned weaves for local interactions.

=== train_washroom ===
-> enter_room(loc_train_washroom, -> train_washroom_entry, -> train_washroom_look, -> train_washroom_exits, -> train_washroom_bucket) -> TURN

Bucket content must be written as complete conditioned weaves directly inside the bucket. Do not split ordinary bucket choices into one-line _choices knots or pass-through knots. A separate knot is allowed only when the content is genuinely reused or when the exception is explicitly justified, such as the identity papers tunnel in character_generator.ink.

=== train_washroom_bucket ===
* {lacks(face_def)} [AUTO: Spiegelbild im Waschraum] #auto
    -> washroom_mirror_character_generator

* {lacks(washroom_toilet_used)} [__Benutze__: Die Toilette. #key:t]
    ~ mark(washroom_toilet_used)
    Du schiebst den Riegel vor und nimmst dir die Zeit, die eine Reise dem Körper selten höflich anbietet.
    -> TURN
-> DONE

Use -> TURN at the end of a chosen atomic weave when play should continue at the current choice surface. Use -> DONE only to close a bucket/provider knot that merely offers choices. Do not call -> provide_choices in authored chapter files; it is internal helper implementation.

Choice text is written from Valerie's perspective before the action. It may describe intention, attention, posture, or immediate action. It must not reveal what the branch will discover after the choice.

Good:

* [__Versuche__: Die andere Übergangstür. #key:w]

Bad:

* [__Prüfe__: Die Tür zu den Wagen zweiter und dritter Klasse. #key:w]

Use Ink's built-in visit tracking for simple “this knot has been seen” facts. Do not create parallel flags such as seen_train_compartment. Use LIST state only for semantic progress, encounter chains, timetable state, locations, character-generation facts, tutorials, and other authored state that has meaning beyond a knot visit.

Helper Conventions

Author-facing helper functions live in data/ink-src/eibenreith/helpers.ink and are documented in comments there. Important families:

  • route_*: Valerie route counters such as route_composure and route_sapphic.
  • time_*, day_*, slot_*, episode_*: timetable and episode control.
  • meal_*: arrival-day meal plan.
  • loc_*, enter_room, present, companion_*: traversal, room setup, and companion presence.
  • state_*: ordered high-watermark encounter/progress state.
  • mark, has, lacks: exact checklist facts.
  • tutorial: returns true once and marks the tutorial as shown.
  • rel_*: relationship counters and two-value relationship-axis queries.

Relationship counters use only the standard value pairs declared in characters.ink:

  • agreeable / adversarial
  • open / closed
  • bold / passive
  • reliable / unreliable
  • insightful / dull

Do not add per-character custom relationship dimensions. If a concept does not fit the shared matrix, express it in prose or in a semantic encounter LIST.

Implemented Tag Forms

Use bracket tags for titles, filenames, and longer text:

#chapter[Eibenreith]
#image[statue.png](square)
#music[Kaiserpunk Waltz.mp3](crossfade, loop, lead=8)
#sfx[church-bells.ogg](max=8, fade)
#score[You reached an ending.]
#achievement[First Steps]
#alert[Try examining the room.]

Use colon tags for short identifiers, categories, and choice keys:

#action:movement
#key:l
#sort:last
#gated:noble

Bare flags are accepted as tags with no value:

#optional
#auto

Right-Page Glossary Notes

Glossary notes are story tags scoped to the paragraph/block they belong to. They affect only the right-page story rendering, never choice text or command history.

The conductor points toward Eibenreith.
#gloss[Eibenreith](A fictional alpine town in the Kaiserpunk setting.)

The bracket value is the visible term to find. The parenthesized value is the note shown on hover/focus. The renderer marks every matching instance of the term in the same right-page block. The tag is not displayed and is not sent to TTS. Avoid raw Ink control characters in the explanation; |, {, and } must be escaped in Ink as \|, \{, and \} if they are needed literally.

TTS Reading Instructions

TTS instruction tags are story tags scoped to the paragraph/block they belong to. They are not rendered, and they are only sent to TTS providers that support per-request reading instructions. Currently this means OpenAI with gpt-4o-mini-tts.

„Ich habe nichts gesehen“, sagt Viktor.
#tts[Read softly, with controlled unease.]

The default form omits a provider and is the preferred authoring style. Providers that support instructions may consume it; providers that do not support instructions silently ignore it. Provider-specific instructions are only needed when two providers should receive different direction, or when an instruction must be hidden from all but one provider. They use the tag parameter position:

„Ich habe nichts gesehen“, sagt Viktor.
#tts[openai](Read softly, with controlled unease.)

The shorthand #tts-openai[...] is also accepted. #tts(...) is equivalent to providerless #tts[...] if parentheses read better in a local context. tts-1 and tts-1-hd ignore these instructions because the OpenAI speech endpoint only supports the instructions request parameter for gpt-4o-mini-tts.

Keep instructions short and describe performance rather than content. OpenAI's TTS guide recommends using gpt-4o-mini-tts when you need controllable delivery; useful instruction targets include tone, emotional range, intonation, speaking speed, accent, impressions, and whispering. Good examples:

#tts[Speak with restrained concern and a slower pace.]
#tts[Whisper the line with controlled urgency.]
#tts-openai[Use a dry, formal tone; avoid melodrama.]

Avoid repeating the full dialogue in the instruction. Put the words to be spoken in the story text, and use #tts only to describe how the provider should read that block.

Choice Metadata

Choice tags are placed on the Ink choice they belong to:

* [__Schaue__: Aus dem Fenster.]
  #action:orientation
  #key:l

Implemented choice metadata:

  • #key:x: reserves keyboard key X for the choice.
  • #letter[x]: older equivalent for reserving keyboard key X.
  • #action:group or #action[group]: assigns the choice to an invisible action group.
  • #auto: hides the choice from the visible list and lets the UI choose it automatically when it is ready.

The current UI renders all non-auto choices in one visible list. Choices are first grouped by #action in the order each new action group appears in the authored choice list. Choices inside each group are randomized. Choices without #action form one final unlabelled group shown after all tagged groups. Explicit keys are assigned before automatic keys; choices without explicit keys receive 1 through 0, then A through Z in final visible order while skipping explicit keys. #optional choices are displayed italic. Grouping columns, #gated[...], and #sort[...] are documented authoring conventions or future metadata, not fully implemented UI behavior yet.

Auto choices are ordinary Ink choices with a developer-facing choice text in [...]. The UI does not show that text in normal play, but Inky needs it for local testing and the text makes the source readable. Ink owns availability and once-only behavior; the UI owns automatic selection and timing. Supported forms:

* {condition} [AUTO: Ereignisname] #auto
    -> event

* {condition} [AUTO: Ereignisname] #auto(2)
    -> event

* {condition} [AUTO: Ereignisname] #auto[tunnel](2)
    -> event

#auto fires as soon as it is the first ready auto choice. #auto(2) waits at least two UI choice turns since the previous global auto trigger. #auto[keyword](2) waits only against the same keyword, so unrelated auto groups do not throttle each other. Use the global form when two different authored events must not fire immediately after each other.

Popup And End-State Tags

These tags may appear as Ink global tags, paragraph tags, or empty tag-only lines. They are dispatched through the same tag channel as media tags.

#score[You reached the quiet ending.]
#error[The story ended unexpectedly.]
#achievement[First Steps]
#alert[Try examining objects before using them.]
  • #score[...]: intended ending. When the turn reaches inputMode: end, the UI shows a localized ending popup with the tag value as the optional message.
  • #error[...]: unrecoverable ending. The UI shows a localized error popup with the tag value as the optional message. The Ink engine emits this automatically if Ink runs out of content without an explicit #score[...] or #error[...].
  • #achievement[...]: queued localized achievement popup while the game continues.
  • #alert[...]: queued localized player hint/tutorial popup while the game continues.

Existing Media And Structure Tags

#chapter[Title]
#section
#textblock
#image[filename.png](landscape)
#image[filename.png](portrait pause=2)
#image[filename.png](square lead=1.5)
#music[track.mp3](crossfade, loop, lead=4)
#sfx[file.ogg](max=8 fade fade-duration=2)

Asset filenames resolve relative to the configured image, music, and sound folders.