tilt 2.3.0 → 2.4.0

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
2
  SHA256:
3
- metadata.gz: 42821dda310628574e4e1c99c69751d463bee48887c8f90c82768b80bb17231b
4
- data.tar.gz: eb67c15726743517bf14d6db8b0034f7cbb7bd6c3c96d72ce24623430df03202
3
+ metadata.gz: d9bb9bafc29e9442fed0bf862fb442ea6efaa97c2881b7b958361f0ef7095aaa
4
+ data.tar.gz: f25db1d4c05ef3b20c5fabefa4eb664e702f51f8d9821b0c44f5f5404ade4c3b
5
5
  SHA512:
6
- metadata.gz: 832ae277c35c2bb4fb36f93d2aaa411ec5ac948eb7d1eec956d70a1a54d27a2c4d326ae02bc5a75d06177aebb29d22cec4437ada71691ca25aba050fcad78236
7
- data.tar.gz: ecc19aa399a14acc5c3d4f5adfc2d0bb70bf8d7552fd90ae7e4165cbad45b8f149e6cd808c49c0808762b6b9c68945dc6009a94c2910056a49f9e702637a8391
6
+ metadata.gz: dc69e05565c5b007fbaaddc7636d6298fc9930c42d1e029834b752236309d97024132118bb723817c5c192cad1f1cef01e278ce4fc46629dac706d0ec4fdd6a2
7
+ data.tar.gz: 702e18b78c3e9b21e1abe86671bbe6f2427db44b05be4941c1693f30070f1de028af5324294d693bdeda130da603ecfd5c98dcefbce7ca21f7e7f6df5a249b97
@@ -2,53 +2,94 @@
2
2
  require_relative 'template'
3
3
  require 'commonmarker'
4
4
 
5
- aliases = {
6
- :smartypants => :SMART
7
- }.freeze
8
- parse_opts = [
9
- :FOOTNOTES,
10
- :LIBERAL_HTML_TAG,
11
- :SMART,
12
- :smartypants,
13
- :STRIKETHROUGH_DOUBLE_TILDE,
14
- :UNSAFE,
15
- :VALIDATE_UTF8,
16
- ].freeze
17
- render_opts = [
18
- :FOOTNOTES,
19
- :FULL_INFO_STRING,
20
- :GITHUB_PRE_LANG,
21
- :HARDBREAKS,
22
- :NOBREAKS,
23
- :SAFE, # Removed in v0.18.0 (2018-10-17)
24
- :SOURCEPOS,
25
- :TABLE_PREFER_STYLE_ATTRIBUTES,
26
- :UNSAFE,
27
- ].freeze
28
- exts = [
29
- :autolink,
30
- :strikethrough,
31
- :table,
32
- :tagfilter,
33
- :tasklist,
34
- ].freeze
5
+ if defined?(::Commonmarker)
6
+ aliases = {
7
+ :smartypants => :smart
8
+ }.freeze
9
+ parse_opts = [
10
+ :smart,
11
+ :default_info_string,
12
+ ].freeze
13
+ render_opts = [
14
+ :hardbreaks,
15
+ :github_pre_lang,
16
+ :width,
17
+ :unsafe,
18
+ :escape,
19
+ :sourcepos,
20
+ ].freeze
21
+ exts = [
22
+ :strikethrough,
23
+ :tagfilter,
24
+ :table,
25
+ :autolink,
26
+ :tasklist,
27
+ :superscript,
28
+ :header_ids,
29
+ :footnotes,
30
+ :description_lists,
31
+ :front_matter_delimiter,
32
+ :shortcodes,
33
+ ].freeze
35
34
 
35
+ Tilt::CommonMarkerTemplate = Tilt::StaticTemplate.subclass do
36
+ parse_options = @options.select { |key, _| parse_opts.include?(key.downcase) }.transform_keys(&:downcase)
37
+ parse_options.merge!(@options.select { |key, _| aliases.has_key?(key) }.transform_keys { |key| aliases[key] })
38
+ render_options = @options.select { |key, _| render_opts.include?(key.downcase) }.transform_keys(&:downcase)
39
+ extensions = @options.select { |key, _| exts.include?(key) }.transform_keys(&:downcase)
36
40
 
37
- Tilt::CommonMarkerTemplate = Tilt::StaticTemplate.subclass do
38
- extensions = exts.select do |extension|
39
- @options[extension]
41
+ Commonmarker.to_html(@data, options: { parse: parse_options, render: render_options, extension: extensions })
40
42
  end
43
+ # :nocov:
44
+ else
45
+ aliases = {
46
+ :smartypants => :SMART
47
+ }.freeze
48
+ parse_opts = [
49
+ :FOOTNOTES,
50
+ :LIBERAL_HTML_TAG,
51
+ :SMART,
52
+ :smartypants,
53
+ :STRIKETHROUGH_DOUBLE_TILDE,
54
+ :UNSAFE,
55
+ :VALIDATE_UTF8,
56
+ ].freeze
57
+ render_opts = [
58
+ :FOOTNOTES,
59
+ :FULL_INFO_STRING,
60
+ :GITHUB_PRE_LANG,
61
+ :HARDBREAKS,
62
+ :NOBREAKS,
63
+ :SAFE, # Removed in v0.18.0 (2018-10-17)
64
+ :SOURCEPOS,
65
+ :TABLE_PREFER_STYLE_ATTRIBUTES,
66
+ :UNSAFE,
67
+ ].freeze
68
+ exts = [
69
+ :autolink,
70
+ :strikethrough,
71
+ :table,
72
+ :tagfilter,
73
+ :tasklist,
74
+ ].freeze
41
75
 
42
- parse_options, render_options = [parse_opts, render_opts].map do |opts|
43
- opts = opts.select do |option|
44
- @options[option]
45
- end.map! do |option|
46
- aliases[option] || option
76
+ Tilt::CommonMarkerTemplate = Tilt::StaticTemplate.subclass do
77
+ extensions = exts.select do |extension|
78
+ @options[extension]
47
79
  end
48
80
 
49
- opts = :DEFAULT unless opts.any?
50
- opts
51
- end
81
+ parse_options, render_options = [parse_opts, render_opts].map do |opts|
82
+ opts = opts.select do |option|
83
+ @options[option]
84
+ end.map! do |option|
85
+ aliases[option] || option
86
+ end
87
+
88
+ opts = :DEFAULT unless opts.any?
89
+ opts
90
+ end
52
91
 
53
- CommonMarker.render_doc(@data, parse_options, extensions).to_html(render_options, extensions)
92
+ CommonMarker.render_doc(@data, parse_options, extensions).to_html(render_options, extensions)
93
+ end
54
94
  end
95
+ # :nocov:
data/lib/tilt/erubis.rb CHANGED
@@ -2,6 +2,8 @@
2
2
  require_relative 'erb'
3
3
  require 'erubis'
4
4
 
5
+ warn 'tilt/erubis is deprecated, as erubis requires modifying string literals', uplevel: 1
6
+
5
7
  module Tilt
6
8
  # Erubis template implementation. See:
7
9
  # http://www.kuwata-lab.com/erubis/
data/lib/tilt/etanni.rb CHANGED
@@ -5,7 +5,7 @@ module Tilt
5
5
  class EtanniTemplate < Template
6
6
  def prepare
7
7
  separator = data.hash.abs
8
- chomp = "<<#{separator}.chomp!"
8
+ chomp = "<<#{separator}.chomp"
9
9
  start = "\n_out_ << #{chomp}\n"
10
10
  stop = "\n#{separator}\n"
11
11
  replacement = "#{stop}\\1#{start}"
@@ -13,7 +13,7 @@ module Tilt
13
13
  temp = @data.strip
14
14
  temp.gsub!(/<\?r\s+(.*?)\s+\?>/m, replacement)
15
15
 
16
- @code = "_out_ = [<<#{separator}.chomp!]\n#{temp}#{stop}_out_.join"
16
+ @code = "_out_ = [<<#{separator}.chomp]\n#{temp}#{stop}_out_.join"
17
17
  end
18
18
 
19
19
  def precompiled_template(locals)
data/lib/tilt/maruku.rb CHANGED
@@ -2,6 +2,8 @@
2
2
  require_relative 'template'
3
3
  require 'maruku'
4
4
 
5
+ warn 'tilt/maruku is deprecated, as maruku requires modifying string literals', uplevel: 1
6
+
5
7
  # Maruku markdown implementation. See: https://github.com/bhollis/maruku
6
8
  Tilt::MarukuTemplate = Tilt::StaticTemplate.subclass do
7
9
  Maruku.new(@data, @options).to_html
data/lib/tilt/sass.rb CHANGED
@@ -13,6 +13,13 @@ module Tilt
13
13
  # :nocov:
14
14
  require 'uri'
15
15
 
16
+ ALLOWED_KEYS = (defined?(::Sass::Compiler) ? ::Sass::Compiler : ::Sass::Embedded).
17
+ instance_method(:compile_string).
18
+ parameters.
19
+ map{|k, v| v if k == :key}.
20
+ compact rescue nil
21
+ private_constant :ALLOWED_KEYS
22
+
16
23
  private
17
24
 
18
25
  def _prepare_output
@@ -22,9 +29,11 @@ module Tilt
22
29
  def sass_options
23
30
  path = File.absolute_path(eval_file)
24
31
  path = '/' + path unless path.start_with?('/')
25
- @options[:url] = ::URI::File.build([nil, ::URI::DEFAULT_PARSER.escape(path)]).to_s
26
- @options[:syntax] = :indented
27
- @options
32
+ opts = @options.dup
33
+ opts[:url] = ::URI::File.build([nil, ::URI::DEFAULT_PARSER.escape(path)]).to_s
34
+ opts[:syntax] = :indented
35
+ opts.delete_if{|k| !ALLOWED_KEYS.include?(k)} if ALLOWED_KEYS
36
+ opts
28
37
  end
29
38
  rescue LoadError => err
30
39
  begin
@@ -61,9 +70,9 @@ module Tilt
61
70
  private
62
71
 
63
72
  def sass_options
64
- super
65
- @options[:syntax] = :scss
66
- @options
73
+ opts = super
74
+ opts[:syntax] = :scss
75
+ opts
67
76
  end
68
77
  end
69
78
  end
@@ -2,6 +2,8 @@
2
2
  require_relative 'template'
3
3
  require 'wikicloth'
4
4
 
5
+ warn 'tilt/wikicloth is deprecated, as wikicloth requires modifying string literals', uplevel: 1
6
+
5
7
  # WikiCloth implementation. See: https://github.com/nricciar/wikicloth
6
8
  Tilt::WikiClothTemplate = Tilt::StaticTemplate.subclass do
7
9
  parser = @options.delete(:parser) || WikiCloth::Parser
data/lib/tilt.rb CHANGED
@@ -5,7 +5,7 @@ require_relative 'tilt/template'
5
5
  # Namespace for Tilt. This module is not intended to be included anywhere.
6
6
  module Tilt
7
7
  # Current version.
8
- VERSION = '2.3.0'
8
+ VERSION = '2.4.0'
9
9
 
10
10
  EMPTY_HASH = {}.freeze
11
11
  private_constant :EMPTY_HASH
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tilt
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-09-14 00:00:00.000000000 Z
13
+ date: 2024-06-27 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Generic interface to multiple Ruby template engines
16
16
  email: code@jeremyevans.net
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  requirements: []
95
- rubygems_version: 3.4.10
95
+ rubygems_version: 3.5.9
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: Generic interface to multiple Ruby template engines