dsl-latex-simple 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'highlight'
4
+ # Specify your gem's dependencies in dsl-latex-simple.gemspec
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Casiano Rodriguez Leon
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Dsl::Latex::Simple
2
+
3
+ TODO: LaTeX like Ruby DSL
4
+
5
+ ## Installation
6
+
7
+ It needs latex and latex2html installed
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'dsl-latex-simple'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install dsl-latex-simple
20
+
21
+ ## Usage
22
+
23
+ TODO:
24
+ 1. Now blocks are used only for environments. A block can follow any latex command
25
+
26
+ ## Contributing
27
+
28
+ 1. Fork it
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,50 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ LATEX2HTMLOPTIONS = '-html_version 4.0,latin1,unicode -contents_in_navigation -style mystyle.css -white -local_icons'
4
+
5
+ task :default => :compile
6
+
7
+ desc "Uses the example inside lib/dsl-latex-simple/simple.rb"
8
+ task :compile do
9
+ sh "ruby -Ilib lib/dsl-latex-simple/simple.rb > examples/simple.tex"
10
+ end
11
+
12
+ desc "compiles example0.rex onto examples/simple.tex"
13
+ task :c0 do
14
+ sh "ruby -Ilib bin/rex examples/example0.rex > examples/simple.tex"
15
+ end
16
+
17
+ desc "simple.tex -> simple.dvi"
18
+ task :dvi do
19
+ sh "latex -output-directory=examples examples/simple.tex"
20
+ end
21
+
22
+ desc "simple.tex -> simple.pdf"
23
+ task :pdf do
24
+ sh "pdflatex -output-directory=examples examples/simple.tex"
25
+ end
26
+
27
+ task :html do
28
+ sh "latex2html #{LATEX2HTMLOPTIONS} examples/simple"
29
+ sh "cp examples/mystyle.css examples/simple/"
30
+ end
31
+
32
+ desc "Have a look to the .dvi generated"
33
+ task :look do
34
+ sh "open examples/simple.dvi"
35
+ end
36
+
37
+ task :clean do
38
+ sh "rm -f examples/*.log examples/*.dvi examples/*.aux examples/*.pdf"
39
+ sh "rm -fR examples/simple"
40
+ end
41
+
42
+ desc "Generates a pygmentize CSS"
43
+ task :css do
44
+ sh "pygmentize -f html -S colorful > examples/colorful.css"
45
+ end
46
+
47
+ desc "uninstall the gem"
48
+ task :uninstall do
49
+ sh "gem uninstall dsl-latex-simple"
50
+ end
data/bin/rex ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'dsl-latex-simple'
4
+
5
+ path = ARGV.shift
6
+
7
+ if path and File.exists? path
8
+ Dsl::Latex::Simple.generate(path)
9
+ else
10
+ puts "Usage:\n\t$0 file"
11
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dsl-latex-simple/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "dsl-latex-simple"
8
+ gem.version = Dsl::Latex::Simple::VERSION
9
+ gem.authors = ["Casiano Rodriguez Leon"]
10
+ gem.email = ["casiano.rodriguez.leon@gmail.com"]
11
+ gem.description = %q{Ruby DSL for LaTeX}
12
+ gem.summary = %q{Ruby DSL for LaTeX}
13
+ gem.homepage = "https://github.com/crguezl/dsl-latex-simple"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ gem.add_dependency 'highlight'
20
+ # gem.add_development_dependency 'rspec', '~> 2.7'
21
+ end
@@ -0,0 +1,51 @@
1
+ documentclass ["12pt"], "article"
2
+ usepackage ["fleqn"], %q{amsmath}
3
+ usepackage ["paper=a4paper,dvips,top=1.5cm,left=1.5cm,right=1.5cm,
4
+ foot=1cm,bottom=1.5cm"], "geometry"
5
+
6
+ title "An elementary proof of the reconstruction conjecture"
7
+
8
+ author do
9
+ c('Dagwood Remifa')
10
+ thanks(%q{Thanks to the editors of this wonderful journal!})
11
+ c '\\\\'
12
+ end
13
+
14
+
15
+ date { today }
16
+
17
+ start "document" do
18
+ maketitle
19
+ start "abstract" do
20
+ c esc %q{ The reconstruction conjecture states that the multiset of unlabeled
21
+ vertex-deleted subgraphs of a graph determines the graph, provided it
22
+ has at least 3 vertices. A version of the problem was first stated
23
+ by Stanis\l aw Ulam. In this paper, we show that the conjecture can
24
+ be proved by elementary methods. It is only necessary to integrate
25
+ the Lenkle potential of the Broglington manifold over the quantum
26
+ supervacillatory measure in order to reduce the set of possible
27
+ counterexamples to a small number (less than a trillion). A simple
28
+ computer program that implements Pipletti's classification theorem
29
+ for torsion-free Aramaic groups with simplectic socles can then
30
+ finish the remaining cases. }
31
+ end
32
+ c "Hola, hoy son las #{Time.now} y $\\sqrt{2} = #{Math.sqrt(2)}$"
33
+ start "verbatim" do
34
+ c "a = 4*5"
35
+ c "b = 4*5"
36
+ end
37
+
38
+ start %q{equation} do
39
+ c esc '\Delta =\sum_{i=1}^N w_i (x_i - \bar{x})^2.'
40
+ end
41
+
42
+ c %q{We can give an equation a label so that we can refer to it later.}
43
+ start %q{equation} do
44
+ label %q{eq:ising}
45
+ c %q{E = -J \sum_{i=1}^N s_i s_{i+1},}
46
+ end
47
+ c esc %q{Equation~\eqref{eq:ising} expresses the energy of a configuration
48
+ of spins in the Ising model.\footnote{It is necessary to typeset a
49
+ file twice to get the counters correct.}}
50
+
51
+ end
@@ -0,0 +1,96 @@
1
+ documentclass ["12pt"], "article"
2
+ usepackage ['pdftex'], %q{graphicx}
3
+ usepackage %q{html}
4
+ usepackage ["fleqn"], %q{amsmath}
5
+
6
+ # this package is not compatible with l2h
7
+ #usepackage ["paper=a4paper,dvips,top=1.5cm,left=1.5cm,right=1.5cm, foot=1cm,bottom=1.5cm"], "geometry"
8
+
9
+ usepackage ['spanish'], %q{babel}
10
+ usepackage %q{ucs}
11
+ usepackage ['utf8x'], %q{inputenc}
12
+ usepackage 'listings'
13
+
14
+ newcommand %q{\lb}, %q{{\langle}}
15
+
16
+ title "An elementary proof of the reconstruction conjecture"
17
+
18
+ author do
19
+ c('Dagwood Remifa')
20
+ thanks(%q{Thanks to the editors of this wonderful journal!})
21
+ c '\\\\'
22
+ end
23
+
24
+
25
+ date { today }
26
+
27
+ start "document" do
28
+ maketitle
29
+ start "abstract" do
30
+ c esc %q{ The reconstruction conjecture states that the multiset of unlabeled
31
+ vertex-deleted subgraphs of a graph determines the graph, provided it
32
+ has at least 3 vertices. A version of the problem was first stated
33
+ by Stanislaw Ulam. In this paper, we show that the conjecture can
34
+ be proved by elementary methods. It is only necessary to integrate
35
+ the Lenkle potential of the Broglington manifold over the quantum
36
+ supervacillatory measure in order to reduce the set of possible
37
+ counterexamples to a small number (less than a trillion). A simple
38
+ computer program that implements Pipletti's classification theorem
39
+ for torsion-free Aramaic groups with simplectic socles can then
40
+ finish the remaining cases. }
41
+ end
42
+ c "Hola, hoy son las #{Time.now} y $\\sqrt{2} = #{Math.sqrt(2)}$"
43
+ start "verbatim" do
44
+ c "a = 4*5"
45
+ c "b = 4*5"
46
+ end
47
+
48
+ start %q{equation} do
49
+ c esc '\Delta =\sum_{i=1}^N w_i (x_i - \bar{x})^2.'
50
+ end
51
+
52
+ c %q{We can give an equation a label so that we can refer to it later.}
53
+ start %q{equation} do
54
+ label %q{eq:ising}
55
+ c %q{E = -J \sum_{i=1}^N s_i s_{i+1},}
56
+ end
57
+ c esc %q{Equation~\eqref{eq:ising} expresses the energy of a configuration
58
+ of spins in the Ising model.\footnote{It is necessary to typeset a
59
+ file twice to get the counters correct.}
60
+ }
61
+
62
+ htmladdnormallink %q{https://github.com/cocoa/eloquent-ruby}, %q{https://github.com/cocoa/eloquent-ruby}
63
+
64
+ start %q{align} do c trim(%q{
65
+ a & = b \\\\
66
+ c &= d,})
67
+ end
68
+
69
+ highlight_code(:ruby,
70
+ %q{
71
+ class Test;
72
+
73
+ def tutu
74
+ end
75
+ end
76
+ })
77
+
78
+ start(%q{tabular}, %q{|c|}) do
79
+ hline
80
+ c %q{
81
+ test1\\\\
82
+ test2\\\\
83
+ }
84
+ hline
85
+ end
86
+
87
+ input "examples/section.tex"
88
+
89
+ start %q{figure}, [ 'htb' ] do
90
+ start %q{center} do
91
+ includegraphics ['scale=0.7'], %q{examples/fibonacci.png}
92
+ end
93
+ label %q{figure:fibonacci}
94
+ caption %q{Arbol de llamadas para la función de Fibonacci}
95
+ end
96
+ end
Binary file
@@ -0,0 +1,154 @@
1
+ @import url(print.css) print;
2
+
3
+ /* Century Schoolbook font is very similar to Computer Modern Math: cmmi */
4
+ .MATH { font-family: "Century Schoolbook", serif; }
5
+ .MATH I { font-family: "Century Schoolbook", serif; font-style: italic }
6
+ .BOLDMATH { font-family: "Century Schoolbook", serif; font-weight: bold }
7
+
8
+ /* implement both fixed-size and relative sizes */
9
+ SMALL.XTINY { font-size : xx-small }
10
+ SMALL.TINY { font-size : x-small }
11
+ SMALL.SCRIPTSIZE { font-size : smaller }
12
+ SMALL.FOOTNOTESIZE { font-size : small }
13
+ SMALL.SMALL { }
14
+ BIG.LARGE { }
15
+ BIG.XLARGE { font-size : large }
16
+ BIG.XXLARGE { font-size : x-large }
17
+ BIG.HUGE { font-size : larger }
18
+ BIG.XHUGE { font-size : xx-large }
19
+
20
+ /* heading styles */
21
+ H1 { }
22
+ H2 { }
23
+ H3 { }
24
+ H4 { }
25
+ H5 { }
26
+
27
+ /* mathematics styles */
28
+ DIV.displaymath { } /* math displays */
29
+ TD.eqno { } /* equation-number cells */
30
+
31
+
32
+ /* document-specific styles come next */
33
+ DIV.logo-LaTeX { }
34
+ SPAN.itshape { }
35
+ /* PRE.preform { } */
36
+ /* pre { color: #fff; background-color: #000; padding: 10px; } */
37
+ pre { color: LightGreen; font-size: larger; background-color: black; padding: 10px; overflow-x: none; } /* width: 900px;} */
38
+ tr pre { color: LightGreen; font-size: larger; background-color: black; padding: 10px; width: auto; overflow-x: none; }
39
+ /* CODE { color: brown; padding: 10px; } */
40
+ CODE { color: brown; }
41
+ i i { color: red; }
42
+
43
+ /* @media print { CODE {color: black; } } */
44
+
45
+ BLOCKQUOTE { background-color: #ADD8E6; }
46
+ DIV.Large { }
47
+ DIV.small { }
48
+ DIV.quote { }
49
+ DIV.center { }
50
+ DIV.verse { }
51
+ DIV.flushleft { }
52
+ TABLE.equation* { }
53
+ SPAN.it { }
54
+ DIV.navigation { }
55
+ SPAN.bfseries { }
56
+ TABLE.equation { }
57
+ DIV.LaTeX { }
58
+ SPAN.tt { }
59
+ DIV.alltt { }
60
+ SPAN.textbf { /* font-weight: bold; */
61
+ color: red
62
+ }
63
+ SPAN.arabic { }
64
+ SPAN.textit { font-style: italic; color: blue }
65
+ #txt7229 { text-decoration: underline; }
66
+ #txt7230 { text-decoration: underline; }
67
+ #txt7757 { text-decoration: underline; }
68
+
69
+ /* Template::Plugin::VimColor style */
70
+
71
+ /* pre { color: green; background-color: #000; padding: 10px; } */
72
+ pre { color: LightGreen; background-color: black; padding: 10px; }
73
+ i pre { font-style: normal; }
74
+
75
+ span.lightblue { color: #ADD8E6; }
76
+ span.red { color: red; }
77
+ span.synComment { color: blue; }
78
+ span.synConstant { color: red; }
79
+ span.synIdentifier { color: aqua; }
80
+ span.synStatement { color: yellow; }
81
+ span.synPreProc { color: fuchsia; }
82
+ span.synType { color: lime; }
83
+ span.synSpecial { color: fuchsia; }
84
+ span.synUnderlined { color: fuchsia; text-decoration: underline; }
85
+ span.synError { background-color: red; color: white; font-weight: bold; }
86
+ span.synTodo { background-color: yellow; color: black; }
87
+ span.Linenum { color: yellow; }
88
+
89
+ /* used for perl debugger to signal user input */
90
+
91
+ /* Simplabs::Highlight.highlight(:ruby, 'class Test; end') */
92
+ /* python pygments */
93
+
94
+ .hll { background-color: #ffffcc }
95
+ .c { color: #808080 } /* Comment */
96
+ .err { color: #F00000; background-color: #F0A0A0 } /* Error */
97
+ .k { color: #008000; font-weight: bold } /* Keyword */
98
+ .o { color: #303030 } /* Operator */
99
+ .cm { color: #808080 } /* Comment.Multiline */
100
+ .cp { color: #507090 } /* Comment.Preproc */
101
+ .c1 { color: #808080 } /* Comment.Single */
102
+ .cs { color: #cc0000; font-weight: bold } /* Comment.Special */
103
+ .gd { color: #A00000 } /* Generic.Deleted */
104
+ .ge { font-style: italic } /* Generic.Emph */
105
+ .gr { color: #FF0000 } /* Generic.Error */
106
+ .gh { color: #000080; font-weight: bold } /* Generic.Heading */
107
+ .gi { color: #00A000 } /* Generic.Inserted */
108
+ .go { color: #808080 } /* Generic.Output */
109
+ .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
110
+ .gs { font-weight: bold } /* Generic.Strong */
111
+ .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
112
+ .gt { color: #0040D0 } /* Generic.Traceback */
113
+ .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
114
+ .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
115
+ .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
116
+ .kp { color: #003080; font-weight: bold } /* Keyword.Pseudo */
117
+ .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
118
+ .kt { color: #303090; font-weight: bold } /* Keyword.Type */
119
+ .m { color: #6000E0; font-weight: bold } /* Literal.Number */
120
+ .s { background-color: #fff0f0 } /* Literal.String */
121
+ .na { color: #0000C0 } /* Name.Attribute */
122
+ .nb { color: #007020 } /* Name.Builtin */
123
+ .nc { color: #B00060; font-weight: bold } /* Name.Class */
124
+ .no { color: #003060; font-weight: bold } /* Name.Constant */
125
+ .nd { color: #505050; font-weight: bold } /* Name.Decorator */
126
+ .ni { color: #800000; font-weight: bold } /* Name.Entity */
127
+ .ne { color: #F00000; font-weight: bold } /* Name.Exception */
128
+ .nf { color: #0060B0; font-weight: bold } /* Name.Function */
129
+ .nl { color: #907000; font-weight: bold } /* Name.Label */
130
+ .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
131
+ .nt { color: #007000 } /* Name.Tag */
132
+ .nv { color: #906030 } /* Name.Variable */
133
+ .ow { color: #000000; font-weight: bold } /* Operator.Word */
134
+ .w { color: #bbbbbb } /* Text.Whitespace */
135
+ .mf { color: #6000E0; font-weight: bold } /* Literal.Number.Float */
136
+ .mh { color: #005080; font-weight: bold } /* Literal.Number.Hex */
137
+ .mi { color: #0000D0; font-weight: bold } /* Literal.Number.Integer */
138
+ .mo { color: #4000E0; font-weight: bold } /* Literal.Number.Oct */
139
+ .sb { background-color: #fff0f0 } /* Literal.String.Backtick */
140
+ .sc { color: #0040D0 } /* Literal.String.Char */
141
+ .sd { color: #D04020 } /* Literal.String.Doc */
142
+ .s2 { background-color: #fff0f0 } /* Literal.String.Double */
143
+ .se { color: #606060; font-weight: bold; background-color: #fff0f0 } /* Literal.String.Escape */
144
+ .sh { background-color: #fff0f0 } /* Literal.String.Heredoc */
145
+ .si { background-color: #e0e0e0 } /* Literal.String.Interpol */
146
+ .sx { color: #D02000; background-color: #fff0f0 } /* Literal.String.Other */
147
+ .sr { color: #000000; background-color: #fff0ff } /* Literal.String.Regex */
148
+ .s1 { background-color: #fff0f0 } /* Literal.String.Single */
149
+ .ss { color: #A06000 } /* Literal.String.Symbol */
150
+ .bp { color: #007020 } /* Name.Builtin.Pseudo */
151
+ .vc { color: #306090 } /* Name.Variable.Class */
152
+ .vg { color: #d07000; font-weight: bold } /* Name.Variable.Global */
153
+ .vi { color: #3030B0 } /* Name.Variable.Instance */
154
+ .il { color: #0000D0; font-weight: bold } /* Literal.Number.Integer.Long */
@@ -0,0 +1,81 @@
1
+ \section{Tipos, Clases y Módulos}
2
+
3
+
4
+ \begin{verbatim}
5
+ >> obj = [1, {:a => 2}]
6
+ => [1, {:a=>2}]
7
+ >> obj.class # retorna la clase de un objeto
8
+ => Array
9
+ >> obj.class.superclass # retorna la superclase de un objeto
10
+ => Object
11
+ >> obj.instance_of? Object # determina si obj.class == Object
12
+ => false
13
+ >> obj.instance_of? Array
14
+ => true
15
+ >> obj.is_a? Object # determina si obj es de una subclase de Object
16
+ => true
17
+ >> obj.is_a? Array
18
+ => true
19
+ >> obj.kind_of? Object # kind_of? es un sinónimo de is_a?
20
+ => true
21
+ >> Array === obj # equivalente a obj.is_a? Array
22
+ => true
23
+ >> Object === obj
24
+ => true
25
+ >> obj.respond_to? 'each' # si tiene un método público o protected llamado 'each'
26
+ => true # si se le pasa true como segundo argumento se comprueban
27
+ # también los privados
28
+ >> Array.instance_methods(false)
29
+ => ["insert"
30
+ "sort" "include?" "size" "&" "to_ary" "clear" "yaml_initialize" "shuffle"
31
+ "replace" "pack" "zip" "flatten!" "to_s" "pop" "pretty_print_cycle" "hash"
32
+ "cycle" "*" "indices" "nitems" "index" "collect" "+" "compact!"
33
+ "last" "rassoc" "count" "drop" "delete" "delete_at" "combination" "collect!"
34
+ "select" "each_index" "-" "flatten" "eql?" "fill" "length" "uniq!"
35
+ "at" "choice" "reject!" "[]" "take" "inspect" "shift" "compact"
36
+ "pretty_print" "[]=" "|" "find_index" "slice!" "each" "empty?" "transpose"
37
+ "<<" "frozen?" "rindex" "map" "reverse_each" "reverse!" "to_a" "push"
38
+ "uniq" "delete_if" "first" "product" "drop_while" "concat" "reject"
39
+ "map!" "join" "slice" "indexes" "taguri" "<=>" "assoc" "fetch" "to_yaml"
40
+ "==" "values_at" "permutation" "take_while" "unshift" "reverse"
41
+ "sort!" "shuffle!" "taguri="]
42
+ \end{verbatim}
43
+
44
+ \subsection{Antepasados y Módulos}
45
+
46
+ Los siguientes métodos sirven para determinar que módulos han sido incluídos
47
+ y cuales son los ancestros de una clase o módulo:
48
+ \begin{verbatim}
49
+ [~/chapter8ReflectionandMetaprogramming]$ cat ancestryAndModules.rb
50
+ module A; end
51
+
52
+ module B; include A; end
53
+
54
+ class C; include B; end
55
+
56
+ if __FILE__ == $0
57
+ puts C < B # => true: C includes B
58
+ puts B < A # => true: B includes A
59
+ puts C < A # => true
60
+ puts Fixnum < Integer # => true: all fixnums are integers
61
+ puts Integer <Comparable # => true: integers are comparable
62
+ puts Integer < Fixnum # => false: not all integers are fixnums
63
+ puts (String < Numeric).inspect # => nil: strings are not numbers
64
+
65
+ puts A.ancestors.inspect # => [A]
66
+ puts B.ancestors.inspect # => [B, A]
67
+ puts C.ancestors.inspect # => [C, B, A, Object, Kernel, BasicObject]
68
+ puts String.ancestors.inspect # => [String, Comparable, Object, Kernel, BasicObject]
69
+
70
+ puts C.include?(B) # => true
71
+ puts C.include?(A) # => true
72
+ puts B.include?(A) # => true
73
+ puts A.include?(A) # => false
74
+ puts A.include?(B) # => false
75
+
76
+ puts A.included_modules.inspect # => []
77
+ puts B.included_modules.inspect # => [A]
78
+ puts C.included_modules.inspect # => [B, A, Kernel]
79
+ end
80
+ \end{verbatim}
81
+
@@ -0,0 +1,3 @@
1
+ require "dsl-latex-simple/version"
2
+ require "dsl-latex-simple/simple"
3
+
@@ -0,0 +1,102 @@
1
+ require 'simplabs/highlight'
2
+ module Dsl
3
+ module Latex
4
+ class Simple
5
+ attr_accessor :out
6
+
7
+ def initialize()
8
+ @out = ''
9
+ end
10
+
11
+ def macro_begin(name, tagname, block)
12
+ @out << "\\#{tagname}"
13
+ @out << '{' if block and tagname != :begin
14
+ name.each do |n|
15
+ if n.is_a? Array
16
+ @out << "["+n.join('][')+"]"
17
+ else
18
+ @out << "{#{n}}"
19
+ end
20
+ end
21
+ @out << "\n"
22
+ end
23
+
24
+ def macro_end(name, tagname)
25
+ if tagname == :begin
26
+ @out << "\\end{#{name[0]}}"
27
+ else
28
+ @out << '}'
29
+ name.each do |n|
30
+ if n.is_a? Array
31
+ @out << "["+n.join('][')+"]"
32
+ else
33
+ @out << "{#{n}}"
34
+ end
35
+ end
36
+ end
37
+ @out << "\n"
38
+ end
39
+
40
+ def tag(tagname, *name, &block)
41
+ if tagname == :start
42
+ tagname = :begin
43
+ end
44
+ macro_begin(name, tagname, block_given?)
45
+ if block_given?
46
+ # create a new object and translate it
47
+ # then concat its output
48
+ aux = Dsl::Latex::Simple.new
49
+ aux.instance_eval &block
50
+ content = aux.out
51
+ if content
52
+ @out << content.to_s
53
+ end
54
+ macro_end(name, tagname)
55
+ end
56
+ nil
57
+ end
58
+
59
+ alias method_missing tag
60
+
61
+ def esc(s)
62
+ s.gsub!(%q{\\},%q{\\\\})
63
+ s
64
+ end
65
+
66
+ def trim(s)
67
+ s.gsub!(/^\s+/,'')
68
+ s.gsub!(/\s+$/,'')
69
+ s
70
+ end
71
+
72
+ def c(*x)
73
+ @out << x.join("\n")+"\n"
74
+ end
75
+
76
+ def self.generate(path)
77
+ s = File.read(path)
78
+ x = Dsl::Latex::Simple.new
79
+ x.instance_eval(s, path, 1)
80
+ puts x.out
81
+ end
82
+
83
+ def highlight_code(language, code)
84
+ start %q{rawhtml} do
85
+ hl = Simplabs::Highlight.highlight(language, code)
86
+ c "<pre>\n#{hl}\n</pre>\n"
87
+ end
88
+
89
+ start %q{latexonly} do
90
+ start :lstlisting, %Q{language=#{language}} do
91
+ c code
92
+ end
93
+ end
94
+ end
95
+
96
+ end
97
+ end
98
+ end
99
+ if $0 == __FILE__
100
+ Dsl::Latex::Simple.generate('examples/example.rex')
101
+ end
102
+
@@ -0,0 +1,7 @@
1
+ module Dsl
2
+ module Latex
3
+ class Simple
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dsl-latex-simple
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Casiano Rodriguez Leon
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: highlight
16
+ requirement: &70227644942980 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70227644942980
25
+ description: Ruby DSL for LaTeX
26
+ email:
27
+ - casiano.rodriguez.leon@gmail.com
28
+ executables:
29
+ - rex
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - Gemfile
35
+ - LICENSE.txt
36
+ - README.md
37
+ - Rakefile
38
+ - bin/rex
39
+ - dsl-latex-simple.gemspec
40
+ - examples/example.rex
41
+ - examples/example0.rex
42
+ - examples/fibonacci.png
43
+ - examples/mystyle.css
44
+ - examples/section.tex
45
+ - lib/dsl-latex-simple.rb
46
+ - lib/dsl-latex-simple/simple.rb
47
+ - lib/dsl-latex-simple/version.rb
48
+ homepage: https://github.com/crguezl/dsl-latex-simple
49
+ licenses: []
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 1.8.11
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: Ruby DSL for LaTeX
72
+ test_files: []
73
+ has_rdoc: