@rspress-theme-anatole/plugin-container-syntax 0.0.3 → 0.1.30

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 (2) hide show
  1. package/dist/index.js +15 -8
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -2,6 +2,13 @@ import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
2
2
  import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
3
3
  import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress-theme-anatole/shared";
4
4
  const DIRECTIVE_TYPES = [
5
+ 'tip',
6
+ 'note',
7
+ 'warning',
8
+ 'caution',
9
+ 'danger',
10
+ 'info',
11
+ 'details',
5
12
  'tabs'
6
13
  ];
7
14
  const REGEX_BEGIN = /^\s*:::\s*(\w+)\s*(.*)?/;
@@ -9,12 +16,12 @@ const REGEX_END = /\s*:::$/;
9
16
  const REGEX_GH_BEGIN = /^\s*\s*\[!(\w+)\]\s*(.*)?/;
10
17
  const TITLE_REGEX_IN_MD = /{\s*title=["']?(.+)}\s*/;
11
18
  const TITLE_REGEX_IN_MDX = /\s*title=["']?(.+)\s*/;
12
- const trimTailingQuote = (str)=>str.replace(/['"]$/g, '');
13
- const parseTitle = (rawTitle = '', isMDX = false)=>{
19
+ const trimTailingQuote = (str) => str.replace(/['"]$/g, '');
20
+ const parseTitle = (rawTitle = '', isMDX = false) => {
14
21
  const matched = rawTitle?.match(isMDX ? TITLE_REGEX_IN_MDX : TITLE_REGEX_IN_MD);
15
22
  return trimTailingQuote(matched?.[1] || rawTitle);
16
23
  };
17
- const createContainer = (type, title, children)=>{
24
+ const createContainer = (type, title, children) => {
18
25
  const isDetails = 'details' === type;
19
26
  const rootHName = isDetails ? 'details' : 'div';
20
27
  const titleHName = isDetails ? 'summary' : 'div';
@@ -58,7 +65,7 @@ const createContainer = (type, title, children)=>{
58
65
  function transformer(tree) {
59
66
  let i = 0;
60
67
  try {
61
- while(i < tree.children.length){
68
+ while (i < tree.children.length) {
62
69
  const node = tree.children[i];
63
70
  if ('children' in node) transformer(node);
64
71
  if ('containerDirective' === node.type) {
@@ -151,7 +158,7 @@ function transformer(tree) {
151
158
  }
152
159
  if (lastChildInNode !== firstTextNode && wrappedChildren.length) wrappedChildren[0].children.push(lastChildInNode);
153
160
  let j = i + 1;
154
- while(j < tree.children.length){
161
+ while (j < tree.children.length) {
155
162
  const currentParagraph = tree.children[j];
156
163
  if ('paragraph' !== currentParagraph.type) {
157
164
  wrappedChildren.push(currentParagraph);
@@ -162,7 +169,7 @@ function transformer(tree) {
162
169
  if (lastChild === firstTextNode || 'text' === lastChild.type && REGEX_END.test(lastChild.value)) {
163
170
  const lastChildText = lastChild.value;
164
171
  const matchedEndContent = lastChildText.slice(0, -3).trim();
165
- wrappedChildren.push(...currentParagraph.children.filter((child)=>child !== firstTextNode && child !== lastChild));
172
+ wrappedChildren.push(...currentParagraph.children.filter((child) => child !== firstTextNode && child !== lastChild));
166
173
  if (matchedEndContent) wrappedChildren.push({
167
174
  type: 'paragraph',
168
175
  children: [
@@ -178,7 +185,7 @@ function transformer(tree) {
178
185
  }
179
186
  wrappedChildren.push({
180
187
  ...currentParagraph,
181
- children: currentParagraph.children.filter((child)=>child !== firstTextNode)
188
+ children: currentParagraph.children.filter((child) => child !== firstTextNode)
182
189
  });
183
190
  j++;
184
191
  }
@@ -190,7 +197,7 @@ function transformer(tree) {
190
197
  throw e;
191
198
  }
192
199
  }
193
- const remarkPluginContainer = ()=>transformer;
200
+ const remarkPluginContainer = () => transformer;
194
201
  const src_dirname = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.normalizePosixPath)(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(import.meta.url)));
195
202
  function pluginContainerSyntax() {
196
203
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress-theme-anatole/plugin-container-syntax",
3
- "version": "0.0.3",
3
+ "version": "0.1.30",
4
4
  "license": "MIT",
5
5
  "sideEffects": [
6
6
  "*.css",
@@ -17,7 +17,7 @@
17
17
  "container.css"
18
18
  ],
19
19
  "dependencies": {
20
- "@rspress-theme-anatole/shared": "0.1.19"
20
+ "@rspress-theme-anatole/shared": "0.1.30"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@microsoft/api-extractor": "^7.49.2",