![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Highlight is a simple syntax highlighting gem for Ruby and Rails. It's basically a wrapper around the popular http://pygments.org highlighter that's written in Python and supports an impressive number of languages.
If pygments is installed on the machine and in the PATH
, that binary is used, otherwise
the plugin falls back to the web API at http://pygments.simplabs.com/,
created by Trevor Turk.
See the API docs at http://rdoc.info/projects/simplabs/highlight.
Highlight can either be used standalone via
require 'simplabs/highlight'
Simplabs::Highlight.highlight(:ruby, 'class Test; end')
or in Rails where it adds the highlight_code
helper:
highlight_code(language, code = nil, &block)
language
may be either a Symbol or a String (see supported languages
below). The code can be passed either as a string or inside a block, e.g.:
highlight_code(:ruby, 'class Test; end')
or
highlight_code(:ruby) do
klass = 'class'
name = 'Test'
_end = 'end'
"#{klass} #{name}; #{_end}"
end
Since highlighting the code takes a while, all highlighted source code should be cached, e.g.:
<%- code = 'class Test; end' -%>
<%- cache Digest::SHA1.hexdigest(code) do -%>
<%= highlight_code(:ruby, code) -%>
<%- end -%>
The following languages are supported (there are probably more that are supported by pygments
).
All of the paranthesized identifiers may be used as parameters for highlight to denote the
language the source code to highlight is written in (use either Symbols or Strings).
as
, as3
, actionscript
)applescript
)bash
, sh
)c
, h
)clojure
)c++
, cpp
, hpp
)c#
, csharp
, cs
)css
)diff
)dylan
)erlang
, erl
, er
)html
, htm
)java
)javascript
, js
, jscript
)jsp
)make
, basemake
, makefile
)objective-c
)ocaml
)perl
, pl
)php
)python
, py
)erb
, rhtml
)ruby
, rb
)scala
)scheme
)smalltalk
)smarty
)sql
)xml
, xsd
)xslt
)yaml
, yml
)Installation is as easy as
gem install highlight
To use highlight in Rails apps, you have to define the dependency in the Gemfile:
gem 'highlight', :require => 'simplabs/highlight'
Highlight also comes with a default CSS file that defines styles for the highlighted code. This CSS file can be copied to
your application's public/stylesheets
directory via
./bin/rails generate highlight_styles
If you don't have python and pygments installed, you will need that too. For instructions on installing pygments, refer to http://pygments.org/docs/installation/.
Copyright (c) 2008-2010 Marco Otte-Witte (http://simplabs.com), released under the MIT license
The actual highlighting is done by Pygments (http://pygments.org).
FAQs
Unknown package
We found that highlight 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.