
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.
vscode-oniguruma
Advanced tools
The vscode-oniguruma package is a Node.js binding to the Oniguruma regular expressions library. It is primarily used in Visual Studio Code to power the textmate tokenizer, which is responsible for syntax highlighting based on TextMate grammars. The package allows for efficient regular expression matching and is optimized for use in text editors.
Regular Expression Matching
This feature allows you to match strings against regular expressions. The code sample demonstrates how to load the Oniguruma WebAssembly binary, create a new OnigScanner with a regular expression, and find the next match in a given string starting from a specific position.
const { loadWASM, OnigScanner } = require('vscode-oniguruma');
// Load the WebAssembly binary for Oniguruma.
loadWASM(require('vscode-oniguruma/release/onig.wasm')).then(() => {
const scanner = new OnigScanner(['\\w+']);
const match = scanner.findNextMatchSync('hello world', 0);
console.log(match);
});
Syntax Highlighting
This feature is used for syntax highlighting by matching keywords or patterns in a source code string. The code sample shows how to create an OnigScanner with a pattern for matching 'if' or 'else' keywords, create an OnigString from source code, and then find and log the matched keyword.
const { OnigScanner, OnigString } = require('vscode-oniguruma');
const scanner = new OnigScanner(['\\b(if|else)\\b']);
const source = new OnigString('if (condition) { return true; } else { return false; }');
const match = scanner.findNextMatchSync(source, 0);
if (match) {
console.log(`Matched keyword: ${source.content.substring(match.captureIndices[0].start, match.captureIndices[0].end)}`);
}
XRegExp is an npm package that provides augmented, extensible regular expressions. It includes additional syntax and flags and offers features like named capture groups and format strings. While it does not use WebAssembly and is not specifically optimized for syntax highlighting in editors, it is a powerful tool for complex regular expression operations in JavaScript.
RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is built on the RE2 C++ library and prevents catastrophic backtracking by design. Unlike vscode-oniguruma, RE2 focuses on performance and safety in regular expression matching rather than syntax highlighting.
access oniguruma api from packaged with vscode
FAQs
VSCode oniguruma bindings
We found that vscode-oniguruma demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 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.