premonition 2.0.1 → 4.0.0.pre1

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: 2aaae4cd98bc03518dfe2ff814d0686aab58f5b0370f8bb3f4d3b19eef303007
4
- data.tar.gz: 28c1d9e93692de8c29affe8982accb19327e4d7fcdb32186f4d00679f8a38964
3
+ metadata.gz: 5790ecdffbb5137fc1deacc1e29077cc574a2c05c60988f2a41b8eca8e160765
4
+ data.tar.gz: e9c80f5a325c183790978ad6d81d48713946935b0ad14396cb28f55ffd8dcd99
5
5
  SHA512:
6
- metadata.gz: 647c3f5c4b253c9f13d447fdcb25e5aa83aba2ff215eb241c63d3cb1103bf26560b967697a6831f95be030691940cf2c4e599cb87f35a050766e5bb5199c87b7
7
- data.tar.gz: 97837e09726a349eaf4817ebe4acb0cbd60042ca8d663c02b737f170fd5759ada261433da5f7b9691cf312aff8a73a9de4df0b2b6200c5c2820b4c39c9b43012
6
+ metadata.gz: c6ab0056c0d15c2e2a0a05af51a9291871f62694a733ed1d10dce35d801ca9ce395f3a9eaafd0261284b2d371d884750671ab8b8b4eebe47f64203f6531ef576
7
+ data.tar.gz: 00b78b8282be668dde7abd6328493a6e267ed8321f209a03675e02586f26df95a56df7752b777c0e2c0fc341f025958a01ea4f7b35813dddabc299921ea94aa8
data/README.md CHANGED
@@ -1,11 +1,10 @@
1
1
  # Premonition
2
2
 
3
- **DEMO: https://lazee.github.io/premonition-demo/ ([Source code](https://github.com/lazee/premonition-demo))**
3
+ [Demo site](https://lazee.github.io/premonition-demo/) | [Source code](https://github.com/lazee/premonition-demo)
4
4
 
5
- Premonition is a [Jekyll](https://jekyllrb.com/) extension that makes it possible to add block-styled content to your site in plain Markdown.
5
+ Premonition is a [Jekyll](https://jekyllrb.com/) extension that can convert Markdown block-quotes into beautiful block styled content.
6
6
 
7
- By adding a special header to the first line of a [block quote](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#blockquotes),
8
- Premonition will transform it into a markup block of your choice.
7
+ By simply adding a special header to the first line of a [block quote](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#blockquotes), Premonition will transform it into a markup block of your choice.
9
8
 
10
9
  <p align="center">
11
10
  <img src="https://github.com/lazee/premonition/raw/master/screen.png" height="450"/>
@@ -14,15 +13,26 @@ Premonition will transform it into a markup block of your choice.
14
13
  ## Features
15
14
 
16
15
  * Highly customizable (Create your own styles and templates easily)
17
- * Non-intrusive - Content are presented as block-quotes by any other renderer.
16
+ * Non-intrusive - Its just Markdown!
18
17
  * Easy to install
19
- * Comes with a stylesheet (Sass/Css) and templates for rendering typical information boxes.
20
- * Support for both Kramdown and RedCarpet.
18
+ * Comes with a stylesheet (Sass/Css) and templates for rendering the most common boxes.
19
+
20
+ ## Version 4 highlights
21
+
22
+ * Added Jekyll Excerpts support
23
+ * Kramdown reference links now supported
24
+ * Jekyll 4 support
25
+ * Added support for block attributes. This is in use in the new citation
26
+ block type:
27
+
28
+ `> citation "-- jakob" [ cite = "jvn" ]`
29
+ * Other minor bug fixes
30
+
21
31
 
22
32
  ## Requirements
23
33
 
24
34
  * Jekyll 3.7.x or higher
25
- * FontAwesome 4.x (If you are using the default template and styles)
35
+ * FontAwesome 5.x
26
36
 
27
37
  ## Installation
28
38
 
@@ -30,7 +40,7 @@ Add the following line to your `Gemfile`:
30
40
 
31
41
  ```
32
42
  group :jekyll_plugins do
33
- gem "premonition", "~> 2.0.0"
43
+ gem "premonition", "~> 4.0.0"
34
44
  end
35
45
  ```
36
46
 
@@ -78,7 +88,7 @@ Example:
78
88
  Premonition will then convert this into something like:
79
89
 
80
90
  ~~~html
81
- <div class="premonition info"><div class="fa fa-check-square"></div><div class="content"><p class="header">Info</p><p>The body of the warning goes here. Premonition also allow you to write Markdown inside the block.</p></div></div>
91
+ <div class="premonition info"><i class="fas fa-check-square"></i><div class="content"><p class="header">Info</p><p>The body of the warning goes here. Premonition also allow you to write Markdown inside the block.</p></div></div>
82
92
  ~~~
83
93
 
84
94
  You can change the markup into anything you like by adding your own template.
@@ -126,7 +136,7 @@ If you want to override the template for one of the default types (like note), d
126
136
  ```yaml
127
137
  premonition:
128
138
  types:
129
- - id: note
139
+ note:
130
140
  template: 'Liquid template goes here'
131
141
  ```
132
142
 
@@ -146,10 +156,10 @@ Each type must have unique id (lowercase letters).
146
156
  ~~~yaml
147
157
  premonition:
148
158
  types:
149
- - id: custombox
159
+ custombox:
150
160
  meta:
151
161
  fa-icon: fa-exclamation-circle
152
- - id: advanced
162
+ advanced:
153
163
  template: 'Liquid template goes here'
154
164
  default_title: 'MY BLOCK'
155
165
  meta:
@@ -164,11 +174,16 @@ as a Sass file or as plain css. The [Jekyll Documentation](https://jekyllrb.com/
164
174
  Download the stylesheet from here : https://github.com/lazee/premonition/tree/master/stylesheet
165
175
 
166
176
  In order to get the fancy icons, you will have to add [Font Awesome](https://fontawesome.com/) to your html header file.
167
- Be aware that you have to use v4.x of Font Awesome together with our CSS.
177
+ Be aware that you have to use v5.x of Font Awesome together with our CSS.
168
178
 
169
179
  The easiest way to get startet with Font Awesome is to add this to your html header file:
170
180
 
171
181
  ~~~html
172
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"/>
182
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.12.1/css/all.css">
173
183
  ~~~~
174
184
 
185
+ If you need backward compability with v4:
186
+
187
+ ~~~html
188
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.12.1/css/v4-shims.css">
189
+ ~~~
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'strscan'
4
+
5
+ module Jekyll
6
+ module Premonition
7
+ module Attributes
8
+ # Public: Custom error for Premonition attributes parser errors.
9
+ class ParserError < StandardError
10
+ # Initialize a new ParserError
11
+ #
12
+ # msg - The error message
13
+ # raw - The raw string send to the parser initially.
14
+ # Used for syntax error output. If nil syntax
15
+ # error output is skipped.
16
+ # pos - The buffer position when error was raised.
17
+ # Used in both error message and syntax error output
18
+ # if raw attribute is set.
19
+ def initialize(msg, raw = nil, pos = 0)
20
+ if raw.nil?
21
+ super(msg)
22
+ else
23
+ super("#{msg} [#{pos}:#{raw.length}]")
24
+ print "Attribute syntax error:\n #{raw}\n"
25
+ pos.times { print ' ' }
26
+ print "^\n"
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,169 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'strscan'
4
+
5
+ module Jekyll
6
+ module Premonition
7
+ module Attributes
8
+ # Public: Premonition block attributes parser.
9
+ #
10
+ # Parses attributes found in block headers like this:
11
+ # > "info" [ foo = abcd, bar = "zot", size = 3 ]
12
+ #
13
+ # The parser itself utilizes the StringScanner in ruby.
14
+ # Each character will be parsed, validated and pushed
15
+ # to a stack (array) according to the rules inside the
16
+ # parser itself.
17
+ #
18
+ # A stack object will be of a certain type:
19
+ #
20
+ # 0 : Outside an attributes block
21
+ # 1 : Inside an attributes block, but between keys or values
22
+ # 2 : Parsing an attribute key
23
+ # 3: Parsing an attribute value
24
+ #
25
+ # Upon parser errors a pretty syntax error will be printed to
26
+ # stdout, showing where the error is.
27
+ class Parser
28
+ # Get parsed attributes as a Hash
29
+ attr_reader :attributes
30
+
31
+ # Initialize a new Parser AND start parsing
32
+ #
33
+ # str - A string containing the attributes block to be parser.
34
+ def initialize(str)
35
+ @raw = str # Keeps th original string for later use
36
+ @buffer = StringScanner.new(str) # Create StringScanner buffer
37
+ @attributes = {} # Initialize the attributes hash
38
+ @stack = [Stacker.new(0)] # Initialize the parser stack with initial "state"
39
+ parse # Start parsing
40
+ end
41
+
42
+ private
43
+
44
+ def parse
45
+ raise error('No attributes block found in given string') unless @raw.match(/^.*\[.*\].*/)
46
+
47
+ until @buffer.eos?
48
+ char = @buffer.getch
49
+
50
+ case @stack.last.type
51
+ when 0 # Outside block mode
52
+ push_stacker(1) if char == '['
53
+ when 1 # In between
54
+ parse_in_between(char)
55
+ when 2 # Key
56
+ parse_key(char)
57
+ when 3 # Value
58
+ parse_value(char)
59
+ end
60
+ end
61
+ end
62
+
63
+ def parse_in_between(char)
64
+ return if char == ' ' # Ignoring all spaces before, between and after keys and values.
65
+
66
+ if char == ']'
67
+ pop_attribute_from_stack
68
+ push_stacker(4)
69
+ elsif char == ','
70
+ raise error("Attribute separator ',' not allowed here.") if @attributes.length.zero?
71
+ push_stacker(2)
72
+ elsif char.match(/^[a-zA-z0-9\-_]$/)
73
+ push_stacker(2)
74
+ append_char(char)
75
+ else
76
+ raise error("Illegal character '#{char}' outside key and value")
77
+ end
78
+ end
79
+
80
+ def parse_key(char)
81
+ if char == '='
82
+ push_stacker(3)
83
+ value_mode('plain')
84
+ elsif char.match(/^[a-zA-z0-9\-_]$/)
85
+ append_char(char)
86
+ elsif char == ' '
87
+ m = @buffer.scan(/\s*\=\s*/)
88
+ raise error('Space not allowed inside attribute key') if m.nil?
89
+ push_stacker(3)
90
+ value_mode('plain')
91
+ else
92
+ raise error("Illegal character '#{char}' for attribute key")
93
+ end
94
+ end
95
+
96
+ def parse_value(char)
97
+ case char
98
+ when ']'
99
+ if plain_mode?
100
+ pop_attribute_from_stack
101
+ push_stacker(4)
102
+ end
103
+ when '"'
104
+ pop_attribute_from_stack unless plain_mode?
105
+ raise error('Illegal " found') unless @stack.last.value.nil? || @stack.last.value.empty?
106
+ value_mode('block')
107
+ when '\\'
108
+ raise error('Backslash is not allowed in unquoted values') if plain_mode?
109
+ raise error('Unsupported escaping of character inside string block') unless ['\\', '"'].include?(@buffer.peek(1))
110
+ append_char(@buffer.peek(1))
111
+ @buffer.pos += 1
112
+ when ','
113
+ if plain_mode?
114
+ pop_attribute_from_stack
115
+ push_stacker(1)
116
+ else
117
+ append_char(char)
118
+ end
119
+ when '='
120
+ raise error('Illegal use of equals character in unquoted value') if plain_mode?
121
+ append_char(char)
122
+ when ' '
123
+ if plain_mode?
124
+ raise error('Illegal spacing in unquoted value') if @buffer.check(/\s*[,\]]/).nil?
125
+ pop_attribute_from_stack
126
+ push_stacker(1)
127
+ else
128
+ append_char(char)
129
+ end
130
+ else
131
+ append_char(char)
132
+ end
133
+ end
134
+
135
+ def error(msg)
136
+ ParserError.new(msg, @raw, @buffer.pos)
137
+ end
138
+
139
+ def push_stacker(type)
140
+ @stack << Stacker.new(type)
141
+ end
142
+
143
+ def append_char(char)
144
+ @stack.last.append(char)
145
+ end
146
+
147
+ def pop_attribute_from_stack
148
+ v = @stack.pop
149
+ return if [0, 1, 2].include?(v.type) # Ignore these types from stack
150
+ k = @stack.pop
151
+ raise error("Expected key but got: #{k.value}, #{k.type}") unless k.type == 2
152
+ @attributes[k.value] = v.value
153
+ end
154
+
155
+ def plain_mode?
156
+ @stack.last.meta['mode'] == 'plain'
157
+ end
158
+
159
+ def block_mode?
160
+ @stack.last.meta['mode'] == 'block'
161
+ end
162
+
163
+ def value_mode(str)
164
+ @stack.last.meta['mode'] = str
165
+ end
166
+ end
167
+ end
168
+ end
169
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'strscan'
4
+
5
+ module Jekyll
6
+ module Premonition
7
+ module Attributes
8
+ # Instances of this class are pushed onto the parser stack upon parsing of block attributes.
9
+ class Stacker
10
+ # Get the string value from the stacker
11
+ attr_reader :value
12
+ # Get the stacker type. 0 = outside block, 1 = in_between, 2 = key, 3 = value
13
+ attr_reader :type
14
+ # Get and set meta attributes for stacker. Used for setting value mode.
15
+ attr_accessor :meta
16
+
17
+ # Initialize a new Stacker
18
+ #
19
+ # type - The stacker type
20
+ def initialize(type)
21
+ @value = nil
22
+ @type = type
23
+ @meta = {}
24
+ end
25
+
26
+ # Append a char to the stacker value
27
+ def append(char)
28
+ @value = @value.nil? ? char : "#{@value}#{char}"
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,82 +1,37 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Jekyll
2
4
  module Premonition
3
5
  class Hook < Generator
4
6
  safe true
5
- priority :low
7
+ priority :high
6
8
 
7
9
  def initialize(p)
8
10
  super(p)
9
11
  end
10
12
 
11
- def generate(site)
12
- @resources = Resources.new site.config
13
- Hooks.register [:documents, :pages], :pre_render do |doc|
14
- adder(doc)
15
- end
16
- end
17
-
18
- def adder(doc)
19
- o = []
20
- b = nil
21
- doc.content.each_line do |l|
22
- if blockquote?(l) && empty_block?(b)
23
- if (m = l.match(/^\s*\>\s+([a-z]+)\s+\"(.*)\"$/i))
24
- y, t = m.captures
25
- b = { 'title' => t.strip, 'type' => y.strip.downcase, 'content' => [] }
26
- else
27
- o << l
28
- end
29
- elsif blockquote?(l) && !empty_block?(b)
30
- b['content'] << l.match(/^\s*\>\s?(.*)$/i).captures[0]
31
- else
32
- if !blockquote?(l) && !empty_block?(b)
33
- o << render_block(b)
34
- b = nil
35
- end
36
- o << l
37
- end
38
- end
39
- o << render_block(b) unless empty_block?(b)
40
- doc.content = o.join
13
+ def generate_excerpt?(doc)
14
+ !doc.data['excerpt_separator'].empty?
41
15
  end
42
16
 
43
- def blockquote?(l)
44
- l.strip.start_with?('>')
17
+ def process?(resources, doc)
18
+ resources.config['extensions'].include?(File.extname(doc.relative_path)[1..-1])
45
19
  end
46
20
 
47
- def empty_block?(b)
48
- b.nil?
49
- end
21
+ def generate(site)
22
+ resources = Resources.new site.config
23
+ processor = Processor.new resources
50
24
 
51
- def render_block(b)
52
- t = create_resource(b)
53
- c = "#{@resources.markdown.convert(b['content'].join("\n"))}\n\n"
54
- template = Liquid::Template.parse(t['template'], error_mode: :strict)
55
- template.render(
56
- {
57
- 'header' => !t['title'].nil?,
58
- 'title' => t['title'],
59
- 'content' => c,
60
- 'type' => b['type'],
61
- 'meta' => t['meta']
62
- },
63
- strict_variables: true
64
- )
65
- end
25
+ Hooks.register [:posts], :pre_render do |doc|
26
+ if process?(resources, doc)
27
+ doc.content = processor.adder(doc.content)
28
+ doc.data['excerpt'] = Jekyll::Excerpt.new(doc) if generate_excerpt? doc
29
+ end
30
+ end
66
31
 
67
- def create_resource(b)
68
- c = {
69
- 'template' => @resources.config['default']['template'],
70
- 'title' => @resources.config['default']['title'],
71
- 'meta' => @resources.config['default']['meta']
72
- }
73
- @resources.config['types'].each do |id, t|
74
- next unless id == b['type']
75
- c['title'] = b['title'].empty? || b['title'].nil? ? t['default_title'] : b['title']
76
- c['template'] = t['template'] unless t['template'].nil?
77
- c['meta'] = c['meta'].merge(t['meta']) unless t['meta'].nil?
32
+ Hooks.register [:pages], :pre_render do |doc|
33
+ doc.content = processor.adder(doc.content) if process?(resources, doc)
78
34
  end
79
- c
80
35
  end
81
36
  end
82
37
  end
@@ -0,0 +1,113 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Premonition
5
+ class Processor
6
+ def initialize(resources)
7
+ @resources = resources
8
+ end
9
+
10
+ def adder(content)
11
+ o = []
12
+ references = load_references(content)
13
+ b = nil
14
+ is_code_block = false
15
+ content.each_line do |l|
16
+ is_code_block = !is_code_block if code_block_line?(l)
17
+ if is_code_block
18
+ o << l
19
+ elsif blockquote?(l) && empty_block?(b)
20
+ if (m = l.match(/^\s*\>\s+([a-z]+)\s+\"(.*)\"\s+(\[.*\])?\s*$/i))
21
+ y, t, attrs = m.captures
22
+ b = { 'title' => t.strip, 'type' => y.strip.downcase, 'content' => [], 'attrs' => attrs }
23
+ else
24
+ o << l
25
+ end
26
+ elsif blockquote?(l) && !empty_block?(b)
27
+ b['content'] << l.match(/^\s*\>\s?(.*)$/i).captures[0]
28
+ else
29
+ if !blockquote?(l) && !empty_block?(b)
30
+ o << render_block(b, references)
31
+ b = nil
32
+ end
33
+ o << l
34
+ end
35
+ end
36
+ o << render_block(b, references) unless empty_block?(b)
37
+ o.join
38
+ end
39
+
40
+ private
41
+
42
+ def load_references(content)
43
+ refs = ["\n"]
44
+ content.each_line do |l|
45
+ refs << l if l.strip!.match(/^\[.*\]:.*\".*\"$/i)
46
+ end
47
+ refs
48
+ end
49
+
50
+ def code_block_line?(line)
51
+ line.strip.start_with?('~~~')
52
+ end
53
+
54
+ def blockquote?(line)
55
+ line.strip.start_with?('>')
56
+ end
57
+
58
+ def empty_block?(block)
59
+ block.nil?
60
+ end
61
+
62
+ def render_block(block, references)
63
+ t = create_resource(block)
64
+ a = block['content'] + references
65
+ c = "#{@resources.markdown.convert(a.join("\n"))}\n\n"
66
+ attrs = {}
67
+
68
+ unless block['attrs'].nil?
69
+ parser = Jekyll::Premonition::Attributes::Parser.new(block['attrs'])
70
+ attrs = parser.attributes
71
+ end
72
+
73
+ template = Liquid::Template.parse(t['template'], error_mode: :strict)
74
+ template.render(
75
+ {
76
+ 'header' => !t['title'].nil?,
77
+ 'title' => t['title'],
78
+ 'content' => c,
79
+ 'type' => block['type'],
80
+ 'meta' => t['meta'],
81
+ 'attrs' => attrs
82
+ },
83
+ strict_variables: true
84
+ )
85
+ end
86
+
87
+ def create_resource(block)
88
+ c = {
89
+ 'template' => @resources.config['default']['template'],
90
+ 'title' => @resources.config['default']['title'],
91
+ 'meta' => @resources.config['default']['meta']
92
+ }
93
+
94
+ unless @resources.config['types'].include? block['type']
95
+ c['title'] = ''
96
+ c['meta'] = { 'fa-icon' => 'fa-bug' }
97
+ c['template'] = '<div class="premonition error"><div class="fa {{meta.fa-icon}}"></div>'\
98
+ '<div class="content"><p class="header">PREMONITION ERROR: Invalid box type</p>You have specified an invalid box type "{{type}}". You can customize your own box types in `_config.yml`. See documentation for help.</div></div>'
99
+ return c
100
+ end
101
+
102
+ @resources.config['types'].each do |id, t|
103
+ next unless id == block['type']
104
+
105
+ c['title'] = block['title'].empty? || block['title'].nil? ? t['default_title'] : block['title']
106
+ c['template'] = t['template'] unless t['template'].nil?
107
+ c['meta'] = c['meta'].merge(t['meta']) unless t['meta'].nil?
108
+ end
109
+ c
110
+ end
111
+ end
112
+ end
113
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Jekyll
2
4
  module Premonition
3
5
  class Resources
@@ -18,13 +20,14 @@ module Jekyll
18
20
  cfg['default']['title'] = df['title'].strip unless df['title'].nil?
19
21
  cfg['default']['meta'] = cfg['default']['meta'].merge(df['meta']) unless df['meta'].nil?
20
22
  load_types p, cfg
23
+ load_extensions p, cfg
21
24
  cfg
22
25
  end
23
26
 
24
27
  def default_config
25
28
  {
26
29
  'default' => {
27
- 'template' => '<div class="premonition {{type}}"><div class="fa {{meta.fa-icon}}"></div>'\
30
+ 'template' => '<div class="premonition {{type}}"><i class="fas {{meta.fa-icon}}"></i>'\
28
31
  '<div class="content">{% if header %}<p class="header">{{title}}</p>{% endif %}{{content}}</div></div>',
29
32
  'meta' => { 'fa-icon' => 'fa-check-square' },
30
33
  'title' => nil
@@ -33,8 +36,17 @@ module Jekyll
33
36
  'note' => { 'meta' => { 'fa-icon' => 'fa-check-square' } },
34
37
  'info' => { 'meta' => { 'fa-icon' => 'fa-info-circle' } },
35
38
  'warning' => { 'meta' => { 'fa-icon' => 'fa-exclamation-circle' } },
36
- 'error' => { 'meta' => { 'fa-icon' => 'fa-exclamation-triangle' } }
37
- }
39
+ 'error' => { 'meta' => { 'fa-icon' => 'fa-exclamation-triangle' } },
40
+ 'citation' => { 'meta' => { 'fa-icon' => 'fa-quote-left' }, 'template' =>
41
+ '<div class="premonition {{type}}"><i class="fas {{meta.fa-icon}}"></i>'\
42
+ '<blockquote class="content blockquote"{% if attrs.cite %} cite="{{attrs.cite}}"{% endif %}>{{content}}{% if header %}'\
43
+ '<footer class="blockquote-footer">'\
44
+ '<cite title="{{title}}">{{title}}</cite></footer>{% endif %}</blockquote></div>' }
45
+ },
46
+ 'extensions' => [
47
+ 'md',
48
+ 'markdown'
49
+ ]
38
50
  }
39
51
  end
40
52
 
@@ -45,6 +57,7 @@ module Jekyll
45
57
 
46
58
  def load_types(p, cfg)
47
59
  return if p['types'].nil?
60
+
48
61
  p['types'].each do |id, obj|
49
62
  t = type_config id, obj
50
63
  cfg['types'][id] = cfg['types'][id].merge(t) unless cfg['types'][id].nil?
@@ -52,6 +65,17 @@ module Jekyll
52
65
  end
53
66
  end
54
67
 
68
+ def load_extensions(p, cfg)
69
+ return if p['extensions'].nil?
70
+ return unless p['extensions'].is_a?(Array)
71
+ return if p['extensions'].empty?
72
+
73
+ cfg['extensions'] = []
74
+ p['extensions'].each do |v|
75
+ cfg['extensions'] << v unless cfg['extensions'].include?(v)
76
+ end
77
+ end
78
+
55
79
  def type_config(id, t)
56
80
  validate_type(id, t)
57
81
  {
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Jekyll
2
4
  module Premonition
3
- VERSION = '2.0.1'.freeze
5
+ VERSION = '4.0.0.pre1'
4
6
  end
5
7
  end
data/lib/premonition.rb CHANGED
@@ -1,7 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'jekyll'
2
- require 'premonition/version'
3
- require 'premonition/resources'
4
- require 'premonition/hook'
4
+ require_relative 'premonition/attributes/error'
5
+ require_relative 'premonition/attributes/stacker'
6
+ require_relative 'premonition/attributes/parser'
7
+ require_relative 'premonition/version'
8
+ require_relative 'premonition/processor'
9
+ require_relative 'premonition/resources'
10
+ require_relative 'premonition/hook'
5
11
 
6
12
  module Jekyll
7
13
  module Premonition
metadata CHANGED
@@ -1,49 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: premonition
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 4.0.0.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakob Vad Nielsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-27 00:00:00.000000000 Z
11
+ date: 2020-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: jekyll
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.5'
20
- type: :development
19
+ version: '3.7'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '3.7'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: '1.5'
32
+ version: '5.0'
27
33
  - !ruby/object:Gem::Dependency
28
- name: jekyll
34
+ name: bundler
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '2.0'
34
- - - "<"
37
+ - - "~>"
35
38
  - !ruby/object:Gem::Version
36
- version: '3.0'
39
+ version: 2.1.4
37
40
  type: :development
38
41
  prerelease: false
39
42
  version_requirements: !ruby/object:Gem::Requirement
40
43
  requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: '2.0'
44
- - - "<"
44
+ - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '3.0'
46
+ version: 2.1.4
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: mocha
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -72,6 +72,40 @@ dependencies:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: 13.0.1
75
+ - !ruby/object:Gem::Dependency
76
+ name: rubocop
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: 0.68.0
82
+ - - "<"
83
+ - !ruby/object:Gem::Version
84
+ version: 0.72.0
85
+ type: :development
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: 0.68.0
92
+ - - "<"
93
+ - !ruby/object:Gem::Version
94
+ version: 0.72.0
95
+ - !ruby/object:Gem::Dependency
96
+ name: rubocop-jekyll
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: 0.10.0
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: 0.10.0
75
109
  - !ruby/object:Gem::Dependency
76
110
  name: turn
77
111
  requirement: !ruby/object:Gem::Requirement
@@ -97,7 +131,11 @@ files:
97
131
  - LICENSE
98
132
  - README.md
99
133
  - lib/premonition.rb
134
+ - lib/premonition/attributes/error.rb
135
+ - lib/premonition/attributes/parser.rb
136
+ - lib/premonition/attributes/stacker.rb
100
137
  - lib/premonition/hook.rb
138
+ - lib/premonition/processor.rb
101
139
  - lib/premonition/resources.rb
102
140
  - lib/premonition/version.rb
103
141
  homepage: http://github.com/lazee/premonition
@@ -116,9 +154,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
154
  version: '0'
117
155
  required_rubygems_version: !ruby/object:Gem::Requirement
118
156
  requirements:
119
- - - ">="
157
+ - - ">"
120
158
  - !ruby/object:Gem::Version
121
- version: '0'
159
+ version: 1.3.1
122
160
  requirements: []
123
161
  rubygems_version: 3.0.3
124
162
  signing_key: