jekyll 3.2.0.pre.beta1 → 3.2.0.pre.beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of jekyll might be problematic. Click here for more details.
- checksums.yaml +4 -4
 - data/.rubocop.yml +17 -95
 - data/README.markdown +6 -4
 - data/{bin → exe}/jekyll +18 -14
 - data/lib/jekyll.rb +79 -76
 - data/lib/jekyll/collection.rb +32 -16
 - data/lib/jekyll/command.rb +17 -13
 - data/lib/jekyll/commands/build.rb +7 -2
 - data/lib/jekyll/commands/doctor.rb +3 -1
 - data/lib/jekyll/commands/new.rb +3 -0
 - data/lib/jekyll/commands/new_theme.rb +7 -4
 - data/lib/jekyll/commands/serve.rb +2 -0
 - data/lib/jekyll/commands/serve/servlet.rb +2 -2
 - data/lib/jekyll/configuration.rb +187 -125
 - data/lib/jekyll/converters/markdown.rb +19 -9
 - data/lib/jekyll/converters/markdown/kramdown_parser.rb +12 -5
 - data/lib/jekyll/converters/markdown/rdiscount_parser.rb +4 -4
 - data/lib/jekyll/converters/markdown/redcarpet_parser.rb +90 -84
 - data/lib/jekyll/convertible.rb +34 -21
 - data/lib/jekyll/deprecator.rb +11 -6
 - data/lib/jekyll/document.rb +52 -50
 - data/lib/jekyll/drops/document_drop.rb +40 -5
 - data/lib/jekyll/drops/drop.rb +49 -10
 - data/lib/jekyll/drops/excerpt_drop.rb +15 -0
 - data/lib/jekyll/drops/jekyll_drop.rb +12 -0
 - data/lib/jekyll/drops/site_drop.rb +4 -2
 - data/lib/jekyll/drops/url_drop.rb +4 -4
 - data/lib/jekyll/entry_filter.rb +9 -6
 - data/lib/jekyll/errors.rb +4 -3
 - data/lib/jekyll/excerpt.rb +4 -6
 - data/lib/jekyll/external.rb +4 -4
 - data/lib/jekyll/filters.rb +67 -34
 - data/lib/jekyll/frontmatter_defaults.rb +45 -38
 - data/lib/jekyll/hooks.rb +21 -21
 - data/lib/jekyll/layout.rb +3 -1
 - data/lib/jekyll/liquid_renderer.rb +7 -3
 - data/lib/jekyll/liquid_renderer/file.rb +1 -1
 - data/lib/jekyll/liquid_renderer/table.rb +11 -11
 - data/lib/jekyll/log_adapter.rb +2 -2
 - data/lib/jekyll/page.rb +10 -10
 - data/lib/jekyll/plugin.rb +5 -5
 - data/lib/jekyll/plugin_manager.rb +12 -8
 - data/lib/jekyll/publisher.rb +1 -1
 - data/lib/jekyll/reader.rb +11 -7
 - data/lib/jekyll/readers/data_reader.rb +9 -9
 - data/lib/jekyll/readers/layout_reader.rb +7 -7
 - data/lib/jekyll/readers/page_reader.rb +3 -1
 - data/lib/jekyll/readers/post_reader.rb +9 -10
 - data/lib/jekyll/readers/static_file_reader.rb +3 -1
 - data/lib/jekyll/regenerator.rb +50 -28
 - data/lib/jekyll/related_posts.rb +1 -1
 - data/lib/jekyll/renderer.rb +29 -20
 - data/lib/jekyll/site.rb +92 -50
 - data/lib/jekyll/static_file.rb +33 -26
 - data/lib/jekyll/stevenson.rb +6 -5
 - data/lib/jekyll/tags/highlight.rb +50 -35
 - data/lib/jekyll/tags/include.rb +42 -31
 - data/lib/jekyll/tags/link.rb +11 -4
 - data/lib/jekyll/tags/post_url.rb +8 -7
 - data/lib/jekyll/theme.rb +4 -3
 - data/lib/jekyll/theme_builder.rb +18 -6
 - data/lib/jekyll/url.rb +21 -14
 - data/lib/jekyll/utils.rb +57 -28
 - data/lib/jekyll/utils/ansi.rb +9 -9
 - data/lib/jekyll/utils/platforms.rb +2 -2
 - data/lib/jekyll/version.rb +1 -1
 - data/lib/site_template/_config.yml +2 -0
 - data/lib/site_template/css/main.scss +3 -17
 - data/lib/theme_template/_layouts/default.html +1 -0
 - data/lib/theme_template/_layouts/page.html +5 -0
 - data/lib/theme_template/_layouts/post.html +5 -0
 - data/lib/theme_template/example/_post.md +1 -2
 - data/lib/theme_template/example/index.html +2 -2
 - data/lib/theme_template/gitignore.erb +4 -0
 - data/lib/theme_template/theme.gemspec.erb +2 -6
 - metadata +10 -18
 - data/lib/site_template/_includes/footer.html +0 -38
 - data/lib/site_template/_includes/head.html +0 -12
 - data/lib/site_template/_includes/header.html +0 -27
 - data/lib/site_template/_includes/icon-github.html +0 -1
 - data/lib/site_template/_includes/icon-github.svg +0 -1
 - data/lib/site_template/_includes/icon-twitter.html +0 -1
 - data/lib/site_template/_includes/icon-twitter.svg +0 -1
 - data/lib/site_template/_layouts/default.html +0 -20
 - data/lib/site_template/_layouts/page.html +0 -14
 - data/lib/site_template/_layouts/post.html +0 -15
 - data/lib/site_template/_sass/_base.scss +0 -200
 - data/lib/site_template/_sass/_layout.scss +0 -242
 - data/lib/site_template/_sass/_syntax-highlighting.scss +0 -71
 
    
        data/lib/jekyll/static_file.rb
    CHANGED
    
    | 
         @@ -1,16 +1,25 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Jekyll
         
     | 
| 
       2 
2 
     | 
    
         
             
              class StaticFile
         
     | 
| 
       3 
     | 
    
         
            -
                # The cache of last modification times [path] -> mtime.
         
     | 
| 
       4 
     | 
    
         
            -
                @@mtimes = {}
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
3 
     | 
    
         
             
                attr_reader :relative_path, :extname
         
     | 
| 
       7 
4 
     | 
    
         | 
| 
      
 5 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # The cache of last modification times [path] -> mtime.
         
     | 
| 
      
 7 
     | 
    
         
            +
                  def mtimes
         
     | 
| 
      
 8 
     | 
    
         
            +
                    @mtimes ||= {}
         
     | 
| 
      
 9 
     | 
    
         
            +
                  end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  def reset_cache
         
     | 
| 
      
 12 
     | 
    
         
            +
                    @mtimes = nil
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
       8 
16 
     | 
    
         
             
                # Initialize a new StaticFile.
         
     | 
| 
       9 
17 
     | 
    
         
             
                #
         
     | 
| 
       10 
18 
     | 
    
         
             
                # site - The Site.
         
     | 
| 
       11 
19 
     | 
    
         
             
                # base - The String path to the <source>.
         
     | 
| 
       12 
20 
     | 
    
         
             
                # dir  - The String path between <source> and the file.
         
     | 
| 
       13 
21 
     | 
    
         
             
                # name - The String filename of the file.
         
     | 
| 
      
 22 
     | 
    
         
            +
                # rubocop: disable ParameterLists
         
     | 
| 
       14 
23 
     | 
    
         
             
                def initialize(site, base, dir, name, collection = nil)
         
     | 
| 
       15 
24 
     | 
    
         
             
                  @site = site
         
     | 
| 
       16 
25 
     | 
    
         
             
                  @base = base
         
     | 
| 
         @@ -20,6 +29,7 @@ module Jekyll 
     | 
|
| 
       20 
29 
     | 
    
         
             
                  @relative_path = File.join(*[@dir, @name].compact)
         
     | 
| 
       21 
30 
     | 
    
         
             
                  @extname = File.extname(@name)
         
     | 
| 
       22 
31 
     | 
    
         
             
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
                # rubocop: enable ParameterLists
         
     | 
| 
       23 
33 
     | 
    
         | 
| 
       24 
34 
     | 
    
         
             
                # Returns source file path.
         
     | 
| 
       25 
35 
     | 
    
         
             
                def path
         
     | 
| 
         @@ -56,7 +66,7 @@ module Jekyll 
     | 
|
| 
       56 
66 
     | 
    
         
             
                #
         
     | 
| 
       57 
67 
     | 
    
         
             
                # Returns true if modified since last write.
         
     | 
| 
       58 
68 
     | 
    
         
             
                def modified?
         
     | 
| 
       59 
     | 
    
         
            -
                   
     | 
| 
      
 69 
     | 
    
         
            +
                  self.class.mtimes[path] != mtime
         
     | 
| 
       60 
70 
     | 
    
         
             
                end
         
     | 
| 
       61 
71 
     | 
    
         | 
| 
       62 
72 
     | 
    
         
             
                # Whether to write the file to the filesystem
         
     | 
| 
         @@ -64,7 +74,7 @@ module Jekyll 
     | 
|
| 
       64 
74 
     | 
    
         
             
                # Returns true unless the defaults for the destination path from
         
     | 
| 
       65 
75 
     | 
    
         
             
                # _config.yml contain `published: false`.
         
     | 
| 
       66 
76 
     | 
    
         
             
                def write?
         
     | 
| 
       67 
     | 
    
         
            -
                  defaults.fetch( 
     | 
| 
      
 77 
     | 
    
         
            +
                  defaults.fetch("published", true)
         
     | 
| 
       68 
78 
     | 
    
         
             
                end
         
     | 
| 
       69 
79 
     | 
    
         | 
| 
       70 
80 
     | 
    
         
             
                # Write the static file to the destination directory (if modified).
         
     | 
| 
         @@ -76,28 +86,15 @@ module Jekyll 
     | 
|
| 
       76 
86 
     | 
    
         
             
                  dest_path = destination(dest)
         
     | 
| 
       77 
87 
     | 
    
         | 
| 
       78 
88 
     | 
    
         
             
                  return false if File.exist?(dest_path) && !modified?
         
     | 
| 
       79 
     | 
    
         
            -
                   
     | 
| 
      
 89 
     | 
    
         
            +
                  self.class.mtimes[path] = mtime
         
     | 
| 
       80 
90 
     | 
    
         | 
| 
       81 
91 
     | 
    
         
             
                  FileUtils.mkdir_p(File.dirname(dest_path))
         
     | 
| 
       82 
92 
     | 
    
         
             
                  FileUtils.rm(dest_path) if File.exist?(dest_path)
         
     | 
| 
       83 
     | 
    
         
            -
                   
     | 
| 
       84 
     | 
    
         
            -
                    FileUtils.cp(path, dest_path)
         
     | 
| 
       85 
     | 
    
         
            -
                  else
         
     | 
| 
       86 
     | 
    
         
            -
                    FileUtils.copy_entry(path, dest_path)
         
     | 
| 
       87 
     | 
    
         
            -
                  end
         
     | 
| 
       88 
     | 
    
         
            -
                  File.utime(@@mtimes[path], @@mtimes[path], dest_path)
         
     | 
| 
      
 93 
     | 
    
         
            +
                  copy_file(dest_path)
         
     | 
| 
       89 
94 
     | 
    
         | 
| 
       90 
95 
     | 
    
         
             
                  true
         
     | 
| 
       91 
96 
     | 
    
         
             
                end
         
     | 
| 
       92 
97 
     | 
    
         | 
| 
       93 
     | 
    
         
            -
                # Reset the mtimes cache (for testing purposes).
         
     | 
| 
       94 
     | 
    
         
            -
                #
         
     | 
| 
       95 
     | 
    
         
            -
                # Returns nothing.
         
     | 
| 
       96 
     | 
    
         
            -
                def self.reset_cache
         
     | 
| 
       97 
     | 
    
         
            -
                  @@mtimes = {}
         
     | 
| 
       98 
     | 
    
         
            -
                  nil
         
     | 
| 
       99 
     | 
    
         
            -
                end
         
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
98 
     | 
    
         
             
                def to_liquid
         
     | 
| 
       102 
99 
     | 
    
         
             
                  {
         
     | 
| 
       103 
100 
     | 
    
         
             
                    "extname"       => extname,
         
     | 
| 
         @@ -109,11 +106,11 @@ module Jekyll 
     | 
|
| 
       109 
106 
     | 
    
         
             
                def placeholders
         
     | 
| 
       110 
107 
     | 
    
         
             
                  {
         
     | 
| 
       111 
108 
     | 
    
         
             
                    :collection => @collection.label,
         
     | 
| 
       112 
     | 
    
         
            -
                    :path 
     | 
| 
      
 109 
     | 
    
         
            +
                    :path       => relative_path[
         
     | 
| 
       113 
110 
     | 
    
         
             
                      @collection.relative_directory.size..relative_path.size],
         
     | 
| 
       114 
     | 
    
         
            -
                    :output_ext =>  
     | 
| 
       115 
     | 
    
         
            -
                    :name 
     | 
| 
       116 
     | 
    
         
            -
                    :title 
     | 
| 
      
 111 
     | 
    
         
            +
                    :output_ext => "",
         
     | 
| 
      
 112 
     | 
    
         
            +
                    :name       => "",
         
     | 
| 
      
 113 
     | 
    
         
            +
                    :title      => ""
         
     | 
| 
       117 
114 
     | 
    
         
             
                  }
         
     | 
| 
       118 
115 
     | 
    
         
             
                end
         
     | 
| 
       119 
116 
     | 
    
         | 
| 
         @@ -125,10 +122,10 @@ module Jekyll 
     | 
|
| 
       125 
122 
     | 
    
         
             
                             relative_path
         
     | 
| 
       126 
123 
     | 
    
         
             
                           else
         
     | 
| 
       127 
124 
     | 
    
         
             
                             ::Jekyll::URL.new({
         
     | 
| 
       128 
     | 
    
         
            -
                               :template 
     | 
| 
      
 125 
     | 
    
         
            +
                               :template     => @collection.url_template,
         
     | 
| 
       129 
126 
     | 
    
         
             
                               :placeholders => placeholders
         
     | 
| 
       130 
127 
     | 
    
         
             
                             })
         
     | 
| 
       131 
     | 
    
         
            -
                           end.to_s.gsub( 
     | 
| 
      
 128 
     | 
    
         
            +
                           end.to_s.gsub(%r!/$!, "")
         
     | 
| 
       132 
129 
     | 
    
         
             
                end
         
     | 
| 
       133 
130 
     | 
    
         | 
| 
       134 
131 
     | 
    
         
             
                # Returns the type of the collection if present, nil otherwise.
         
     | 
| 
         @@ -141,5 +138,15 @@ module Jekyll 
     | 
|
| 
       141 
138 
     | 
    
         
             
                def defaults
         
     | 
| 
       142 
139 
     | 
    
         
             
                  @defaults ||= @site.frontmatter_defaults.all url, type
         
     | 
| 
       143 
140 
     | 
    
         
             
                end
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
                private
         
     | 
| 
      
 143 
     | 
    
         
            +
                def copy_file(dest_path)
         
     | 
| 
      
 144 
     | 
    
         
            +
                  if @site.safe || Jekyll.env == "production"
         
     | 
| 
      
 145 
     | 
    
         
            +
                    FileUtils.cp(path, dest_path)
         
     | 
| 
      
 146 
     | 
    
         
            +
                  else
         
     | 
| 
      
 147 
     | 
    
         
            +
                    FileUtils.copy_entry(path, dest_path)
         
     | 
| 
      
 148 
     | 
    
         
            +
                  end
         
     | 
| 
      
 149 
     | 
    
         
            +
                  File.utime(self.class.mtimes[path], self.class.mtimes[path], dest_path)
         
     | 
| 
      
 150 
     | 
    
         
            +
                end
         
     | 
| 
       144 
151 
     | 
    
         
             
              end
         
     | 
| 
       145 
152 
     | 
    
         
             
            end
         
     | 
    
        data/lib/jekyll/stevenson.rb
    CHANGED
    
    | 
         @@ -6,13 +6,13 @@ module Jekyll 
     | 
|
| 
       6 
6 
     | 
    
         
             
                  @default_formatter = Formatter.new
         
     | 
| 
       7 
7 
     | 
    
         
             
                  @logdev = $stdout
         
     | 
| 
       8 
8 
     | 
    
         
             
                  @formatter = proc do |_, _, _, msg|
         
     | 
| 
       9 
     | 
    
         
            -
                     
     | 
| 
      
 9 
     | 
    
         
            +
                    msg.to_s
         
     | 
| 
       10 
10 
     | 
    
         
             
                  end
         
     | 
| 
       11 
11 
     | 
    
         
             
                end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
                def add(severity, message = nil, progname = nil 
     | 
| 
      
 13 
     | 
    
         
            +
                def add(severity, message = nil, progname = nil)
         
     | 
| 
       14 
14 
     | 
    
         
             
                  severity ||= UNKNOWN
         
     | 
| 
       15 
     | 
    
         
            -
                  @logdev =  
     | 
| 
      
 15 
     | 
    
         
            +
                  @logdev = logdevice(severity)
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
                  if @logdev.nil? || severity < @level
         
     | 
| 
       18 
18 
     | 
    
         
             
                    return true
         
     | 
| 
         @@ -27,7 +27,8 @@ module Jekyll 
     | 
|
| 
       27 
27 
     | 
    
         
             
                    end
         
     | 
| 
       28 
28 
     | 
    
         
             
                  end
         
     | 
| 
       29 
29 
     | 
    
         
             
                  @logdev.puts(
         
     | 
| 
       30 
     | 
    
         
            -
                    format_message(format_severity(severity), Time.now, progname, message) 
     | 
| 
      
 30 
     | 
    
         
            +
                    format_message(format_severity(severity), Time.now, progname, message)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  )
         
     | 
| 
       31 
32 
     | 
    
         
             
                  true
         
     | 
| 
       32 
33 
     | 
    
         
             
                end
         
     | 
| 
       33 
34 
     | 
    
         | 
| 
         @@ -47,7 +48,7 @@ module Jekyll 
     | 
|
| 
       47 
48 
     | 
    
         | 
| 
       48 
49 
     | 
    
         
             
                private
         
     | 
| 
       49 
50 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
                def  
     | 
| 
      
 51 
     | 
    
         
            +
                def logdevice(severity)
         
     | 
| 
       51 
52 
     | 
    
         
             
                  if severity > INFO
         
     | 
| 
       52 
53 
     | 
    
         
             
                    $stderr
         
     | 
| 
       53 
54 
     | 
    
         
             
                  else
         
     | 
| 
         @@ -8,28 +8,15 @@ module Jekyll 
     | 
|
| 
       8 
8 
     | 
    
         
             
                  # forms: name, name=value, or name="<quoted list>"
         
     | 
| 
       9 
9 
     | 
    
         
             
                  #
         
     | 
| 
       10 
10 
     | 
    
         
             
                  # <quoted list> is a space-separated list of numbers
         
     | 
| 
       11 
     | 
    
         
            -
                  SYNTAX =  
     | 
| 
      
 11 
     | 
    
         
            +
                  SYNTAX = %r!^([a-zA-Z0-9.+#-]+)((\s+\w+(=(\w+|"([0-9]+\s)*[0-9]+"))?)*)$!
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
                  def initialize(tag_name, markup, tokens)
         
     | 
| 
       14 
14 
     | 
    
         
             
                    super
         
     | 
| 
       15 
15 
     | 
    
         
             
                    if markup.strip =~ SYNTAX
         
     | 
| 
       16 
16 
     | 
    
         
             
                      @lang = Regexp.last_match(1).downcase
         
     | 
| 
       17 
     | 
    
         
            -
                      @highlight_options =  
     | 
| 
       18 
     | 
    
         
            -
                      if defined?(Regexp.last_match(2)) && Regexp.last_match(2) != ''
         
     | 
| 
       19 
     | 
    
         
            -
                        # Split along 3 possible forms -- key="<quoted list>", key=value, or key
         
     | 
| 
       20 
     | 
    
         
            -
                        Regexp.last_match(2).scan(/(?:\w="[^"]*"|\w=\w|\w)+/) do |opt|
         
     | 
| 
       21 
     | 
    
         
            -
                          key, value = opt.split('=')
         
     | 
| 
       22 
     | 
    
         
            -
                          # If a quoted list, convert to array
         
     | 
| 
       23 
     | 
    
         
            -
                          if value && value.include?("\"")
         
     | 
| 
       24 
     | 
    
         
            -
                            value.delete!('"')
         
     | 
| 
       25 
     | 
    
         
            -
                              value = value.split
         
     | 
| 
       26 
     | 
    
         
            -
                          end
         
     | 
| 
       27 
     | 
    
         
            -
                          @highlight_options[key.to_sym] = value || true
         
     | 
| 
       28 
     | 
    
         
            -
                        end
         
     | 
| 
       29 
     | 
    
         
            -
                      end
         
     | 
| 
       30 
     | 
    
         
            -
                      @highlight_options[:linenos] = "inline" if @highlight_options.key?(:linenos) && @highlight_options[:linenos] == true
         
     | 
| 
      
 17 
     | 
    
         
            +
                      @highlight_options = parse_options(Regexp.last_match(2))
         
     | 
| 
       31 
18 
     | 
    
         
             
                    else
         
     | 
| 
       32 
     | 
    
         
            -
                      raise SyntaxError 
     | 
| 
      
 19 
     | 
    
         
            +
                      raise SyntaxError, <<-eos
         
     | 
| 
       33 
20 
     | 
    
         
             
            Syntax Error in tag 'highlight' while parsing the following markup:
         
     | 
| 
       34 
21 
     | 
    
         | 
| 
       35 
22 
     | 
    
         
             
              #{markup}
         
     | 
| 
         @@ -42,15 +29,15 @@ eos 
     | 
|
| 
       42 
29 
     | 
    
         
             
                  def render(context)
         
     | 
| 
       43 
30 
     | 
    
         
             
                    prefix = context["highlighter_prefix"] || ""
         
     | 
| 
       44 
31 
     | 
    
         
             
                    suffix = context["highlighter_suffix"] || ""
         
     | 
| 
       45 
     | 
    
         
            -
                    code = super.to_s.gsub( 
     | 
| 
      
 32 
     | 
    
         
            +
                    code = super.to_s.gsub(%r!\A(\n|\r)+|(\n|\r)+\z!, "")
         
     | 
| 
       46 
33 
     | 
    
         | 
| 
       47 
34 
     | 
    
         
             
                    is_safe = !!context.registers[:site].safe
         
     | 
| 
       48 
35 
     | 
    
         | 
| 
       49 
36 
     | 
    
         
             
                    output =
         
     | 
| 
       50 
37 
     | 
    
         
             
                      case context.registers[:site].highlighter
         
     | 
| 
       51 
     | 
    
         
            -
                      when  
     | 
| 
      
 38 
     | 
    
         
            +
                      when "pygments"
         
     | 
| 
       52 
39 
     | 
    
         
             
                        render_pygments(code, is_safe)
         
     | 
| 
       53 
     | 
    
         
            -
                      when  
     | 
| 
      
 40 
     | 
    
         
            +
                      when "rouge"
         
     | 
| 
       54 
41 
     | 
    
         
             
                        render_rouge(code)
         
     | 
| 
       55 
42 
     | 
    
         
             
                      else
         
     | 
| 
       56 
43 
     | 
    
         
             
                        render_codehighlighter(code)
         
     | 
| 
         @@ -66,7 +53,7 @@ eos 
     | 
|
| 
       66 
53 
     | 
    
         
             
                        [:startinline, opts.fetch(:startinline, nil)],
         
     | 
| 
       67 
54 
     | 
    
         
             
                        [:hl_lines,    opts.fetch(:hl_lines, nil)],
         
     | 
| 
       68 
55 
     | 
    
         
             
                        [:linenos,     opts.fetch(:linenos, nil)],
         
     | 
| 
       69 
     | 
    
         
            -
                        [:encoding,    opts.fetch(:encoding,  
     | 
| 
      
 56 
     | 
    
         
            +
                        [:encoding,    opts.fetch(:encoding, "utf-8")],
         
     | 
| 
       70 
57 
     | 
    
         
             
                        [:cssclass,    opts.fetch(:cssclass, nil)]
         
     | 
| 
       71 
58 
     | 
    
         
             
                      ].reject { |f| f.last.nil? }]
         
     | 
| 
       72 
59 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -74,8 +61,30 @@ eos 
     | 
|
| 
       74 
61 
     | 
    
         
             
                    end
         
     | 
| 
       75 
62 
     | 
    
         
             
                  end
         
     | 
| 
       76 
63 
     | 
    
         | 
| 
      
 64 
     | 
    
         
            +
                  private
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                  def parse_options(input)
         
     | 
| 
      
 67 
     | 
    
         
            +
                    options = {}
         
     | 
| 
      
 68 
     | 
    
         
            +
                    unless input.empty?
         
     | 
| 
      
 69 
     | 
    
         
            +
                      # Split along 3 possible forms -- key="<quoted list>", key=value, or key
         
     | 
| 
      
 70 
     | 
    
         
            +
                      input.scan(%r!(?:\w="[^"]*"|\w=\w|\w)+!) do |opt|
         
     | 
| 
      
 71 
     | 
    
         
            +
                        key, value = opt.split("=")
         
     | 
| 
      
 72 
     | 
    
         
            +
                        # If a quoted list, convert to array
         
     | 
| 
      
 73 
     | 
    
         
            +
                        if value && value.include?("\"")
         
     | 
| 
      
 74 
     | 
    
         
            +
                          value.delete!('"')
         
     | 
| 
      
 75 
     | 
    
         
            +
                          value = value.split
         
     | 
| 
      
 76 
     | 
    
         
            +
                        end
         
     | 
| 
      
 77 
     | 
    
         
            +
                        options[key.to_sym] = value || true
         
     | 
| 
      
 78 
     | 
    
         
            +
                      end
         
     | 
| 
      
 79 
     | 
    
         
            +
                    end
         
     | 
| 
      
 80 
     | 
    
         
            +
                    if options.key?(:linenos) && options[:linenos] == true
         
     | 
| 
      
 81 
     | 
    
         
            +
                      options[:linenos] = "inline"
         
     | 
| 
      
 82 
     | 
    
         
            +
                    end
         
     | 
| 
      
 83 
     | 
    
         
            +
                    options
         
     | 
| 
      
 84 
     | 
    
         
            +
                  end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
       77 
86 
     | 
    
         
             
                  def render_pygments(code, is_safe)
         
     | 
| 
       78 
     | 
    
         
            -
                    Jekyll::External.require_with_graceful_fail( 
     | 
| 
      
 87 
     | 
    
         
            +
                    Jekyll::External.require_with_graceful_fail("pygments")
         
     | 
| 
       79 
88 
     | 
    
         | 
| 
       80 
89 
     | 
    
         
             
                    highlighted_code = Pygments.highlight(
         
     | 
| 
       81 
90 
     | 
    
         
             
                      code,
         
     | 
| 
         @@ -84,22 +93,27 @@ eos 
     | 
|
| 
       84 
93 
     | 
    
         
             
                    )
         
     | 
| 
       85 
94 
     | 
    
         | 
| 
       86 
95 
     | 
    
         
             
                    if highlighted_code.nil?
         
     | 
| 
       87 
     | 
    
         
            -
                      Jekyll.logger.error  
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
      
 96 
     | 
    
         
            +
                      Jekyll.logger.error <<eos
         
     | 
| 
      
 97 
     | 
    
         
            +
            There was an error highlighting your code:
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
            #{code}
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
            While attempting to convert the above code, Pygments.rb returned an unacceptable value.
         
     | 
| 
      
 102 
     | 
    
         
            +
            This is usually a timeout problem solved by running `jekyll build` again.
         
     | 
| 
      
 103 
     | 
    
         
            +
            eos
         
     | 
| 
      
 104 
     | 
    
         
            +
                      raise ArgumentError, "Pygments.rb returned an unacceptable value "\
         
     | 
| 
      
 105 
     | 
    
         
            +
                      "when attempting to highlight some code."
         
     | 
| 
       95 
106 
     | 
    
         
             
                    end
         
     | 
| 
       96 
107 
     | 
    
         | 
| 
       97 
     | 
    
         
            -
                    highlighted_code.sub('<div class="highlight"><pre>',  
     | 
| 
      
 108 
     | 
    
         
            +
                    highlighted_code.sub('<div class="highlight"><pre>', "").sub("</pre></div>", "")
         
     | 
| 
       98 
109 
     | 
    
         
             
                  end
         
     | 
| 
       99 
110 
     | 
    
         | 
| 
       100 
111 
     | 
    
         
             
                  def render_rouge(code)
         
     | 
| 
       101 
     | 
    
         
            -
                    Jekyll::External.require_with_graceful_fail( 
     | 
| 
       102 
     | 
    
         
            -
                    formatter = Rouge::Formatters::HTML.new( 
     | 
| 
      
 112 
     | 
    
         
            +
                    Jekyll::External.require_with_graceful_fail("rouge")
         
     | 
| 
      
 113 
     | 
    
         
            +
                    formatter = Rouge::Formatters::HTML.new(
         
     | 
| 
      
 114 
     | 
    
         
            +
                      :line_numbers => @highlight_options[:linenos],
         
     | 
| 
      
 115 
     | 
    
         
            +
                      :wrap         => false
         
     | 
| 
      
 116 
     | 
    
         
            +
                    )
         
     | 
| 
       103 
117 
     | 
    
         
             
                    lexer = Rouge::Lexer.find_fancy(@lang, code) || Rouge::Lexers::PlainText
         
     | 
| 
       104 
118 
     | 
    
         
             
                    formatter.format(lexer.lex(code))
         
     | 
| 
       105 
119 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -110,13 +124,14 @@ eos 
     | 
|
| 
       110 
124 
     | 
    
         | 
| 
       111 
125 
     | 
    
         
             
                  def add_code_tag(code)
         
     | 
| 
       112 
126 
     | 
    
         
             
                    code_attributes = [
         
     | 
| 
       113 
     | 
    
         
            -
                      "class=\"language-#{@lang.to_s.tr( 
     | 
| 
      
 127 
     | 
    
         
            +
                      "class=\"language-#{@lang.to_s.tr("+", "-")}\"",
         
     | 
| 
       114 
128 
     | 
    
         
             
                      "data-lang=\"#{@lang}\""
         
     | 
| 
       115 
129 
     | 
    
         
             
                    ].join(" ")
         
     | 
| 
       116 
     | 
    
         
            -
                    "<figure class=\"highlight\"><pre><code #{code_attributes} 
     | 
| 
      
 130 
     | 
    
         
            +
                    "<figure class=\"highlight\"><pre><code #{code_attributes}>"\
         
     | 
| 
      
 131 
     | 
    
         
            +
                    "#{code.chomp}</code></pre></figure>"
         
     | 
| 
       117 
132 
     | 
    
         
             
                  end
         
     | 
| 
       118 
133 
     | 
    
         
             
                end
         
     | 
| 
       119 
134 
     | 
    
         
             
              end
         
     | 
| 
       120 
135 
     | 
    
         
             
            end
         
     | 
| 
       121 
136 
     | 
    
         | 
| 
       122 
     | 
    
         
            -
            Liquid::Template.register_tag( 
     | 
| 
      
 137 
     | 
    
         
            +
            Liquid::Template.register_tag("highlight", Jekyll::Tags::HighlightBlock)
         
     | 
    
        data/lib/jekyll/tags/include.rb
    CHANGED
    
    | 
         @@ -12,17 +12,23 @@ module Jekyll 
     | 
|
| 
       12 
12 
     | 
    
         
             
                end
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
                class IncludeTag < Liquid::Tag
         
     | 
| 
       15 
     | 
    
         
            -
                  VALID_SYNTAX =  
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
                  VALID_SYNTAX = %r!
         
     | 
| 
      
 16 
     | 
    
         
            +
                    ([\w-]+)\s*=\s*
         
     | 
| 
      
 17 
     | 
    
         
            +
                    (?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w\.-]+))
         
     | 
| 
      
 18 
     | 
    
         
            +
                  !x
         
     | 
| 
      
 19 
     | 
    
         
            +
                  VARIABLE_SYNTAX = %r!
         
     | 
| 
      
 20 
     | 
    
         
            +
                    (?<variable>[^{]*(\{\{\s*[\w\-\.]+\s*(\|.*)?\}\}[^\s{}]*)+)
         
     | 
| 
      
 21 
     | 
    
         
            +
                    (?<params>.*)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  !x
         
     | 
| 
       17 
23 
     | 
    
         | 
| 
       18 
24 
     | 
    
         
             
                  def initialize(tag_name, markup, tokens)
         
     | 
| 
       19 
25 
     | 
    
         
             
                    super
         
     | 
| 
       20 
26 
     | 
    
         
             
                    matched = markup.strip.match(VARIABLE_SYNTAX)
         
     | 
| 
       21 
27 
     | 
    
         
             
                    if matched
         
     | 
| 
       22 
     | 
    
         
            -
                      @file = matched[ 
     | 
| 
       23 
     | 
    
         
            -
                      @params = matched[ 
     | 
| 
      
 28 
     | 
    
         
            +
                      @file = matched["variable"].strip
         
     | 
| 
      
 29 
     | 
    
         
            +
                      @params = matched["params"].strip
         
     | 
| 
       24 
30 
     | 
    
         
             
                    else
         
     | 
| 
       25 
     | 
    
         
            -
                      @file, @params = markup.strip.split( 
     | 
| 
      
 31 
     | 
    
         
            +
                      @file, @params = markup.strip.split(%r!\s+!, 2)
         
     | 
| 
       26 
32 
     | 
    
         
             
                    end
         
     | 
| 
       27 
33 
     | 
    
         
             
                    validate_params if @params
         
     | 
| 
       28 
34 
     | 
    
         
             
                    @tag_name = tag_name
         
     | 
| 
         @@ -36,13 +42,13 @@ module Jekyll 
     | 
|
| 
       36 
42 
     | 
    
         
             
                    params = {}
         
     | 
| 
       37 
43 
     | 
    
         
             
                    markup = @params
         
     | 
| 
       38 
44 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
                    while match = VALID_SYNTAX.match(markup) 
     | 
| 
      
 45 
     | 
    
         
            +
                    while (match = VALID_SYNTAX.match(markup))
         
     | 
| 
       40 
46 
     | 
    
         
             
                      markup = markup[match.end(0)..-1]
         
     | 
| 
       41 
47 
     | 
    
         | 
| 
       42 
48 
     | 
    
         
             
                      value = if match[2]
         
     | 
| 
       43 
     | 
    
         
            -
                                match[2].gsub( 
     | 
| 
      
 49 
     | 
    
         
            +
                                match[2].gsub(%r!\\"!, '"')
         
     | 
| 
       44 
50 
     | 
    
         
             
                              elsif match[3]
         
     | 
| 
       45 
     | 
    
         
            -
                                match[3].gsub( 
     | 
| 
      
 51 
     | 
    
         
            +
                                match[3].gsub(%r!\\'!, "'")
         
     | 
| 
       46 
52 
     | 
    
         
             
                              elsif match[4]
         
     | 
| 
       47 
53 
     | 
    
         
             
                                context[match[4]]
         
     | 
| 
       48 
54 
     | 
    
         
             
                              end
         
     | 
| 
         @@ -53,8 +59,8 @@ module Jekyll 
     | 
|
| 
       53 
59 
     | 
    
         
             
                  end
         
     | 
| 
       54 
60 
     | 
    
         | 
| 
       55 
61 
     | 
    
         
             
                  def validate_file_name(file)
         
     | 
| 
       56 
     | 
    
         
            -
                    if file !~  
     | 
| 
       57 
     | 
    
         
            -
                      raise ArgumentError 
     | 
| 
      
 62 
     | 
    
         
            +
                    if file !~ %r!^[a-zA-Z0-9_/\.-]+$! || file =~ %r!\./! || file =~ %r!/\.!
         
     | 
| 
      
 63 
     | 
    
         
            +
                      raise ArgumentError, <<-eos
         
     | 
| 
       58 
64 
     | 
    
         
             
            Invalid syntax for include tag. File contains invalid characters or sequences:
         
     | 
| 
       59 
65 
     | 
    
         | 
| 
       60 
66 
     | 
    
         
             
              #{file}
         
     | 
| 
         @@ -68,9 +74,9 @@ eos 
     | 
|
| 
       68 
74 
     | 
    
         
             
                  end
         
     | 
| 
       69 
75 
     | 
    
         | 
| 
       70 
76 
     | 
    
         
             
                  def validate_params
         
     | 
| 
       71 
     | 
    
         
            -
                    full_valid_syntax =  
     | 
| 
      
 77 
     | 
    
         
            +
                    full_valid_syntax = %r!\A\s*(?:#{VALID_SYNTAX}(?=\s|\z)\s*)*\z!
         
     | 
| 
       72 
78 
     | 
    
         
             
                    unless @params =~ full_valid_syntax
         
     | 
| 
       73 
     | 
    
         
            -
                      raise ArgumentError 
     | 
| 
      
 79 
     | 
    
         
            +
                      raise ArgumentError, <<-eos
         
     | 
| 
       74 
80 
     | 
    
         
             
            Invalid syntax for include tag:
         
     | 
| 
       75 
81 
     | 
    
         | 
| 
       76 
82 
     | 
    
         
             
              #{@params}
         
     | 
| 
         @@ -91,7 +97,10 @@ eos 
     | 
|
| 
       91 
97 
     | 
    
         
             
                  # Render the variable if required
         
     | 
| 
       92 
98 
     | 
    
         
             
                  def render_variable(context)
         
     | 
| 
       93 
99 
     | 
    
         
             
                    if @file.match(VARIABLE_SYNTAX)
         
     | 
| 
       94 
     | 
    
         
            -
                      partial = context.registers[:site] 
     | 
| 
      
 100 
     | 
    
         
            +
                      partial = context.registers[:site]
         
     | 
| 
      
 101 
     | 
    
         
            +
                        .liquid_renderer
         
     | 
| 
      
 102 
     | 
    
         
            +
                        .file("(variable)")
         
     | 
| 
      
 103 
     | 
    
         
            +
                        .parse(@file)
         
     | 
| 
       95 
104 
     | 
    
         
             
                      partial.render!(context)
         
     | 
| 
       96 
105 
     | 
    
         
             
                    end
         
     | 
| 
       97 
106 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -106,9 +115,9 @@ eos 
     | 
|
| 
       106 
115 
     | 
    
         
             
                      path = File.join(dir, file)
         
     | 
| 
       107 
116 
     | 
    
         
             
                      return path if valid_include_file?(path, dir, safe)
         
     | 
| 
       108 
117 
     | 
    
         
             
                    end
         
     | 
| 
       109 
     | 
    
         
            -
                    raise IOError, "Could not locate the included file '#{file}' in any of  
     | 
| 
       110 
     | 
    
         
            -
                      " Ensure it exists in one of those directories and,  
     | 
| 
       111 
     | 
    
         
            -
                      "does not point outside your site source."
         
     | 
| 
      
 118 
     | 
    
         
            +
                    raise IOError, "Could not locate the included file '#{file}' in any of "\
         
     | 
| 
      
 119 
     | 
    
         
            +
                      "#{includes_dirs}. Ensure it exists in one of those directories and, "\
         
     | 
| 
      
 120 
     | 
    
         
            +
                      "if it is a symlink, does not point outside your site source."
         
     | 
| 
       112 
121 
     | 
    
         
             
                  end
         
     | 
| 
       113 
122 
     | 
    
         | 
| 
       114 
123 
     | 
    
         
             
                  def render(context)
         
     | 
| 
         @@ -120,24 +129,23 @@ eos 
     | 
|
| 
       120 
129 
     | 
    
         
             
                    path = locate_include_file(context, file, site.safe)
         
     | 
| 
       121 
130 
     | 
    
         
             
                    return unless path
         
     | 
| 
       122 
131 
     | 
    
         | 
| 
       123 
     | 
    
         
            -
                     
     | 
| 
      
 132 
     | 
    
         
            +
                    add_include_to_dependency(site, path, context)
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
                    partial = load_cached_partial(path, context)
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
      
 136 
     | 
    
         
            +
                    context.stack do
         
     | 
| 
      
 137 
     | 
    
         
            +
                      context["include"] = parse_params(context) if @params
         
     | 
| 
      
 138 
     | 
    
         
            +
                      partial.render!(context)
         
     | 
| 
      
 139 
     | 
    
         
            +
                    end
         
     | 
| 
      
 140 
     | 
    
         
            +
                  end
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
                  def add_include_to_dependency(site, path, context)
         
     | 
| 
       124 
143 
     | 
    
         
             
                    if context.registers[:page] && context.registers[:page].key?("path")
         
     | 
| 
       125 
144 
     | 
    
         
             
                      site.regenerator.add_dependency(
         
     | 
| 
       126 
145 
     | 
    
         
             
                        site.in_source_dir(context.registers[:page]["path"]),
         
     | 
| 
       127 
146 
     | 
    
         
             
                        path
         
     | 
| 
       128 
147 
     | 
    
         
             
                      )
         
     | 
| 
       129 
148 
     | 
    
         
             
                    end
         
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
                    #begin
         
     | 
| 
       132 
     | 
    
         
            -
                      partial = load_cached_partial(path, context)
         
     | 
| 
       133 
     | 
    
         
            -
             
     | 
| 
       134 
     | 
    
         
            -
                      context.stack do
         
     | 
| 
       135 
     | 
    
         
            -
                        context['include'] = parse_params(context) if @params
         
     | 
| 
       136 
     | 
    
         
            -
                        partial.render!(context)
         
     | 
| 
       137 
     | 
    
         
            -
                      end
         
     | 
| 
       138 
     | 
    
         
            -
                      #rescue => e
         
     | 
| 
       139 
     | 
    
         
            -
                      #raise IncludeTagError.new e.message, path
         
     | 
| 
       140 
     | 
    
         
            -
                      #end
         
     | 
| 
       141 
149 
     | 
    
         
             
                  end
         
     | 
| 
       142 
150 
     | 
    
         | 
| 
       143 
151 
     | 
    
         
             
                  def load_cached_partial(path, context)
         
     | 
| 
         @@ -147,7 +155,10 @@ eos 
     | 
|
| 
       147 
155 
     | 
    
         
             
                    if cached_partial.key?(path)
         
     | 
| 
       148 
156 
     | 
    
         
             
                      cached_partial[path]
         
     | 
| 
       149 
157 
     | 
    
         
             
                    else
         
     | 
| 
       150 
     | 
    
         
            -
                      cached_partial[path] = context.registers[:site] 
     | 
| 
      
 158 
     | 
    
         
            +
                      cached_partial[path] = context.registers[:site]
         
     | 
| 
      
 159 
     | 
    
         
            +
                        .liquid_renderer
         
     | 
| 
      
 160 
     | 
    
         
            +
                        .file(path)
         
     | 
| 
      
 161 
     | 
    
         
            +
                        .parse(read_file(path, context))
         
     | 
| 
       151 
162 
     | 
    
         
             
                    end
         
     | 
| 
       152 
163 
     | 
    
         
             
                  end
         
     | 
| 
       153 
164 
     | 
    
         | 
| 
         @@ -188,5 +199,5 @@ eos 
     | 
|
| 
       188 
199 
     | 
    
         
             
              end
         
     | 
| 
       189 
200 
     | 
    
         
             
            end
         
     | 
| 
       190 
201 
     | 
    
         | 
| 
       191 
     | 
    
         
            -
            Liquid::Template.register_tag( 
     | 
| 
       192 
     | 
    
         
            -
            Liquid::Template.register_tag( 
     | 
| 
      
 202 
     | 
    
         
            +
            Liquid::Template.register_tag("include", Jekyll::Tags::IncludeTag)
         
     | 
| 
      
 203 
     | 
    
         
            +
            Liquid::Template.register_tag("include_relative", Jekyll::Tags::IncludeRelativeTag)
         
     |