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 +11 -1
- package/index.js +7 -8
- package/package.json +1 -1
- package/styles/admonition.css +7 -3
package/CHANGELOG.md
CHANGED
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 `<
|
|
61
|
+
return `<div class="admonition-title"><button class="collapsible-toggle" tabindex="0">${expanded ? '−' : '+'}</button>`;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
function renderCollapsibleTitleClose() {
|
|
65
|
-
return '</
|
|
65
|
+
return '</div>\n';
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
function renderCollapsibleContentOpen(tokens, idx) {
|
|
69
|
-
return '
|
|
69
|
+
return '';
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
function renderCollapsibleContentClose() {
|
|
73
|
-
return '
|
|
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', '
|
|
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', '
|
|
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
package/styles/admonition.css
CHANGED
|
@@ -28,10 +28,12 @@
|
|
|
28
28
|
.collapsible.expanded {
|
|
29
29
|
/* Optionally highlight expanded state */
|
|
30
30
|
}
|
|
31
|
-
|
|
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 .
|
|
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
|
-
|
|
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
|
|