jekyll-gfm-admonitions 0.2.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +100 -12
  3. data/lib/jekyll-gfm-admonitions.rb +16 -2
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f4d88903b4f39d857f537e963c51676d129aa64a1b01b1347384d450f1c715b
4
- data.tar.gz: 27f1bb25919a5de02325aa0000fff47840ef0a96fdcccde1f55527cf4b1d2d7c
3
+ metadata.gz: 36fde0cfed94f6d07ba07bb23551ddfb045ba9a1d587811a78b6be9407bc4ad9
4
+ data.tar.gz: efcf212c70ccffeb7f4d834445adec477d2c748e15e2408ea94782bbee70852d
5
5
  SHA512:
6
- metadata.gz: 8c6a301cf15df7bd44ed11138059799d73c494a092649c0b92bfe9c189c026b8642de86d52d1fc90151b0063f446f8fb56ec4ac625f2e59018a445400459377a
7
- data.tar.gz: 90f9cd3ead495506ddc433b2b593286ec8ba1f6e8d3477d992b779b3f2d70d54f4e3b3f55e67a7099bb7ab73b141a84a276661d179e6c395de9e89024bdbc362
6
+ metadata.gz: 230a0a16955e61fd32809530db0ca343730d9ce366f89416696ca5d8f85843f824121bfa3ab816aa5c264b9761aff3b3d1eabfa72264154b748a5fdaf4121c2e
7
+ data.tar.gz: 2c4b40928769e81341fc9961e0a8b8c6a55c02d492e1ac93d9db6ba38912a8ba09a0c0a3c16448bf69d292282b1ccf3a2a3e837bd80287db5fe25cdb34b4b2d4
data/README.md CHANGED
@@ -20,35 +20,35 @@ To use admonitions in your markdown files, simply add the following syntax:
20
20
 
21
21
  ```markdown
22
22
  > [!IMPORTANT]
23
- > This is an important message.
23
+ > This is an **important** message.
24
24
 
25
25
  > [!NOTE]
26
- > This is a note.
26
+ > This is a **note**.
27
27
 
28
28
  > [!TIP]
29
- > This is a helpful tip.
29
+ > This is a **helpful** tip.
30
30
 
31
31
  > [!WARNING]
32
- > This is a warning.
32
+ > This is a **warning**.
33
33
 
34
34
  > [!CAUTION]
35
- > This is a caution message.
35
+ > This is a **caution** message.
36
36
  ```
37
37
 
38
38
  > [!IMPORTANT]
39
- > This is an important message.
39
+ > This is an **important** message.
40
40
 
41
41
  > [!NOTE]
42
- > This is a note.
42
+ > This is a **note**.
43
43
 
44
44
  > [!TIP]
45
- > This is a helpful tip.
45
+ > This is a **helpful** tip.
46
46
 
47
47
  > [!WARNING]
48
- > This is a warning.
48
+ > This is a **warning**.
49
49
 
50
50
  > [!CAUTION]
51
- > This is a caution message.
51
+ > This is a **caution** message.
52
52
 
53
53
  ## Installation
54
54
 
@@ -61,9 +61,16 @@ group :jekyll_plugins do
61
61
 
62
62
  # ... Add this line:
63
63
  gem "jekyll-gfm-admonitions"
64
+ gem "jekyll-optional-front-matter"
64
65
  end
65
66
  ```
66
67
 
68
+ > [!TIP]
69
+ >
70
+ > By installing `jekyll-optional-front-matter` alongside this package, you won't need to
71
+ > add ([visible](https://github.com/github/markup/issues/994)) frontmatter headers to each
72
+ > of your files.
73
+
67
74
  Then run:
68
75
 
69
76
  ```bash
@@ -77,14 +84,18 @@ Next, you need to enable the plugin in your Jekyll configuration file (`_config.
77
84
  ```yaml
78
85
  plugins:
79
86
  - jekyll-gfm-admonitions
87
+ - jekyll-optional-front-matter
80
88
  ```
81
89
 
82
- Then, during build/serve, you should see a log similar to:
90
+ Then, during `build`/`serve`, you should see logs similar to:
83
91
 
84
92
  ```
85
- GFMA: Converted adminitions in 1 file(s).
93
+ GFMA: Converted adminitions in 36 file(s).
94
+ GFMA: Injecting admonition CSS in 36 page(s).
86
95
  ```
87
96
 
97
+ More details are available by passing the `--verbose` flag to your `jekyll` command.
98
+
88
99
  ## When using GitHub Pages
89
100
 
90
101
  To enable custom plugins in your Jekyll build for GitHub Pages, you need to use GitHub
@@ -92,6 +103,83 @@ Actions (GHA) to build and deploy your Jekyll site. For detailed instructions on
92
103
  up GitHub Actions for your Jekyll project, please follow this link:
93
104
  [GitHub Actions Setup for Jekyll](https://jekyllrb.com/docs/continuous-integration/github-actions/).
94
105
 
106
+ After following the steps you will have to set up a minimal valid Jekyll project.
107
+
108
+ ### Add a `_config.yml`
109
+
110
+ ```yaml
111
+ # Site settings
112
+ title: Your Project Title
113
+ repository: your-username/your-repository
114
+ description: >-
115
+ A description of your project
116
+
117
+ markdown: GFM
118
+ plugins:
119
+ - jekyll-gfm-admonitions
120
+ - jekyll-optional-front-matter
121
+
122
+ exclude:
123
+ - "**/*.ts" # Exclude source code files!
124
+ - "**/*.js"
125
+ - "*.ts" # Also those in the root directory!
126
+ - "*.js"
127
+ - "*.json" # Don't forget about assets!
128
+ - node_modules/ # And large vendored directories
129
+ # And these ignore all the artifacts the build produces:
130
+ - .sass-cache/
131
+ - .jekyll-cache/
132
+ - gemfiles/
133
+ - Gemfile
134
+ - Gemfile.lock
135
+ - vendor/bundle/
136
+ - vendor/cache/
137
+ - vendor/gems/
138
+ - vendor/ruby/
139
+ ```
140
+
141
+ > [!CAUTION]
142
+ >
143
+ > For private repositories, make sure you exclude your source code files from the Jekyll
144
+ > build, or they might be publicly deployed! Also exclude large vendored package
145
+ > directories such as `node_modules/`.
146
+
147
+ ### Add a `Gemfile`:
148
+
149
+ ```ruby
150
+ source 'https://rubygems.org'
151
+
152
+ gem 'jekyll'
153
+ group :jekyll_plugins do
154
+ gem 'jekyll-gfm-admonitions'
155
+ gem 'jekyll-optional-front-matter'
156
+ gem 'github-pages'
157
+ end
158
+ gem 'jekyll-remote-theme'
159
+ ```
160
+
161
+ ### Add [front matter](https://jekyllrb.com/docs/front-matter/)
162
+
163
+ This step is optional if you've added `jekyll-front-matter`. If you do not, any file
164
+ without a front matter header will be ignored by Jekyll, and only partially included by
165
+ the GitHub Pages plugin.
166
+
167
+ Make sure that all your `.md` files begin with a valid front matter header:
168
+
169
+ ```markdown
170
+ ---
171
+ ---
172
+
173
+ Your markdown files should start like this.
174
+ ```
175
+
176
+ > [!IMPORTANT]
177
+ >
178
+ > Your root `README.md` front matter should contain the following `permalink` attribute:
179
+ > ```yaml
180
+ > permalink: /index.html
181
+ > ```
182
+
95
183
  ## License
96
184
 
97
185
  This project is licensed under the MIT License. See the [LICENSE.txt](LICENSE.txt) file
@@ -44,8 +44,12 @@ module JekyllGFMAdmonitions
44
44
 
45
45
  # Process admonitions in pages
46
46
  site.pages.each do |page|
47
+ # Patch the root README for GitHub Pages builds
48
+ if page.path == 'README.md' && page.dir == '/'
49
+ Jekyll.logger.info 'GFMA:', "Patched /README.html to /index.html"
50
+ page.instance_variable_set(:@url, '/index.html')
51
+ end
47
52
  Jekyll.logger.debug 'GFMA:', "Processing page '#{page.path}' (#{page.content.length} characters)."
48
- Jekyll.logger.debug 'GFMA:', "#{page.content.inspect}"
49
53
  process(page)
50
54
  end
51
55
 
@@ -67,6 +71,12 @@ module JekyllGFMAdmonitions
67
71
  end
68
72
 
69
73
  def convert_admonitions(doc)
74
+ code_blocks = []
75
+ doc.content.gsub!(/```.*?```/m) do |match|
76
+ code_blocks << match
77
+ "```{{CODE_BLOCK_#{code_blocks.length - 1}}}```"
78
+ end
79
+
70
80
  doc.content.gsub!(/>\s*\[!(IMPORTANT|NOTE|WARNING|TIP|CAUTION)\]\s*\n((?:>.*\n?)*)/) do
71
81
  type = ::Regexp.last_match(1).downcase
72
82
  title = type.capitalize
@@ -77,7 +87,11 @@ module JekyllGFMAdmonitions
77
87
  "<div class='markdown-alert markdown-alert-#{type}'>
78
88
  <p class='markdown-alert-title'>#{icon} #{title}</p>
79
89
  <p>#{@markdown.convert(text)}</p>
80
- </div>"
90
+ </div>\n\n"
91
+ end
92
+
93
+ doc.content.gsub!(/```\{\{CODE_BLOCK_(\d+)}}```/) do
94
+ "```#{code_blocks[$1.to_i]}```"
81
95
  end
82
96
  end
83
97
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-gfm-admonitions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin De Schepper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-27 00:00:00.000000000 Z
11
+ date: 2024-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll