Yuki Takei 3 лет назад
Родитель
Сommit
d4ab84fcc1

+ 13 - 0
packages/remark-growi-plugin/.eslintrc.cjs

@@ -0,0 +1,13 @@
+module.exports = {
+  rules: {
+    'import/extensions': [
+      'error',
+      'ignorePackages',
+      {
+        ts: 'never',
+        tsx: 'never',
+      },
+    ],
+    '@typescript-eslint/no-use-before-define': 'off',
+  },
+};

+ 2 - 2
packages/remark-growi-plugin/package.json

@@ -23,8 +23,8 @@
     "test": "cross-env NODE_ENV=test npm run test-coverage",
     "test-api": "node --conditions development test/index.js",
     "test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov npm run test-api",
-    "lint": "eslint src --ext .ts",
-    "lint:fix": "eslint src --ext .ts --fix"
+    "lint": "eslint \"**/*.{cjs, js,jsx,ts,tsx}\"",
+    "lint:fix": "eslint \"**/*.{cjs, js,jsx,ts,tsx}\" --fix"
   },
   "dependencies": {
     "@types/mdast": "^3.0.0",

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

@@ -1,5 +1,5 @@
-import type {Parent} from 'unist'
-import type {PhrasingContent, BlockContent} from 'mdast'
+import type { PhrasingContent, BlockContent } from 'mdast';
+import type { Parent } from 'unist';
 
 type DirectiveAttributes = Record<string, string>
 

+ 136 - 129
packages/remark-growi-plugin/src/mdast-util-growi-plugin/index.js

@@ -15,19 +15,19 @@
  * @typedef {ContainerDirective|LeafDirective|TextDirective} Directive
  */
 
-import {parseEntities} from 'parse-entities'
-import {stringifyEntitiesLight} from 'stringify-entities'
-import {visitParents} from 'unist-util-visit-parents'
-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 {checkQuote} from 'mdast-util-to-markdown/lib/util/check-quote.js'
-import {track} from 'mdast-util-to-markdown/lib/util/track.js'
+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';
+import { stringifyEntitiesLight } from 'stringify-entities';
+import { visitParents } from 'unist-util-visit-parents';
 
-const own = {}.hasOwnProperty
+const own = {}.hasOwnProperty;
 
-const shortcut = /^[^\t\n\r "#'.<=>`}]+$/
+const shortcut = /^[^\t\n\r "#'.<=>`}]+$/;
 
-handleDirective.peek = peekDirective
+handleDirective.peek = peekDirective;
 
 /** @type {FromMarkdownExtension} */
 export const directiveFromMarkdown = {
@@ -41,7 +41,7 @@ export const directiveFromMarkdown = {
     directiveLeafAttributes: enterAttributes,
 
     directiveText: enterText,
-    directiveTextAttributes: enterAttributes
+    directiveTextAttributes: enterAttributes,
   },
   exit: {
     directiveContainer: exit,
@@ -67,49 +67,49 @@ export const directiveFromMarkdown = {
     directiveTextAttributeName: exitAttributeName,
     directiveTextAttributeValue: exitAttributeValue,
     directiveTextAttributes: exitAttributes,
-    directiveTextName: exitName
-  }
-}
+    directiveTextName: exitName,
+  },
+};
 
 /** @type {ToMarkdownExtension} */
 export const directiveToMarkdown = {
   unsafe: [
     {
       character: '\r',
-      inConstruct: ['leafDirectiveLabel', 'containerDirectiveLabel']
+      inConstruct: ['leafDirectiveLabel', 'containerDirectiveLabel'],
     },
     {
       character: '\n',
-      inConstruct: ['leafDirectiveLabel', 'containerDirectiveLabel']
+      inConstruct: ['leafDirectiveLabel', 'containerDirectiveLabel'],
     },
     {
       before: '[^:]',
       character: ':',
       after: '[A-Za-z]',
-      inConstruct: ['phrasing']
+      inConstruct: ['phrasing'],
     },
-    {atBreak: true, character: ':', after: ':'}
+    { atBreak: true, character: ':', after: ':' },
   ],
   handlers: {
     containerDirective: handleDirective,
     leafDirective: handleDirective,
-    textDirective: handleDirective
-  }
-}
+    textDirective: handleDirective,
+  },
+};
 
 /** @type {FromMarkdownHandle} */
 function enterContainer(token) {
-  enter.call(this, 'containerDirective', token)
+  enter.call(this, 'containerDirective', token);
 }
 
 /** @type {FromMarkdownHandle} */
 function enterLeaf(token) {
-  enter.call(this, 'leafDirective', token)
+  enter.call(this, 'leafDirective', token);
 }
 
 /** @type {FromMarkdownHandle} */
 function enterText(token) {
-  enter.call(this, 'textDirective', token)
+  enter.call(this, 'textDirective', token);
 }
 
 /**
@@ -118,7 +118,9 @@ function enterText(token) {
  * @param {Token} token
  */
 function enter(type, token) {
-  this.enter({type, name: '', attributes: {}, children: []}, token)
+  this.enter({
+    type, name: '', attributes: {}, children: [],
+  }, token);
 }
 
 /**
@@ -126,92 +128,93 @@ function enter(type, token) {
  * @param {Token} token
  */
 function exitName(token) {
-  const node = /** @type {Directive} */ (this.stack[this.stack.length - 1])
-  node.name = this.sliceSerialize(token)
+  const node = /** @type {Directive} */ (this.stack[this.stack.length - 1]);
+  node.name = this.sliceSerialize(token);
 }
 
 /** @type {FromMarkdownHandle} */
 function enterContainerLabel(token) {
   this.enter(
-    {type: 'paragraph', data: {directiveLabel: true}, children: []},
-    token
-  )
+    { type: 'paragraph', data: { directiveLabel: true }, children: [] },
+    token,
+  );
 }
 
 /** @type {FromMarkdownHandle} */
 function exitContainerLabel(token) {
-  this.exit(token)
+  this.exit(token);
 }
 
 /** @type {FromMarkdownHandle} */
 function enterAttributes() {
-  this.setData('directiveAttributes', [])
-  this.buffer() // Capture EOLs
+  this.setData('directiveAttributes', []);
+  this.buffer(); // Capture EOLs
 }
 
 /** @type {FromMarkdownHandle} */
 function exitAttributeIdValue(token) {
   const list = /** @type {Array.<[string, string]>} */ (
     this.getData('directiveAttributes')
-  )
-  list.push(['id', parseEntities(this.sliceSerialize(token))])
+  );
+  list.push(['id', parseEntities(this.sliceSerialize(token))]);
 }
 
 /** @type {FromMarkdownHandle} */
 function exitAttributeClassValue(token) {
   const list = /** @type {Array.<[string, string]>} */ (
     this.getData('directiveAttributes')
-  )
-  list.push(['class', parseEntities(this.sliceSerialize(token))])
+  );
+  list.push(['class', parseEntities(this.sliceSerialize(token))]);
 }
 
 /** @type {FromMarkdownHandle} */
 function exitAttributeValue(token) {
   const list = /** @type {Array.<[string, string]>} */ (
     this.getData('directiveAttributes')
-  )
-  list[list.length - 1][1] = parseEntities(this.sliceSerialize(token))
+  );
+  list[list.length - 1][1] = parseEntities(this.sliceSerialize(token));
 }
 
 /** @type {FromMarkdownHandle} */
 function exitAttributeName(token) {
   const list = /** @type {Array.<[string, string]>} */ (
     this.getData('directiveAttributes')
-  )
+  );
 
   // Attribute names in CommonMark are significantly limited, so character
   // references can’t exist.
-  list.push([this.sliceSerialize(token), ''])
+  list.push([this.sliceSerialize(token), '']);
 }
 
 /** @type {FromMarkdownHandle} */
 function exitAttributes() {
   const list = /** @type {Array.<[string, string]>} */ (
     this.getData('directiveAttributes')
-  )
+  );
   /** @type {Record.<string, string>} */
-  const cleaned = {}
-  let index = -1
+  const cleaned = {};
+  let index = -1;
 
   while (++index < list.length) {
-    const attribute = list[index]
+    const attribute = list[index];
 
     if (attribute[0] === 'class' && cleaned.class) {
-      cleaned.class += ' ' + attribute[1]
-    } else {
-      cleaned[attribute[0]] = attribute[1]
+      cleaned.class += ` ${attribute[1]}`;
+    }
+    else {
+      cleaned[attribute[0]] = attribute[1];
     }
   }
 
-  this.setData('directiveAttributes')
-  this.resume() // Drop EOLs
-  const node = /** @type {Directive} */ (this.stack[this.stack.length - 1])
-  node.attributes = cleaned
+  this.setData('directiveAttributes');
+  this.resume(); // Drop EOLs
+  const node = /** @type {Directive} */ (this.stack[this.stack.length - 1]);
+  node.attributes = cleaned;
 }
 
 /** @type {FromMarkdownHandle} */
 function exit(token) {
-  this.exit(token)
+  this.exit(token);
 }
 
 /**
@@ -219,59 +222,59 @@ function exit(token) {
  * @param {Directive} node
  */
 function handleDirective(node, _, context, safeOptions) {
-  const tracker = track(safeOptions)
-  const sequence = fence(node)
-  const exit = context.enter(node.type)
-  let value = tracker.move(sequence + (node.name || ''))
+  const tracker = track(safeOptions);
+  const sequence = fence(node);
+  const exit = context.enter(node.type);
+  let value = tracker.move(sequence + (node.name || ''));
   /** @type {Directive|Paragraph|undefined} */
-  let label = node
+  let label = node;
 
   if (node.type === 'containerDirective') {
-    const head = (node.children || [])[0]
-    label = inlineDirectiveLabel(head) ? head : undefined
+    const head = (node.children || [])[0];
+    label = inlineDirectiveLabel(head) ? head : undefined;
   }
 
   if (label && label.children && label.children.length > 0) {
-    const exit = context.enter('label')
-    const subexit = context.enter(node.type + 'Label')
-    value += tracker.move('[')
+    const exit = context.enter('label');
+    const subexit = context.enter(`${node.type}Label`);
+    value += tracker.move('[');
     value += tracker.move(
       containerPhrasing(label, context, {
         ...tracker.current(),
         before: value,
-        after: ']'
-      })
-    )
-    value += tracker.move(']')
-    subexit()
-    exit()
+        after: ']',
+      }),
+    );
+    value += tracker.move(']');
+    subexit();
+    exit();
   }
 
-  value += tracker.move(attributes(node, context))
+  value += tracker.move(attributes(node, context));
 
   if (node.type === 'containerDirective') {
-    const head = (node.children || [])[0]
-    let shallow = node
+    const head = (node.children || [])[0];
+    let shallow = node;
 
     if (inlineDirectiveLabel(head)) {
-      shallow = Object.assign({}, node, {children: node.children.slice(1)})
+      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');
+      value += tracker.move(containerFlow(shallow, context, tracker.current()));
     }
 
-    value += tracker.move('\n' + sequence)
+    value += tracker.move(`\n${sequence}`);
   }
 
-  exit()
-  return value
+  exit();
+  return value;
 }
 
 /** @type {ToMarkdownHandle} */
 function peekDirective() {
-  return ':'
+  return ':';
 }
 
 /**
@@ -280,68 +283,70 @@ function peekDirective() {
  * @returns {string}
  */
 function attributes(node, context) {
-  const quote = checkQuote(context)
-  const subset = node.type === 'textDirective' ? [quote] : [quote, '\n', '\r']
-  const attrs = node.attributes || {}
+  const quote = checkQuote(context);
+  const subset = node.type === 'textDirective' ? [quote] : [quote, '\n', '\r'];
+  const attrs = node.attributes || {};
   /** @type {Array.<string>} */
-  const values = []
+  const values = [];
   /** @type {string|undefined} */
-  let classesFull
+  let classesFull;
   /** @type {string|undefined} */
-  let classes
+  let classes;
   /** @type {string|undefined} */
-  let id
+  let id;
   /** @type {string} */
-  let key
+  let key;
 
+  // eslint-disable-next-line no-restricted-syntax
   for (key in attrs) {
     if (
-      own.call(attrs, key) &&
-      attrs[key] !== undefined &&
-      attrs[key] !== null
+      own.call(attrs, key)
+      && attrs[key] !== undefined
+      && attrs[key] !== null
     ) {
-      const value = String(attrs[key])
+      const value = String(attrs[key]);
 
       if (key === 'id') {
-        id = shortcut.test(value) ? '#' + value : quoted('id', value)
-      } else if (key === 'class') {
-        const list = value.split(/[\t\n\r ]+/g)
+        id = shortcut.test(value) ? `#${value}` : quoted('id', value);
+      }
+      else if (key === 'class') {
+        const list = value.split(/[\t\n\r ]+/g);
         /** @type {Array.<string>} */
-        const classesFullList = []
+        const classesFullList = [];
         /** @type {Array.<string>} */
-        const classesList = []
-        let index = -1
+        const classesList = [];
+        let index = -1;
 
         while (++index < list.length) {
-          ;(shortcut.test(list[index]) ? classesList : classesFullList).push(
-            list[index]
-          )
+          (shortcut.test(list[index]) ? classesList : classesFullList).push(
+            list[index],
+          );
         }
 
-        classesFull =
-          classesFullList.length > 0
-            ? quoted('class', classesFullList.join(' '))
-            : ''
-        classes = classesList.length > 0 ? '.' + classesList.join('.') : ''
-      } else {
-        values.push(quoted(key, value))
+        classesFull = classesFullList.length > 0
+          ? quoted('class', classesFullList.join(' '))
+          : '';
+        classes = classesList.length > 0 ? `.${classesList.join('.')}` : '';
+      }
+      else {
+        values.push(quoted(key, value));
       }
     }
   }
 
   if (classesFull) {
-    values.unshift(classesFull)
+    values.unshift(classesFull);
   }
 
   if (classes) {
-    values.unshift(classes)
+    values.unshift(classes);
   }
 
   if (id) {
-    values.unshift(id)
+    values.unshift(id);
   }
 
-  return values.length > 0 ? '{' + values.join(' ') + '}' : ''
+  return values.length > 0 ? `{${values.join(' ')}}` : '';
 
   /**
    * @param {string} key
@@ -350,11 +355,11 @@ function attributes(node, context) {
    */
   function quoted(key, value) {
     return (
-      key +
-      (value
-        ? '=' + quote + stringifyEntitiesLight(value, {subset}) + quote
+      key
+      + (value
+        ? `=${quote}${stringifyEntitiesLight(value, { subset })}${quote}`
         : '')
-    )
+    );
   }
 }
 
@@ -364,8 +369,8 @@ function attributes(node, context) {
  */
 function inlineDirectiveLabel(node) {
   return Boolean(
-    node && node.type === 'paragraph' && node.data && node.data.directiveLabel
-  )
+    node && node.type === 'paragraph' && node.data && node.data.directiveLabel,
+  );
 }
 
 /**
@@ -373,30 +378,32 @@ function inlineDirectiveLabel(node) {
  * @returns {string}
  */
 function fence(node) {
-  let size = 0
+  let size = 0;
 
   if (node.type === 'containerDirective') {
-    visitParents(node, 'containerDirective', onvisit)
-    size += 3
-  } else if (node.type === 'leafDirective') {
-    size = 2
-  } else {
-    size = 1
+    visitParents(node, 'containerDirective', onvisit);
+    size += 3;
+  }
+  else if (node.type === 'leafDirective') {
+    size = 2;
+  }
+  else {
+    size = 1;
   }
 
-  return ':'.repeat(size)
+  return ':'.repeat(size);
 
   /** @type {import('unist-util-visit-parents/complex-types').BuildVisitor<Root, Directive>} */
   function onvisit(_, parents) {
-    let index = parents.length
-    let nesting = 0
+    let index = parents.length;
+    let nesting = 0;
 
     while (index--) {
       if (parents[index].type === 'containerDirective') {
-        nesting++
+        nesting++;
       }
     }
 
-    if (nesting > size) size = nesting
+    if (nesting > size) size = nesting;
   }
 }

+ 102 - 102
packages/remark-growi-plugin/src/micromark-extension-growi-plugin/dev/lib/directive-container.js

@@ -5,233 +5,233 @@
  * @typedef {import('micromark-util-types').Token} Token
  */
 
-import {ok as assert} from 'uvu/assert'
-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 {factoryAttributes} from './factory-attributes.js'
-import {factoryLabel} from './factory-label.js'
-import {factoryName} from './factory-name.js'
+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
-}
+  concrete: true,
+};
 
-const label = {tokenize: tokenizeLabel, partial: true}
-const attributes = {tokenize: tokenizeAttributes, partial: true}
-const nonLazyLine = {tokenize: tokenizeNonLazyLine, partial: 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) {
-  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
+  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
+  let previous;
 
-  return start
+  return start;
 
   /** @type {State} */
   function start(code) {
-    assert(code === codes.colon, 'expected `:`')
-    effects.enter('directiveContainer')
-    effects.enter('directiveContainerFence')
-    effects.enter('directiveContainerSequence')
-    return sequenceOpen(code)
+    assert(code === codes.colon, 'expected `:`');
+    effects.enter('directiveContainer');
+    effects.enter('directiveContainerFence');
+    effects.enter('directiveContainerSequence');
+    return sequenceOpen(code);
   }
 
   /** @type {State} */
   function sequenceOpen(code) {
     if (code === codes.colon) {
-      effects.consume(code)
-      sizeOpen++
-      return sequenceOpen
+      effects.consume(code);
+      sizeOpen++;
+      return sequenceOpen;
     }
 
     if (sizeOpen < constants.codeFencedSequenceSizeMin) {
-      return nok(code)
+      return nok(code);
     }
 
-    effects.exit('directiveContainerSequence')
+    effects.exit('directiveContainerSequence');
     return factoryName.call(
       self,
       effects,
       afterName,
       nok,
-      'directiveContainerName'
-    )(code)
+      'directiveContainerName',
+    )(code);
   }
 
   /** @type {State} */
   function afterName(code) {
     return code === codes.leftSquareBracket
       ? effects.attempt(label, afterLabel, afterLabel)(code)
-      : afterLabel(code)
+      : afterLabel(code);
   }
 
   /** @type {State} */
   function afterLabel(code) {
     return code === codes.leftCurlyBrace
       ? effects.attempt(attributes, afterAttributes, afterAttributes)(code)
-      : afterAttributes(code)
+      : afterAttributes(code);
   }
 
   /** @type {State} */
   function afterAttributes(code) {
-    return factorySpace(effects, openAfter, types.whitespace)(code)
+    return factorySpace(effects, openAfter, types.whitespace)(code);
   }
 
   /** @type {State} */
   function openAfter(code) {
-    effects.exit('directiveContainerFence')
+    effects.exit('directiveContainerFence');
 
     if (code === codes.eof) {
-      return afterOpening(code)
+      return afterOpening(code);
     }
 
     if (markdownLineEnding(code)) {
       if (self.interrupt) {
-        return ok(code)
+        return ok(code);
       }
 
-      return effects.attempt(nonLazyLine, contentStart, afterOpening)(code)
+      return effects.attempt(nonLazyLine, contentStart, afterOpening)(code);
     }
 
-    return nok(code)
+    return nok(code);
   }
 
   /** @type {State} */
   function afterOpening(code) {
-    effects.exit('directiveContainer')
-    return ok(code)
+    effects.exit('directiveContainer');
+    return ok(code);
   }
 
   /** @type {State} */
   function contentStart(code) {
     if (code === codes.eof) {
-      effects.exit('directiveContainer')
-      return ok(code)
+      effects.exit('directiveContainer');
+      return ok(code);
     }
 
-    effects.enter('directiveContainerContent')
-    return lineStart(code)
+    effects.enter('directiveContainerContent');
+    return lineStart(code);
   }
 
   /** @type {State} */
   function lineStart(code) {
     if (code === codes.eof) {
-      return after(code)
+      return after(code);
     }
 
     return effects.attempt(
-      {tokenize: tokenizeClosingFence, partial: true},
+      { tokenize: tokenizeClosingFence, partial: true },
       after,
       initialSize
         ? factorySpace(effects, chunkStart, types.linePrefix, initialSize + 1)
-        : chunkStart
-    )(code)
+        : chunkStart,
+    )(code);
   }
 
   /** @type {State} */
   function chunkStart(code) {
     if (code === codes.eof) {
-      return after(code)
+      return after(code);
     }
 
     const token = effects.enter(types.chunkDocument, {
       contentType: constants.contentTypeDocument,
-      previous
-    })
-    if (previous) previous.next = token
-    previous = token
-    return contentContinue(code)
+      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)
+      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)
+      return effects.check(nonLazyLine, nonLazyLineAfter, lineAfter)(code);
     }
 
-    effects.consume(code)
-    return contentContinue
+    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
+    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)
+    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)
+    effects.exit('directiveContainerContent');
+    effects.exit('directiveContainer');
+    return ok(code);
   }
 
   /** @type {Tokenizer} */
   function tokenizeClosingFence(effects, ok, nok) {
-    let size = 0
+    let size = 0;
 
     return factorySpace(
       effects,
       closingPrefixAfter,
       types.linePrefix,
-      constants.tabSize
-    )
+      constants.tabSize,
+    );
 
     /** @type {State} */
     function closingPrefixAfter(code) {
-      effects.enter('directiveContainerFence')
-      effects.enter('directiveContainerSequence')
-      return closingSequence(code)
+      effects.enter('directiveContainerFence');
+      effects.enter('directiveContainerSequence');
+      return closingSequence(code);
     }
 
     /** @type {State} */
     function closingSequence(code) {
       if (code === codes.colon) {
-        effects.consume(code)
-        size++
-        return closingSequence
+        effects.consume(code);
+        size++;
+        return closingSequence;
       }
 
-      if (size < sizeOpen) return nok(code)
-      effects.exit('directiveContainerSequence')
-      return factorySpace(effects, closingSequenceEnd, types.whitespace)(code)
+      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)
+        effects.exit('directiveContainerFence');
+        return ok(code);
       }
 
-      return nok(code)
+      return nok(code);
     }
   }
 }
@@ -246,8 +246,8 @@ function tokenizeLabel(effects, ok, nok) {
     'directiveContainerLabel',
     'directiveContainerLabelMarker',
     'directiveContainerLabelString',
-    true
-  )
+    true,
+  );
 }
 
 /** @type {Tokenizer} */
@@ -268,27 +268,27 @@ function tokenizeAttributes(effects, ok, nok) {
     'directiveContainerAttributeValue',
     'directiveContainerAttributeValueMarker',
     'directiveContainerAttributeValueData',
-    true
-  )
+    true,
+  );
 }
 
 /** @type {Tokenizer} */
 function tokenizeNonLazyLine(effects, ok, nok) {
-  const self = this
+  const self = this;
 
-  return start
+  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
+    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)
+    return self.parser.lazy[self.now().line] ? nok(code) : ok(code);
   }
 }

+ 35 - 33
packages/remark-growi-plugin/src/micromark-extension-growi-plugin/dev/lib/directive-leaf.js

@@ -4,80 +4,82 @@
  * @typedef {import('micromark-util-types').State} State
  */
 
-import {ok as assert} from 'uvu/assert'
-import {factorySpace} from 'micromark-factory-space'
-import {markdownLineEnding} from 'micromark-util-character'
-import {codes} from 'micromark-util-symbol/codes.js'
-import {types} from 'micromark-util-symbol/types.js'
-import {factoryAttributes} from './factory-attributes.js'
-import {factoryLabel} from './factory-label.js'
-import {factoryName} from './factory-name.js'
+import { factorySpace } from 'micromark-factory-space';
+import { markdownLineEnding } from 'micromark-util-character';
+import { codes } from 'micromark-util-symbol/codes.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 directiveLeaf = {tokenize: tokenizeDirectiveLeaf}
+export const directiveLeaf = { tokenize: tokenizeDirectiveLeaf };
 
-const label = {tokenize: tokenizeLabel, partial: true}
-const attributes = {tokenize: tokenizeAttributes, partial: true}
+const label = { tokenize: tokenizeLabel, partial: true };
+const attributes = { tokenize: tokenizeAttributes, partial: true };
 
 /** @type {Tokenizer} */
 function tokenizeDirectiveLeaf(effects, ok, nok) {
-  const self = this
+  // eslint-disable-next-line @typescript-eslint/no-this-alias
+  const self = this;
 
-  return start
+  return start;
 
   /** @type {State} */
   function start(code) {
-    assert(code === codes.colon, 'expected `:`')
-    effects.enter('directiveLeaf')
-    effects.enter('directiveLeafSequence')
-    effects.consume(code)
-    return inStart
+    assert(code === codes.colon, 'expected `:`');
+    effects.enter('directiveLeaf');
+    effects.enter('directiveLeafSequence');
+    effects.consume(code);
+    return inStart;
   }
 
   /** @type {State} */
   function inStart(code) {
     if (code === codes.colon) {
-      effects.consume(code)
-      effects.exit('directiveLeafSequence')
+      effects.consume(code);
+      effects.exit('directiveLeafSequence');
       return factoryName.call(
         self,
         effects,
         afterName,
         nok,
-        'directiveLeafName'
-      )
+        'directiveLeafName',
+      );
     }
 
-    return nok(code)
+    return nok(code);
   }
 
   /** @type {State} */
   function afterName(code) {
     return code === codes.leftSquareBracket
       ? effects.attempt(label, afterLabel, afterLabel)(code)
-      : afterLabel(code)
+      : afterLabel(code);
   }
 
   /** @type {State} */
   function afterLabel(code) {
     return code === codes.leftCurlyBrace
       ? effects.attempt(attributes, afterAttributes, afterAttributes)(code)
-      : afterAttributes(code)
+      : afterAttributes(code);
   }
 
   /** @type {State} */
   function afterAttributes(code) {
-    return factorySpace(effects, end, types.whitespace)(code)
+    return factorySpace(effects, end, types.whitespace)(code);
   }
 
   /** @type {State} */
   function end(code) {
     if (code === codes.eof || markdownLineEnding(code)) {
-      effects.exit('directiveLeaf')
-      return ok(code)
+      effects.exit('directiveLeaf');
+      return ok(code);
     }
 
-    return nok(code)
+    return nok(code);
   }
 }
 
@@ -91,8 +93,8 @@ function tokenizeLabel(effects, ok, nok) {
     'directiveLeafLabel',
     'directiveLeafLabelMarker',
     'directiveLeafLabelString',
-    true
-  )
+    true,
+  );
 }
 
 /** @type {Tokenizer} */
@@ -113,6 +115,6 @@ function tokenizeAttributes(effects, ok, nok) {
     'directiveLeafAttributeValue',
     'directiveLeafAttributeValueMarker',
     'directiveLeafAttributeValueData',
-    true
-  )
+    true,
+  );
 }

+ 34 - 31
packages/remark-growi-plugin/src/micromark-extension-growi-plugin/dev/lib/directive-text.js

@@ -5,68 +5,71 @@
  * @typedef {import('micromark-util-types').State} State
  */
 
-import {ok as assert} from 'uvu/assert'
-import {codes} from 'micromark-util-symbol/codes.js'
-import {types} from 'micromark-util-symbol/types.js'
-import {factoryAttributes} from './factory-attributes.js'
-import {factoryLabel} from './factory-label.js'
-import {factoryName} from './factory-name.js'
+import { codes } from 'micromark-util-symbol/codes.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 directiveText = {
   tokenize: tokenizeDirectiveText,
-  previous
-}
+  previous,
+};
 
-const label = {tokenize: tokenizeLabel, partial: true}
-const attributes = {tokenize: tokenizeAttributes, partial: true}
+const label = { tokenize: tokenizeLabel, partial: true };
+const attributes = { tokenize: tokenizeAttributes, partial: true };
 
 /** @type {Previous} */
 function previous(code) {
   // If there is a previous code, there will always be a tail.
   return (
-    code !== codes.colon ||
-    this.events[this.events.length - 1][1].type === types.characterEscape
-  )
+    code !== codes.colon
+    || this.events[this.events.length - 1][1].type === types.characterEscape
+  );
 }
 
 /** @type {Tokenizer} */
 function tokenizeDirectiveText(effects, ok, nok) {
-  const self = this
+  // eslint-disable-next-line @typescript-eslint/no-this-alias
+  const self = this;
 
-  return start
+  return start;
 
   /** @type {State} */
   function start(code) {
-    assert(code === codes.colon, 'expected `:`')
-    assert(previous.call(self, self.previous), 'expected correct previous')
-    effects.enter('directiveText')
-    effects.enter('directiveTextMarker')
-    effects.consume(code)
-    effects.exit('directiveTextMarker')
-    return factoryName.call(self, effects, afterName, nok, 'directiveTextName')
+    assert(code === codes.colon, 'expected `:`');
+    assert(previous.call(self, self.previous), 'expected correct previous');
+    effects.enter('directiveText');
+    effects.enter('directiveTextMarker');
+    effects.consume(code);
+    effects.exit('directiveTextMarker');
+    return factoryName.call(self, effects, afterName, nok, 'directiveTextName');
   }
 
   /** @type {State} */
   function afterName(code) {
+    // eslint-disable-next-line no-nested-ternary
     return code === codes.colon
       ? nok(code)
       : code === codes.leftSquareBracket
-      ? effects.attempt(label, afterLabel, afterLabel)(code)
-      : afterLabel(code)
+        ? 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)
+      : afterAttributes(code);
   }
 
   /** @type {State} */
   function afterAttributes(code) {
-    effects.exit('directiveText')
-    return ok(code)
+    effects.exit('directiveText');
+    return ok(code);
   }
 }
 
@@ -79,8 +82,8 @@ function tokenizeLabel(effects, ok, nok) {
     nok,
     'directiveTextLabel',
     'directiveTextLabelMarker',
-    'directiveTextLabelString'
-  )
+    'directiveTextLabelString',
+  );
 }
 
 /** @type {Tokenizer} */
@@ -100,6 +103,6 @@ function tokenizeAttributes(effects, ok, nok) {
     'directiveTextAttributeValueLiteral',
     'directiveTextAttributeValue',
     'directiveTextAttributeValueMarker',
-    'directiveTextAttributeValueData'
-  )
+    'directiveTextAttributeValueData',
+  );
 }

+ 159 - 159
packages/remark-growi-plugin/src/micromark-extension-growi-plugin/dev/lib/factory-attributes.js

@@ -4,18 +4,18 @@
  * @typedef {import('micromark-util-types').Code} Code
  */
 
-import {ok as assert} from 'uvu/assert'
-import {factorySpace} from 'micromark-factory-space'
-import {factoryWhitespace} from 'micromark-factory-whitespace'
+import { factorySpace } from 'micromark-factory-space';
+import { factoryWhitespace } from 'micromark-factory-whitespace';
 import {
   asciiAlpha,
   asciiAlphanumeric,
   markdownLineEnding,
   markdownLineEndingOrSpace,
-  markdownSpace
-} from 'micromark-util-character'
-import {codes} from 'micromark-util-symbol/codes.js'
-import {types} from 'micromark-util-symbol/types.js'
+  markdownSpace,
+} from 'micromark-util-character';
+import { codes } from 'micromark-util-symbol/codes.js';
+import { types } from 'micromark-util-symbol/types.js';
+import { ok as assert } from 'uvu/assert';
 
 /**
  * @param {Effects} effects
@@ -36,301 +36,301 @@ import {types} from 'micromark-util-symbol/types.js'
  */
 /* eslint-disable-next-line max-params */
 export function factoryAttributes(
-  effects,
-  ok,
-  nok,
-  attributesType,
-  attributesMarkerType,
-  attributeType,
-  attributeIdType,
-  attributeClassType,
-  attributeNameType,
-  attributeInitializerType,
-  attributeValueLiteralType,
-  attributeValueType,
-  attributeValueMarker,
-  attributeValueData,
-  disallowEol
+    effects,
+    ok,
+    nok,
+    attributesType,
+    attributesMarkerType,
+    attributeType,
+    attributeIdType,
+    attributeClassType,
+    attributeNameType,
+    attributeInitializerType,
+    attributeValueLiteralType,
+    attributeValueType,
+    attributeValueMarker,
+    attributeValueData,
+    disallowEol,
 ) {
   /** @type {string} */
-  let type
+  let type;
   /** @type {Code|undefined} */
-  let marker
+  let marker;
 
-  return start
+  return start;
 
   /** @type {State} */
   function start(code) {
-    assert(code === codes.leftCurlyBrace, 'expected `{`')
-    effects.enter(attributesType)
-    effects.enter(attributesMarkerType)
-    effects.consume(code)
-    effects.exit(attributesMarkerType)
-    return between
+    assert(code === codes.leftCurlyBrace, 'expected `{`');
+    effects.enter(attributesType);
+    effects.enter(attributesMarkerType);
+    effects.consume(code);
+    effects.exit(attributesMarkerType);
+    return between;
   }
 
   /** @type {State} */
   function between(code) {
     if (code === codes.numberSign) {
-      type = attributeIdType
-      return shortcutStart(code)
+      type = attributeIdType;
+      return shortcutStart(code);
     }
 
     if (code === codes.dot) {
-      type = attributeClassType
-      return shortcutStart(code)
+      type = attributeClassType;
+      return shortcutStart(code);
     }
 
     if (code === codes.colon || code === codes.underscore || asciiAlpha(code)) {
-      effects.enter(attributeType)
-      effects.enter(attributeNameType)
-      effects.consume(code)
-      return name
+      effects.enter(attributeType);
+      effects.enter(attributeNameType);
+      effects.consume(code);
+      return name;
     }
 
     if (disallowEol && markdownSpace(code)) {
-      return factorySpace(effects, between, types.whitespace)(code)
+      return factorySpace(effects, between, types.whitespace)(code);
     }
 
     if (!disallowEol && markdownLineEndingOrSpace(code)) {
-      return factoryWhitespace(effects, between)(code)
+      return factoryWhitespace(effects, between)(code);
     }
 
-    return end(code)
+    return end(code);
   }
 
   /** @type {State} */
   function shortcutStart(code) {
-    effects.enter(attributeType)
-    effects.enter(type)
-    effects.enter(type + 'Marker')
-    effects.consume(code)
-    effects.exit(type + 'Marker')
-    return shortcutStartAfter
+    effects.enter(attributeType);
+    effects.enter(type);
+    effects.enter(`${type}Marker`);
+    effects.consume(code);
+    effects.exit(`${type}Marker`);
+    return shortcutStartAfter;
   }
 
   /** @type {State} */
   function shortcutStartAfter(code) {
     if (
-      code === codes.eof ||
-      code === codes.quotationMark ||
-      code === codes.numberSign ||
-      code === codes.apostrophe ||
-      code === codes.dot ||
-      code === codes.lessThan ||
-      code === codes.equalsTo ||
-      code === codes.greaterThan ||
-      code === codes.graveAccent ||
-      code === codes.rightCurlyBrace ||
-      markdownLineEndingOrSpace(code)
+      code === codes.eof
+      || code === codes.quotationMark
+      || code === codes.numberSign
+      || code === codes.apostrophe
+      || code === codes.dot
+      || code === codes.lessThan
+      || code === codes.equalsTo
+      || code === codes.greaterThan
+      || code === codes.graveAccent
+      || code === codes.rightCurlyBrace
+      || markdownLineEndingOrSpace(code)
     ) {
-      return nok(code)
+      return nok(code);
     }
 
-    effects.enter(type + 'Value')
-    effects.consume(code)
-    return shortcut
+    effects.enter(`${type}Value`);
+    effects.consume(code);
+    return shortcut;
   }
 
   /** @type {State} */
   function shortcut(code) {
     if (
-      code === codes.eof ||
-      code === codes.quotationMark ||
-      code === codes.apostrophe ||
-      code === codes.lessThan ||
-      code === codes.equalsTo ||
-      code === codes.greaterThan ||
-      code === codes.graveAccent
+      code === codes.eof
+      || code === codes.quotationMark
+      || code === codes.apostrophe
+      || code === codes.lessThan
+      || code === codes.equalsTo
+      || code === codes.greaterThan
+      || code === codes.graveAccent
     ) {
-      return nok(code)
+      return nok(code);
     }
 
     if (
-      code === codes.numberSign ||
-      code === codes.dot ||
-      code === codes.rightCurlyBrace ||
-      markdownLineEndingOrSpace(code)
+      code === codes.numberSign
+      || code === codes.dot
+      || code === codes.rightCurlyBrace
+      || markdownLineEndingOrSpace(code)
     ) {
-      effects.exit(type + 'Value')
-      effects.exit(type)
-      effects.exit(attributeType)
-      return between(code)
+      effects.exit(`${type}Value`);
+      effects.exit(type);
+      effects.exit(attributeType);
+      return between(code);
     }
 
-    effects.consume(code)
-    return shortcut
+    effects.consume(code);
+    return shortcut;
   }
 
   /** @type {State} */
   function name(code) {
     if (
-      code === codes.dash ||
-      code === codes.dot ||
-      code === codes.colon ||
-      code === codes.underscore ||
-      asciiAlphanumeric(code)
+      code === codes.dash
+      || code === codes.dot
+      || code === codes.colon
+      || code === codes.underscore
+      || asciiAlphanumeric(code)
     ) {
-      effects.consume(code)
-      return name
+      effects.consume(code);
+      return name;
     }
 
-    effects.exit(attributeNameType)
+    effects.exit(attributeNameType);
 
     if (disallowEol && markdownSpace(code)) {
-      return factorySpace(effects, nameAfter, types.whitespace)(code)
+      return factorySpace(effects, nameAfter, types.whitespace)(code);
     }
 
     if (!disallowEol && markdownLineEndingOrSpace(code)) {
-      return factoryWhitespace(effects, nameAfter)(code)
+      return factoryWhitespace(effects, nameAfter)(code);
     }
 
-    return nameAfter(code)
+    return nameAfter(code);
   }
 
   /** @type {State} */
   function nameAfter(code) {
     if (code === codes.equalsTo) {
-      effects.enter(attributeInitializerType)
-      effects.consume(code)
-      effects.exit(attributeInitializerType)
-      return valueBefore
+      effects.enter(attributeInitializerType);
+      effects.consume(code);
+      effects.exit(attributeInitializerType);
+      return valueBefore;
     }
 
     // Attribute w/o value.
-    effects.exit(attributeType)
-    return between(code)
+    effects.exit(attributeType);
+    return between(code);
   }
 
   /** @type {State} */
   function valueBefore(code) {
     if (
-      code === codes.eof ||
-      code === codes.lessThan ||
-      code === codes.equalsTo ||
-      code === codes.greaterThan ||
-      code === codes.graveAccent ||
-      code === codes.rightCurlyBrace ||
-      (disallowEol && markdownLineEnding(code))
+      code === codes.eof
+      || code === codes.lessThan
+      || code === codes.equalsTo
+      || code === codes.greaterThan
+      || code === codes.graveAccent
+      || code === codes.rightCurlyBrace
+      || (disallowEol && markdownLineEnding(code))
     ) {
-      return nok(code)
+      return nok(code);
     }
 
     if (code === codes.quotationMark || code === codes.apostrophe) {
-      effects.enter(attributeValueLiteralType)
-      effects.enter(attributeValueMarker)
-      effects.consume(code)
-      effects.exit(attributeValueMarker)
-      marker = code
-      return valueQuotedStart
+      effects.enter(attributeValueLiteralType);
+      effects.enter(attributeValueMarker);
+      effects.consume(code);
+      effects.exit(attributeValueMarker);
+      marker = code;
+      return valueQuotedStart;
     }
 
     if (disallowEol && markdownSpace(code)) {
-      return factorySpace(effects, valueBefore, types.whitespace)(code)
+      return factorySpace(effects, valueBefore, types.whitespace)(code);
     }
 
     if (!disallowEol && markdownLineEndingOrSpace(code)) {
-      return factoryWhitespace(effects, valueBefore)(code)
+      return factoryWhitespace(effects, valueBefore)(code);
     }
 
-    effects.enter(attributeValueType)
-    effects.enter(attributeValueData)
-    effects.consume(code)
-    marker = undefined
-    return valueUnquoted
+    effects.enter(attributeValueType);
+    effects.enter(attributeValueData);
+    effects.consume(code);
+    marker = undefined;
+    return valueUnquoted;
   }
 
   /** @type {State} */
   function valueUnquoted(code) {
     if (
-      code === codes.eof ||
-      code === codes.quotationMark ||
-      code === codes.apostrophe ||
-      code === codes.lessThan ||
-      code === codes.equalsTo ||
-      code === codes.greaterThan ||
-      code === codes.graveAccent
+      code === codes.eof
+      || code === codes.quotationMark
+      || code === codes.apostrophe
+      || code === codes.lessThan
+      || code === codes.equalsTo
+      || code === codes.greaterThan
+      || code === codes.graveAccent
     ) {
-      return nok(code)
+      return nok(code);
     }
 
     if (code === codes.rightCurlyBrace || markdownLineEndingOrSpace(code)) {
-      effects.exit(attributeValueData)
-      effects.exit(attributeValueType)
-      effects.exit(attributeType)
-      return between(code)
+      effects.exit(attributeValueData);
+      effects.exit(attributeValueType);
+      effects.exit(attributeType);
+      return between(code);
     }
 
-    effects.consume(code)
-    return valueUnquoted
+    effects.consume(code);
+    return valueUnquoted;
   }
 
   /** @type {State} */
   function valueQuotedStart(code) {
     if (code === marker) {
-      effects.enter(attributeValueMarker)
-      effects.consume(code)
-      effects.exit(attributeValueMarker)
-      effects.exit(attributeValueLiteralType)
-      effects.exit(attributeType)
-      return valueQuotedAfter
+      effects.enter(attributeValueMarker);
+      effects.consume(code);
+      effects.exit(attributeValueMarker);
+      effects.exit(attributeValueLiteralType);
+      effects.exit(attributeType);
+      return valueQuotedAfter;
     }
 
-    effects.enter(attributeValueType)
-    return valueQuotedBetween(code)
+    effects.enter(attributeValueType);
+    return valueQuotedBetween(code);
   }
 
   /** @type {State} */
   function valueQuotedBetween(code) {
     if (code === marker) {
-      effects.exit(attributeValueType)
-      return valueQuotedStart(code)
+      effects.exit(attributeValueType);
+      return valueQuotedStart(code);
     }
 
     if (code === codes.eof) {
-      return nok(code)
+      return nok(code);
     }
 
     // Note: blank lines can’t exist in content.
     if (markdownLineEnding(code)) {
       return disallowEol
         ? nok(code)
-        : factoryWhitespace(effects, valueQuotedBetween)(code)
+        : factoryWhitespace(effects, valueQuotedBetween)(code);
     }
 
-    effects.enter(attributeValueData)
-    effects.consume(code)
-    return valueQuoted
+    effects.enter(attributeValueData);
+    effects.consume(code);
+    return valueQuoted;
   }
 
   /** @type {State} */
   function valueQuoted(code) {
     if (code === marker || code === codes.eof || markdownLineEnding(code)) {
-      effects.exit(attributeValueData)
-      return valueQuotedBetween(code)
+      effects.exit(attributeValueData);
+      return valueQuotedBetween(code);
     }
 
-    effects.consume(code)
-    return valueQuoted
+    effects.consume(code);
+    return valueQuoted;
   }
 
   /** @type {State} */
   function valueQuotedAfter(code) {
     return code === codes.rightCurlyBrace || markdownLineEndingOrSpace(code)
       ? between(code)
-      : end(code)
+      : end(code);
   }
 
   /** @type {State} */
   function end(code) {
     if (code === codes.rightCurlyBrace) {
-      effects.enter(attributesMarkerType)
-      effects.consume(code)
-      effects.exit(attributesMarkerType)
-      effects.exit(attributesType)
-      return ok
+      effects.enter(attributesMarkerType);
+      effects.consume(code);
+      effects.exit(attributesMarkerType);
+      effects.exit(attributesType);
+      return ok;
     }
 
-    return nok(code)
+    return nok(code);
   }
 }

+ 60 - 60
packages/remark-growi-plugin/src/micromark-extension-growi-plugin/dev/lib/factory-label.js

@@ -4,11 +4,11 @@
  * @typedef {import('micromark-util-types').Token} Token
  */
 
-import {ok as assert} from 'uvu/assert'
-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 { 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';
 
 // This is a fork of:
 // <https://github.com/micromark/micromark/tree/main/packages/micromark-factory-label>
@@ -26,114 +26,114 @@ import {types} from 'micromark-util-symbol/types.js'
  */
 // eslint-disable-next-line max-params
 export function factoryLabel(
-  effects,
-  ok,
-  nok,
-  type,
-  markerType,
-  stringType,
-  disallowEol
+    effects,
+    ok,
+    nok,
+    type,
+    markerType,
+    stringType,
+    disallowEol,
 ) {
-  let size = 0
-  let balance = 0
+  let size = 0;
+  let balance = 0;
   /** @type {Token|undefined} */
-  let previous
+  let previous;
 
-  return start
+  return start;
 
   /** @type {State} */
   function start(code) {
-    assert(code === codes.leftSquareBracket, 'expected `[`')
-    effects.enter(type)
-    effects.enter(markerType)
-    effects.consume(code)
-    effects.exit(markerType)
-    return afterStart
+    assert(code === codes.leftSquareBracket, 'expected `[`');
+    effects.enter(type);
+    effects.enter(markerType);
+    effects.consume(code);
+    effects.exit(markerType);
+    return afterStart;
   }
 
   /** @type {State} */
   function afterStart(code) {
     if (code === codes.rightSquareBracket) {
-      effects.enter(markerType)
-      effects.consume(code)
-      effects.exit(markerType)
-      effects.exit(type)
-      return ok
+      effects.enter(markerType);
+      effects.consume(code);
+      effects.exit(markerType);
+      effects.exit(type);
+      return ok;
     }
 
-    effects.enter(stringType)
-    return lineStart(code)
+    effects.enter(stringType);
+    return lineStart(code);
   }
 
   /** @type {State} */
   function lineStart(code) {
     if (code === codes.rightSquareBracket && !balance) {
-      return atClosingBrace(code)
+      return atClosingBrace(code);
     }
 
     const token = effects.enter(types.chunkText, {
       contentType: constants.contentTypeText,
-      previous
-    })
-    if (previous) previous.next = token
-    previous = token
-    return data(code)
+      previous,
+    });
+    if (previous) previous.next = token;
+    previous = token;
+    return data(code);
   }
 
   /** @type {State} */
   function data(code) {
     if (code === codes.eof || size > constants.linkReferenceSizeMax) {
-      return nok(code)
+      return nok(code);
     }
 
     if (
-      code === codes.leftSquareBracket &&
-      ++balance > constants.linkResourceDestinationBalanceMax
+      code === codes.leftSquareBracket
+      && ++balance > constants.linkResourceDestinationBalanceMax
     ) {
-      return nok(code)
+      return nok(code);
     }
 
     if (code === codes.rightSquareBracket && !balance--) {
-      effects.exit(types.chunkText)
-      return atClosingBrace(code)
+      effects.exit(types.chunkText);
+      return atClosingBrace(code);
     }
 
     if (markdownLineEnding(code)) {
       if (disallowEol) {
-        return nok(code)
+        return nok(code);
       }
 
-      effects.consume(code)
-      effects.exit(types.chunkText)
-      return lineStart
+      effects.consume(code);
+      effects.exit(types.chunkText);
+      return lineStart;
     }
 
-    effects.consume(code)
-    return code === codes.backslash ? dataEscape : data
+    effects.consume(code);
+    return code === codes.backslash ? dataEscape : data;
   }
 
   /** @type {State} */
   function dataEscape(code) {
     if (
-      code === codes.leftSquareBracket ||
-      code === codes.backslash ||
-      code === codes.rightSquareBracket
+      code === codes.leftSquareBracket
+      || code === codes.backslash
+      || code === codes.rightSquareBracket
     ) {
-      effects.consume(code)
-      size++
-      return data
+      effects.consume(code);
+      size++;
+      return data;
     }
 
-    return data(code)
+    return data(code);
   }
 
   /** @type {State} */
   function atClosingBrace(code) {
-    effects.exit(stringType)
-    effects.enter(markerType)
-    effects.consume(code)
-    effects.exit(markerType)
-    effects.exit(type)
-    return ok
+    effects.exit(stringType);
+    effects.enter(markerType);
+    effects.consume(code);
+    effects.exit(markerType);
+    effects.exit(type);
+    return ok;
   }
 }

+ 16 - 15
packages/remark-growi-plugin/src/micromark-extension-growi-plugin/dev/lib/factory-name.js

@@ -4,8 +4,8 @@
  * @typedef {import('micromark-util-types').State} State
  */
 
-import {asciiAlpha, asciiAlphanumeric} from 'micromark-util-character'
-import {codes} from 'micromark-util-symbol/codes.js'
+import { asciiAlpha, asciiAlphanumeric } from 'micromark-util-character';
+import { codes } from 'micromark-util-symbol/codes.js';
 
 /**
  * @this {TokenizeContext}
@@ -15,35 +15,36 @@ import {codes} from 'micromark-util-symbol/codes.js'
  * @param {string} type
  */
 export function factoryName(effects, ok, nok, type) {
-  const self = this
+  // eslint-disable-next-line @typescript-eslint/no-this-alias
+  const self = this;
 
-  return start
+  return start;
 
   /** @type {State} */
   function start(code) {
     if (asciiAlpha(code)) {
-      effects.enter(type)
-      effects.consume(code)
-      return name
+      effects.enter(type);
+      effects.consume(code);
+      return name;
     }
 
-    return nok(code)
+    return nok(code);
   }
 
   /** @type {State} */
   function name(code) {
     if (
-      code === codes.dash ||
-      code === codes.underscore ||
-      asciiAlphanumeric(code)
+      code === codes.dash
+      || code === codes.underscore
+      || asciiAlphanumeric(code)
     ) {
-      effects.consume(code)
-      return name
+      effects.consume(code);
+      return name;
     }
 
-    effects.exit(type)
+    effects.exit(type);
     return self.previous === codes.dash || self.previous === codes.underscore
       ? nok(code)
-      : ok(code)
+      : ok(code);
   }
 }

+ 8 - 7
packages/remark-growi-plugin/src/micromark-extension-growi-plugin/dev/lib/syntax.js

@@ -2,17 +2,18 @@
  * @typedef {import('micromark-util-types').Extension} Extension
  */
 
-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'
+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';
 
 /**
  * @returns {Extension}
  */
 export function directive() {
   return {
-    text: {[codes.colon]: directiveText},
-    flow: {[codes.colon]: [directiveContainer, directiveLeaf]}
-  }
+    text: { [codes.colon]: directiveText },
+    flow: { [codes.colon]: [directiveContainer, directiveLeaf] },
+  };
 }

+ 2 - 2
packages/remark-growi-plugin/src/remark-growi-plugin.ts

@@ -1,7 +1,7 @@
 import { Plugin } from 'unified';
 
-import { directiveFromMarkdown, directiveToMarkdown } from './mdast-util-growi-plugin';
-import { directive } from './micromark-extension-growi-plugin/dev';
+import { directiveFromMarkdown, directiveToMarkdown } from './mdast-util-growi-plugin/index.js';
+import { directive } from './micromark-extension-growi-plugin/dev/index.js';
 
 export const remarkGrowiPlugin: Plugin = function() {
   const data = this.data();