GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - RickAllMighty8195/test-grammar: utility for testing vscode grammar files

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

18 Commits
18 Commits

Folders and files

NameName
Last commit message
Last commit date
.vscode
.vscode
 
 
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
suf.config.json
suf.config.json
 
 
tsconfig.json
tsconfig.json
 
 
tslint.json
tslint.json
 
 

Repository files navigation

Test grammar

npmV Custom githubLastCommit

Utility for testing grammar files, used with vscode.

Usage example

import { TestGrammar } from 'test-grammar';
new TestGrammar(
  JSON.stringify({
    scopeName: 'source.test',
    name: 'test',
    patterns: [
      {
        begin: '@',
        end: '$\\n?|(?=\\s|,|\\(|\\)|\\[|>)',
        name: 'at',
        patterns: [
          {
            match: '.*',
            name: 'name'
          }
        ]
      },
      {
        begin: '\\*\\*',
        end: '\\*\\*',
        name: 'bold',
        patterns: [
          {
            match: '[A-z]+',
            name: 'text'
          },
          {
            match: '\\d+',
            name: 'number'
          },
          {
            match: ' *',
            name: 'whitespace'
          }
        ]
      }
    ]
  }),
  { useSourceAsFile: true },
  run => {
    run(
      'test',
      `@syler
**text 0**`,
      `at|at name
bold|bold text|bold whitespace|bold number|bold`
    );
  }
);

Docs

  • interfaces

    • Expect
    • Text
    • Options
    • Run
    • RunOptions

interfaces

Expect
type Expect = string[][][] | string;
Text
type Text = string[] | string;
Options
interface Options {
    /** Also Logs Tokens that passed the test. */
    logAllTokens: boolean;
    /** Calls `process.exit(1)` when tests failed or if there is an error. */
    exitProcess: boolean;
    /** Uses the source parameter as input file, the input string is expected to be valid json textmate grammar. */
    useSourceAsFile: boolean;
}
Run
type Run = (name: string, text: Text, expect: Expect, options?: Partial<RunOptions>) => void;
RunOptions
type RunOptions = Pick<Options, 'logAllTokens'>;

Generated with suf-cli

Copyright (c) 2020 Leonard Grosoli Licensed under the MIT license.

About

utility for testing vscode grammar files

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.