
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
= Syntax
A syntax highlighting a library for Ruby.
{}[https://travis-ci.org/dblock/syntax]
This fork is maintained and version 1.1.0 has been published from it. However, there's currently none or not much new development going on here and the original author, @jamis[https://github.com/jamis], recommends using CodeRay[http://coderay.rubychan.de], over this library.
== About
This is a simple syntax highlighting library for Ruby. It is a naive syntax analysis tool, meaning that it does not "understand" the syntaxes of the languages it processes, but merely does some semi-intelligent pattern matching.
== Usage
There are primarily two uses for the Syntax library:
=== Highlighting a supported syntax
require 'syntax/convertors/html'
convertor = Syntax::Convertors::HTML.for_syntax "ruby" puts convertor.convert( File.read( "file.rb" ) )
The above snippet will emit HTML, using spans and CSS to indicate the different highlight "groups". (Sample CSS files are included in the "data" directory.)
=== Tokenize text
require 'syntax'
tokenizer = Syntax.load "ruby" tokenizer.tokenize( File.read( "file.rb" ) ) do |token| puts "group(#{token.group}, #{token.instruction}) lexeme(#{token})" end
Tokenizing is straightforward process. Each time a new token is discovered by the tokenizer, it is yielded to the given block.
FAQs
Unknown package
We found that syntax demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.