Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 193
- Log:
First stage commit of Typo 4.1, modified for the ROOL site.
Includes all local modifications but a final pass needs to be
made to delete any files left over from earlier Typo versions
that shouldn't be here anymore. See the 'tags' section of the
repository for a clean Typo 4.1 tree.Note that symlinks to shared files in the RISC OS Open theme
directory have been deliberately included this time around; I
decided that on balance it was better to leave them in as
placeholders, since unlike symlinks in app/views/shared, the
Typo theme structure is not a standard Rails concept.
- Author:
- rool
- Date:
- Wed Apr 04 18:51:02 +0100 2007
- Size:
- 2002 Bytes
1 | require 'syntax/convertors/html' |
2 | |
3 | class Typo |
4 | class Textfilter |
5 | class Code < TextFilterPlugin::MacroPre |
6 | plugin_display_name "Code" |
7 | plugin_description "Apply syntax highlighting to a code block" |
8 | |
9 | def self.help_text |
10 | %{ |
11 | You can use `<typo:code>` to include syntax-highlighted code blocks. Example: |
12 | |
13 | <typo:code lang="ruby"> |
14 | class Foo |
15 | def bar |
16 | "abcde" |
17 | end |
18 | end |
19 | </typo:code> |
20 | |
21 | This uses the Ruby [Syntax](http://syntax.rubyforge.org/) module. Options: |
22 | |
23 | * **lang**. Sets the programming language. Currently supported languages are |
24 | `ruby`, `yaml`, and `xml`. Other languages will format correctly but will not |
25 | have syntax highlighting. |
26 | * **linenumber**. Turns on line numbering. Use `linenumber="true"` to enable. |
27 | * **title**. Adds a title block to the top of the code block. |
28 | * **class**. Adds a new CSS class to the wrapper around the code block. |
29 | } |
30 | end |
31 | |
32 | def self.macrofilter(blog,content,attrib,params,text="") |
33 | lang = attrib['lang'] || 'default' |
34 | title = attrib['title'] |
35 | cssclass = attrib['class'] |
36 | linenumber = attrib['linenumber'] |
37 | |
38 | text = text.to_s.gsub(/\r/,'').gsub(/\A\n/,'').chomp |
39 | |
40 | convertor = Syntax::Convertors::HTML.for_syntax lang |
41 | text = convertor.convert(text) |
42 | text.gsub!(/<pre>/,"<pre><code class=\"typocode_#{lang} #{cssclass}\"><notextile>") |
43 | text.gsub!(/<\/pre>/,"</notextile></code></pre>") |
44 | |
45 | if(linenumber) |
46 | lines = text.split(/\n/).size |
47 | linenumbers = (1..lines).to_a.collect{|line| line.to_s}.join("\n") |
48 | |
49 | text = "<table class=\"typocode_linenumber\"><tr><td class=\"lineno\">\n<pre>\n#{linenumbers}\n</pre>\n</td><td width=\"100%\">#{text}</td></tr></table>" |
50 | end |
51 | |
52 | if(title) |
53 | titlecode="<div class=\"codetitle\">#{title}</div>" |
54 | else |
55 | titlecode='' |
56 | end |
57 | |
58 | "<div class=\"typocode\">#{titlecode}#{text}</div>" |
59 | end |
60 | end |
61 | end |
62 | end |