jekyll-gfm-admonitions 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll-gfm-admonitions.rb +12 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 219a16407153ff4afd7586cd7f06bd865db5eacbb11c2ccd42f4567777b8813c
|
4
|
+
data.tar.gz: 9e72824ed765b818af835f074be64ba7786a2248d4df9b6f433c2c9aee949cf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8c5bb02c6c4c8724233f44eaf8dc8ca6a1e20b402e68a7bf2433ca9bb74e429d6ca3d5df868c4769201e693fcb5261d01a5ae6bc9ec420f56b53e1a1a39b76d
|
7
|
+
data.tar.gz: a17141f9008abb7a5aa289201677e99168f1932486c87d6e76d474920d82f5a79d950959a657a114665cff2645c0e306315f8e35902d08b9c284e8244cfbb46c
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'octicons'
|
4
4
|
require 'cssminify'
|
5
|
+
require 'liquid/template'
|
5
6
|
|
6
7
|
ADMONITION_ICONS = {
|
7
8
|
'important' => 'report',
|
@@ -29,13 +30,21 @@ module JekyllGFMAdmonitions
|
|
29
30
|
end
|
30
31
|
|
31
32
|
def generate(site)
|
33
|
+
@markdown = site.converters.find { |c| c.is_a?(Jekyll::Converters::Markdown) }
|
34
|
+
unless @markdown
|
35
|
+
raise "Markdown converter not found. Please ensure that you have a markdown converter configured in your Jekyll site."
|
36
|
+
end
|
37
|
+
|
32
38
|
# Process admonitions in posts
|
33
39
|
site.posts.docs.each do |doc|
|
40
|
+
Jekyll.logger.debug 'GFMA:', "Processing post '#{doc.path}' (#{doc.content.length} characters)."
|
34
41
|
process(doc)
|
35
42
|
end
|
36
43
|
|
37
44
|
# Process admonitions in pages
|
38
45
|
site.pages.each do |page|
|
46
|
+
Jekyll.logger.debug 'GFMA:', "Processing page '#{page.path}' (#{page.content.length} characters)."
|
47
|
+
Jekyll.logger.debug 'GFMA:', "#{page.content.inspect}"
|
39
48
|
process(page)
|
40
49
|
end
|
41
50
|
|
@@ -58,15 +67,17 @@ module JekyllGFMAdmonitions
|
|
58
67
|
title = type.capitalize
|
59
68
|
text = ::Regexp.last_match(2).gsub(/^>\s*/, '').strip
|
60
69
|
icon = Octicons::Octicon.new(ADMONITION_ICONS[type]).to_svg
|
70
|
+
Jekyll.logger.debug 'GFMA:', "Converting #{type} admonition."
|
61
71
|
|
62
72
|
"<div class='markdown-alert markdown-alert-#{type}'>
|
63
73
|
<p class='markdown-alert-title'>#{icon} #{title}</p>
|
64
|
-
<p>#{text}</p>
|
74
|
+
<p>#{@markdown.convert(text)}</p>
|
65
75
|
</div>"
|
66
76
|
end
|
67
77
|
end
|
68
78
|
|
69
79
|
def inject_css(doc)
|
80
|
+
Jekyll.logger.debug 'GFMA:', "Appending admonition style to '#{doc.path}'."
|
70
81
|
css = File.read(File.expand_path('../assets/admonitions.css', __dir__))
|
71
82
|
doc.content += "<style>#{CSSminify.compress(css)}</style>"
|
72
83
|
end
|