Bläddra i källkod

remove directive-container

Yuki Takei 3 år sedan
förälder
incheckning
5d4a7cc532

+ 3 - 6
packages/remark-growi-plugin/readme.md

@@ -138,8 +138,7 @@ function myRemarkPlugin() {
     visit(tree, (node) => {
       if (
         node.type === 'textGrowiPluginDirective' ||
-        node.type === 'leafGrowiPluginDirective' ||
-        node.type === 'containerGrowiPluginDirective'
+        node.type === 'leafGrowiPluginDirective'
       ) {
         const data = node.data || (node.data = {})
         const hast = h(node.name, node.attributes)
@@ -189,8 +188,7 @@ function myRemarkPlugin() {
     visit(tree, (node) => {
       if (
         node.type === 'textGrowiPluginDirective' ||
-        node.type === 'leafGrowiPluginDirective' ||
-        node.type === 'containerGrowiPluginDirective'
+        node.type === 'leafGrowiPluginDirective'
       ) {
         if (node.name !== 'youtube') return
 
@@ -248,8 +246,7 @@ function myRemarkPlugin() {
     visit(tree, (node) => {
       if (
         node.type === 'textGrowiPluginDirective' ||
-        node.type === 'leafGrowiPluginDirective' ||
-        node.type === 'containerGrowiPluginDirective'
+        node.type === 'leafGrowiPluginDirective'
       ) {
         if (node.name !== 'note') return
 

+ 0 - 6
packages/remark-growi-plugin/src/mdast-util-growi-plugin/complex-types.d.ts

@@ -18,18 +18,12 @@ export interface LeafDirective extends Parent, DirectiveFields {
   children: PhrasingContent[]
 }
 
-export interface ContainerDirective extends Parent, DirectiveFields {
-  type: 'containerGrowiPluginDirective'
-  children: BlockContent[]
-}
-
 declare module 'mdast' {
   interface StaticPhrasingContentMap {
     textGrowiPluginDirective: TextDirective
   }
 
   interface BlockContentMap {
-    containerGrowiPluginDirective: ContainerDirective
     leafGrowiPluginDirective: LeafDirective
   }
 }

+ 5 - 87
packages/remark-growi-plugin/src/mdast-util-growi-plugin/index.js

@@ -9,14 +9,12 @@
  * @typedef {import('mdast-util-to-markdown/lib/types.js').Handle} ToMarkdownHandle
  * @typedef {import('mdast-util-to-markdown/lib/types.js').Context} Context
  * @typedef {import('mdast-util-to-markdown/lib/types.js').Options} ToMarkdownExtension
- * @typedef {import('./complex-types').ContainerDirective} ContainerDirective
  * @typedef {import('./complex-types').LeafDirective} LeafDirective
  * @typedef {import('./complex-types').TextDirective} TextDirective
- * @typedef {ContainerDirective|LeafDirective|TextDirective} Directive
+ * @typedef {LeafDirective|TextDirective} Directive
  */
 
 import { checkQuote } from 'mdast-util-to-markdown/lib/util/check-quote.js';
-import { containerFlow } from 'mdast-util-to-markdown/lib/util/container-flow.js';
 import { containerPhrasing } from 'mdast-util-to-markdown/lib/util/container-phrasing.js';
 import { track } from 'mdast-util-to-markdown/lib/util/track.js';
 import { parseEntities } from 'parse-entities';
@@ -33,10 +31,6 @@ handleDirective.peek = peekDirective;
 export const directiveFromMarkdown = {
   canContainEols: ['textGrowiPluginDirective'],
   enter: {
-    directiveContainer: enterContainer,
-    directiveContainerAttributes: enterAttributes,
-    directiveContainerLabel: enterContainerLabel,
-
     directiveLeaf: enterLeaf,
     directiveLeafAttributes: enterAttributes,
 
@@ -44,15 +38,6 @@ export const directiveFromMarkdown = {
     directiveTextAttributes: enterAttributes,
   },
   exit: {
-    directiveContainer: exit,
-    directiveContainerAttributeClassValue: exitAttributeClassValue,
-    directiveContainerAttributeIdValue: exitAttributeIdValue,
-    directiveContainerAttributeName: exitAttributeName,
-    directiveContainerAttributeValue: exitAttributeValue,
-    directiveContainerAttributes: exitAttributes,
-    directiveContainerLabel: exitContainerLabel,
-    directiveContainerName: exitName,
-
     directiveLeaf: exit,
     directiveLeafAttributeClassValue: exitAttributeClassValue,
     directiveLeafAttributeIdValue: exitAttributeIdValue,
@@ -76,11 +61,11 @@ export const directiveToMarkdown = {
   unsafe: [
     {
       character: '\r',
-      inConstruct: ['leafGrowiPluginDirectiveLabel', 'containerGrowiPluginDirectiveLabel'],
+      inConstruct: ['leafGrowiPluginDirectiveLabel'],
     },
     {
       character: '\n',
-      inConstruct: ['leafGrowiPluginDirectiveLabel', 'containerGrowiPluginDirectiveLabel'],
+      inConstruct: ['leafGrowiPluginDirectiveLabel'],
     },
     {
       before: '[^$]',
@@ -91,17 +76,11 @@ export const directiveToMarkdown = {
     { atBreak: true, character: '$', after: '$' },
   ],
   handlers: {
-    containerGrowiPluginDirective: handleDirective,
     leafGrowiPluginDirective: handleDirective,
     textGrowiPluginDirective: handleDirective,
   },
 };
 
-/** @type {FromMarkdownHandle} */
-function enterContainer(token) {
-  enter.call(this, 'containerGrowiPluginDirective', token);
-}
-
 /** @type {FromMarkdownHandle} */
 function enterLeaf(token) {
   enter.call(this, 'leafGrowiPluginDirective', token);
@@ -132,19 +111,6 @@ function exitName(token) {
   node.name = this.sliceSerialize(token);
 }
 
-/** @type {FromMarkdownHandle} */
-function enterContainerLabel(token) {
-  this.enter(
-    { type: 'paragraph', data: { directiveLabel: true }, children: [] },
-    token,
-  );
-}
-
-/** @type {FromMarkdownHandle} */
-function exitContainerLabel(token) {
-  this.exit(token);
-}
-
 /** @type {FromMarkdownHandle} */
 function enterAttributes() {
   this.setData('directiveAttributes', []);
@@ -227,12 +193,7 @@ function handleDirective(node, _, context, safeOptions) {
   const exit = context.enter(node.type);
   let value = tracker.move(sequence + (node.name || ''));
   /** @type {Directive|Paragraph|undefined} */
-  let label = node;
-
-  if (node.type === 'containerGrowiPluginDirective') {
-    const head = (node.children || [])[0];
-    label = inlineDirectiveLabel(head) ? head : undefined;
-  }
+  const label = node;
 
   if (label && label.children && label.children.length > 0) {
     const exit = context.enter('label');
@@ -252,22 +213,6 @@ function handleDirective(node, _, context, safeOptions) {
 
   value += tracker.move(attributes(node, context));
 
-  if (node.type === 'containerGrowiPluginDirective') {
-    const head = (node.children || [])[0];
-    let shallow = node;
-
-    if (inlineDirectiveLabel(head)) {
-      shallow = Object.assign({}, node, { children: node.children.slice(1) });
-    }
-
-    if (shallow && shallow.children && shallow.children.length > 0) {
-      value += tracker.move('\n');
-      value += tracker.move(containerFlow(shallow, context, tracker.current()));
-    }
-
-    value += tracker.move(`\n${sequence}`);
-  }
-
   exit();
   return value;
 }
@@ -363,16 +308,6 @@ function attributes(node, context) {
   }
 }
 
-/**
- * @param {BlockContent} node
- * @returns {node is Paragraph & {data: {directiveLabel: boolean}}}
- */
-function inlineDirectiveLabel(node) {
-  return Boolean(
-    node && node.type === 'paragraph' && node.data && node.data.directiveLabel,
-  );
-}
-
 /**
  * @param {Directive} node
  * @returns {string}
@@ -380,11 +315,7 @@ function inlineDirectiveLabel(node) {
 function fence(node) {
   let size = 0;
 
-  if (node.type === 'containerGrowiPluginDirective') {
-    visitParents(node, 'containerGrowiPluginDirective', onvisit);
-    size += 3;
-  }
-  else if (node.type === 'leafGrowiPluginDirective') {
+  if (node.type === 'leafGrowiPluginDirective') {
     size = 1;
   }
   else {
@@ -393,17 +324,4 @@ function fence(node) {
 
   return '$'.repeat(size);
 
-  /** @type {import('unist-util-visit-parents/complex-types').BuildVisitor<Root, Directive>} */
-  function onvisit(_, parents) {
-    let index = parents.length;
-    let nesting = 0;
-
-    while (index--) {
-      if (parents[index].type === 'containerGrowiPluginDirective') {
-        nesting++;
-      }
-    }
-
-    if (nesting > size) size = nesting;
-  }
 }

+ 1 - 45
packages/remark-growi-plugin/src/mdast-util-growi-plugin/readme.md

@@ -239,51 +239,7 @@ Yields:
 
 #### `ContainerDirective`
 
-```idl
-interface ContainerDirective <: Parent {
-  type: 'containerGrowiPluginDirective'
-  children: [FlowContent]
-}
-
-ContainerDirective includes Directive
-```
-
-**ContainerDirective** (**[Parent][dfn-parent]**) is a directive.
-It can be used where **[flow][dfn-flow-content]** content is expected.
-Its content model is also **[flow][dfn-flow-content]** content.
-It includes the mixin **[Directive][dfn-mxn-directive]**.
-
-The phrasing in the label is, when available, added as a paragraph with a
-`directiveLabel: true` field, as the head of its content.
-
-For example, the following Markdown:
-
-```markdown
-:::spoiler[Open at your own peril]
-He dies.
-:::
-```
-
-Yields:
-
-```js
-{
-  type: 'containerGrowiPluginDirective',
-  name: 'spoiler',
-  attributes: {},
-  children: [
-    {
-      type: 'paragraph',
-      data: {directiveLabel: true},
-      children: [{type: 'text', value: 'Open at your own peril'}]
-    },
-    {
-      type: 'paragraph',
-      children: [{type: 'text', value: 'He dies.'}]
-    }
-  ]
-}
-```
+ContainerDirective is not supported.
 
 ### Mixin
 

+ 0 - 296
packages/remark-growi-plugin/src/micromark-extension-growi-plugin/lib/directive-container.js

@@ -1,296 +0,0 @@
-/**
- * @typedef {import('micromark-util-types').Construct} Construct
- * @typedef {import('micromark-util-types').Tokenizer} Tokenizer
- * @typedef {import('micromark-util-types').State} State
- * @typedef {import('micromark-util-types').Token} Token
- */
-
-import { factorySpace } from 'micromark-factory-space';
-import { markdownLineEnding } from 'micromark-util-character';
-import { codes } from 'micromark-util-symbol/codes.js';
-import { constants } from 'micromark-util-symbol/constants.js';
-import { types } from 'micromark-util-symbol/types.js';
-import { ok as assert } from 'uvu/assert';
-
-import { factoryAttributes } from './factory-attributes.js';
-import { factoryLabel } from './factory-label.js';
-import { factoryName } from './factory-name.js';
-
-/** @type {Construct} */
-export const directiveContainer = {
-  tokenize: tokenizeDirectiveContainer,
-  concrete: true,
-};
-
-const label = { tokenize: tokenizeLabel, partial: true };
-const attributes = { tokenize: tokenizeAttributes, partial: true };
-const nonLazyLine = { tokenize: tokenizeNonLazyLine, partial: true };
-
-/** @type {Tokenizer} */
-function tokenizeDirectiveContainer(effects, ok, nok) {
-  // eslint-disable-next-line @typescript-eslint/no-this-alias
-  const self = this;
-  const tail = self.events[self.events.length - 1];
-  const initialSize = tail && tail[1].type === types.linePrefix
-    ? tail[2].sliceSerialize(tail[1], true).length
-    : 0;
-  let sizeOpen = 0;
-  /** @type {Token} */
-  let previous;
-
-  return start;
-
-  /** @type {State} */
-  function start(code) {
-    assert(code === codes.dollarSign, 'expected `$`');
-    effects.enter('directiveContainer');
-    effects.enter('directiveContainerFence');
-    effects.enter('directiveContainerSequence');
-    return sequenceOpen(code);
-  }
-
-  /** @type {State} */
-  function sequenceOpen(code) {
-    if (code === codes.dollarSign) {
-      effects.consume(code);
-      sizeOpen++;
-      return sequenceOpen;
-    }
-
-    if (sizeOpen < constants.codeFencedSequenceSizeMin) {
-      return nok(code);
-    }
-
-    effects.exit('directiveContainerSequence');
-    return factoryName.call(
-      self,
-      effects,
-      afterName,
-      nok,
-      'directiveContainerName',
-    )(code);
-  }
-
-  /** @type {State} */
-  function afterName(code) {
-    return code === codes.leftSquareBracket
-      ? effects.attempt(label, afterLabel, afterLabel)(code)
-      : afterLabel(code);
-  }
-
-  /** @type {State} */
-  function afterLabel(code) {
-    return code === codes.leftCurlyBrace
-      ? effects.attempt(attributes, afterAttributes, afterAttributes)(code)
-      : afterAttributes(code);
-  }
-
-  /** @type {State} */
-  function afterAttributes(code) {
-    return factorySpace(effects, openAfter, types.whitespace)(code);
-  }
-
-  /** @type {State} */
-  function openAfter(code) {
-    effects.exit('directiveContainerFence');
-
-    if (code === codes.eof) {
-      return afterOpening(code);
-    }
-
-    if (markdownLineEnding(code)) {
-      if (self.interrupt) {
-        return ok(code);
-      }
-
-      return effects.attempt(nonLazyLine, contentStart, afterOpening)(code);
-    }
-
-    return nok(code);
-  }
-
-  /** @type {State} */
-  function afterOpening(code) {
-    effects.exit('directiveContainer');
-    return ok(code);
-  }
-
-  /** @type {State} */
-  function contentStart(code) {
-    if (code === codes.eof) {
-      effects.exit('directiveContainer');
-      return ok(code);
-    }
-
-    effects.enter('directiveContainerContent');
-    return lineStart(code);
-  }
-
-  /** @type {State} */
-  function lineStart(code) {
-    if (code === codes.eof) {
-      return after(code);
-    }
-
-    return effects.attempt(
-      { tokenize: tokenizeClosingFence, partial: true },
-      after,
-      initialSize
-        ? factorySpace(effects, chunkStart, types.linePrefix, initialSize + 1)
-        : chunkStart,
-    )(code);
-  }
-
-  /** @type {State} */
-  function chunkStart(code) {
-    if (code === codes.eof) {
-      return after(code);
-    }
-
-    const token = effects.enter(types.chunkDocument, {
-      contentType: constants.contentTypeDocument,
-      previous,
-    });
-    if (previous) previous.next = token;
-    previous = token;
-    return contentContinue(code);
-  }
-
-  /** @type {State} */
-  function contentContinue(code) {
-    if (code === codes.eof) {
-      const t = effects.exit(types.chunkDocument);
-      self.parser.lazy[t.start.line] = false;
-      return after(code);
-    }
-
-    if (markdownLineEnding(code)) {
-      return effects.check(nonLazyLine, nonLazyLineAfter, lineAfter)(code);
-    }
-
-    effects.consume(code);
-    return contentContinue;
-  }
-
-  /** @type {State} */
-  function nonLazyLineAfter(code) {
-    effects.consume(code);
-    const t = effects.exit(types.chunkDocument);
-    self.parser.lazy[t.start.line] = false;
-    return lineStart;
-  }
-
-  /** @type {State} */
-  function lineAfter(code) {
-    const t = effects.exit(types.chunkDocument);
-    self.parser.lazy[t.start.line] = false;
-    return after(code);
-  }
-
-  /** @type {State} */
-  function after(code) {
-    effects.exit('directiveContainerContent');
-    effects.exit('directiveContainer');
-    return ok(code);
-  }
-
-  /** @type {Tokenizer} */
-  function tokenizeClosingFence(effects, ok, nok) {
-    let size = 0;
-
-    return factorySpace(
-      effects,
-      closingPrefixAfter,
-      types.linePrefix,
-      constants.tabSize,
-    );
-
-    /** @type {State} */
-    function closingPrefixAfter(code) {
-      effects.enter('directiveContainerFence');
-      effects.enter('directiveContainerSequence');
-      return closingSequence(code);
-    }
-
-    /** @type {State} */
-    function closingSequence(code) {
-      if (code === codes.dollarSign) {
-        effects.consume(code);
-        size++;
-        return closingSequence;
-      }
-
-      if (size < sizeOpen) return nok(code);
-      effects.exit('directiveContainerSequence');
-      return factorySpace(effects, closingSequenceEnd, types.whitespace)(code);
-    }
-
-    /** @type {State} */
-    function closingSequenceEnd(code) {
-      if (code === codes.eof || markdownLineEnding(code)) {
-        effects.exit('directiveContainerFence');
-        return ok(code);
-      }
-
-      return nok(code);
-    }
-  }
-}
-
-/** @type {Tokenizer} */
-function tokenizeLabel(effects, ok, nok) {
-  // Always a `[`
-  return factoryLabel(
-    effects,
-    ok,
-    nok,
-    'directiveContainerLabel',
-    'directiveContainerLabelMarker',
-    'directiveContainerLabelString',
-    true,
-  );
-}
-
-/** @type {Tokenizer} */
-function tokenizeAttributes(effects, ok, nok) {
-  // Always a `{`
-  return factoryAttributes(
-    effects,
-    ok,
-    nok,
-    'directiveContainerAttributes',
-    'directiveContainerAttributesMarker',
-    'directiveContainerAttribute',
-    'directiveContainerAttributeId',
-    'directiveContainerAttributeClass',
-    'directiveContainerAttributeName',
-    'directiveContainerAttributeInitializerMarker',
-    'directiveContainerAttributeValueLiteral',
-    'directiveContainerAttributeValue',
-    'directiveContainerAttributeValueMarker',
-    'directiveContainerAttributeValueData',
-    true,
-  );
-}
-
-/** @type {Tokenizer} */
-function tokenizeNonLazyLine(effects, ok, nok) {
-  // eslint-disable-next-line @typescript-eslint/no-this-alias
-  const self = this;
-
-  return start;
-
-  /** @type {State} */
-  function start(code) {
-    assert(markdownLineEnding(code), 'expected eol');
-    effects.enter(types.lineEnding);
-    effects.consume(code);
-    effects.exit(types.lineEnding);
-    return lineStart;
-  }
-
-  /** @type {State} */
-  function lineStart(code) {
-    return self.parser.lazy[self.now().line] ? nok(code) : ok(code);
-  }
-}

+ 1 - 38
packages/remark-growi-plugin/src/micromark-extension-growi-plugin/lib/html.js

@@ -6,7 +6,7 @@
 
 /**
  * @typedef {[string, string]} Attribute
- * @typedef {'containerGrowiPluginDirective'|'leafGrowiPluginDirective'|'textGrowiPluginDirective'} DirectiveType
+ * @typedef {'leafGrowiPluginDirective'|'textGrowiPluginDirective'} DirectiveType
  *
  * @typedef Directive
  * @property {DirectiveType} type
@@ -33,14 +33,6 @@ const own = {}.hasOwnProperty;
 export function directiveHtml(options = {}) {
   return {
     enter: {
-      directiveContainer() {
-        return enter.call(this, 'containerGrowiPluginDirective');
-      },
-      directiveContainerAttributes: enterAttributes,
-      directiveContainerLabel: enterLabel,
-      directiveContainerContent() {
-        this.buffer();
-      },
 
       directiveLeaf() {
         return enter.call(this, 'leafGrowiPluginDirective');
@@ -55,17 +47,6 @@ export function directiveHtml(options = {}) {
       directiveTextLabel: enterLabel,
     },
     exit: {
-      directiveContainer: exit,
-      directiveContainerAttributeClassValue: exitAttributeClassValue,
-      directiveContainerAttributeIdValue: exitAttributeIdValue,
-      directiveContainerAttributeName: exitAttributeName,
-      directiveContainerAttributeValue: exitAttributeValue,
-      directiveContainerAttributes: exitAttributes,
-      directiveContainerContent: exitContainerContent,
-      directiveContainerFence: exitContainerFence,
-      directiveContainerLabel: exitLabel,
-      directiveContainerName: exitName,
-
       directiveLeaf: exit,
       directiveLeafAttributeClassValue: exitAttributeClassValue,
       directiveLeafAttributeIdValue: exitAttributeIdValue,
@@ -185,24 +166,6 @@ export function directiveHtml(options = {}) {
     stack[stack.length - 1].attributes = cleaned;
   }
 
-  /** @type {_Handle} */
-  function exitContainerContent() {
-    const data = this.resume();
-    /** @type {Directive[]} */
-    const stack = this.getData('directiveStack');
-    stack[stack.length - 1].content = data;
-  }
-
-  /** @type {_Handle} */
-  function exitContainerFence() {
-    /** @type {Directive[]} */
-    const stack = this.getData('directiveStack');
-    const directive = stack[stack.length - 1];
-    if (!directive._fenceCount) directive._fenceCount = 0;
-    directive._fenceCount++;
-    if (directive._fenceCount === 1) this.setData('slurpOneLineEnding', true);
-  }
-
   /** @type {_Handle} */
   function exit() {
     /** @type {Directive} */

+ 1 - 2
packages/remark-growi-plugin/src/micromark-extension-growi-plugin/lib/syntax.js

@@ -4,7 +4,6 @@
 
 import { codes } from 'micromark-util-symbol/codes.js';
 
-import { directiveContainer } from './directive-container.js';
 import { directiveLeaf } from './directive-leaf.js';
 import { directiveText } from './directive-text.js';
 
@@ -14,6 +13,6 @@ import { directiveText } from './directive-text.js';
 export function directive() {
   return {
     text: { [codes.dollarSign]: directiveText },
-    flow: { [codes.dollarSign]: [directiveContainer, directiveLeaf] },
+    flow: { [codes.dollarSign]: [directiveLeaf] },
   };
 }

+ 1 - 1
packages/remark-growi-plugin/src/micromark-extension-growi-plugin/readme.md

@@ -120,7 +120,7 @@ An object representing a directive.
 
 ###### Fields
 
-*   `type` (`'textGrowiPluginDirective'|'leafGrowiPluginDirective'|'containerGrowiPluginDirective'`)
+*   `type` (`'textGrowiPluginDirective'|'leafGrowiPluginDirective'`)
 *   `name` (`string`) — name of directive
 *   `label` (`string?`) — compiled HTML content that was in `[brackets]`
 *   `attributes` (`Record<string, string>?`) — object w/ HTML attributes

+ 0 - 32
packages/remark-growi-plugin/test/fixtures/container/input.md

@@ -1,32 +0,0 @@
-:::a
-:::
-
-:::a[b]
-:::
-
-:::a{b}
-:::
-
-:::a[b]{c}
-:::
-
-:::a[b *c* d **e**]
-:::
-
-:::a{#b.c.d id=e class="f g" h="i &amp; j k"}
-:::
-
-:::::a
-::::b
-:::c
-:::::
-
-:::::a
-b
-::::c
-d
-:::e
-- - f
-:::
-> g h
-:::::

+ 0 - 38
packages/remark-growi-plugin/test/fixtures/container/output.md

@@ -1,38 +0,0 @@
-:::a
-:::
-
-:::a[b]
-:::
-
-:::a{b}
-:::
-
-:::a[b]{c}
-:::
-
-:::a[b *c* d **e**]
-:::
-
-:::a{#e .c.d.f.g h="i & j k"}
-:::
-
-:::::a
-::::b
-:::c
-:::
-::::
-:::::
-
-:::::a
-b
-
-::::c
-d
-
-:::e
-*   *   f
-:::
-
-> g h
-::::
-:::::

+ 0 - 666
packages/remark-growi-plugin/test/fixtures/container/tree.json

@@ -1,666 +0,0 @@
-{
-  "type": "root",
-  "children": [
-    {
-      "type": "containerGrowiPluginDirective",
-      "name": "a",
-      "attributes": {},
-      "children": [],
-      "position": {
-        "start": {
-          "line": 1,
-          "column": 1,
-          "offset": 0
-        },
-        "end": {
-          "line": 2,
-          "column": 4,
-          "offset": 8
-        }
-      }
-    },
-    {
-      "type": "containerGrowiPluginDirective",
-      "name": "a",
-      "attributes": {},
-      "children": [
-        {
-          "type": "paragraph",
-          "data": {
-            "directiveLabel": true
-          },
-          "children": [
-            {
-              "type": "text",
-              "value": "b",
-              "position": {
-                "start": {
-                  "line": 4,
-                  "column": 6,
-                  "offset": 15
-                },
-                "end": {
-                  "line": 4,
-                  "column": 7,
-                  "offset": 16
-                }
-              }
-            }
-          ],
-          "position": {
-            "start": {
-              "line": 4,
-              "column": 5,
-              "offset": 14
-            },
-            "end": {
-              "line": 4,
-              "column": 8,
-              "offset": 17
-            }
-          }
-        }
-      ],
-      "position": {
-        "start": {
-          "line": 4,
-          "column": 1,
-          "offset": 10
-        },
-        "end": {
-          "line": 5,
-          "column": 4,
-          "offset": 21
-        }
-      }
-    },
-    {
-      "type": "containerGrowiPluginDirective",
-      "name": "a",
-      "attributes": {
-        "b": ""
-      },
-      "children": [],
-      "position": {
-        "start": {
-          "line": 7,
-          "column": 1,
-          "offset": 23
-        },
-        "end": {
-          "line": 8,
-          "column": 4,
-          "offset": 34
-        }
-      }
-    },
-    {
-      "type": "containerGrowiPluginDirective",
-      "name": "a",
-      "attributes": {
-        "c": ""
-      },
-      "children": [
-        {
-          "type": "paragraph",
-          "data": {
-            "directiveLabel": true
-          },
-          "children": [
-            {
-              "type": "text",
-              "value": "b",
-              "position": {
-                "start": {
-                  "line": 10,
-                  "column": 6,
-                  "offset": 41
-                },
-                "end": {
-                  "line": 10,
-                  "column": 7,
-                  "offset": 42
-                }
-              }
-            }
-          ],
-          "position": {
-            "start": {
-              "line": 10,
-              "column": 5,
-              "offset": 40
-            },
-            "end": {
-              "line": 10,
-              "column": 8,
-              "offset": 43
-            }
-          }
-        }
-      ],
-      "position": {
-        "start": {
-          "line": 10,
-          "column": 1,
-          "offset": 36
-        },
-        "end": {
-          "line": 11,
-          "column": 4,
-          "offset": 50
-        }
-      }
-    },
-    {
-      "type": "containerGrowiPluginDirective",
-      "name": "a",
-      "attributes": {},
-      "children": [
-        {
-          "type": "paragraph",
-          "data": {
-            "directiveLabel": true
-          },
-          "children": [
-            {
-              "type": "text",
-              "value": "b ",
-              "position": {
-                "start": {
-                  "line": 13,
-                  "column": 6,
-                  "offset": 57
-                },
-                "end": {
-                  "line": 13,
-                  "column": 8,
-                  "offset": 59
-                }
-              }
-            },
-            {
-              "type": "emphasis",
-              "children": [
-                {
-                  "type": "text",
-                  "value": "c",
-                  "position": {
-                    "start": {
-                      "line": 13,
-                      "column": 9,
-                      "offset": 60
-                    },
-                    "end": {
-                      "line": 13,
-                      "column": 10,
-                      "offset": 61
-                    }
-                  }
-                }
-              ],
-              "position": {
-                "start": {
-                  "line": 13,
-                  "column": 8,
-                  "offset": 59
-                },
-                "end": {
-                  "line": 13,
-                  "column": 11,
-                  "offset": 62
-                }
-              }
-            },
-            {
-              "type": "text",
-              "value": " d ",
-              "position": {
-                "start": {
-                  "line": 13,
-                  "column": 11,
-                  "offset": 62
-                },
-                "end": {
-                  "line": 13,
-                  "column": 14,
-                  "offset": 65
-                }
-              }
-            },
-            {
-              "type": "strong",
-              "children": [
-                {
-                  "type": "text",
-                  "value": "e",
-                  "position": {
-                    "start": {
-                      "line": 13,
-                      "column": 16,
-                      "offset": 67
-                    },
-                    "end": {
-                      "line": 13,
-                      "column": 17,
-                      "offset": 68
-                    }
-                  }
-                }
-              ],
-              "position": {
-                "start": {
-                  "line": 13,
-                  "column": 14,
-                  "offset": 65
-                },
-                "end": {
-                  "line": 13,
-                  "column": 19,
-                  "offset": 70
-                }
-              }
-            }
-          ],
-          "position": {
-            "start": {
-              "line": 13,
-              "column": 5,
-              "offset": 56
-            },
-            "end": {
-              "line": 13,
-              "column": 20,
-              "offset": 71
-            }
-          }
-        }
-      ],
-      "position": {
-        "start": {
-          "line": 13,
-          "column": 1,
-          "offset": 52
-        },
-        "end": {
-          "line": 14,
-          "column": 4,
-          "offset": 75
-        }
-      }
-    },
-    {
-      "type": "containerGrowiPluginDirective",
-      "name": "a",
-      "attributes": {
-        "id": "e",
-        "class": "c d f g",
-        "h": "i & j k"
-      },
-      "children": [],
-      "position": {
-        "start": {
-          "line": 16,
-          "column": 1,
-          "offset": 77
-        },
-        "end": {
-          "line": 17,
-          "column": 4,
-          "offset": 126
-        }
-      }
-    },
-    {
-      "type": "containerGrowiPluginDirective",
-      "name": "a",
-      "attributes": {},
-      "children": [
-        {
-          "type": "containerGrowiPluginDirective",
-          "name": "b",
-          "attributes": {},
-          "children": [
-            {
-              "type": "containerGrowiPluginDirective",
-              "name": "c",
-              "attributes": {},
-              "children": [],
-              "position": {
-                "start": {
-                  "line": 21,
-                  "column": 1,
-                  "offset": 141
-                },
-                "end": {
-                  "line": 22,
-                  "column": 1,
-                  "offset": 146
-                }
-              }
-            }
-          ],
-          "position": {
-            "start": {
-              "line": 20,
-              "column": 1,
-              "offset": 135
-            },
-            "end": {
-              "line": 22,
-              "column": 1,
-              "offset": 146
-            }
-          }
-        }
-      ],
-      "position": {
-        "start": {
-          "line": 19,
-          "column": 1,
-          "offset": 128
-        },
-        "end": {
-          "line": 22,
-          "column": 6,
-          "offset": 151
-        }
-      }
-    },
-    {
-      "type": "containerGrowiPluginDirective",
-      "name": "a",
-      "attributes": {},
-      "children": [
-        {
-          "type": "paragraph",
-          "children": [
-            {
-              "type": "text",
-              "value": "b",
-              "position": {
-                "start": {
-                  "line": 25,
-                  "column": 1,
-                  "offset": 160
-                },
-                "end": {
-                  "line": 25,
-                  "column": 2,
-                  "offset": 161
-                }
-              }
-            }
-          ],
-          "position": {
-            "start": {
-              "line": 25,
-              "column": 1,
-              "offset": 160
-            },
-            "end": {
-              "line": 25,
-              "column": 2,
-              "offset": 161
-            }
-          }
-        },
-        {
-          "type": "containerGrowiPluginDirective",
-          "name": "c",
-          "attributes": {},
-          "children": [
-            {
-              "type": "paragraph",
-              "children": [
-                {
-                  "type": "text",
-                  "value": "d",
-                  "position": {
-                    "start": {
-                      "line": 27,
-                      "column": 1,
-                      "offset": 168
-                    },
-                    "end": {
-                      "line": 27,
-                      "column": 2,
-                      "offset": 169
-                    }
-                  }
-                }
-              ],
-              "position": {
-                "start": {
-                  "line": 27,
-                  "column": 1,
-                  "offset": 168
-                },
-                "end": {
-                  "line": 27,
-                  "column": 2,
-                  "offset": 169
-                }
-              }
-            },
-            {
-              "type": "containerGrowiPluginDirective",
-              "name": "e",
-              "attributes": {},
-              "children": [
-                {
-                  "type": "list",
-                  "ordered": false,
-                  "start": null,
-                  "spread": false,
-                  "children": [
-                    {
-                      "type": "listItem",
-                      "spread": false,
-                      "checked": null,
-                      "children": [
-                        {
-                          "type": "list",
-                          "ordered": false,
-                          "start": null,
-                          "spread": false,
-                          "children": [
-                            {
-                              "type": "listItem",
-                              "spread": false,
-                              "checked": null,
-                              "children": [
-                                {
-                                  "type": "paragraph",
-                                  "children": [
-                                    {
-                                      "type": "text",
-                                      "value": "f",
-                                      "position": {
-                                        "start": {
-                                          "line": 29,
-                                          "column": 5,
-                                          "offset": 179
-                                        },
-                                        "end": {
-                                          "line": 29,
-                                          "column": 6,
-                                          "offset": 180
-                                        }
-                                      }
-                                    }
-                                  ],
-                                  "position": {
-                                    "start": {
-                                      "line": 29,
-                                      "column": 5,
-                                      "offset": 179
-                                    },
-                                    "end": {
-                                      "line": 29,
-                                      "column": 6,
-                                      "offset": 180
-                                    }
-                                  }
-                                }
-                              ],
-                              "position": {
-                                "start": {
-                                  "line": 29,
-                                  "column": 3,
-                                  "offset": 177
-                                },
-                                "end": {
-                                  "line": 29,
-                                  "column": 6,
-                                  "offset": 180
-                                }
-                              }
-                            }
-                          ],
-                          "position": {
-                            "start": {
-                              "line": 29,
-                              "column": 3,
-                              "offset": 177
-                            },
-                            "end": {
-                              "line": 29,
-                              "column": 6,
-                              "offset": 180
-                            }
-                          }
-                        }
-                      ],
-                      "position": {
-                        "start": {
-                          "line": 29,
-                          "column": 1,
-                          "offset": 175
-                        },
-                        "end": {
-                          "line": 29,
-                          "column": 6,
-                          "offset": 180
-                        }
-                      }
-                    }
-                  ],
-                  "position": {
-                    "start": {
-                      "line": 29,
-                      "column": 1,
-                      "offset": 175
-                    },
-                    "end": {
-                      "line": 29,
-                      "column": 6,
-                      "offset": 180
-                    }
-                  }
-                }
-              ],
-              "position": {
-                "start": {
-                  "line": 28,
-                  "column": 1,
-                  "offset": 170
-                },
-                "end": {
-                  "line": 30,
-                  "column": 4,
-                  "offset": 184
-                }
-              }
-            },
-            {
-              "type": "blockquote",
-              "children": [
-                {
-                  "type": "paragraph",
-                  "children": [
-                    {
-                      "type": "text",
-                      "value": "g h",
-                      "position": {
-                        "start": {
-                          "line": 31,
-                          "column": 3,
-                          "offset": 187
-                        },
-                        "end": {
-                          "line": 31,
-                          "column": 6,
-                          "offset": 190
-                        }
-                      }
-                    }
-                  ],
-                  "position": {
-                    "start": {
-                      "line": 31,
-                      "column": 3,
-                      "offset": 187
-                    },
-                    "end": {
-                      "line": 31,
-                      "column": 6,
-                      "offset": 190
-                    }
-                  }
-                }
-              ],
-              "position": {
-                "start": {
-                  "line": 31,
-                  "column": 1,
-                  "offset": 185
-                },
-                "end": {
-                  "line": 31,
-                  "column": 6,
-                  "offset": 190
-                }
-              }
-            }
-          ],
-          "position": {
-            "start": {
-              "line": 26,
-              "column": 1,
-              "offset": 162
-            },
-            "end": {
-              "line": 32,
-              "column": 1,
-              "offset": 191
-            }
-          }
-        }
-      ],
-      "position": {
-        "start": {
-          "line": 24,
-          "column": 1,
-          "offset": 153
-        },
-        "end": {
-          "line": 32,
-          "column": 6,
-          "offset": 196
-        }
-      }
-    }
-  ],
-  "position": {
-    "start": {
-      "line": 1,
-      "column": 1,
-      "offset": 0
-    },
-    "end": {
-      "line": 33,
-      "column": 1,
-      "offset": 197
-    }
-  }
-}

+ 63 - 0
packages/remark-growi-plugin/test/fixtures/leaf/actual.ts

@@ -0,0 +1,63 @@
+{ type: 'root', children: [
+    { type: 'leafGrowiPluginDirective',
+    name: 'a', attributes: {}, children: [], position: { start: { line: 1, column: 1, offset: 0
+        }, end: { line: 1, column: 3, offset: 2
+        }
+      }
+    },
+    { type: 'leafGrowiPluginDirective', name: 'a', attributes: {}, children: [
+        { type: 'text', value: 'b', position: [Object
+          ]
+        }
+      ], position: { start: { line: 3, column: 1, offset: 4
+        }, end: { line: 3, column: 6, offset: 9
+        }
+      }
+    },
+    { type: 'leafGrowiPluginDirective', name: 'a', attributes: { b: ''
+      }, children: [], position: { start: { line: 5, column: 1, offset: 11
+        }, end: { line: 5, column: 6, offset: 16
+        }
+      }
+    },
+    { type: 'leafGrowiPluginDirective', name: 'a', attributes: { c: ''
+      }, children: [
+        { type: 'text', value: 'b', position: [Object
+          ]
+        }
+      ], position: { start: { line: 7, column: 1, offset: 18
+        }, end: { line: 7, column: 9, offset: 26
+        }
+      }
+    },
+    { type: 'leafGrowiPluginDirective', name: 'a', attributes: {}, children: [
+        { type: 'text', value: 'b ', position: [Object
+          ]
+        },
+        { type: 'emphasis', children: [Array
+          ], position: [Object
+          ]
+        },
+        { type: 'text', value: ' d ', position: [Object
+          ]
+        },
+        { type: 'strong', children: [Array
+          ], position: [Object
+          ]
+        }
+      ], position: { start: { line: 9, column: 1, offset: 28
+        }, end: { line: 9, column: 18, offset: 45
+        }
+      }
+    },
+    { type: 'leafGrowiPluginDirective', name: 'a', attributes: { id: 'e', class: 'c d f g', h: 'i & j k'
+      }, children: [], position: { start: { line: 11, column: 1, offset: 47
+        }, end: { line: 11, column: 44, offset: 90
+        }
+      }
+    }
+  ], position: { start: { line: 1, column: 1, offset: 0
+    }, end: { line: 12, column: 1, offset: 91
+    }
+  }
+}

+ 6 - 6
packages/remark-growi-plugin/test/fixtures/leaf/input.md

@@ -1,11 +1,11 @@
-::a
+$a
 
-::a[b]
+$a[b]
 
-::a{b}
+$a{b}
 
-::a[b]{c}
+$a[b]{c}
 
-::a[b *c* d **e**]
+$a[b *c* d **e**]
 
-::a{#b.c.d id=e class="f g" h="i &amp; j k"}
+$a{#b.c.d id=e class="f g" h="i &amp; j k"}

+ 6 - 6
packages/remark-growi-plugin/test/fixtures/leaf/output.md

@@ -1,11 +1,11 @@
-::a
+$a
 
-::a[b]
+$a[b]
 
-::a{b}
+$a{b}
 
-::a[b]{c}
+$a[b]{c}
 
-::a[b *c* d **e**]
+$a[b *c* d **e**]
 
-::a{#e .c.d.f.g h="i & j k"}
+$a{#e .c.d.f.g h="i & j k"}

+ 50 - 50
packages/remark-growi-plugin/test/fixtures/leaf/tree.json

@@ -14,8 +14,8 @@
         },
         "end": {
           "line": 1,
-          "column": 4,
-          "offset": 3
+          "column": 3,
+          "offset": 2
         }
       }
     },
@@ -30,13 +30,13 @@
           "position": {
             "start": {
               "line": 3,
-              "column": 5,
-              "offset": 9
+              "column": 4,
+              "offset": 7
             },
             "end": {
               "line": 3,
-              "column": 6,
-              "offset": 10
+              "column": 5,
+              "offset": 8
             }
           }
         }
@@ -45,12 +45,12 @@
         "start": {
           "line": 3,
           "column": 1,
-          "offset": 5
+          "offset": 4
         },
         "end": {
           "line": 3,
-          "column": 7,
-          "offset": 11
+          "column": 6,
+          "offset": 9
         }
       }
     },
@@ -65,12 +65,12 @@
         "start": {
           "line": 5,
           "column": 1,
-          "offset": 13
+          "offset": 11
         },
         "end": {
           "line": 5,
-          "column": 7,
-          "offset": 19
+          "column": 6,
+          "offset": 16
         }
       }
     },
@@ -87,13 +87,13 @@
           "position": {
             "start": {
               "line": 7,
-              "column": 5,
-              "offset": 25
+              "column": 4,
+              "offset": 21
             },
             "end": {
               "line": 7,
-              "column": 6,
-              "offset": 26
+              "column": 5,
+              "offset": 22
             }
           }
         }
@@ -102,12 +102,12 @@
         "start": {
           "line": 7,
           "column": 1,
-          "offset": 21
+          "offset": 18
         },
         "end": {
           "line": 7,
-          "column": 10,
-          "offset": 30
+          "column": 9,
+          "offset": 26
         }
       }
     },
@@ -122,13 +122,13 @@
           "position": {
             "start": {
               "line": 9,
-              "column": 5,
-              "offset": 36
+              "column": 4,
+              "offset": 31
             },
             "end": {
               "line": 9,
-              "column": 7,
-              "offset": 38
+              "column": 6,
+              "offset": 33
             }
           }
         },
@@ -141,13 +141,13 @@
               "position": {
                 "start": {
                   "line": 9,
-                  "column": 8,
-                  "offset": 39
+                  "column": 7,
+                  "offset": 34
                 },
                 "end": {
                   "line": 9,
-                  "column": 9,
-                  "offset": 40
+                  "column": 8,
+                  "offset": 35
                 }
               }
             }
@@ -155,13 +155,13 @@
           "position": {
             "start": {
               "line": 9,
-              "column": 7,
-              "offset": 38
+              "column": 6,
+              "offset": 33
             },
             "end": {
               "line": 9,
-              "column": 10,
-              "offset": 41
+              "column": 9,
+              "offset": 36
             }
           }
         },
@@ -171,13 +171,13 @@
           "position": {
             "start": {
               "line": 9,
-              "column": 10,
-              "offset": 41
+              "column": 9,
+              "offset": 36
             },
             "end": {
               "line": 9,
-              "column": 13,
-              "offset": 44
+              "column": 12,
+              "offset": 39
             }
           }
         },
@@ -190,13 +190,13 @@
               "position": {
                 "start": {
                   "line": 9,
-                  "column": 15,
-                  "offset": 46
+                  "column": 14,
+                  "offset": 41
                 },
                 "end": {
                   "line": 9,
-                  "column": 16,
-                  "offset": 47
+                  "column": 15,
+                  "offset": 42
                 }
               }
             }
@@ -204,13 +204,13 @@
           "position": {
             "start": {
               "line": 9,
-              "column": 13,
-              "offset": 44
+              "column": 12,
+              "offset": 39
             },
             "end": {
               "line": 9,
-              "column": 18,
-              "offset": 49
+              "column": 17,
+              "offset": 44
             }
           }
         }
@@ -219,12 +219,12 @@
         "start": {
           "line": 9,
           "column": 1,
-          "offset": 32
+          "offset": 28
         },
         "end": {
           "line": 9,
-          "column": 19,
-          "offset": 50
+          "column": 18,
+          "offset": 45
         }
       }
     },
@@ -241,12 +241,12 @@
         "start": {
           "line": 11,
           "column": 1,
-          "offset": 52
+          "offset": 47
         },
         "end": {
           "line": 11,
-          "column": 45,
-          "offset": 96
+          "column": 44,
+          "offset": 90
         }
       }
     }
@@ -260,7 +260,7 @@
     "end": {
       "line": 12,
       "column": 1,
-      "offset": 97
+      "offset": 91
     }
   }
 }

+ 3 - 3
packages/remark-growi-plugin/test/fixtures/text/input.md

@@ -1,7 +1,7 @@
-One :a, two :a[b], three :a{b}, four :a[b]{c}.
+One $a, two $a[b], three $a{b}, four $a[b]{c}.
 
-:a[b *c*
+$a[b *c*
 d **e**].
 
-:a{#b.c.d id=e class="f g" h="i &amp; j
+$a{#b.c.d id=e class="f g" h="i &amp; j
 k"}.

+ 3 - 3
packages/remark-growi-plugin/test/fixtures/text/output.md

@@ -1,7 +1,7 @@
-One :a, two :a[b], three :a{b}, four :a[b]{c}.
+One $a, two $a[b], three $a{b}, four $a[b]{c}.
 
-:a[b *c*
+$a[b *c*
 d **e**].
 
-:a{#e .c.d.f.g h="i & j
+$a{#e .c.d.f.g h="i & j
 k"}.

+ 42 - 372
packages/remark-growi-plugin/test/mdast-util-growi-plugin.test.js

@@ -8,7 +8,7 @@ import { directive } from '../src/micromark-extension-growi-plugin/index.js';
 
 test('markdown -> mdast', (t) => {
   t.deepEqual(
-    fromMarkdown('a :b[c]{d} e.', {
+    fromMarkdown('a $b[c]{d} e.', {
       extensions: [directive()],
       mdastExtensions: [directiveFromMarkdown],
     }).children[0],
@@ -60,7 +60,7 @@ test('markdown -> mdast', (t) => {
   );
 
   t.deepEqual(
-    fromMarkdown('::a[b]{c}', {
+    fromMarkdown('$a[b]{c}', {
       extensions: [directive()],
       mdastExtensions: [directiveFromMarkdown],
     }).children[0],
@@ -73,76 +73,22 @@ test('markdown -> mdast', (t) => {
           type: 'text',
           value: 'b',
           position: {
-            start: { line: 1, column: 5, offset: 4 },
-            end: { line: 1, column: 6, offset: 5 },
+            start: { line: 1, column: 4, offset: 3 },
+            end: { line: 1, column: 5, offset: 4 },
           },
         },
       ],
       position: {
         start: { line: 1, column: 1, offset: 0 },
-        end: { line: 1, column: 10, offset: 9 },
+        end: { line: 1, column: 9, offset: 8 },
       },
     },
     'should support directives (leaf)',
   );
 
-  t.deepEqual(
-    fromMarkdown(':::a[b]{c}\nd', {
-      extensions: [directive()],
-      mdastExtensions: [directiveFromMarkdown],
-    }).children[0],
-    {
-      type: 'containerGrowiPluginDirective',
-      name: 'a',
-      attributes: { c: '' },
-      children: [
-        {
-          type: 'paragraph',
-          data: { directiveLabel: true },
-          children: [
-            {
-              type: 'text',
-              value: 'b',
-              position: {
-                start: { line: 1, column: 6, offset: 5 },
-                end: { line: 1, column: 7, offset: 6 },
-              },
-            },
-          ],
-          position: {
-            start: { line: 1, column: 5, offset: 4 },
-            end: { line: 1, column: 8, offset: 7 },
-          },
-        },
-        {
-          type: 'paragraph',
-          children: [
-            {
-              type: 'text',
-              value: 'd',
-              position: {
-                start: { line: 2, column: 1, offset: 11 },
-                end: { line: 2, column: 2, offset: 12 },
-              },
-            },
-          ],
-          position: {
-            start: { line: 2, column: 1, offset: 11 },
-            end: { line: 2, column: 2, offset: 12 },
-          },
-        },
-      ],
-      position: {
-        start: { line: 1, column: 1, offset: 0 },
-        end: { line: 2, column: 2, offset: 12 },
-      },
-    },
-    'should support directives (container)',
-  );
-
   t.deepEqual(
     removePosition(
-      fromMarkdown(':a[b *c*\nd]', {
+      fromMarkdown('x $a[b *c*\nd]', {
         extensions: [directive()],
         mdastExtensions: [directiveFromMarkdown],
       }),
@@ -154,6 +100,7 @@ test('markdown -> mdast', (t) => {
         {
           type: 'paragraph',
           children: [
+            { type: 'text', value: 'x ' },
             {
               type: 'textGrowiPluginDirective',
               name: 'a',
@@ -173,7 +120,7 @@ test('markdown -> mdast', (t) => {
 
   t.deepEqual(
     removePosition(
-      fromMarkdown(':a{#b.c.d e=f g="h&amp;i&unknown;j"}', {
+      fromMarkdown('x $a{#b.c.d e=f g="h&amp;i&unknown;j"}', {
         extensions: [directive()],
         mdastExtensions: [directiveFromMarkdown],
       }),
@@ -185,6 +132,7 @@ test('markdown -> mdast', (t) => {
         {
           type: 'paragraph',
           children: [
+            { type: 'text', value: 'x ' },
             {
               type: 'textGrowiPluginDirective',
               name: 'a',
@@ -202,7 +150,7 @@ test('markdown -> mdast', (t) => {
 
   t.deepEqual(
     removePosition(
-      fromMarkdown(':a{b\nc="d\ne"}', {
+      fromMarkdown('$a{b\nc="d\ne"}', {
         extensions: [directive()],
         mdastExtensions: [directiveFromMarkdown],
       }),
@@ -227,47 +175,6 @@ test('markdown -> mdast', (t) => {
     'should support EOLs in attributes',
   );
 
-  t.deepEqual(
-    removePosition(
-      fromMarkdown('::::a\n:::b\n:c\n:::\n::::', {
-        extensions: [directive()],
-        mdastExtensions: [directiveFromMarkdown],
-      }),
-      true,
-    ),
-    {
-      type: 'root',
-      children: [
-        {
-          type: 'containerGrowiPluginDirective',
-          name: 'a',
-          attributes: {},
-          children: [
-            {
-              type: 'containerGrowiPluginDirective',
-              name: 'b',
-              attributes: {},
-              children: [
-                {
-                  type: 'paragraph',
-                  children: [
-                    {
-                      type: 'textGrowiPluginDirective',
-                      name: 'c',
-                      attributes: {},
-                      children: [],
-                    },
-                  ],
-                },
-              ],
-            },
-          ],
-        },
-      ],
-    },
-    'should support directives in directives',
-  );
-
   t.end();
 });
 
@@ -285,7 +192,7 @@ test('mdast -> markdown', (t) => {
       },
       { extensions: [directiveToMarkdown] },
     ),
-    'a : b.\n',
+    'a $ b.\n',
     'should try to serialize a directive (text) w/o `name`',
   );
 
@@ -302,7 +209,7 @@ test('mdast -> markdown', (t) => {
       },
       { extensions: [directiveToMarkdown] },
     ),
-    'a :b c.\n',
+    'a $b c.\n',
     'should serialize a directive (text) w/ `name`',
   );
 
@@ -322,7 +229,7 @@ test('mdast -> markdown', (t) => {
       },
       { extensions: [directiveToMarkdown] },
     ),
-    'a :b[c] d.\n',
+    'a $b[c] d.\n',
     'should serialize a directive (text) w/ `children`',
   );
 
@@ -342,7 +249,7 @@ test('mdast -> markdown', (t) => {
       },
       { extensions: [directiveToMarkdown] },
     ),
-    'a :b[c\\[d\\]e] f.\n',
+    'a $b[c\\[d\\]e] f.\n',
     'should escape brackets in a directive (text) label',
   );
 
@@ -362,7 +269,7 @@ test('mdast -> markdown', (t) => {
       },
       { extensions: [directiveToMarkdown] },
     ),
-    'a :b[c\nd] e.\n',
+    'a $b[c\nd] e.\n',
     'should support EOLs in a directive (text) label',
   );
 
@@ -386,7 +293,7 @@ test('mdast -> markdown', (t) => {
       },
       { extensions: [directiveToMarkdown] },
     ),
-    'a :b{c="d" e="f" g j="2"} k.\n',
+    'a $b{c="d" e="f" g j="2"} k.\n',
     'should serialize a directive (text) w/ `attributes`',
   );
 
@@ -407,7 +314,7 @@ test('mdast -> markdown', (t) => {
       },
       { extensions: [directiveToMarkdown] },
     ),
-    'a :b{#d .a.b.c key="value"} k.\n',
+    'a $b{#d .a.b.c key="value"} k.\n',
     'should serialize a directive (text) w/ `id`, `class` attributes',
   );
 
@@ -428,7 +335,7 @@ test('mdast -> markdown', (t) => {
       },
       { extensions: [directiveToMarkdown] },
     ),
-    'a :b{x="y&#x22;\'\r\nz"} k.\n',
+    'a $b{x="y&#x22;\'\r\nz"} k.\n',
     'should encode the quote in an attribute value (text)',
   );
 
@@ -449,7 +356,7 @@ test('mdast -> markdown', (t) => {
       },
       { extensions: [directiveToMarkdown] },
     ),
-    'a :b{x="y&#x22;\'\r\nz"} k.\n',
+    'a $b{x="y&#x22;\'\r\nz"} k.\n',
     'should encode the quote in an attribute value (text)',
   );
 
@@ -470,7 +377,7 @@ test('mdast -> markdown', (t) => {
       },
       { extensions: [directiveToMarkdown] },
     ),
-    'a :b{id="c#d"} e.\n',
+    'a $b{id="c#d"} e.\n',
     'should not use the `id` shortcut if impossible characters exist',
   );
 
@@ -491,7 +398,7 @@ test('mdast -> markdown', (t) => {
       },
       { extensions: [directiveToMarkdown] },
     ),
-    'a :b{class="c.d e<f"} g.\n',
+    'a $b{class="c.d e<f"} g.\n',
     'should not use the `class` shortcut if impossible characters exist',
   );
 
@@ -512,14 +419,14 @@ test('mdast -> markdown', (t) => {
       },
       { extensions: [directiveToMarkdown] },
     ),
-    'a :b{.e.hij class="c.d f<g"} k.\n',
+    'a $b{.e.hij class="c.d f<g"} k.\n',
     'should not use the `class` shortcut if impossible characters exist (but should use it for classes that don’t)',
   );
 
   t.deepEqual(
     // @ts-expect-error: `children`, `name` missing.
     toMarkdown({ type: 'leafGrowiPluginDirective' }, { extensions: [directiveToMarkdown] }),
-    '::\n',
+    '$\n',
     'should try to serialize a directive (leaf) w/o `name`',
   );
 
@@ -529,7 +436,7 @@ test('mdast -> markdown', (t) => {
       { type: 'leafGrowiPluginDirective', name: 'a' },
       { extensions: [directiveToMarkdown] },
     ),
-    '::a\n',
+    '$a\n',
     'should serialize a directive (leaf) w/ `name`',
   );
 
@@ -542,7 +449,7 @@ test('mdast -> markdown', (t) => {
       },
       { extensions: [directiveToMarkdown] },
     ),
-    '::a[b]\n',
+    '$a[b]\n',
     'should serialize a directive (leaf) w/ `children`',
   );
 
@@ -555,7 +462,7 @@ test('mdast -> markdown', (t) => {
       },
       { extensions: [directiveToMarkdown] },
     ),
-    '::a[b]\n',
+    '$a[b]\n',
     'should serialize a directive (leaf) w/ `children`',
   );
 
@@ -568,7 +475,7 @@ test('mdast -> markdown', (t) => {
       },
       { extensions: [directiveToMarkdown] },
     ),
-    '::a[b&#xA;c]\n',
+    '$a[b&#xA;c]\n',
     'should serialize a directive (leaf) w/ EOLs in `children`',
   );
 
@@ -582,232 +489,19 @@ test('mdast -> markdown', (t) => {
       },
       { extensions: [directiveToMarkdown] },
     ),
-    '::a{#b .c.d key="e&#xA;f"}\n',
+    '$a{#b .c.d key="e&#xA;f"}\n',
     'should serialize a directive (leaf) w/ EOLs in `attributes`',
   );
 
-  t.deepEqual(
-    toMarkdown(
-      // @ts-expect-error: `children`, `name` missing.
-      { type: 'containerGrowiPluginDirective' },
-      { extensions: [directiveToMarkdown] },
-    ),
-    ':::\n:::\n',
-    'should try to serialize a directive (container) w/o `name`',
-  );
-
-  t.deepEqual(
-    toMarkdown(
-      // @ts-expect-error: `children` missing.
-      { type: 'containerGrowiPluginDirective', name: 'a' },
-      { extensions: [directiveToMarkdown] },
-    ),
-    ':::a\n:::\n',
-    'should serialize a directive (container) w/ `name`',
-  );
-
-  t.deepEqual(
-    toMarkdown(
-      {
-        type: 'containerGrowiPluginDirective',
-        name: 'a',
-        children: [{ type: 'paragraph', children: [{ type: 'text', value: 'b' }] }],
-      },
-      { extensions: [directiveToMarkdown] },
-    ),
-    ':::a\nb\n:::\n',
-    'should serialize a directive (container) w/ `children`',
-  );
-
-  t.deepEqual(
-    toMarkdown(
-      {
-        type: 'containerGrowiPluginDirective',
-        name: 'a',
-        children: [
-          { type: 'heading', depth: 1, children: [{ type: 'text', value: 'b' }] },
-        ],
-      },
-      { extensions: [directiveToMarkdown] },
-    ),
-    ':::a\n# b\n:::\n',
-    'should serialize a directive (container) w/ `children` (heading)',
-  );
-
-  t.deepEqual(
-    toMarkdown(
-      {
-        type: 'containerGrowiPluginDirective',
-        name: 'a',
-        children: [
-          { type: 'paragraph', children: [{ type: 'text', value: 'b\nc' }] },
-        ],
-      },
-      { extensions: [directiveToMarkdown] },
-    ),
-    ':::a\nb\nc\n:::\n',
-    'should serialize a directive (container) w/ EOLs in `children`',
-  );
-
-  t.deepEqual(
-    toMarkdown(
-      {
-        type: 'containerGrowiPluginDirective',
-        name: 'a',
-        attributes: { id: 'b', class: 'c d', key: 'e\nf' },
-        children: [],
-      },
-      { extensions: [directiveToMarkdown] },
-    ),
-    ':::a{#b .c.d key="e&#xA;f"}\n:::\n',
-    'should serialize a directive (container) w/ EOLs in `attributes`',
-  );
-
-  t.deepEqual(
-    toMarkdown(
-      {
-        type: 'containerGrowiPluginDirective',
-        name: 'a',
-        children: [
-          {
-            type: 'paragraph',
-            data: { directiveLabel: true },
-            children: [{ type: 'text', value: 'b' }],
-          },
-        ],
-      },
-      { extensions: [directiveToMarkdown] },
-    ),
-    ':::a[b]\n:::\n',
-    'should serialize the first paragraph w/ `data.directiveLabel` as a label in a directive (container)',
-  );
-
-  t.deepEqual(
-    toMarkdown(
-      {
-        type: 'containerGrowiPluginDirective',
-        name: 'a',
-        children: [
-          {
-            type: 'containerGrowiPluginDirective',
-            name: 'b',
-            children: [
-              {
-                type: 'paragraph',
-                children: [{ type: 'text', value: 'c' }],
-              },
-            ],
-          },
-        ],
-      },
-      { extensions: [directiveToMarkdown] },
-    ),
-    '::::a\n:::b\nc\n:::\n::::\n',
-    'should serialize the outer containers w/ more colons than inner containers',
-  );
-
-  t.deepEqual(
-    toMarkdown(
-      {
-        type: 'containerGrowiPluginDirective',
-        name: 'a',
-        children: [
-          {
-            type: 'containerGrowiPluginDirective',
-            name: 'b',
-            children: [
-              {
-                type: 'paragraph',
-                children: [{ type: 'text', value: 'c' }],
-              },
-            ],
-          },
-          {
-            type: 'containerGrowiPluginDirective',
-            name: 'd',
-            children: [
-              {
-                type: 'paragraph',
-                children: [{ type: 'text', value: 'e' }],
-              },
-            ],
-          },
-        ],
-      },
-      { extensions: [directiveToMarkdown] },
-    ),
-    '::::a\n:::b\nc\n:::\n\n:::d\ne\n:::\n::::\n',
-    'should serialize w/ `3 + nesting`, not the total count (1)',
-  );
-
-  t.deepEqual(
-    toMarkdown(
-      {
-        type: 'containerGrowiPluginDirective',
-        name: 'a',
-        children: [
-          {
-            type: 'containerGrowiPluginDirective',
-            name: 'b',
-            children: [
-              {
-                type: 'containerGrowiPluginDirective',
-                name: 'c',
-                children: [
-                  {
-                    type: 'paragraph',
-                    children: [{ type: 'text', value: 'd' }],
-                  },
-                ],
-              },
-            ],
-          },
-        ],
-      },
-      { extensions: [directiveToMarkdown] },
-    ),
-    ':::::a\n::::b\n:::c\nd\n:::\n::::\n:::::\n',
-    'should serialize w/ `3 + nesting`, not the total count (2)',
-  );
-
-  t.deepEqual(
-    toMarkdown(
-      {
-        type: 'containerGrowiPluginDirective',
-        name: 'a',
-        children: [
-          {
-            type: 'blockquote',
-            children: [
-              {
-                type: 'containerGrowiPluginDirective',
-                name: 'b',
-                children: [
-                  {
-                    type: 'paragraph',
-                    children: [{ type: 'text', value: 'c' }],
-                  },
-                ],
-              },
-            ],
-          },
-        ],
-      },
-      { extensions: [directiveToMarkdown] },
-    ),
-    '::::a\n> :::b\n> c\n> :::\n::::\n',
-    'should serialize w/ `3 + nesting`, not the total count (3)',
-  );
-
   t.deepEqual(
     toMarkdown(
       {
         type: 'paragraph',
-        children: [{ type: 'text', value: 'a:b' }],
+        children: [{ type: 'text', value: 'a$b' }],
       },
       { extensions: [directiveToMarkdown] },
     ),
-    'a\\:b\n',
+    'a\\$b\n',
     'should escape a `:` in phrasing when followed by an alpha',
   );
 
@@ -815,11 +509,11 @@ test('mdast -> markdown', (t) => {
     toMarkdown(
       {
         type: 'paragraph',
-        children: [{ type: 'text', value: 'a:9' }],
+        children: [{ type: 'text', value: 'a$9' }],
       },
       { extensions: [directiveToMarkdown] },
     ),
-    'a:9\n',
+    'a$9\n',
     'should not escape a `:` in phrasing when followed by a non-alpha',
   );
 
@@ -827,11 +521,11 @@ test('mdast -> markdown', (t) => {
     toMarkdown(
       {
         type: 'paragraph',
-        children: [{ type: 'text', value: 'a::c' }],
+        children: [{ type: 'text', value: 'a$c' }],
       },
       { extensions: [directiveToMarkdown] },
     ),
-    'a::c\n',
+    'a\\$c\n',
     'should not escape a `:` in phrasing when preceded by a colon',
   );
 
@@ -839,11 +533,11 @@ test('mdast -> markdown', (t) => {
     toMarkdown(
       {
         type: 'paragraph',
-        children: [{ type: 'text', value: ':\na' }],
+        children: [{ type: 'text', value: '$\na' }],
       },
       { extensions: [directiveToMarkdown] },
     ),
-    ':\na\n',
+    '$\na\n',
     'should not escape a `:` at a break',
   );
 
@@ -851,11 +545,11 @@ test('mdast -> markdown', (t) => {
     toMarkdown(
       {
         type: 'paragraph',
-        children: [{ type: 'text', value: ':a' }],
+        children: [{ type: 'text', value: '$a' }],
       },
       { extensions: [directiveToMarkdown] },
     ),
-    '\\:a\n',
+    '\\$a\n',
     'should not escape a `:` at a break when followed by an alpha',
   );
 
@@ -863,50 +557,26 @@ test('mdast -> markdown', (t) => {
     toMarkdown(
       {
         type: 'paragraph',
-        children: [{ type: 'text', value: '::\na' }],
+        children: [{ type: 'text', value: '$\na' }],
       },
       { extensions: [directiveToMarkdown] },
     ),
-    '\\::\na\n',
+    '$\na\n',
     'should escape a `:` at a break when followed by a colon',
   );
 
-  t.deepEqual(
-    toMarkdown(
-      {
-        type: 'paragraph',
-        children: [{ type: 'text', value: ':::\na' }],
-      },
-      { extensions: [directiveToMarkdown] },
-    ),
-    '\\:::\na\n',
-    'should escape a `:` at a break when followed by two colons',
-  );
-
-  t.deepEqual(
-    toMarkdown(
-      {
-        type: 'paragraph',
-        children: [{ type: 'text', value: ':::\na' }],
-      },
-      { extensions: [directiveToMarkdown] },
-    ),
-    '\\:::\na\n',
-    'should escape a `:` at a break when followed by two colons',
-  );
-
   t.deepEqual(
     toMarkdown(
       {
         type: 'paragraph',
         children: [
           { type: 'textGrowiPluginDirective', name: 'red', children: [] },
-          { type: 'text', value: ':' },
+          { type: 'text', value: '$' },
         ],
       },
       { extensions: [directiveToMarkdown] },
     ),
-    ':red:\n',
+    '$red$\n',
     'should escape a `:` after a text directive',
   );
 

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 136 - 564
packages/remark-growi-plugin/test/micromark-extension-growi-plugin.test.js


Vissa filer visades inte eftersom för många filer har ändrats