Module: Jekyll::GithubAlerts
- Defined in:
- lib/jekyll-github-alerts.rb,
lib/jekyll-github-alerts/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"- @@octicon_mapping =
{ note: "info", tip: "light-bulb", important: "report", warning: "alert", caution: "stop" }
Class Method Summary collapse
Class Method Details
.is_markdown?(doc) ⇒ Boolean
23 24 25 |
# File 'lib/jekyll-github-alerts.rb', line 23 def self.is_markdown?(doc) markdown_extname_list(doc).include?(doc.extname.delete_prefix(".")) end |
.jekyllify(doc) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/jekyll-github-alerts.rb', line 13 def self.jekyllify(doc) doc.content = doc.content.gsub(/^> *\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\] *\R(.+?\R)+/i) { |match| "#{match}{:.markdown-alert.markdown-alert-#{$1.downcase}}" } doc.content = doc.content.gsub(/^> *\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]/i) { "> **{% octicon #{@@octicon_mapping[$1.downcase.to_sym]} width:16 height:16 class:\"mr-2\" aria-hidden:true %}#{$1.capitalize}**{:.markdown-alert-title}\n>" } end |
.markdown_extname_list(doc) ⇒ Object
27 28 29 |
# File 'lib/jekyll-github-alerts.rb', line 27 def self.markdown_extname_list(doc) doc.site.config["markdown_ext"].split(",") end |