Crate choco

source ·
Expand description

§Syntax

Every signal is prefixed with @-character. Signals may contain

  • just a prompt (e.g. @wave)
  • just a parameter (e.g. @{ My important param })
  • both prompt and parameter (e.g. @bookmark{into})
  • or neither (e.g. Pay attention! @).

Three signal prompts are taken by Choco. These are bookmark, choice and style.

§Branching

Branching is easy in Choco. @bookmark{bookmark-name} registers a graph node, and @choice{chosen-bookmark-name} creates an edge between bookmark this choice belongs to and chosen bookmark. For example:

@bookmark{greet}
– Hello, you!
@choice{greet}– Come again?
@choice{bye}– Hi!

@bookmark{bye}
– Well, farewell..

§Styling

Styling text is done with @style signal. It accepts a mix of shortened to one character style names and prefixes promptless parameter, containing text. For example,

@style{qbp}@{- Hello, you!}

Style names are slightly opinionated, but you decide how to display a mix of them:

CharStyleNote
pPaneli.e. block
cCode
q> Quotedoesn’t have to be block-quote
bBold
iItalic
sScratchi.e. strike-through

Re-exports§

Structs§

Enums§

Functions§

  • Go through text and parse signals out
  • Consume bookmark and choice signals from text to create a graph

Type Aliases§

  • Guide can help searching for the particular bookmark story should continue from
  • A story is a graph where spans of text are connected to each other through choices. Ranges of original string stored in nodes relate to main text under a particular bookmark, and the ranges stored in edges relate to the text of a certain choice.