From c194637b0d9af5ee756c5efa0942fe8cc09769e5 Mon Sep 17 00:00:00 2001 From: murphy Date: Sat, 1 Oct 2005 02:14:46 +0000 Subject: Some demos updated. Massive changes for HTML output layout. --- demo/demo_css.rb | 6 ++---- demo/demo_dump.rb | 19 +++++++++++++------ demo/demo_html.rb | 1 - 3 files changed, 15 insertions(+), 11 deletions(-) (limited to 'demo') diff --git a/demo/demo_css.rb b/demo/demo_css.rb index e4cd455..93a6ef0 100644 --- a/demo/demo_css.rb +++ b/demo/demo_css.rb @@ -1,6 +1,4 @@ require 'coderay' -data = File.read $0 -page = CodeRay.scan(data, :ruby).optimize.html(:css => :style, :debug => $DEBUG).page - -puts page +# print the default stylesheet for HTML codes +puts CodeRay::Encoders[:html]::CSS::DEFAULT_STYLESHEET diff --git a/demo/demo_dump.rb b/demo/demo_dump.rb index b848dcd..cd68dc8 100644 --- a/demo/demo_dump.rb +++ b/demo/demo_dump.rb @@ -1,8 +1,15 @@ require 'coderay' -puts CodeRay. - scan("puts 'Hello, world!'", :ruby). - compact. - dump. - undump. - html(:wrap => :div) +# scan some code +tokens = CodeRay.scan(File.read($0), :ruby) + +# dump using YAML +yaml = tokens.yaml +puts 'YAML: %4d bytes' % yaml.size + +# dump using Marshal +dump = tokens.dump(0) +puts 'Dump: %4d bytes' % dump.size + +# undump and encode +puts 'undumped:', dump.undump.div(:css => :class) diff --git a/demo/demo_html.rb b/demo/demo_html.rb index d2d25a1..c854635 100644 --- a/demo/demo_html.rb +++ b/demo/demo_html.rb @@ -392,4 +392,3 @@ module CodeRay end end - -- cgit v1.2.1