npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ink-tmlanguage

v0.2.3

Published

TextMate grammar files for Ink. (VS Code, Sublime Text, and Atom)

Downloads

14

Readme

Ink TMLanguage

Build Status npm version Licence Dependencies

Brings syntax highlighting for inkle's Ink, in your editor of choice (as long as it supports TextMate grammars).

If you're just looking for the plist-based grammar, head over to the releases!

Table of contents

Building the grammar

The grammar is written using the YAML-tmLanguage format, with a couple of additions borrowed from TypeScript-TmLanguage.

Building the grammar is easy, you need the latest version of node.js and your favourite npm-compatible package manager.

  1. clone this repository;
  2. run npm install or yarn install;
  3. run npm run build or yarn run build;
  4. the Ink.tmLanguage file should be available in grammars/.

Limitations

{ } constructs

In Ink, { } can be an alternative, a sequence, a switch, a conditional, etc. Since TextMate grammars can only match one line at a time, there are some small limitations.

Expressions

Expressions will not be fully highlighted in conditionals. Anything contained in the condition (before :) is named with the same scope.

{ x == 0: Hello }
{ x == 0: Hello | hi }
{ x == 0:
	Hello
  - else:
  	Hi
}
{
	- x == 0:
		Hello
}
{ window_opts < 2 || learnt(fingerprints_on_glass) || GlassState ? steamed:
	I looked away from the dreary glass.
}

This is not the case in the following example, where all expression tokens are named with their own scopes.

~ y = (x == 0)
~ myFunction(x == 0)

Additionally, while the following is perfectly valid ink, there's a false positive on both else: and then:.

{conditional()}
{conditional()}
{conditional()}
{conditional()}

=== function conditional() ===
{once:
  - if condition
  - then: do this
  - else: do that
  - end
}

This limitation can be worked around by escaping the colon:

=== function conditional() ===
{once:
  - if condition
  - then\: do this
  - else\: do that
  - end
}

Choices

In choice, it's sometimes possible for the content to be expressed on the next line if it's preceded by a condition. In the example below, the text supression of the first choice will not be highlighted, as it won't be matched as part of the choice. The second choice will however be highlighted properly.

VAR x = 0

* (firstChoice) {x == 0}
"Hello John Doe[."], I need to tell you something special"

* (secondChoice) {x != 0} "Hello John Doe[."], I won't say a word"

Building a custom theme

All the captures support the generic scopes recommended by the Sublime Text documentation, narrowed down to .ink. This means that the grammar will work out of box with existing themes.

Most of the captures are multi-scoped, with the first scope defined by the theme being used. Some of these multi-scoped captures support ink-specific scopes, which can be implemented by your custom theme. They are described below:

  • string.label.ink(label)
  • entity.tag.ink#tag
  • entity.todo.inkTODO
  • keyword.glue.ink<>
  • keyword.choice.ink*
  • keyword.choice.sticky.ink+
  • keyword.choice.suppression.ink[ ]
  • keyword.logic.ink~
  • keyword.gather.ink-
  • keyword.divert.ink-> or <-
  • keyword.alternative.type.ink& or ~ or ! inside { }
  • storage.knot.ink → Identifier after / between =
  • variable.other.knot.ink → a knot identifier in a divert
  • variable.other.stitch.ink → a stitch identifier in a divert
  • variable.other.label.ink → a label identifier in a divert

Availability through npm

As a convenience, the grammar is also available through the npm registry. If you're building an extension for Atom or VS Code, you may want to depend on this package.

Once installed, the grammar can be found in node_modules/ink-tmlanguage/grammars/Ink.tmLanguage.

Contributing

If the grammar is missing something, open an issue or fix it and submit a pull request! When working on the grammar, you may want to use npm run watch, which will rebuild the plist grammar on every change.

License

The grammar is released under the MIT license. See LICENSE for details.

This project borrows some code from TypeScript-TmLanguage, licensed under the MIT license.