codemirror-lang-inform7
v0.2.0
Published
Inform 7 language support for the CodeMirror code editor.
Readme
Inform 7 for CodeMirror
This package implements Inform 7 syntax highlighting for the CodeMirror 6 code editor.
Inform 7 extensions are not fully supported. (They are mostly fine, only extension-specific parts such as the documentation are not highlighted.)
Inform 6 inclusions have basic highlighting, and Preform inclusions are not supported at all.
Usage
import { EditorState, EditorView, basicSetup } from "@codemirror/basic-setup"
import { inform7 } from "codemirror-lang-inform7"
const editor = new EditorView({
state: EditorState.create({
extensions: [
basicSetup,
EditorView.lineWrapping,
inform7(),
],
}),
parent: document.body,
})Theming
The highlighter uses the following tags in Inform 7:
blockCommentfor commentsbracketfor(-and-)surrounding I6 inclusionsdefinitionKeywordfor table names (might change in the future)escapefor text substitutions (might change in the future)heading1for the story title (e.g."My awesome IF" by Natrium729)heading2forVolumeheadingsheading3forBookheadingsheading4forPartheadingsheading5forChapterheadingsheading6forSectionheadingsinvalidfor unpaired brackets in I7 texts and substitutionsstringfor texts
Inside I6 inclusions, the following are used:
atomfor dictionary wordsboolfortrueandfalsecontrolKeywordsfor keywords (e.g.if, but those that are not really for control, likenew_line, might be attributed another tag in the future)escapefor escape sequences in strings (e.g.~or@:e)floatfor floats (e.g.$+9.3e-2)integerfor numbers, binary numbers (e.g.$$10), hex number (e.g.$E9) and characters (e.g.'n')lineCommentfor commentsnullfornothingoperatorKeywordfor e.g.hasorofclassprocessingInstructionfor directives (might change in the future)selfforselfstringfor strings
For developers
The syntax highlighting is implemented with a stream parser in src/index.ts.
To build, use:
$ npm run prepareTo test the highlighting in a CodeMirror editor, use:
$ npm run build-previewThen you can open the file preview/index.html in your favourite browser and type some Inform 7 code.
License
MIT. See the file LICENSE at the root of the repository.
