Namespace: parser

parser

Parchment features

Since:
  • 2.4
Source:

Methods

closeAllTags()

Closes all open tags opened by parser#openTag.

Since:
  • 2.5
Source:

closeTag()

Close a tag opened by parser#openTag and end output to it. The output will be directed to the previously open tag, or to the main stream if none is open.

Since:
  • 2.5
Source:

getStream()

This is used by Parchment to determine which element to use for stream output.

Source:

hideCommand(hide)

Hides the current turn's command at the end of turn.

Parameters:
Name Type Argument Default Description
hide boolean <optional>
true

Set to false to undo a previous call to this method.

Source:

hideOutput(silent)

Sets the current turn silent, i.e. its output will be hidden.

Parameters:
Name Type Argument Default Description
silent boolean <optional>
true

Set to false to undo a previous call to this method.

Source:

isVorpleStory() → {boolean}

Tells whether the currently loaded story file supports Vorple.

Since:
  • 2.5
Source:
Returns:
Type
boolean

openTag(tag, classes)

Open a HTML tag. The output will be directed inside this tag until it's closed.

Parameters:
Name Type Description
tag string

The tag's name (e.g. "span", "p")

classes string

Classes to be applied to the tag, separated by spaces

Since:
  • 2.5
Source:

registerFilter(filter, options) → {object}

Registers a new output or input filter.

Parameters:
Name Type Description
filter function

The filter function. The function is called with two parameters, the first containing the text passing through the filter (story output or reader input) and the second is an object containing various meta information.

options object

Options. name (string): the name of the filter. Filters must have unique names; if a new filter is registered with the same name as an existing one, the old filter is replaced. If no name is provided a random name is generated. priority (int): the order in which the filters are executed. Filters with higher priority are executed first. Default is 0. Negative priorities are allowed. type (string): either "input" or "output" (default is "output").

Source:
Returns:

The created filter object: { filter: (function), name: (string), priority: (integer) }

Type
object

scrollTo(target, duration, callback)

Scrolls to a given position on the page.

Parameters:
Name Type Argument Default Description
target jQuery | string | number

The element to which the page should scroll to, either as a jQuery element or a jQuery selector, or the target position in pixels

duration number <optional>
150

The duration of the scroll animation in milliseconds. Set to 0 for no animation.

callback function <optional>

Callback function executed after scrolling has finished.

Source:

sendCommand(command, options)

Sends a command to the parser.

Parameters:
Name Type Description
command string

The command to send

options object

Options as an object:

  • hideCommand (default false): hide the prompt of this command from the transcript

  • hideOutput (default false): don't show the output of the command

  • skipFilters (default false): don't apply input/output filters to this command

Source:

sendPrimaryCommand(command, options)

Sends a primary command to the parser. Primary commands are put into a different queue and handled before the main command queue. This guarantees that command-specific communication with the story file is handled right after the main command has finished.

Parameters:
Name Type Description
command string

The command to send

options object

Options as an object, see sendCommand()

Source:

sendSilentCommand(command)

Sends a command to the parser behind the scenes without showing either the command or the result to the reader. A shortcut for vorple.parser.sendCommand( command, { hideCommand: true, hideOutput: true, skipFilters: true } );

Parameters:
Name Type Description
command string

The command to send

Source:

sendSilentPrimaryCommand()

sendSilentCommand(), but the command is placed in the primary command queue. See also sendPrimaryCommand().

Source:

setTurnType(type)

Sets the current turn's type. Supported types are "normal", "meta", "undo" and "dialog".

Parameters:
Name Type Description
type string
Source:

setVorpleSupport()

Calling this method tells the interpreter that the story file supports Vorple. The Inform extension does this automatically and there shouldn't be a need to call it anywhere else.

Since:
  • 2.5
Source:

unregisterFilter(name)

Unregisters (removes) a filter.

Parameters:
Name Type Description
name string

The name of the filter to remove

Source:
Vorple Copyright © 2011-2014 the Vorple project
Documentation generated by JSDoc 3.2.2 on Wed May 07 2014 14:47:40 GMT+0300 (EEST) using the DocStrap template.