jekyll-gfm-admonitions 1.4.1 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll-gfm-admonitions.rb +22 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07e17e25979aa7572958ae2357a07be27183eb6d0a23c6e3f6dbbdb66652da1e
4
- data.tar.gz: 73803ee7ccd91d8d280baa7158787e2bfa170e701b03b39db5946b48f3d61d1d
3
+ metadata.gz: c6910784b96f5dcd1ad72291571d8b2d6bd128ee83a864646e50f9105f5ecf89
4
+ data.tar.gz: 578db5f897f05bbefc2a4db39e8ce35fdb21a4e089e5dfe45bae96449eb684d1
5
5
  SHA512:
6
- metadata.gz: f30a9aa688e29865453add96e1fc1ed43ed60f34fcb7916cfdbc7ee528ae5b80bcd164ce640ebfa5b1422831488934c7f0bd64f785b1afc1279c1928cb9f90ef
7
- data.tar.gz: 9d5368112460487c81e3e7b3dec3f21dcc531adcfd9e847077a23a45936b7b5021615e49a7522492cb5d7435a8036ac28b932b9ea33d3e4b159348168dda82c5
6
+ metadata.gz: faefa50977e2bd6deea394d3d2d883d6ffc356aa6f1912808a29e903cad9b987eab82cd15c3c13a42318ccbf49c51fbfce205fe1016414edffc677802b90df6d
7
+ data.tar.gz: 4211efed84d862d1c278d6db488ae4c2234e09bfd8f12f75dc4863b3493659d736f8f7676276ef0a14bed37d2407b844c5878e936158a563da0f8d5b5038445b
@@ -103,16 +103,30 @@ module JekyllGFMAdmonitions
103
103
  doc.content = doc.content.dup if doc.content.frozen?
104
104
 
105
105
  code_blocks = []
106
- # Temporarily replace code blocks by a tag, so that we don't process any admonitions
107
- # inside of code blocks.
106
+ # Temporarily replace fenced code blocks by a tag, so that we don't process any
107
+ # admonitions inside of code blocks.
108
108
  doc.content.gsub!(/(?:^|\n)(?<!>)\s*```.*?```/m) do |match|
109
109
  code_blocks << match
110
110
  "```{{CODE_BLOCK_#{code_blocks.length - 1}}}```"
111
111
  end
112
112
 
113
+ indented_blocks = []
114
+ # Temporarily replace 4-space/tab indented code blocks (CommonMark §4.4).
115
+ # These must be preceded by a blank line or appear at start of content —
116
+ # indented code blocks cannot interrupt a paragraph.
117
+ doc.content.gsub!(/(\A|\n\n)((?:(?:[ ]{4,}|\t)[^\n]*(?:\n|\z))+)/) do
118
+ anchor = ::Regexp.last_match(1)
119
+ block = ::Regexp.last_match(2)
120
+ indented_blocks << block
121
+ "#{anchor}{{INDENTED_CODE_BLOCK_#{indented_blocks.length - 1}}}"
122
+ end
123
+
113
124
  convert_admonitions(doc)
114
125
 
115
- # Put the code blocks back in place
126
+ # Restore indented code blocks, then fenced code blocks.
127
+ doc.content.gsub!(/\{\{INDENTED_CODE_BLOCK_(\d+)\}\}/) do
128
+ indented_blocks[::Regexp.last_match(1).to_i]
129
+ end
116
130
  doc.content.gsub!(/```\{\{CODE_BLOCK_(\d+)}}```/) do
117
131
  code_blocks[::Regexp.last_match(1).to_i]
118
132
  end
@@ -123,7 +137,11 @@ module JekyllGFMAdmonitions
123
137
  initial_indent = ::Regexp.last_match(1)
124
138
  type = ::Regexp.last_match(2).downcase
125
139
  title = ::Regexp.last_match(3).strip.empty? ? type.capitalize : ::Regexp.last_match(3).strip
126
- text = ::Regexp.last_match(4).gsub(/^#{Regexp.escape(initial_indent)}[^\S\n]*>[^\S\n]*/, '').strip
140
+ # Strip the blockquote prefix from each line. Per CommonMark, a `>`
141
+ # marker consumes at most ONE following space, so we only remove a
142
+ # single space here. Consuming all whitespace would flatten the
143
+ # indentation that distinguishes nested list items (see issue #20).
144
+ text = ::Regexp.last_match(4).gsub(/^#{Regexp.escape(initial_indent)}[^\S\n]*>[^\S\n]?/, '').strip
127
145
 
128
146
  icon = Octicons::Octicon.new(ADMONITION_ICONS[type]).to_svg
129
147
  html = admonition_html(type, title, text, icon)
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: 1.4.1
4
+ version: 1.4.3
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: 2026-03-25 00:00:00.000000000 Z
11
+ date: 2026-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cssminify