premonition 4.0.0.pre3 → 4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +71 -67
- data/lib/premonition/attributes/parser.rb +0 -1
- data/lib/premonition/commands/install_scss.rb +32 -32
- data/lib/premonition/hook.rb +23 -8
- data/lib/premonition/processor.rb +32 -5
- data/lib/premonition/resources.rb +43 -10
- data/lib/premonition/version.rb +2 -1
- metadata +40 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0afd588a585aa18e2b848b6db7218e7023da46485f7eb5be786c46b3829b49c
|
4
|
+
data.tar.gz: e6ef83f13bf6b05af34eb1a0eb1d06eb50441b989f39bf760fbe2fc19630741a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4640af00a49c1ebd749c7addf2687254cf49f8b18ffbf401be0816bd3cd0df280c40d110a99ada680ef77e2c162a885c3da35541fe70e9d2c3075f4548883c70
|
7
|
+
data.tar.gz: 8eae8618c054023a9573178d70adf0434d3ebe06bf66c8290b33df0ba6b85b7e338c847ce12e06f592843f77c4b7d759350800b39675d5a688affa1aeb568958
|
data/README.md
CHANGED
@@ -1,51 +1,49 @@
|
|
1
1
|
# Premonition
|
2
2
|
|
3
|
-
NOTE: This is the documentation for the version 4 release, coming soon. For 2.x documentation, please switch to the `2.x` branch.
|
4
|
-
|
5
3
|
[Demo site](https://lazee.github.io/premonition-demo/) ([Source code](https://github.com/lazee/premonition-demo))
|
6
4
|
|
7
|
-
Premonition is a higly customizable [Jekyll](https://jekyllrb.com/) plugin that can convert Markdown block-quotes into beautiful block styled content.
|
5
|
+
Premonition is a higly customizable [Jekyll](https://jekyllrb.com/) plugin that can convert Markdown block-quotes into beautiful block styled content.
|
8
6
|
|
9
7
|
By simply adding a custom 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.
|
10
8
|
|
11
9
|
<p align="center">
|
12
|
-
<img src="https://github.com/lazee/premonition/raw/master/screen.png" height="
|
10
|
+
<img src="https://github.com/lazee/premonition/raw/master/screen.png" height="550"/>
|
13
11
|
</p>
|
14
12
|
|
15
13
|
## Features
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
15
|
+
- Highly customizable (Create your own styles and templates easily)
|
16
|
+
- Non-intrusive - Its just Markdown!
|
17
|
+
- Easy to install
|
18
|
+
- Comes with a default stylesheet (Sass/Css) and templates for beautiful messages boxes and citation.
|
19
|
+
- Font Awesome 5 support
|
20
|
+
|
21
|
+
## Version 4 Highlights
|
22
|
+
|
23
|
+
- Jekyll [Post Excerpts](https://jekyllrb.com/docs/posts/#post-excerpts) support
|
24
|
+
- New install command for the default stylesheet.
|
25
|
+
- [Kramdown reference links](https://kramdown.gettalong.org/quickref.html#links-and-images) support
|
26
|
+
- Jekyll 4 support (3.7 still supported)
|
27
|
+
- Added support for block attributes (See documentation further down)
|
28
|
+
- Added new citation block type.
|
29
|
+
- Minor fixes to the Premonition stylesheet.
|
30
|
+
- Removed the need Font Awesome css in default stylesheet, but
|
31
|
+
Font Awesome is still supported.
|
32
|
+
- Other bug fixes. See HISTORY.md.
|
33
|
+
|
34
|
+
See UPGRADE.md for help on how to upgrade from 2.x to 4.0.
|
35
|
+
|
38
36
|
## Requirements
|
39
37
|
|
40
|
-
|
41
|
-
|
38
|
+
- Jekyll 3.7.x or higher (We recommend the new Jekyll 4)
|
39
|
+
|
42
40
|
## Installation
|
43
41
|
|
44
42
|
Add the following line to your `Gemfile` inside your Jekyll project folder:
|
45
43
|
|
46
44
|
```
|
47
45
|
group :jekyll_plugins do
|
48
|
-
gem "premonition", "4.0.
|
46
|
+
gem "premonition", "4.0.1"
|
49
47
|
end
|
50
48
|
```
|
51
49
|
|
@@ -53,7 +51,7 @@ Then add the the plugin to your `_config.yml`:
|
|
53
51
|
|
54
52
|
```yaml
|
55
53
|
plugins:
|
56
|
-
|
54
|
+
- premonition
|
57
55
|
```
|
58
56
|
|
59
57
|
Now make sure to download the Premonition bundle:
|
@@ -89,54 +87,60 @@ defined by you in `_config.yml`.
|
|
89
87
|
|
90
88
|
The default types are:
|
91
89
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
90
|
+
- note
|
91
|
+
- info
|
92
|
+
- warning
|
93
|
+
- error
|
94
|
+
- citation
|
97
95
|
|
98
|
-
The
|
96
|
+
The _Title_ will normally be the block header. Leave it empty to disable
|
99
97
|
the header.
|
100
98
|
|
101
|
-
|
99
|
+
_attributes_ are in use by the Citation type, but can be skipped for the other default types. See section about custom types for more info.
|
102
100
|
|
103
101
|
### Examples
|
104
102
|
|
105
103
|
Simple note with no header
|
106
|
-
|
104
|
+
|
105
|
+
```markdown
|
107
106
|
> note ""
|
108
107
|
> No headers in here
|
109
|
-
|
108
|
+
```
|
110
109
|
|
111
110
|
Note
|
112
|
-
|
111
|
+
|
112
|
+
```markdown
|
113
113
|
> note "I am a not"
|
114
114
|
> The body of the note goes here. Premonition allows you to write any `Markdown` inside the block.
|
115
|
-
|
115
|
+
```
|
116
116
|
|
117
117
|
Info
|
118
|
-
|
118
|
+
|
119
|
+
```markdown
|
119
120
|
> info "I am some info"
|
120
121
|
> The body of the info box goes here. Premonition allows you to write any `Markdown` inside the block.
|
121
|
-
|
122
|
+
```
|
122
123
|
|
123
124
|
Warning
|
124
|
-
|
125
|
+
|
126
|
+
```markdown
|
125
127
|
> warning "I am a warning"
|
126
128
|
> The body of the warning box goes here. Premonition allows you to write any `Markdown` inside the block.
|
127
|
-
|
129
|
+
```
|
128
130
|
|
129
131
|
Error
|
130
|
-
|
132
|
+
|
133
|
+
```markdown
|
131
134
|
> error "I am an error"
|
132
135
|
> The body of the error box goes here. Premonition allows you to write any `Markdown` inside the block.
|
133
|
-
|
136
|
+
```
|
134
137
|
|
135
138
|
Citation (Note the use of attributes here)
|
136
|
-
|
137
|
-
|
139
|
+
|
140
|
+
```markdown
|
141
|
+
> citation "Mark Twain" [ cite = "mt" ]
|
138
142
|
> I will be a beautiful citation quote
|
139
|
-
|
143
|
+
```
|
140
144
|
|
141
145
|
## Configuration
|
142
146
|
|
@@ -150,12 +154,12 @@ Like Jekyll itself, Premonition uses the [Liquid Markup Language](https://github
|
|
150
154
|
|
151
155
|
Six variables are available to the template engine:
|
152
156
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
157
|
+
- _header_ Boolean that tells you if a title exists and that a header should be added.
|
158
|
+
- _content_ The rendered content for your block.
|
159
|
+
- _title_ The block title.
|
160
|
+
- _type_ The type name (eg: note).
|
161
|
+
- _meta_ This is a hash that can contain any properties you would like to make available to your template. It is configured in `_config.yml`
|
162
|
+
- _attrs_ These are the attributes set in the block header. Like we did in the Citation example above.
|
159
163
|
|
160
164
|
Take a look at our default template inside `lib/premonition/resources.rb` to
|
161
165
|
get an idea of how this is done.
|
@@ -167,7 +171,7 @@ You can override the default template like this in your `_config.yml`:
|
|
167
171
|
```yaml
|
168
172
|
premonition:
|
169
173
|
default:
|
170
|
-
template:
|
174
|
+
template: "Liquid template goes here"
|
171
175
|
```
|
172
176
|
|
173
177
|
#### Overriding the template for a default type
|
@@ -178,7 +182,7 @@ If you want to override the template for one of the default types (like note), d
|
|
178
182
|
premonition:
|
179
183
|
types:
|
180
184
|
note:
|
181
|
-
template:
|
185
|
+
template: "Liquid template goes here"
|
182
186
|
```
|
183
187
|
|
184
188
|
### Adding custom types
|
@@ -188,24 +192,24 @@ of the defaults, or add a new one.
|
|
188
192
|
|
189
193
|
For each type you can
|
190
194
|
|
191
|
-
|
192
|
-
|
193
|
-
|
195
|
+
- Add a custom template (template)
|
196
|
+
- Set a default title (default_title)
|
197
|
+
- Set meta data that can be used inside the template
|
194
198
|
|
195
199
|
Each type must have unique id (lowercase letters).
|
196
200
|
|
197
|
-
|
201
|
+
```yaml
|
198
202
|
premonition:
|
199
203
|
types:
|
200
204
|
custombox:
|
201
205
|
meta:
|
202
|
-
my-meta:
|
206
|
+
my-meta: "By myself"
|
203
207
|
advanced:
|
204
|
-
template:
|
205
|
-
default_title:
|
208
|
+
template: "Liquid template goes here"
|
209
|
+
default_title: "MY BLOCK"
|
206
210
|
meta:
|
207
|
-
my-meta:
|
208
|
-
|
211
|
+
my-meta: "By myself"
|
212
|
+
```
|
209
213
|
|
210
214
|
## More on styling
|
211
215
|
|
@@ -241,7 +245,7 @@ Then just add this to your `_config.yml`:
|
|
241
245
|
premonition:
|
242
246
|
types:
|
243
247
|
error:
|
244
|
-
fa-icon:
|
248
|
+
fa-icon: "fa-bug"
|
245
249
|
```
|
246
250
|
|
247
251
|
Simple as that :)
|
@@ -4,6 +4,9 @@ require 'net/http'
|
|
4
4
|
|
5
5
|
module Jekyll
|
6
6
|
module Premonition
|
7
|
+
# Public: Premonition stylesheet installer command
|
8
|
+
#
|
9
|
+
# Jekyll command that will install the Premonition stylesheet and add it to the needed resource files.
|
7
10
|
class InstallScssCommand < Jekyll::Command
|
8
11
|
class << self
|
9
12
|
def init_with_program(prog)
|
@@ -19,45 +22,42 @@ module Jekyll
|
|
19
22
|
end
|
20
23
|
|
21
24
|
def process(_args, opts)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
raise StandardError, "#{main} does not exist" unless File.exist?(main)
|
25
|
+
puts '== Installing Premonition Stylesheet and resources =="'
|
26
|
+
puts '-- premonition.scss --'
|
27
|
+
dest = opts['dest'].nil? || opts['dest'].empty? ? './_sass/' : File.join(opts['dest'], '')
|
28
|
+
main = opts['main'].nil? || opts['main'].empty? ? './assets/css/styles.scss' : opts['main']
|
29
|
+
raise StandardError, "#{dest} folder does not exist. Create it manually, and run script again." unless Dir.exist?(dest)
|
30
|
+
raise StandardError, "#{main} does not exist" unless File.exist?(main)
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
+
uri = URI('https://raw.githubusercontent.com/lazee/premonition/master/stylesheet/premonition.scss')
|
33
|
+
pf = "#{dest}premonition.scss"
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
if File.exist?(pf)
|
36
|
+
print "You already have #{pf} installed. Continue? [Y/n]"
|
37
|
+
override = gets.chomp
|
38
|
+
raise StandardError, 'Aborted. No harm done.' if override == 'n'
|
39
|
+
end
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
+
File.write(pf, Net::HTTP.get(uri))
|
42
|
+
puts "Saved stylesheet in #{pf}"
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
+
if File.readlines(main).grep(/\@import \"premonition\"/).any?
|
45
|
+
puts "#{main} already imports the Premonition stylesheet."
|
46
|
+
else
|
47
|
+
puts 'You must add Premonition to your main SASS file.'
|
48
|
+
print "Add '@import \"premonition\";' to end of #{main} now? [Y/n] "
|
49
|
+
add = gets.chomp
|
50
|
+
if add == 'n'
|
51
|
+
puts 'Ok. But then you will need to add it manually for the styling of Premonition to work.'
|
44
52
|
else
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
puts 'Ok. But then you will need to add it manually for the styling of Premonition to work.'
|
50
|
-
else
|
51
|
-
f = File.open(main, 'a')
|
52
|
-
f.write("\n@import \"premonition\";\n")
|
53
|
-
f.close
|
54
|
-
puts "Added Premonition stylesheet to #{main}."
|
55
|
-
end
|
53
|
+
f = File.open(main, 'a')
|
54
|
+
f.write("\n@import \"premonition\";\n")
|
55
|
+
f.close
|
56
|
+
puts "Added Premonition stylesheet to #{main}."
|
56
57
|
end
|
57
|
-
|
58
|
-
rescue StandardError => msg
|
59
|
-
puts "ERROR: #{msg}"
|
60
58
|
end
|
59
|
+
rescue StandardError => e
|
60
|
+
puts "ERROR: #{e}"
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
data/lib/premonition/hook.rb
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
module Jekyll
|
4
4
|
module Premonition
|
5
|
+
# Registers Premonition hooks in Jekyll.
|
6
|
+
#
|
7
|
+
# Two hooks are added. One general hook for pages and another special
|
8
|
+
# hook for dealing with excerpts within posts.
|
9
|
+
#
|
10
|
+
# This ladder is really a hack as we scan all Markdown files and insert the
|
11
|
+
# excerpt ourselves in the document data. Unfortunately Jekyll prepares
|
12
|
+
# the excerpt way to early in the process, preventing us from hooking
|
13
|
+
# into it in a prober way. We only support excerpts if the excerpt_separator
|
14
|
+
# is explicitly set: https://jekyllrb.com/docs/posts/#post-excerpts
|
5
15
|
class Hook < Generator
|
6
16
|
safe true
|
7
17
|
priority :high
|
@@ -10,14 +20,6 @@ module Jekyll
|
|
10
20
|
super(p)
|
11
21
|
end
|
12
22
|
|
13
|
-
def generate_excerpt?(doc)
|
14
|
-
!doc.data['excerpt_separator'].nil? && !doc.data['excerpt_separator'].empty?
|
15
|
-
end
|
16
|
-
|
17
|
-
def process?(resources, doc)
|
18
|
-
resources.config['extensions'].include?(File.extname(doc.relative_path)[1..-1])
|
19
|
-
end
|
20
|
-
|
21
23
|
def generate(site)
|
22
24
|
resources = Resources.new site.config
|
23
25
|
processor = Processor.new resources
|
@@ -29,9 +31,22 @@ module Jekyll
|
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
34
|
+
Hooks.register [:documents], :pre_render do |doc|
|
35
|
+
doc.content = processor.adder(doc.content) if process?(resources, doc)
|
36
|
+
end
|
32
37
|
Hooks.register [:pages], :pre_render do |doc|
|
33
38
|
doc.content = processor.adder(doc.content) if process?(resources, doc)
|
34
39
|
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def generate_excerpt?(doc)
|
45
|
+
!doc.data['excerpt_separator'].nil? && !doc.data['excerpt_separator'].empty?
|
46
|
+
end
|
47
|
+
|
48
|
+
def process?(resources, doc)
|
49
|
+
resources.config['extensions'].include?(File.extname(doc.relative_path)[1..-1])
|
35
50
|
end
|
36
51
|
end
|
37
52
|
end
|
@@ -2,14 +2,22 @@
|
|
2
2
|
|
3
3
|
module Jekyll
|
4
4
|
module Premonition
|
5
|
+
|
6
|
+
# Class that does all of the rendering magic within Premonition.
|
5
7
|
class Processor
|
6
8
|
def initialize(resources)
|
7
9
|
@resources = resources
|
8
10
|
end
|
9
11
|
|
12
|
+
# Called by the registered pre_render hooks.
|
13
|
+
#
|
14
|
+
# This function takes markdown content as input and converts
|
15
|
+
# all the block quotes, with a Premonition header, into html.
|
16
|
+
#
|
17
|
+
# content - Markdown content
|
10
18
|
def adder(content)
|
11
19
|
o = []
|
12
|
-
references =
|
20
|
+
references = ["\n"]
|
13
21
|
b = nil
|
14
22
|
is_code_block = false
|
15
23
|
content.each_line do |l|
|
@@ -17,6 +25,7 @@ module Jekyll
|
|
17
25
|
if is_code_block
|
18
26
|
o << l
|
19
27
|
elsif blockquote?(l) && empty_block?(b)
|
28
|
+
|
20
29
|
if (m = l.match(/^\s*\>\s+([a-z]+)\s+\"(.*)\"\s+(\[.*\])?\s*$/i))
|
21
30
|
y, t, attrs = m.captures
|
22
31
|
b = { 'title' => t.strip, 'type' => y.strip.downcase, 'content' => [], 'attrs' => attrs }
|
@@ -27,6 +36,7 @@ module Jekyll
|
|
27
36
|
b['content'] << l.match(/^\s*\>\s?(.*)$/i).captures[0]
|
28
37
|
else
|
29
38
|
if !blockquote?(l) && !empty_block?(b)
|
39
|
+
references = load_references(content)
|
30
40
|
o << render_block(b, references)
|
31
41
|
b = nil
|
32
42
|
end
|
@@ -39,16 +49,21 @@ module Jekyll
|
|
39
49
|
|
40
50
|
private
|
41
51
|
|
52
|
+
# Find all the Kramdown reference name links.
|
53
|
+
# https://kramdown.gettalong.org/quickref.html#links-and-images
|
54
|
+
# https://github.com/lazee/premonition/issues/10
|
42
55
|
def load_references(content)
|
43
56
|
refs = ["\n"]
|
44
57
|
content.each_line do |l|
|
45
|
-
refs << l if l.strip!.match(/^\[.*\]:.*\".*\"$/i)
|
58
|
+
# refs << l if l.strip!.match(/^\[.*\]:.*\".*\"$/i)
|
59
|
+
|
60
|
+
refs << l if l.strip.length.positive? && l.strip.match(/^\[.*\]:.*\".*\"$/i)
|
46
61
|
end
|
47
62
|
refs
|
48
63
|
end
|
49
64
|
|
50
65
|
def code_block_line?(line)
|
51
|
-
line.strip.start_with?('~~~')
|
66
|
+
line.strip.start_with?('~~~') || line.strip.start_with?('```')
|
52
67
|
end
|
53
68
|
|
54
69
|
def blockquote?(line)
|
@@ -84,6 +99,19 @@ module Jekyll
|
|
84
99
|
)
|
85
100
|
end
|
86
101
|
|
102
|
+
def error_template
|
103
|
+
<<~TEMPLATE
|
104
|
+
<div class="premonition error">
|
105
|
+
<div class="fa {{meta.pn-icon}}"></div>
|
106
|
+
<div class="content">
|
107
|
+
<p class="header">PREMONITION ERROR: Invalid box type</p>
|
108
|
+
You have specified an invalid box type "{{type}}". You can customize your own box types in `_config.yml`.
|
109
|
+
See documentation for more help.
|
110
|
+
</div>
|
111
|
+
</div>
|
112
|
+
TEMPLATE
|
113
|
+
end
|
114
|
+
|
87
115
|
def create_resource(block)
|
88
116
|
c = {
|
89
117
|
'template' => @resources.config['default']['template'],
|
@@ -94,8 +122,7 @@ module Jekyll
|
|
94
122
|
unless @resources.config['types'].include? block['type']
|
95
123
|
c['title'] = ''
|
96
124
|
c['meta'] = { 'pn-icon' => 'pn-error' }
|
97
|
-
c['template'] =
|
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>'
|
125
|
+
c['template'] = error_template
|
99
126
|
return c
|
100
127
|
end
|
101
128
|
|
@@ -2,15 +2,18 @@
|
|
2
2
|
|
3
3
|
module Jekyll
|
4
4
|
module Premonition
|
5
|
+
# Class for loading the Premonition configuration and preparing it for use.
|
5
6
|
class Resources
|
6
7
|
attr_reader :config
|
7
8
|
attr_reader :markdown
|
8
9
|
|
9
10
|
def initialize(site_config)
|
10
11
|
@config = load site_config
|
12
|
+
# Setup a new Markdown renderer.
|
11
13
|
@markdown = Converters::Markdown.new site_config
|
12
14
|
end
|
13
15
|
|
16
|
+
# Load the configuration of Premonition from Jekyll site configuration object.
|
14
17
|
def load(site_config)
|
15
18
|
cfg = default_config
|
16
19
|
p = site_config['premonition'] || {}
|
@@ -24,11 +27,38 @@ module Jekyll
|
|
24
27
|
cfg
|
25
28
|
end
|
26
29
|
|
30
|
+
def default_template
|
31
|
+
<<~TEMPLATE
|
32
|
+
<div class="premonition {% if meta.style %}{{meta.style}} {% endif %}{{type}}">
|
33
|
+
<i class="{% if meta.fa-icon %}fas {{meta.fa-icon}}{% else %}premonition {{meta.pn-icon}}{% endif %}"></i>
|
34
|
+
<div class="content">
|
35
|
+
{% if header %}<p class="header">{{title}}</p>{% endif %}{{content}}
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
TEMPLATE
|
39
|
+
end
|
40
|
+
|
41
|
+
def citation_template
|
42
|
+
<<~TEMPLATE
|
43
|
+
<div class="premonition {% if meta.style %}{{meta.style}} {% endif %}{{type}}">
|
44
|
+
<i class="{% if meta.fa-icon %}fas {{meta.fa-icon}}{% else %}premonition {{meta.pn-icon}}{% endif %}"></i>
|
45
|
+
<blockquote class="content blockquote"{% if attrs.cite %} cite="{{attrs.cite}}"{% endif %}>
|
46
|
+
{{content}}
|
47
|
+
{% if header %}
|
48
|
+
<footer class="blockquote-footer">
|
49
|
+
<cite title="{{title}}">{{title}}</cite>
|
50
|
+
</footer>
|
51
|
+
{% endif %}
|
52
|
+
</blockquote>
|
53
|
+
</div>
|
54
|
+
TEMPLATE
|
55
|
+
end
|
56
|
+
|
57
|
+
# Setup the default configuration and types
|
27
58
|
def default_config
|
28
59
|
{
|
29
60
|
'default' => {
|
30
|
-
'template' =>
|
31
|
-
'<div class="content">{% if header %}<p class="header">{{title}}</p>{% endif %}{{content}}</div></div>',
|
61
|
+
'template' => default_template,
|
32
62
|
'meta' => { 'pn-icon' => 'pn-square', 'fa-icon' => nil },
|
33
63
|
'title' => nil
|
34
64
|
},
|
@@ -37,24 +67,22 @@ module Jekyll
|
|
37
67
|
'info' => { 'meta' => { 'pn-icon' => 'pn-info' } },
|
38
68
|
'warning' => { 'meta' => { 'pn-icon' => 'pn-warn' } },
|
39
69
|
'error' => { 'meta' => { 'pn-icon' => 'pn-error' } },
|
40
|
-
'citation' => { 'meta' => { 'pn-icon' => 'pn-quote' }, 'template' =>
|
41
|
-
'<div class="premonition {{type}}"><i class="{% if meta.fa-icon %}fas {{meta.fa-icon}}{% else %}premonition {{meta.pn-icon}}{% endif %}"></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>' }
|
70
|
+
'citation' => { 'meta' => { 'pn-icon' => 'pn-quote' }, 'template' => citation_template }
|
45
71
|
},
|
46
|
-
'extensions' => [
|
47
|
-
|
48
|
-
|
72
|
+
'extensions' => %w[
|
73
|
+
md
|
74
|
+
markdown
|
49
75
|
]
|
50
76
|
}
|
51
77
|
end
|
52
78
|
|
79
|
+
# Basic configuration validation
|
53
80
|
def validate_defaults(df, prem)
|
54
81
|
fail 'meta must be a hash' if !df['meta'].nil? && !df['meta'].is_a?(Hash)
|
55
82
|
fail 'types must be a hash' if !prem['types'].nil? && !prem['types'].is_a?(Hash)
|
56
83
|
end
|
57
84
|
|
85
|
+
# Load extra Premonition types configured/overriden in _config.yml
|
58
86
|
def load_types(p, cfg)
|
59
87
|
return if p['types'].nil?
|
60
88
|
|
@@ -65,6 +93,9 @@ module Jekyll
|
|
65
93
|
end
|
66
94
|
end
|
67
95
|
|
96
|
+
# Load extra extensions from config.
|
97
|
+
#
|
98
|
+
# We need this when looking for excerpts
|
68
99
|
def load_extensions(p, cfg)
|
69
100
|
return if p['extensions'].nil?
|
70
101
|
return unless p['extensions'].is_a?(Array)
|
@@ -76,6 +107,7 @@ module Jekyll
|
|
76
107
|
end
|
77
108
|
end
|
78
109
|
|
110
|
+
# Validate a configured type and return as type hash
|
79
111
|
def type_config(id, t)
|
80
112
|
validate_type(id, t)
|
81
113
|
{
|
@@ -85,6 +117,7 @@ module Jekyll
|
|
85
117
|
}
|
86
118
|
end
|
87
119
|
|
120
|
+
# Type validation
|
88
121
|
def validate_type(id, t)
|
89
122
|
fail 'id missing from type' if id.nil?
|
90
123
|
fail "id can only be lowercase letters: #{id}" unless id[/[a-z]+/] == id
|
data/lib/premonition/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: premonition
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakob Vad Nielsen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -34,16 +34,22 @@ dependencies:
|
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "
|
37
|
+
- - ">"
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: 2.1.4
|
40
|
+
- - "<="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 2.3.8
|
40
43
|
type: :development
|
41
44
|
prerelease: false
|
42
45
|
version_requirements: !ruby/object:Gem::Requirement
|
43
46
|
requirements:
|
44
|
-
- - "
|
47
|
+
- - ">"
|
45
48
|
- !ruby/object:Gem::Version
|
46
49
|
version: 2.1.4
|
50
|
+
- - "<="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 2.3.8
|
47
53
|
- !ruby/object:Gem::Dependency
|
48
54
|
name: mocha
|
49
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -79,9 +85,9 @@ dependencies:
|
|
79
85
|
- - ">="
|
80
86
|
- !ruby/object:Gem::Version
|
81
87
|
version: 0.68.0
|
82
|
-
- - "
|
88
|
+
- - "<="
|
83
89
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
90
|
+
version: 1.25.1
|
85
91
|
type: :development
|
86
92
|
prerelease: false
|
87
93
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -89,38 +95,52 @@ dependencies:
|
|
89
95
|
- - ">="
|
90
96
|
- !ruby/object:Gem::Version
|
91
97
|
version: 0.68.0
|
92
|
-
- - "
|
98
|
+
- - "<="
|
93
99
|
- !ruby/object:Gem::Version
|
94
|
-
version:
|
100
|
+
version: 1.25.1
|
95
101
|
- !ruby/object:Gem::Dependency
|
96
102
|
name: rubocop-jekyll
|
97
103
|
requirement: !ruby/object:Gem::Requirement
|
98
104
|
requirements:
|
99
105
|
- - "~>"
|
100
106
|
- !ruby/object:Gem::Version
|
101
|
-
version: 0.
|
107
|
+
version: 0.12.0
|
102
108
|
type: :development
|
103
109
|
prerelease: false
|
104
110
|
version_requirements: !ruby/object:Gem::Requirement
|
105
111
|
requirements:
|
106
112
|
- - "~>"
|
107
113
|
- !ruby/object:Gem::Version
|
108
|
-
version: 0.
|
114
|
+
version: 0.12.0
|
109
115
|
- !ruby/object:Gem::Dependency
|
110
|
-
name:
|
116
|
+
name: rubocop-rails
|
111
117
|
requirement: !ruby/object:Gem::Requirement
|
112
118
|
requirements:
|
113
119
|
- - "~>"
|
114
120
|
- !ruby/object:Gem::Version
|
115
|
-
version:
|
121
|
+
version: 2.13.2
|
116
122
|
type: :development
|
117
123
|
prerelease: false
|
118
124
|
version_requirements: !ruby/object:Gem::Requirement
|
119
125
|
requirements:
|
120
126
|
- - "~>"
|
121
127
|
- !ruby/object:Gem::Version
|
122
|
-
version:
|
123
|
-
|
128
|
+
version: 2.13.2
|
129
|
+
- !ruby/object:Gem::Dependency
|
130
|
+
name: test-unit
|
131
|
+
requirement: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - "~>"
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: 3.3.5
|
136
|
+
type: :development
|
137
|
+
prerelease: false
|
138
|
+
version_requirements: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - "~>"
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: 3.3.5
|
143
|
+
description:
|
124
144
|
email:
|
125
145
|
- jakobvadnielsen@gmail.com
|
126
146
|
executables: []
|
@@ -143,7 +163,7 @@ homepage: http://github.com/lazee/premonition
|
|
143
163
|
licenses:
|
144
164
|
- MIT
|
145
165
|
metadata: {}
|
146
|
-
post_install_message:
|
166
|
+
post_install_message:
|
147
167
|
rdoc_options: []
|
148
168
|
require_paths:
|
149
169
|
- lib
|
@@ -155,12 +175,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
155
175
|
version: '0'
|
156
176
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
177
|
requirements:
|
158
|
-
- - "
|
178
|
+
- - ">="
|
159
179
|
- !ruby/object:Gem::Version
|
160
|
-
version:
|
180
|
+
version: '0'
|
161
181
|
requirements: []
|
162
|
-
rubygems_version: 3.
|
163
|
-
signing_key:
|
182
|
+
rubygems_version: 3.3.7
|
183
|
+
signing_key:
|
164
184
|
specification_version: 4
|
165
185
|
summary: Jekyll generator that will convert special block quotes into message boxes.
|
166
186
|
test_files: []
|