markdown-it-admon-collapsible 1.9.2 → 1.9.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
- # 1.9.2 (2025-12-26)
1
+ # Changelog
2
+
3
+ ## 1.9.2
4
+
5
+ 2025-12-26
2
6
 
3
7
  - forked from markdown-it-admon
8
+
9
+ ## 1.9.3
10
+
11
+ 2025-12-27
12
+
13
+ - Changed the generated HTML to be more like markdown-it-container
package/index.js CHANGED
@@ -58,19 +58,19 @@ function renderCollapsibleOpen(tokens, idx) {
58
58
  function renderCollapsibleTitleOpen(tokens, idx) {
59
59
  const expanded = tokens[idx - 1]?.meta?.expanded;
60
60
  // Add toggle button
61
- return `<p class="admonition-title"><button class="collapsible-toggle" tabindex="0">${expanded ? '&#x2212;' : '&#x2b;'}</button>`;
61
+ return `<div class="admonition-title"><button class="collapsible-toggle" tabindex="0">${expanded ? '&#x2212;' : '&#x2b;'}</button>`;
62
62
  }
63
63
 
64
64
  function renderCollapsibleTitleClose() {
65
- return '</p>\n';
65
+ return '</div>\n';
66
66
  }
67
67
 
68
68
  function renderCollapsibleContentOpen(tokens, idx) {
69
- return '<div class="collapsible-content">\n';
69
+ return '';
70
70
  }
71
71
 
72
72
  function renderCollapsibleContentClose() {
73
- return '</div>\n';
73
+ return '';
74
74
  }
75
75
 
76
76
 
@@ -166,7 +166,7 @@ function admonition(state, startLine, endLine, silent) {
166
166
 
167
167
  if (title) {
168
168
  const titleMarkup = markup + ' ' + tag;
169
- token = state.push(isCollapsible ? 'collapsible_title_open' : 'admonition_title_open', 'p', 1);
169
+ token = state.push(isCollapsible ? 'collapsible_title_open' : 'admonition_title_open', 'div', 1);
170
170
  token.markup = titleMarkup;
171
171
  token.attrs = [['class', 'admonition-title']];
172
172
  token.map = [startLine, startLine + 1];
@@ -176,7 +176,7 @@ function admonition(state, startLine, endLine, silent) {
176
176
  token.map = [startLine, startLine + 1];
177
177
  token.children = [];
178
178
 
179
- token = state.push(isCollapsible ? 'collapsible_title_close' : 'admonition_title_close', 'p', -1);
179
+ token = state.push(isCollapsible ? 'collapsible_title_close' : 'admonition_title_close', 'div', -1);
180
180
  token.markup = titleMarkup;
181
181
  }
182
182
 
@@ -204,8 +204,7 @@ module.exports = function admonitionPlugin(md, options = {}) {
204
204
 
205
205
  // Collapsible rendering
206
206
  md.renderer.rules.collapsible_open = renderCollapsibleOpen;
207
- md.renderer.rules.collapsible_close = (tokens, idx) => '</div>';
208
- md.renderer.rules.collapsible_close = (tokens, idx) => '</div>\n';
207
+ md.renderer.rules.collapsible_close = (tokens, idx) => '</div>\n';
209
208
  md.renderer.rules.collapsible_title_open = renderCollapsibleTitleOpen;
210
209
  md.renderer.rules.collapsible_title_close = renderCollapsibleTitleClose;
211
210
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdown-it-admon-collapsible",
3
- "version": "1.9.2",
3
+ "version": "1.9.3",
4
4
  "description": "Plugin to create admonitions for markdown-it markdown parser",
5
5
  "keywords": [
6
6
  "admonition",
@@ -28,10 +28,12 @@
28
28
  .collapsible.expanded {
29
29
  /* Optionally highlight expanded state */
30
30
  }
31
- .collapsible-content {
31
+
32
+ /* Hide all siblings of .admonition-title when not expanded */
33
+ .collapsible:not(.expanded) > .admonition-title ~ * {
32
34
  display: none;
33
35
  }
34
- .collapsible.expanded .collapsible-content {
36
+ .collapsible.expanded > .admonition-title ~ * {
35
37
  display: block;
36
38
  }
37
39
  /**
@@ -58,7 +60,9 @@
58
60
  overflow: auto;
59
61
  }
60
62
 
61
- .admonition>p {
63
+
64
+ /* Ensure spacing for first child after .admonition-title (now a div) */
65
+ .admonition > .admonition-title + * {
62
66
  margin-top: .8rem;
63
67
  }
64
68