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

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 +9 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2,19 +2,19 @@ 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
- 'tabs'
5
+ 'tabs',
6
6
  ];
7
7
  const REGEX_BEGIN = /^\s*:::\s*(\w+)\s*(.*)?/;
8
8
  const REGEX_END = /\s*:::$/;
9
9
  const REGEX_GH_BEGIN = /^\s*\s*\[!(\w+)\]\s*(.*)?/;
10
10
  const TITLE_REGEX_IN_MD = /{\s*title=["']?(.+)}\s*/;
11
11
  const TITLE_REGEX_IN_MDX = /\s*title=["']?(.+)\s*/;
12
- const trimTailingQuote = (str)=>str.replace(/['"]$/g, '');
13
- const parseTitle = (rawTitle = '', isMDX = false)=>{
12
+ const trimTailingQuote = (str) => str.replace(/['"]$/g, '');
13
+ const parseTitle = (rawTitle = '', isMDX = false) => {
14
14
  const matched = rawTitle?.match(isMDX ? TITLE_REGEX_IN_MDX : TITLE_REGEX_IN_MD);
15
15
  return trimTailingQuote(matched?.[1] || rawTitle);
16
16
  };
17
- const createContainer = (type, title, children)=>{
17
+ const createContainer = (type, title, children) => {
18
18
  const isDetails = 'details' === type;
19
19
  const rootHName = isDetails ? 'details' : 'div';
20
20
  const titleHName = isDetails ? 'summary' : 'div';
@@ -58,7 +58,7 @@ const createContainer = (type, title, children)=>{
58
58
  function transformer(tree) {
59
59
  let i = 0;
60
60
  try {
61
- while(i < tree.children.length){
61
+ while (i < tree.children.length) {
62
62
  const node = tree.children[i];
63
63
  if ('children' in node) transformer(node);
64
64
  if ('containerDirective' === node.type) {
@@ -151,7 +151,7 @@ function transformer(tree) {
151
151
  }
152
152
  if (lastChildInNode !== firstTextNode && wrappedChildren.length) wrappedChildren[0].children.push(lastChildInNode);
153
153
  let j = i + 1;
154
- while(j < tree.children.length){
154
+ while (j < tree.children.length) {
155
155
  const currentParagraph = tree.children[j];
156
156
  if ('paragraph' !== currentParagraph.type) {
157
157
  wrappedChildren.push(currentParagraph);
@@ -162,7 +162,7 @@ function transformer(tree) {
162
162
  if (lastChild === firstTextNode || 'text' === lastChild.type && REGEX_END.test(lastChild.value)) {
163
163
  const lastChildText = lastChild.value;
164
164
  const matchedEndContent = lastChildText.slice(0, -3).trim();
165
- wrappedChildren.push(...currentParagraph.children.filter((child)=>child !== firstTextNode && child !== lastChild));
165
+ wrappedChildren.push(...currentParagraph.children.filter((child) => child !== firstTextNode && child !== lastChild));
166
166
  if (matchedEndContent) wrappedChildren.push({
167
167
  type: 'paragraph',
168
168
  children: [
@@ -178,7 +178,7 @@ function transformer(tree) {
178
178
  }
179
179
  wrappedChildren.push({
180
180
  ...currentParagraph,
181
- children: currentParagraph.children.filter((child)=>child !== firstTextNode)
181
+ children: currentParagraph.children.filter((child) => child !== firstTextNode)
182
182
  });
183
183
  j++;
184
184
  }
@@ -190,7 +190,7 @@ function transformer(tree) {
190
190
  throw e;
191
191
  }
192
192
  }
193
- const remarkPluginContainer = ()=>transformer;
193
+ const remarkPluginContainer = () => transformer;
194
194
  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
195
  function pluginContainerSyntax() {
196
196
  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.0.4",
4
4
  "license": "MIT",
5
5
  "sideEffects": [
6
6
  "*.css",