Sha256: b9986acd7a29c18db3197dd8945def2c792655fbe0bba204241ea8fb7c3dd8b0

Contents?: true

Size: 1010 Bytes

Versions: 20

Compression:

Stored size: 1010 Bytes

Contents

Because Syntax was written primarily to support syntax highlighting, that is going to be the task most clients of the library will use it for. So, to get you up and running quickly, converting, for example, Ruby code to HTML, consider the following:

{{{lang=ruby,number=true,caption=Convert a Ruby script to HTML
require 'syntax/convertors/html'

convertor = Syntax::Convertors::HTML.for_syntax "ruby"
html = convertor.convert( File.read( "program.rb" ) )

puts html
}}}

The above script will convert a Ruby file called @program.rb@ to HTML, writing the HTML to stdout. HTML @span@ tags will be used in conjunction with "class" attributes to describe the various tokens--this allows you to use CSS to colorize the result.

Incidentally, this entire document uses the Syntax library to colorize the Ruby code snippets!

_Note: currently, only HTML conversion is supported, but it should be possible to create a convertor that takes the tokenized output and emits other formats, like LaTeX, PDF, or Rich Text._

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
typo-3.99.0 vendor/syntax/doc/manual/parts/0001.txt
typo-3.99.2 vendor/syntax/doc/manual/parts/0001.txt
typo-3.99.1 vendor/syntax/doc/manual/parts/0001.txt
typo-3.99.3 vendor/syntax/doc/manual/parts/0001.txt
typo-4.0.1 vendor/syntax/doc/manual/parts/0001.txt
typo-3.99.4 vendor/syntax/doc/manual/parts/0001.txt
typo-4.0.0 vendor/syntax/doc/manual/parts/0001.txt
typo-4.0.2 vendor/syntax/doc/manual/parts/0001.txt
typo-4.1.1 vendor/syntax/doc/manual/parts/0001.txt
typo-4.0.3 vendor/syntax/doc/manual/parts/0001.txt
typo-5.0.1 vendor/syntax/doc/manual/parts/0001.txt
typo-4.1 vendor/syntax/doc/manual/parts/0001.txt
typo-5.0.2 vendor/syntax/doc/manual/parts/0001.txt
typo-5.0.3.98.1 vendor/syntax/doc/manual/parts/0001.txt
typo-5.0.3.98 vendor/syntax/doc/manual/parts/0001.txt
typo-5.0 vendor/syntax/doc/manual/parts/0001.txt
typo-5.1.1 vendor/syntax/doc/manual/parts/0001.txt
typo-5.1.2 vendor/syntax/doc/manual/parts/0001.txt
typo-5.1.3 vendor/syntax/doc/manual/parts/0001.txt
typo-5.1 vendor/syntax/doc/manual/parts/0001.txt