
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
The gherkin npm package is a parser for the Gherkin language, which is used to write structured tests in a business-readable, domain-specific language. It is commonly used in Behavior-Driven Development (BDD) frameworks like Cucumber.
Parsing Gherkin Syntax
This feature allows you to parse Gherkin syntax into a structured format. The code sample demonstrates how to parse a simple Gherkin feature file and output the resulting JSON structure.
const { Parser } = require('gherkin');
const parser = new Parser();
const gherkinDocument = parser.parse(`
Feature: Example feature
Scenario: Example scenario
Given a precondition
When an action is performed
Then an outcome is expected
`);
console.log(JSON.stringify(gherkinDocument, null, 2));
Tokenizing Gherkin Syntax
This feature allows you to tokenize Gherkin syntax, breaking it down into individual tokens. The code sample demonstrates how to read and print tokens from a Gherkin feature file.
const { TokenScanner, TokenMatcher, GherkinLine, Token } = require('gherkin');
const scanner = new TokenScanner(`
Feature: Example feature
Scenario: Example scenario
Given a precondition
When an action is performed
Then an outcome is expected
`);
const matcher = new TokenMatcher();
let token;
while ((token = scanner.read()) && token.isEOF === false) {
console.log(token);
}
Generating Pickles
This feature allows you to generate 'pickles' from Gherkin documents. Pickles are a simplified, executable representation of Gherkin scenarios. The code sample demonstrates how to parse a Gherkin document and compile it into pickles.
const { Parser, Compiler } = require('gherkin');
const parser = new Parser();
const compiler = new Compiler();
const gherkinDocument = parser.parse(`
Feature: Example feature
Scenario: Example scenario
Given a precondition
When an action is performed
Then an outcome is expected
`);
const pickles = compiler.compile(gherkinDocument);
console.log(JSON.stringify(pickles, null, 2));
Cucumber is a tool for running automated tests written in plain language. It supports the Gherkin syntax and integrates with various programming languages. Compared to gherkin, Cucumber provides a full-fledged testing framework, including test execution and reporting.
Ace is a standalone code editor written in JavaScript. Our goal is to create a web based code editor that matches and extends the features, usability and performance of existing native editors such as TextMate, Vim or Eclipse. It can be easily embedded in any web page and JavaScript application. Ace is developed as the primary editor for Cloud9 IDE and the successor of the Mozilla Skywriter (Bespin) Project.
Check out the Ace live demo or get a Cloud9 IDE account to experience Ace while editing one of your own GitHub projects.
If you want, you can use Ace as a textarea replacement thanks to the Ace Bookmarklet.
Previously known as “Bespin” or lately “Skywriter” it’s now known as Ace (Ajax.org Cloud9 Editor)! Bespin and Ace started as two independent projects both aiming to build a no compromise code editor component for the web. Bespin started as part of Mozilla Labs and was based on the canvas tag, while Ace is the Editor component of the Cloud9 IDE and is using the DOM for rendering. After the release of Ace at JSConf.eu 2010 in Berlin the Skywriter team decided to merge Ace with a simplified version of Skywriter's plugin system and some of Skywriter's extensibility points. All these changes have been merged back to Ace now, which supersedes Skywriter. Both Ajax.org and Mozilla are actively developing and maintaining Ace.
Ace is a community project. We actively encourage and support contributions. The Ace source code is hosted on GitHub. It is released under the Mozilla tri-license (MPL/GPL/LGPL). This is the same license used by Firefox. This license is friendly to all kinds of projects, whether open source or not. Take charge of your editor and add your favorite language highlighting and keybindings!
git clone git://github.com/ajaxorg/ace.git
git submodule update --init --recursive
Ace can be easily embedded into any existing web page. The Ace git repository ships with a pre-packaged version of Ace inside of the build
directory. The same packaged files are also available as a separate download. Simply copy the contents of the src
subdirectory somewhere into your project and take a look at the included demos of how to use Ace.
The easiest version is simply:
<div id="editor">some text</div>
<script src="src/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
window.onload = function() {
var editor = ace.edit("editor");
};
</script>
To change the theme simply include the Theme's JavaScript file
<script src="src/theme-twilight.js" type="text/javascript" charset="utf-8"></script>
and configure the editor to use the theme:
editor.setTheme("ace/theme/twilight");
By default the editor only supports plain text mode. However all other language modes are available as separate modules. After including the mode's Javascript file
<script src="src/mode-javascript.js" type="text/javascript" charset="utf-8"></script>
the mode can be used like this:
var JavaScriptMode = require("ace/mode/javascript").Mode;
editor.getSession().setMode(new JavaScriptMode());
After the checkout Ace works out of the box. No build step is required. Simply open 'editor.html' in any browser except Google Chrome. Google Chrome doesn't allow XMLHTTPRequests from files loaded from disc (i.e. with a file:/// URL). To open the Ace in Chrome simply start the bundled mini HTTP server:
./static.py
The editor can then be opened at http://localhost:9999/editor.html.
To package Ace we use the dryice build tool developed by the Mozilla Skywriter team. To install dryice and all its dependencies simply call:
npm link .
Afterwards Ace can by build by calling
./Makefile.dryice.js
The packaged Ace will be put in the 'build' folder.
The Ace unit tests run on node.js. Before the first run a couple of node mudules have to be installed. The easiest way to do this is by using the node package manager (npm). In the Ace base directory simply call
npm link .
To run the tests call:
node lib/ace/test/all.js
FAQs
Gherkin parser
The npm package gherkin receives a total of 560,602 weekly downloads. As such, gherkin popularity was classified as popular.
We found that gherkin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.