scarlet 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,11 +10,11 @@ h2. Features
10
10
 
11
11
  * *Syntax Highlighting*: If you have "Pygments":http://pygments.org/ installed, Scarlet will automatically highlight your code.
12
12
  * *Custom Templates*: Create and re-use your own templates for the slideshows.
13
+ * *PDF and LaTeX Generation*: Highly experimental. Patches are welcome and very appreciated.
13
14
 
14
15
  h2. TODO
15
16
 
16
17
  * Finish writing tests
17
- * PDF generation
18
18
  * Simple style customization
19
19
 
20
20
  h2. Usage
@@ -61,10 +61,14 @@ In the previously created folder:
61
61
 
62
62
  <pre>scarlet slideshow.textile > slideshow.html</pre>
63
63
 
64
+ h2. Contributors
65
+
66
+ * *Matias Korhonen*: PDF and LaTeX generation
67
+
64
68
  h2. Special Thanks
65
69
 
66
70
  * *Pat Nakajima* for creating "slidedown":http://github.com/nakajima/slidedown
67
- * *Matias Korhonen*: for forcing me to publish Scarlet and for the help
71
+ * *Matias Korhonen* for forcing me to publish Scarlet
68
72
 
69
73
  h2. Copyright
70
74
 
@@ -78,8 +82,8 @@ Copyright (c) 2009 João Carlos Cardoso, excluding the following files:
78
82
 
79
83
  * Files under *lib/scarlet/html/templates/stylesheets/*:
80
84
  ** *slides.css*: Based on the stylesheet for "slidedown":http://github.com/nakajima/slidedown created by Pat Nakajima
81
- ** *syntax_***.css*: Generated with "Pygments":http://pygments.org/
85
+ ** <strong>syntax_*.css</strong>: Generated with "Pygments":http://pygments.org/
82
86
 
83
87
  h2. License
84
88
 
85
- Scarlet is released under the MIT License (see the LICENSE file).
89
+ Scarlet is released under the MIT License (see the LICENSE file).
@@ -4,5 +4,7 @@ require 'scarlet/highlighter'
4
4
  require 'scarlet/generator'
5
5
  require 'scarlet/formatters/base'
6
6
  require 'scarlet/formatters/html'
7
+ require 'scarlet/formatters/latex'
8
+ require 'scarlet/formatters/pdf'
7
9
  require 'scarlet/formatter'
8
10
  require 'scarlet/runner'
@@ -3,7 +3,9 @@ module Scarlet
3
3
  DEFAULT = Scarlet::Formatters::HTML
4
4
  FORMATTERS = {
5
5
  :html => Scarlet::Formatters::HTML,
6
- :xhtml => Scarlet::Formatters::HTML
6
+ :xhtml => Scarlet::Formatters::HTML,
7
+ :latex => Scarlet::Formatters::LATEX,
8
+ :pdf => Scarlet::Formatters::PDF
7
9
  }
8
10
 
9
11
  def Formatter.for(format)
@@ -0,0 +1,19 @@
1
+ require 'RedCloth'
2
+
3
+ module Scarlet::Formatters
4
+ class LATEX
5
+ include Scarlet::Formatters::Base
6
+
7
+ def text
8
+ process_code do |code, language, before, after|
9
+ before + "<notextile>" + Scarlet::Highlighter.run(code, :format => "latex", :lexer => language, :arguments => "-P verboptions='fontfamily=lcmtt'") + "</notextile>" + after
10
+ end
11
+
12
+ RedCloth.new(slide.text).to_latex
13
+ end
14
+
15
+ def self.default_template
16
+ File.join(File.dirname(__FILE__), "..", "templates", "latex", "default.erb")
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ require 'rtex'
2
+
3
+ module Scarlet::Formatters
4
+ class PDF < Scarlet::Formatters::LATEX
5
+ include Scarlet::Formatters::Base
6
+
7
+ def self.from_latex(latex)
8
+ RTeX::Document.new(latex).to_pdf
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require 'open4'
2
3
 
3
4
  module Scarlet
@@ -5,7 +6,8 @@ module Scarlet
5
6
  def self.run(text, options={})
6
7
  options[:format] ||= "html"
7
8
  options[:lexer] ||= "text"
8
- pid, stdin, stdout, stderr = Open4.popen4("pygmentize -f #{options[:format]} -l #{options[:lexer]}")
9
+ options[:arguments] ||= ""
10
+ pid, stdin, stdout, stderr = Open4.popen4("pygmentize -f #{options[:format]} -l #{options[:lexer]} #{options[:arguments]}")
9
11
  stdin.puts(text)
10
12
  stdin.close
11
13
  stdout.read.strip
@@ -14,6 +14,12 @@ module Scarlet
14
14
  when :html
15
15
  template = File.read(options[:template] || Scarlet::Formatters::HTML.default_template)
16
16
  ERB.new(template).result(binding)
17
+ when :latex
18
+ template = File.read(options[:template] || Scarlet::Formatters::LATEX.default_template)
19
+ ERB.new(template).result(binding)
20
+ when :pdf
21
+ template = File.read(options[:template] || Scarlet::Formatters::PDF.default_template)
22
+ Scarlet::Formatters::PDF.from_latex(ERB.new(template).result(binding))
17
23
  else
18
24
  raise "Format not supported."
19
25
  end
@@ -0,0 +1,85 @@
1
+ \documentclass{slides}
2
+ \usepackage[a4paper,landscape]{geometry}
3
+ \usepackage{fancyvrb}
4
+ \usepackage{color}
5
+ \usepackage[T1]{fontenc}
6
+ \renewcommand*\sfdefault{uop}
7
+ \usepackage[bookmarks=true,pdftex]{hyperref}
8
+
9
+ \hypersetup{
10
+ pdfauthor = {Scarlet},
11
+ pdftitle = {Scarlet Slides},
12
+ pdfsubject = {Scarlet Slideshow}}
13
+
14
+ \newcommand\PYZat{@}
15
+ \newcommand\PYZlb{[}
16
+ \newcommand\PYZrb{]}
17
+ \newcommand\PYbh[1]{\textcolor[rgb]{0.00,0.50,0.00}{\textbf{#1}}}
18
+ \newcommand\PYbg[1]{\textcolor[rgb]{0.73,0.40,0.53}{\textbf{#1}}}
19
+ \newcommand\PYbf[1]{\textcolor[rgb]{0.82,0.25,0.23}{\textbf{#1}}}
20
+ \newcommand\PYbe[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
21
+ \newcommand\PYbd[1]{\textcolor[rgb]{0.73,0.13,0.13}{#1}}
22
+ \newcommand\PYbc[1]{\textcolor[rgb]{0.00,0.50,0.00}{\textbf{#1}}}
23
+ \newcommand\PYbb[1]{\textcolor[rgb]{0.00,0.50,0.00}{#1}}
24
+ \newcommand\PYba[1]{\textcolor[rgb]{0.00,0.00,0.50}{\textbf{#1}}}
25
+ \newcommand\PYaJ[1]{\textcolor[rgb]{0.69,0.00,0.25}{#1}}
26
+ \newcommand\PYaK[1]{\textcolor[rgb]{0.73,0.13,0.13}{#1}}
27
+ \newcommand\PYaH[1]{\textcolor[rgb]{0.50,0.00,0.50}{\textbf{#1}}}
28
+ \newcommand\PYaI[1]{\fcolorbox[rgb]{1.00,0.00,0.00}{1,1,1}{#1}}
29
+ \newcommand\PYaN[1]{\textcolor[rgb]{0.74,0.48,0.00}{#1}}
30
+ \newcommand\PYaO[1]{\textcolor[rgb]{0.00,0.00,1.00}{\textbf{#1}}}
31
+ \newcommand\PYaL[1]{\textcolor[rgb]{0.00,0.00,1.00}{#1}}
32
+ \newcommand\PYaM[1]{\textcolor[rgb]{0.73,0.73,0.73}{#1}}
33
+ \newcommand\PYaB[1]{\textcolor[rgb]{0.73,0.13,0.13}{#1}}
34
+ \newcommand\PYaC[1]{\textcolor[rgb]{0.67,0.13,1.00}{#1}}
35
+ \newcommand\PYaA[1]{\textcolor[rgb]{0.00,0.50,0.00}{#1}}
36
+ \newcommand\PYaF[1]{\textcolor[rgb]{0.63,0.00,0.00}{#1}}
37
+ \newcommand\PYaG[1]{\textcolor[rgb]{1.00,0.00,0.00}{#1}}
38
+ \newcommand\PYaD[1]{\textcolor[rgb]{0.00,0.50,0.00}{\textbf{#1}}}
39
+ \newcommand\PYaE[1]{\textcolor[rgb]{0.25,0.50,0.50}{\textit{#1}}}
40
+ \newcommand\PYaZ[1]{\textcolor[rgb]{0.00,0.50,0.00}{\textbf{#1}}}
41
+ \newcommand\PYaX[1]{\textcolor[rgb]{0.00,0.50,0.00}{#1}}
42
+ \newcommand\PYaY[1]{\textcolor[rgb]{0.73,0.13,0.13}{#1}}
43
+ \newcommand\PYaR[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
44
+ \newcommand\PYaS[1]{\textcolor[rgb]{0.10,0.09,0.49}{#1}}
45
+ \newcommand\PYaP[1]{\textcolor[rgb]{0.00,0.00,0.50}{\textbf{#1}}}
46
+ \newcommand\PYaQ[1]{\textcolor[rgb]{0.49,0.56,0.16}{#1}}
47
+ \newcommand\PYaV[1]{\textcolor[rgb]{0.00,0.00,1.00}{\textbf{#1}}}
48
+ \newcommand\PYaW[1]{\textcolor[rgb]{0.73,0.13,0.13}{#1}}
49
+ \newcommand\PYaT[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
50
+ \newcommand\PYaU[1]{\textcolor[rgb]{0.25,0.50,0.50}{\textit{#1}}}
51
+ \newcommand\PYaj[1]{\textcolor[rgb]{0.00,0.50,0.00}{#1}}
52
+ \newcommand\PYak[1]{\textcolor[rgb]{0.73,0.40,0.53}{#1}}
53
+ \newcommand\PYah[1]{\textcolor[rgb]{0.63,0.63,0.00}{#1}}
54
+ \newcommand\PYai[1]{\textcolor[rgb]{0.10,0.09,0.49}{#1}}
55
+ \newcommand\PYan[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
56
+ \newcommand\PYao[1]{\textcolor[rgb]{0.73,0.40,0.13}{\textbf{#1}}}
57
+ \newcommand\PYal[1]{\textcolor[rgb]{0.25,0.50,0.50}{\textit{#1}}}
58
+ \newcommand\PYam[1]{\textbf{#1}}
59
+ \newcommand\PYab[1]{\textit{#1}}
60
+ \newcommand\PYac[1]{\textcolor[rgb]{0.73,0.13,0.13}{#1}}
61
+ \newcommand\PYaa[1]{\textcolor[rgb]{0.50,0.50,0.50}{#1}}
62
+ \newcommand\PYaf[1]{\textcolor[rgb]{0.25,0.50,0.50}{\textit{#1}}}
63
+ \newcommand\PYag[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
64
+ \newcommand\PYad[1]{\textcolor[rgb]{0.00,0.25,0.82}{#1}}
65
+ \newcommand\PYae[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
66
+ \newcommand\PYaz[1]{\textcolor[rgb]{0.00,0.63,0.00}{#1}}
67
+ \newcommand\PYax[1]{\textcolor[rgb]{0.60,0.60,0.60}{\textbf{#1}}}
68
+ \newcommand\PYay[1]{\textcolor[rgb]{0.00,0.50,0.00}{\textbf{#1}}}
69
+ \newcommand\PYar[1]{\textcolor[rgb]{0.10,0.09,0.49}{#1}}
70
+ \newcommand\PYas[1]{\textcolor[rgb]{0.73,0.13,0.13}{\textit{#1}}}
71
+ \newcommand\PYap[1]{\textcolor[rgb]{0.00,0.50,0.00}{\textbf{#1}}}
72
+ \newcommand\PYaq[1]{\textcolor[rgb]{0.53,0.00,0.00}{#1}}
73
+ \newcommand\PYav[1]{\textcolor[rgb]{0.67,0.13,1.00}{\textbf{#1}}}
74
+ \newcommand\PYaw[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
75
+ \newcommand\PYat[1]{\textcolor[rgb]{0.10,0.09,0.49}{#1}}
76
+ \newcommand\PYau[1]{\textcolor[rgb]{0.10,0.09,0.49}{#1}}
77
+
78
+ \begin{document}
79
+
80
+ <% for slide in @slides %>
81
+ <%= slide.text %>
82
+ \newpage
83
+ <% end %>
84
+
85
+ \end{document}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scarlet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joao Carlos Cardoso
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-20 00:00:00 +03:00
12
+ date: 2009-11-20 00:00:00 +02:00
13
13
  default_executable: scarlet
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -32,6 +32,16 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: 4.2.2
34
34
  version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: rtex
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 2.1.1
44
+ version:
35
45
  description: Generates XHTML slideshows from text files using Textile for markup. Does syntax highlighting if Pygments is installed.
36
46
  email: mail@joao-carlos.com
37
47
  executables:
@@ -47,6 +57,8 @@ files:
47
57
  - lib/scarlet/formatter.rb
48
58
  - lib/scarlet/formatters/base.rb
49
59
  - lib/scarlet/formatters/html.rb
60
+ - lib/scarlet/formatters/latex.rb
61
+ - lib/scarlet/formatters/pdf.rb
50
62
  - lib/scarlet/generator.rb
51
63
  - lib/scarlet/highlighter.rb
52
64
  - lib/scarlet/runner.rb
@@ -62,6 +74,7 @@ files:
62
74
  - lib/scarlet/templates/html/stylesheets/syntax_default.css
63
75
  - lib/scarlet/templates/html/stylesheets/syntax_emacs.css
64
76
  - lib/scarlet/templates/html/stylesheets/syntax_friendly.css
77
+ - lib/scarlet/templates/latex/default.erb
65
78
  - LICENSE
66
79
  - README.textile
67
80
  has_rdoc: true