Sha256: 22858e3e9dae00d0386f9a0e914a945b3c64a74cf8c9189039582067867ecd93

Contents?: true

Size: 820 Bytes

Versions: 20

Compression:

Stored size: 820 Bytes

Contents

Colorizing code has already been touched on briefly in the Introduction chapter (under "Quick Start"). To review, the process is a mere three steps:

# Require the class for the type of the output you want (currently, only HTML is supported).
# Obtain an instance of the convertor, for the syntax you wish to convert.
# Call @#convert@ on that convertor, passing in the text you want to convert. The return value is the HTML representation of the colorized text.

For example:

{{{lang=ruby,number=true,caption=Colorizing a Ruby script
# Step 1: require the HTML convertor
require 'syntax/convertor/html'

# Step 2: get an instance of the HTML convertor for the Ruby syntax
convertor = Syntax::Convertor::HTML.for_syntax "ruby"

# Step 3: convert the text to HTML
puts convertor.convert( File.read( "program.rb" ) )
}}}

Version data entries

20 entries across 20 versions & 1 rubygems

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