Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 15
- Log:
Attempt to update Typo to a Typo SVN HEAD release from around the
time the prototype installation was set up on the RISC OS Open Limited
web site. Timestamps place this at 04-Jul so a revision from 05-Jul or
earlier was pulled and copied over the 2.6.0 tarball stable code.
- Author:
- adh
- Date:
- Sat Jul 22 23:27:35 +0100 2006
- Size:
- 1738 Bytes
1 | = Syntax |
2 | |
3 | A syntax highlighting a library for Ruby. |
4 | |
5 | == About |
6 | |
7 | 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. |
8 | |
9 | == Usage |
10 | |
11 | There are primarily two uses for the Syntax library: |
12 | |
13 | # Convert text from a supported syntax to a supported highlight format (like HTML). |
14 | # Tokenize text in a supported syntax and process the tokens directly. |
15 | |
16 | === Highlighting a supported syntax |
17 | |
18 | require 'syntax/convertors/html' |
19 | |
20 | convertor = Syntax::Convertors::HTML.for_syntax "ruby" |
21 | puts convertor.convert( File.read( "file.rb" ) ) |
22 | |
23 | 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.) |
24 | |
25 | === Tokenize text |
26 | |
27 | require 'syntax' |
28 | |
29 | tokenizer = Syntax.load "ruby" |
30 | tokenizer.tokenize( File.read( "file.rb" ) ) do |token| |
31 | puts "group(#{token.group}, #{token.instruction}) lexeme(#{token})" |
32 | end |
33 | |
34 | Tokenizing is straightforward process. Each time a new token is discovered by the tokenizer, it is yielded to the given block. |
35 | |
36 | * <tt>token.group</tt> is the lexical group to which the token belongs. Each supported syntax may have it's own set of lexical groups. |
37 | * <tt>token.instruction</tt> is an instruction used to determine how this token should be treated. It will be <tt>:none</tt> for normal tokens, <tt>:region_open</tt> if the token starts a nested region, and <tt>:region_close</tt> if it closes the last opened region. |
38 | * <tt>token</tt> is itself a subclass of String, so you can use it just as you would a string. It represents the lexeme that was actually parsed. |