tilt 2.0.10 → 2.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 65edfb577c11890055c06be1af7c6cd1692d6bb1
4
- data.tar.gz: 025cb576450017fe953040a197522416e98c7835
2
+ SHA256:
3
+ metadata.gz: a552c8551a7093b787234c00bac7ccaaef77e89b1d4835c31ddbaeb8388c74ae
4
+ data.tar.gz: 014cff88cd5ec4157d02127576eb788a6b0ae3795e69dc448781093f59153769
5
5
  SHA512:
6
- metadata.gz: f1bbd4f61540f418aed012bd34cca939a7a208f0dc73ec5283041a0611fb629d5941bf24ab2976e2038774599b5d5e8f29c7beb0fababdf91c6f2d4eb9628a0b
7
- data.tar.gz: 32cb517066dc3550f33b201980884479dbd387864133267ac1563fcfa8500386bbcf204ca0fbb9c98bac8f910cc1af647ff9464839806b1d32a088865c0d6e52
6
+ metadata.gz: 9d9da743f0359f10e8486b946132d39ba892482a99e7961c4a62258a680a214030824e92442db2421f35cac7c4378ff3e8e8e0af72bd8af35150aae2cc58555b
7
+ data.tar.gz: 2755a44a43e094eb95bffe6ab095f4d8a6cc1b58d1c96d6c20325d8d607ada32da7529758dfed8f8d8f09a3eafe2c7d96f381c314c7cc99f950a36c5eaff3454
@@ -9,21 +9,31 @@ module Tilt
9
9
  :smartypants => :SMART
10
10
  }
11
11
  PARSE_OPTIONS = [
12
+ :FOOTNOTES,
13
+ :LIBERAL_HTML_TAG,
12
14
  :SMART,
13
15
  :smartypants,
16
+ :STRIKETHROUGH_DOUBLE_TILDE,
17
+ :UNSAFE,
18
+ :VALIDATE_UTF8,
14
19
  ].freeze
15
20
  RENDER_OPTIONS = [
21
+ :FOOTNOTES,
22
+ :FULL_INFO_STRING,
16
23
  :GITHUB_PRE_LANG,
17
24
  :HARDBREAKS,
18
25
  :NOBREAKS,
19
- :SAFE,
26
+ :SAFE, # Removed in v0.18.0 (2018-10-17)
20
27
  :SOURCEPOS,
28
+ :TABLE_PREFER_STYLE_ATTRIBUTES,
29
+ :UNSAFE,
21
30
  ].freeze
22
31
  EXTENSIONS = [
23
32
  :autolink,
24
33
  :strikethrough,
25
34
  :table,
26
35
  :tagfilter,
36
+ :tasklist,
27
37
  ].freeze
28
38
 
29
39
  def extensions
data/lib/tilt/csv.rb CHANGED
@@ -50,7 +50,7 @@ module Tilt
50
50
 
51
51
  def precompiled_template(locals)
52
52
  <<-RUBY
53
- #{@outvar} = #{self.class.engine}.generate(#{options}) do |csv|
53
+ #{@outvar} = #{self.class.engine}.generate(**#{options}) do |csv|
54
54
  #{data}
55
55
  end
56
56
  RUBY
data/lib/tilt/pandoc.rb CHANGED
@@ -7,30 +7,38 @@ module Tilt
7
7
  class PandocTemplate < Template
8
8
  self.default_mime_type = 'text/html'
9
9
 
10
- def tilt_to_pandoc_mapping
11
- { :smartypants => :smart,
12
- :escape_html => { :f => 'markdown-raw_html' },
13
- :commonmark => { :f => 'commonmark' },
14
- :markdown_strict => { :f => 'markdown_strict' }
15
- }
16
- end
17
-
18
10
  # turn options hash into an array
19
11
  # Map tilt options to pandoc options
20
12
  # Replace hash keys with value true with symbol for key
21
13
  # Remove hash keys with value false
22
14
  # Leave other hash keys untouched
23
15
  def pandoc_options
24
- options.reduce([]) do |sum, (k,v)|
25
- case v
26
- when true
27
- sum << (tilt_to_pandoc_mapping[k] || k)
28
- when false
29
- sum
16
+ result = []
17
+ from = "markdown"
18
+ smart_extension = "-smart"
19
+ options.each do |k,v|
20
+ case k
21
+ when :smartypants
22
+ smart_extension = "+smart" if v
23
+ when :escape_html
24
+ from = "markdown-raw_html" if v
25
+ when :commonmark
26
+ from = "commonmark" if v
27
+ when :markdown_strict
28
+ from = "markdown_strict" if v
30
29
  else
31
- sum << { k => v }
30
+ case v
31
+ when true
32
+ result << k
33
+ when false
34
+ # do nothing
35
+ else
36
+ result << { k => v }
37
+ end
32
38
  end
33
39
  end
40
+ result << { :f => from + smart_extension }
41
+ result
34
42
  end
35
43
 
36
44
  def prepare
@@ -75,9 +75,12 @@ module Tilt
75
75
  end
76
76
 
77
77
  if defined? ::Redcarpet::Render and defined? ::Redcarpet::Markdown
78
- RedcarpetTemplate = Redcarpet2Template
78
+ superclass = Redcarpet2Template
79
79
  else
80
- RedcarpetTemplate = Redcarpet1Template
80
+ superclass = Redcarpet1Template
81
+ end
82
+
83
+ class RedcarpetTemplate < superclass
81
84
  end
82
85
  end
83
86
 
@@ -1,18 +1,23 @@
1
1
  require 'tilt/template'
2
- require 'tilt/pandoc'
2
+ require 'pandoc'
3
3
 
4
4
  module Tilt
5
5
  # Pandoc reStructuredText implementation. See:
6
6
  # http://pandoc.org/
7
- # Use PandocTemplate and specify input format
8
7
  class RstPandocTemplate < PandocTemplate
9
- def tilt_to_pandoc_mapping
10
- { :smartypants => :smart }
8
+ self.default_mime_type = 'text/html'
9
+
10
+ def prepare
11
+ @engine = PandocRuby.new(data, :f => "rst")
12
+ @output = nil
13
+ end
14
+
15
+ def evaluate(scope, locals, &block)
16
+ @output ||= @engine.to_html.strip
11
17
  end
12
18
 
13
- def pandoc_options
14
- options.merge!(f: 'rst')
15
- super
19
+ def allows_script?
20
+ false
16
21
  end
17
22
  end
18
23
  end
data/lib/tilt/sass.rb CHANGED
@@ -9,23 +9,35 @@ module Tilt
9
9
  self.default_mime_type = 'text/css'
10
10
 
11
11
  begin
12
- require 'sassc'
13
- Sass = ::SassC
12
+ require 'sass-embedded'
13
+ require 'uri'
14
+ Engine = nil
14
15
  rescue LoadError => err
15
16
  begin
16
- require 'sass'
17
- Sass = ::Sass
17
+ require 'sassc'
18
+ Engine = ::SassC::Engine
18
19
  rescue LoadError
19
- raise err
20
+ begin
21
+ require 'sass'
22
+ Engine = ::Sass::Engine
23
+ rescue LoadError
24
+ raise err
25
+ end
20
26
  end
21
27
  end
22
28
 
23
29
  def prepare
24
- @engine = Sass::Engine.new(data, sass_options)
30
+ @engine = unless Engine.nil?
31
+ Engine.new(data, sass_options)
32
+ end
25
33
  end
26
34
 
27
35
  def evaluate(scope, locals, &block)
28
- @output ||= @engine.render
36
+ @output ||= if @engine.nil?
37
+ ::Sass.compile_string(data, **sass_embedded_options).css
38
+ else
39
+ @engine.render
40
+ end
29
41
  end
30
42
 
31
43
  def allows_script?
@@ -33,6 +45,16 @@ module Tilt
33
45
  end
34
46
 
35
47
  private
48
+ def eval_file_url
49
+ path = File.absolute_path(eval_file)
50
+ path = '/' + path unless path.start_with?('/')
51
+ ::URI::File.build([nil, ::URI::DEFAULT_PARSER.escape(path)]).to_s
52
+ end
53
+
54
+ def sass_embedded_options
55
+ options.merge(:url => eval_file_url, :syntax => :indented)
56
+ end
57
+
36
58
  def sass_options
37
59
  options.merge(:filename => eval_file, :line => line, :syntax => :sass)
38
60
  end
@@ -43,6 +65,10 @@ module Tilt
43
65
  self.default_mime_type = 'text/css'
44
66
 
45
67
  private
68
+ def sass_embedded_options
69
+ options.merge(:url => eval_file_url, :syntax => :scss)
70
+ end
71
+
46
72
  def sass_options
47
73
  options.merge(:filename => eval_file, :line => line, :syntax => :scss)
48
74
  end
data/lib/tilt/template.rb CHANGED
@@ -157,6 +157,8 @@ module Tilt
157
157
  raise NotImplementedError
158
158
  end
159
159
 
160
+ CLASS_METHOD = Kernel.instance_method(:class)
161
+
160
162
  # Execute the compiled template and return the result string. Template
161
163
  # evaluation is guaranteed to be performed in the scope object with the
162
164
  # locals specified and with support for yielding to the block.
@@ -166,7 +168,16 @@ module Tilt
166
168
  def evaluate(scope, locals, &block)
167
169
  locals_keys = locals.keys
168
170
  locals_keys.sort!{|x, y| x.to_s <=> y.to_s}
169
- method = compiled_method(locals_keys, scope.is_a?(Module) ? scope : scope.class)
171
+ case scope
172
+ when Object
173
+ method = compiled_method(locals_keys, Module === scope ? scope : scope.class)
174
+ else
175
+ if RUBY_VERSION >= '2'
176
+ method = compiled_method(locals_keys, CLASS_METHOD.bind(scope).call)
177
+ else
178
+ method = compiled_method(locals_keys, Object)
179
+ end
180
+ end
170
181
  method.bind(scope).call(locals, &block)
171
182
  end
172
183
 
data/lib/tilt.rb CHANGED
@@ -4,7 +4,7 @@ require 'tilt/template'
4
4
  # Namespace for Tilt. This module is not intended to be included anywhere.
5
5
  module Tilt
6
6
  # Current version.
7
- VERSION = '2.0.10'
7
+ VERSION = '2.0.11'
8
8
 
9
9
  @default_mapping = Mapping.new
10
10
 
@@ -161,6 +161,7 @@ module Tilt
161
161
  register_lazy 'Slim::Template', 'slim', 'slim'
162
162
  register_lazy 'Tilt::HandlebarsTemplate', 'tilt/handlebars', 'handlebars', 'hbs'
163
163
  register_lazy 'Tilt::OrgTemplate', 'org-ruby', 'org'
164
+ register_lazy 'Tilt::EmacsOrgTemplate', 'tilt/emacs_org', 'org'
164
165
  register_lazy 'Opal::Processor', 'opal', 'opal', 'rb'
165
166
  register_lazy 'Tilt::JbuilderTemplate', 'tilt/jbuilder', 'jbuilder'
166
167
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tilt
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.10
4
+ version: 2.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-23 00:00:00.000000000 Z
11
+ date: 2022-07-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Generic interface to multiple Ruby template engines
14
14
  email: r@tomayko.com
@@ -58,11 +58,11 @@ files:
58
58
  - lib/tilt/typescript.rb
59
59
  - lib/tilt/wikicloth.rb
60
60
  - lib/tilt/yajl.rb
61
- homepage: http://github.com/rtomayko/tilt/
61
+ homepage: https://github.com/rtomayko/tilt/
62
62
  licenses:
63
63
  - MIT
64
64
  metadata: {}
65
- post_install_message:
65
+ post_install_message:
66
66
  rdoc_options:
67
67
  - "--line-numbers"
68
68
  - "--inline-source"
@@ -83,9 +83,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  requirements: []
86
- rubyforge_project:
87
- rubygems_version: 2.6.11
88
- signing_key:
86
+ rubygems_version: 3.2.29
87
+ signing_key:
89
88
  specification_version: 2
90
89
  summary: Generic interface to multiple Ruby template engines
91
90
  test_files: []