jekyll-haml-markup 0.1.0 → 0.1.6

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.
@@ -1,80 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- jekyll-haml-markup (0.1.0)
5
- haml (~> 5.0)
6
- jekyll (~> 3.7)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- addressable (2.5.2)
12
- public_suffix (>= 2.0.2, < 4.0)
13
- colorator (1.1.0)
14
- concurrent-ruby (1.0.5)
15
- em-websocket (0.5.1)
16
- eventmachine (>= 0.12.9)
17
- http_parser.rb (~> 0.6.0)
18
- eventmachine (1.2.5)
19
- ffi (1.9.18)
20
- forwardable-extended (2.6.0)
21
- haml (5.0.4)
22
- temple (>= 0.8.0)
23
- tilt
24
- http_parser.rb (0.6.0)
25
- i18n (0.9.3)
26
- concurrent-ruby (~> 1.0)
27
- jekyll (3.7.2)
28
- addressable (~> 2.4)
29
- colorator (~> 1.0)
30
- em-websocket (~> 0.5)
31
- i18n (~> 0.7)
32
- jekyll-sass-converter (~> 1.0)
33
- jekyll-watch (~> 2.0)
34
- kramdown (~> 1.14)
35
- liquid (~> 4.0)
36
- mercenary (~> 0.3.3)
37
- pathutil (~> 0.9)
38
- rouge (>= 1.7, < 4)
39
- safe_yaml (~> 1.0)
40
- jekyll-sass-converter (1.5.1)
41
- sass (~> 3.4)
42
- jekyll-watch (2.0.0)
43
- listen (~> 3.0)
44
- kramdown (1.16.2)
45
- liquid (4.0.0)
46
- listen (3.1.5)
47
- rb-fsevent (~> 0.9, >= 0.9.4)
48
- rb-inotify (~> 0.9, >= 0.9.7)
49
- ruby_dep (~> 1.2)
50
- mercenary (0.3.6)
51
- minitest (5.11.3)
52
- pathutil (0.16.1)
53
- forwardable-extended (~> 2.6)
54
- public_suffix (3.0.1)
55
- rake (10.5.0)
56
- rb-fsevent (0.10.2)
57
- rb-inotify (0.9.10)
58
- ffi (>= 0.5.0, < 2)
59
- rouge (3.1.0)
60
- ruby_dep (1.5.0)
61
- safe_yaml (1.0.4)
62
- sass (3.5.5)
63
- sass-listen (~> 4.0.0)
64
- sass-listen (4.0.0)
65
- rb-fsevent (~> 0.9, >= 0.9.4)
66
- rb-inotify (~> 0.9, >= 0.9.7)
67
- temple (0.8.0)
68
- tilt (2.0.8)
69
-
70
- PLATFORMS
71
- ruby
72
-
73
- DEPENDENCIES
74
- bundler (~> 1.16)
75
- jekyll-haml-markup!
76
- minitest (~> 5.0)
77
- rake (~> 10.0)
78
-
79
- BUNDLED WITH
80
- 1.16.1
@@ -1,92 +0,0 @@
1
- require 'jekyll/configuration'
2
- # frozen_string_literal: true
3
-
4
- module Jekyll
5
- class Configuration < Hash
6
- # Default options. Overridden by values in _config.yml.
7
- # Strings rather than symbols are used for compatibility with YAML.
8
- DEFAULTS = Configuration[{
9
- 'haml_ext' => 'haml',
10
- 'haml' => 'lib-haml',
11
- 'lib-haml' => {},
12
-
13
- # Where things are
14
- "source" => Dir.pwd,
15
- "destination" => File.join(Dir.pwd, "_site"),
16
- "collections_dir" => "",
17
- "plugins_dir" => "_plugins",
18
- "layouts_dir" => "_layouts",
19
- "data_dir" => "_data",
20
- "includes_dir" => "_includes",
21
- "collections" => {},
22
-
23
- # Handling Reading
24
- "safe" => false,
25
- "include" => [".htaccess"],
26
- "exclude" => %w(
27
- Gemfile Gemfile.lock node_modules vendor/bundle/ vendor/cache/ vendor/gems/
28
- vendor/ruby/
29
- ),
30
- "keep_files" => [".git", ".svn"],
31
- "encoding" => "utf-8",
32
- "markdown_ext" => "markdown,mkdown,mkdn,mkd,md",
33
- "strict_front_matter" => false,
34
-
35
- # Filtering Content
36
- "show_drafts" => nil,
37
- "limit_posts" => 0,
38
- "future" => false,
39
- "unpublished" => false,
40
-
41
- # Plugins
42
- "whitelist" => [],
43
- "plugins" => [],
44
-
45
- # Conversion
46
- "markdown" => "kramdown",
47
- "highlighter" => "rouge",
48
- "lsi" => false,
49
- "excerpt_separator" => "\n\n",
50
- "incremental" => false,
51
-
52
- # Serving
53
- "detach" => false, # default to not detaching the server
54
- "port" => "4000",
55
- "host" => "127.0.0.1",
56
- "baseurl" => nil, # this mounts at /, i.e. no subdirectory
57
- "show_dir_listing" => false,
58
-
59
- # Output Configuration
60
- "permalink" => "date",
61
- "paginate_path" => "/page:num",
62
- "timezone" => nil, # use the local timezone
63
-
64
- "quiet" => false,
65
- "verbose" => false,
66
- "defaults" => [],
67
-
68
- "liquid" => {
69
- "error_mode" => "warn",
70
- },
71
-
72
- "rdiscount" => {
73
- "extensions" => [],
74
- },
75
-
76
- "redcarpet" => {
77
- "extensions" => [],
78
- },
79
-
80
- "kramdown" => {
81
- "auto_ids" => true,
82
- "toc_levels" => "1..6",
83
- "entity_output" => "as_char",
84
- "smart_quotes" => "lsquo,rsquo,ldquo,rdquo",
85
- "input" => "GFM",
86
- "hard_wrap" => false,
87
- "footnote_nr" => 1,
88
- "show_warnings" => false,
89
- },
90
- }.map { |k, v| [k, v.freeze] }].freeze
91
- end
92
- end
@@ -1,34 +0,0 @@
1
- require 'jekyll/converter'
2
- require 'jekyll/haml/parser'
3
-
4
- module Jekyll
5
- module Converters
6
- class Haml < Identity
7
- safe true
8
-
9
- def extname_list
10
- @extname_list ||= @config["haml_ext"].split(",").map do |e|
11
- ".#{e.downcase}"
12
- end
13
- end
14
-
15
- def matches(ext)
16
- extname_list.include?(ext.downcase)
17
- end
18
-
19
- def output_ext(ext)
20
- '.html'
21
- end
22
-
23
- def get_processor
24
- case @config["haml"].downcase
25
- when "lib-haml" then return Jekyll::Haml::Parser.new(@config)
26
- end
27
- end
28
-
29
- def convert(content)
30
- get_processor.convert content
31
- end
32
- end
33
- end
34
- end
@@ -1,15 +0,0 @@
1
- require 'jekyll/convertible'
2
-
3
- module Jekyll
4
- module Convertible
5
-
6
- def haml_file?
7
- %w(.haml).include?(ext)
8
- end
9
-
10
- def render_with_haml?
11
- haml_file?
12
- end
13
-
14
- end
15
- end
@@ -1,9 +0,0 @@
1
- require 'jekyll/excerpt'
2
-
3
- module Jekyll
4
- class Excerpt
5
-
6
- def_delegators :render_with_haml?
7
-
8
- end
9
- end
@@ -1,11 +0,0 @@
1
- require "jekyll/haml/version"
2
-
3
- require_relative 'converters/haml'
4
- require_relative 'haml/parser'
5
- require_relative 'tags/include'
6
- require_relative 'configuration'
7
- require_relative 'convertible'
8
- require_relative 'excerpt'
9
- require_relative 'haml_renderer'
10
- require_relative 'renderer'
11
- require_relative 'site'
@@ -1,225 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Jekyll
4
- module Tags
5
- class IncludeTagError < StandardError
6
- attr_accessor :path
7
-
8
- def initialize(msg, path)
9
- super(msg)
10
- @path = path
11
- end
12
- end
13
-
14
- class IncludeTag < Liquid::Tag
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
23
-
24
- def initialize(tag_name, markup, tokens)
25
- super
26
- matched = markup.strip.match(VARIABLE_SYNTAX)
27
- if matched
28
- @file = matched["variable"].strip
29
- @params = matched["params"].strip
30
- else
31
- @file, @params = markup.strip.split(%r!\s+!, 2)
32
- end
33
- validate_params if @params
34
- @tag_name = tag_name
35
- end
36
-
37
- def syntax_example
38
- "{% #{@tag_name} file.ext param='value' param2='value' %}"
39
- end
40
-
41
- def parse_params(context)
42
- params = {}
43
- markup = @params
44
-
45
- while (match = VALID_SYNTAX.match(markup))
46
- markup = markup[match.end(0)..-1]
47
-
48
- value = if match[2]
49
- match[2].gsub(%r!\\"!, '"')
50
- elsif match[3]
51
- match[3].gsub(%r!\\'!, "'")
52
- elsif match[4]
53
- context[match[4]]
54
- end
55
-
56
- params[match[1]] = value
57
- end
58
- params
59
- end
60
-
61
- def validate_file_name(file)
62
- if file !~ %r!^[a-zA-Z0-9_/\.-]+$! || file =~ %r!\./! || file =~ %r!/\.!
63
- raise ArgumentError, <<-MSG
64
- Invalid syntax for include tag. File contains invalid characters or sequences:
65
-
66
- #{file}
67
-
68
- Valid syntax:
69
-
70
- #{syntax_example}
71
-
72
- MSG
73
- end
74
- end
75
-
76
- def validate_params
77
- full_valid_syntax = %r!\A\s*(?:#{VALID_SYNTAX}(?=\s|\z)\s*)*\z!
78
- unless @params =~ full_valid_syntax
79
- raise ArgumentError, <<-MSG
80
- Invalid syntax for include tag:
81
-
82
- #{@params}
83
-
84
- Valid syntax:
85
-
86
- #{syntax_example}
87
-
88
- MSG
89
- end
90
- end
91
-
92
- # Grab file read opts in the context
93
- def file_read_opts(context)
94
- context.registers[:site].file_read_opts
95
- end
96
-
97
- # Render the variable if required
98
- def render_variable(context)
99
- if @file.match(VARIABLE_SYNTAX)
100
- partial = context.registers[:site]
101
- .liquid_renderer
102
- .file("(variable)")
103
- .parse(@file)
104
- partial.render!(context)
105
- end
106
- end
107
-
108
- def tag_includes_dirs(context)
109
- context.registers[:site].includes_load_paths.freeze
110
- end
111
-
112
- def locate_include_file(context, file, safe)
113
- includes_dirs = tag_includes_dirs(context)
114
- includes_dirs.each do |dir|
115
- path = File.join(dir.to_s, file.to_s)
116
- return path if valid_include_file?(path, dir.to_s, safe)
117
- end
118
- raise IOError, could_not_locate_message(file, includes_dirs, safe)
119
- end
120
-
121
- def render(context)
122
- site = context.registers[:site]
123
-
124
- file = render_variable(context) || @file
125
- validate_file_name(file)
126
-
127
- path = locate_include_file(context, file, site.safe)
128
- return unless path
129
-
130
- add_include_to_dependency(site, path, context)
131
-
132
- partial = load_cached_partial(path, context)
133
-
134
- context.stack do
135
- context["include"] = parse_params(context) if @params
136
- begin
137
- partial.render!(context)
138
- rescue Liquid::Error => e
139
- e.template_name = path
140
- e.markup_context = "included " if e.markup_context.nil?
141
- raise e
142
- end
143
- end
144
- end
145
-
146
- def add_include_to_dependency(site, path, context)
147
- if context.registers[:page] && context.registers[:page].key?("path")
148
- site.regenerator.add_dependency(
149
- site.in_source_dir(context.registers[:page]["path"]),
150
- path
151
- )
152
- end
153
- end
154
-
155
- def load_cached_partial(path, context)
156
- context.registers[:cached_partials] ||= {}
157
- cached_partial = context.registers[:cached_partials]
158
-
159
- if cached_partial.key?(path)
160
- cached_partial[path]
161
- else
162
- unparsed_file = context.registers[:site]
163
- .liquid_renderer
164
- .file(path)
165
- begin
166
- cached_partial[path] = unparsed_file.parse(read_file(path, context))
167
- rescue Liquid::Error => e
168
- e.template_name = path
169
- e.markup_context = "included " if e.markup_context.nil?
170
- raise e
171
- end
172
- end
173
- end
174
-
175
- def valid_include_file?(path, dir, safe)
176
- !outside_site_source?(path, dir, safe) && File.file?(path)
177
- end
178
-
179
- def outside_site_source?(path, dir, safe)
180
- safe && !realpath_prefixed_with?(path, dir)
181
- end
182
-
183
- def realpath_prefixed_with?(path, dir)
184
- File.exist?(path) && File.realpath(path).start_with?(dir)
185
- rescue StandardError
186
- false
187
- end
188
-
189
- # This method allows to modify the file content by inheriting from the class.
190
- def read_file(file, context)
191
- File.read(file, file_read_opts(context))
192
- end
193
-
194
- private
195
-
196
- def could_not_locate_message(file, includes_dirs, safe)
197
- message = "Could not locate the included file '#{file}' in any of "\
198
- "#{includes_dirs}. Ensure it exists in one of those directories and"
199
- message + if safe
200
- " is not a symlink as those are not allowed in safe mode."
201
- else
202
- ", if it is a symlink, does not point outside your site source."
203
- end
204
- end
205
- end
206
-
207
- class IncludeRelativeTag < IncludeTag
208
- def tag_includes_dirs(context)
209
- Array(page_path(context)).freeze
210
- end
211
-
212
- def page_path(context)
213
- if context.registers[:page].nil?
214
- context.registers[:site].source
215
- else
216
- current_doc_dir = File.dirname(context.registers[:page]["path"])
217
- context.registers[:site].in_source_dir current_doc_dir
218
- end
219
- end
220
- end
221
- end
222
- end
223
-
224
- Liquid::Template.register_tag("include", Jekyll::Tags::IncludeTag)
225
- Liquid::Template.register_tag("include_relative", Jekyll::Tags::IncludeRelativeTag)