frontispiece / packages / ink-processor / src / config.ts
config.ts
Raw
/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

import { InkChoice } from "./inkTypes"
import { VisualInkChoice, VisualInkLine } from "./types"

export type InkParserConfigParams = {
	/**
	 * The prefix of a line that would be identified as a command.
	 * Setting it to an empty string will remove the custom command functionality.
	 * By default, is `$`.
	 */
	commandIdentifier: string

	/**
	 * Custom line parser, if you want a different set of tokens and tags from the default
	 * included with ink-processor. This should be defined as a function that takes in the original line,
	 * and produces an object with any amount of tokens or additional metadata to feed into your story.
	 */
	lineParser?: (line: string) => VisualInkLine 

	/**
	 * Custom choice parser, if you want a different set of tokens and tags from the default
	 * included with ink-processor. This should be defined as a function that takes in the original choice text,
	 * and produces an object with any amount of tokens or additional metadata to feed into your story.
	 */
	choiceParser?: (choice: InkChoice) => VisualInkChoice
}