jekyll-gfm-admonitions 0.1.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/admonitions.css +1 -1
- data/lib/jekyll-gfm-admonitions.rb +15 -5
- 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: 2bd3b14863c909fa009e741f378bff65b4727794fce307818a742e50859d233e
|
4
|
+
data.tar.gz: bcbe98766111c4a71e8f98f1ba8fe00d9c036754262d9e6bc227a3dc54a60c59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57df6efea88902eefe6de29525a290de68cb78165c9924d7d95f2f583c5812d9a676eb81570fa2649ec6201b04ac2eefbfaf9bb36e298548bb6de160555502bf
|
7
|
+
data.tar.gz: d6f84ec3048005512cb32cde7647bfc0c02ab500a1b2bd8a74605e2a6053c66384829ac4a60b5b1b9cfc777020aab048492b7203eff770480e15f96d1a676af0
|
data/assets/admonitions.css
CHANGED
@@ -23,6 +23,7 @@ module JekyllGFMAdmonitions
|
|
23
23
|
# syntax with HTML markup that includes appropriate iconography and CSS styling.
|
24
24
|
class GFMAdmonitionConverter < Jekyll::Generator
|
25
25
|
safe true
|
26
|
+
@@admonition_pages = []
|
26
27
|
|
27
28
|
def initialize(*args)
|
28
29
|
super(*args)
|
@@ -57,10 +58,14 @@ module JekyllGFMAdmonitions
|
|
57
58
|
|
58
59
|
return unless doc.content != original_content
|
59
60
|
|
60
|
-
|
61
|
+
@@admonition_pages << doc
|
61
62
|
@converted += 1
|
62
63
|
end
|
63
64
|
|
65
|
+
def self.admonition_pages
|
66
|
+
return @@admonition_pages
|
67
|
+
end
|
68
|
+
|
64
69
|
def convert_admonitions(doc)
|
65
70
|
doc.content.gsub!(/>\s*\[!(IMPORTANT|NOTE|WARNING|TIP|CAUTION)\]\s*\n((?:>.*\n?)*)/) do
|
66
71
|
type = ::Regexp.last_match(1).downcase
|
@@ -72,14 +77,19 @@ module JekyllGFMAdmonitions
|
|
72
77
|
"<div class='markdown-alert markdown-alert-#{type}'>
|
73
78
|
<p class='markdown-alert-title'>#{icon} #{title}</p>
|
74
79
|
<p>#{@markdown.convert(text)}</p>
|
75
|
-
</div
|
80
|
+
</div>\n\n"
|
76
81
|
end
|
77
82
|
end
|
83
|
+
end
|
78
84
|
|
79
|
-
|
80
|
-
|
85
|
+
Jekyll::Hooks.register :site, :post_render do |site|
|
86
|
+
Jekyll.logger.info 'GFMA:', "Injecting admonition CSS in #{GFMAdmonitionConverter.admonition_pages.length} page(s)."
|
87
|
+
|
88
|
+
for page in GFMAdmonitionConverter.admonition_pages do
|
89
|
+
Jekyll.logger.debug 'GFMA:', "Appending admonition style to '#{page.path}'."
|
81
90
|
css = File.read(File.expand_path('../assets/admonitions.css', __dir__))
|
82
|
-
|
91
|
+
|
92
|
+
page.output += "<style>#{CSSminify.compress(css)}</style>"
|
83
93
|
end
|
84
94
|
end
|
85
95
|
end
|