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

+ 2 - 51
packages/remark-growi-directive/src/mdast-util-growi-directive/index.js

@@ -40,16 +40,12 @@ export const directiveFromMarkdown = {
   },
   },
   exit: {
   exit: {
     directiveLeaf: exit,
     directiveLeaf: exit,
-    directiveLeafAttributeClassValue: exitAttributeClassValue,
-    directiveLeafAttributeIdValue: exitAttributeIdValue,
     directiveLeafAttributeName: exitAttributeName,
     directiveLeafAttributeName: exitAttributeName,
     directiveLeafAttributeValue: exitAttributeValue,
     directiveLeafAttributeValue: exitAttributeValue,
     directiveLeafAttributes: exitAttributes,
     directiveLeafAttributes: exitAttributes,
     directiveLeafName: exitName,
     directiveLeafName: exitName,
 
 
     directiveText: exit,
     directiveText: exit,
-    directiveTextAttributeClassValue: exitAttributeClassValue,
-    directiveTextAttributeIdValue: exitAttributeIdValue,
     directiveTextAttributeName: exitAttributeName,
     directiveTextAttributeName: exitAttributeName,
     directiveTextAttributeValue: exitAttributeValue,
     directiveTextAttributeValue: exitAttributeValue,
     directiveTextAttributes: exitAttributes,
     directiveTextAttributes: exitAttributes,
@@ -118,22 +114,6 @@ function enterAttributes() {
   this.buffer(); // Capture EOLs
   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))]);
-}
-
-/** @type {FromMarkdownHandle} */
-function exitAttributeClassValue(token) {
-  const list = /** @type {Array.<[string, string]>} */ (
-    this.getData('directiveAttributes')
-  );
-  list.push(['class', parseEntities(this.sliceSerialize(token))]);
-}
-
 /** @type {FromMarkdownHandle} */
 /** @type {FromMarkdownHandle} */
 function exitAttributeValue(token) {
 function exitAttributeValue(token) {
   const list = /** @type {Array.<[string, string]>} */ (
   const list = /** @type {Array.<[string, string]>} */ (
@@ -165,12 +145,7 @@ function exitAttributes() {
   while (++index < list.length) {
   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[attribute[0]] = attribute[1];
   }
   }
 
 
   this.setData('directiveAttributes');
   this.setData('directiveAttributes');
@@ -252,31 +227,7 @@ function attributes(node, context) {
     ) {
     ) {
       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);
-        /** @type {Array.<string>} */
-        const classesFullList = [];
-        /** @type {Array.<string>} */
-        const classesList = [];
-        let index = -1;
-
-        while (++index < list.length) {
-          (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));
-      }
+      values.push(quoted(key, value));
     }
     }
   }
   }
 
 

+ 0 - 2
packages/remark-growi-directive/src/micromark-extension-growi-directive/lib/directive-leaf.js

@@ -125,8 +125,6 @@ function tokenizeAttributes(effects, ok, nok) {
     'directiveLeafAttributes',
     'directiveLeafAttributes',
     'directiveLeafAttributesMarker',
     'directiveLeafAttributesMarker',
     'directiveLeafAttribute',
     'directiveLeafAttribute',
-    'directiveLeafAttributeId',
-    'directiveLeafAttributeClass',
     'directiveLeafAttributeName',
     'directiveLeafAttributeName',
     'directiveLeafAttributeInitializerMarker',
     'directiveLeafAttributeInitializerMarker',
     'directiveLeafAttributeValueLiteral',
     'directiveLeafAttributeValueLiteral',

+ 0 - 2
packages/remark-growi-directive/src/micromark-extension-growi-directive/lib/directive-text.js

@@ -96,8 +96,6 @@ function tokenizeAttributes(effects, ok, nok) {
     'directiveTextAttributes',
     'directiveTextAttributes',
     'directiveTextAttributesMarker',
     'directiveTextAttributesMarker',
     'directiveTextAttribute',
     'directiveTextAttribute',
-    'directiveTextAttributeId',
-    'directiveTextAttributeClass',
     'directiveTextAttributeName',
     'directiveTextAttributeName',
     'directiveTextAttributeInitializerMarker',
     'directiveTextAttributeInitializerMarker',
     'directiveTextAttributeValueLiteral',
     'directiveTextAttributeValueLiteral',

+ 0 - 79
packages/remark-growi-directive/src/micromark-extension-growi-directive/lib/factory-attributes.js

@@ -24,8 +24,6 @@ import { markdownLineEndingOrSpaceOrComma, factoryAttributesDevider } from '../.
  * @param {string} attributesType
  * @param {string} attributesType
  * @param {string} attributesMarkerType
  * @param {string} attributesMarkerType
  * @param {string} attributeType
  * @param {string} attributeType
- * @param {string} attributeIdType
- * @param {string} attributeClassType
  * @param {string} attributeNameType
  * @param {string} attributeNameType
  * @param {string} attributeInitializerType
  * @param {string} attributeInitializerType
  * @param {string} attributeValueLiteralType
  * @param {string} attributeValueLiteralType
@@ -42,8 +40,6 @@ export function factoryAttributes(
     attributesType,
     attributesType,
     attributesMarkerType,
     attributesMarkerType,
     attributeType,
     attributeType,
-    attributeIdType,
-    attributeClassType,
     attributeNameType,
     attributeNameType,
     attributeInitializerType,
     attributeInitializerType,
     attributeValueLiteralType,
     attributeValueLiteralType,
@@ -71,16 +67,6 @@ export function factoryAttributes(
 
 
   /** @type {State} */
   /** @type {State} */
   function between(code) {
   function between(code) {
-    if (code === codes.numberSign) {
-      type = attributeIdType;
-      return shortcutStart(code);
-    }
-
-    if (code === codes.dot) {
-      type = attributeClassType;
-      return shortcutStart(code);
-    }
-
     if (disallowEol) {
     if (disallowEol) {
       if (markdownSpace(code)) {
       if (markdownSpace(code)) {
         return factorySpace(effects, between, types.whitespace)(code);
         return factorySpace(effects, between, types.whitespace)(code);
@@ -110,69 +96,6 @@ export function factoryAttributes(
     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;
-  }
-
-  /** @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.rightParenthesis
-      || code === codes.comma
-    ) {
-      return nok(code);
-    }
-
-    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
-    ) {
-      return nok(code);
-    }
-
-    if (
-      code === codes.numberSign
-      || code === codes.dot
-      || code === codes.rightParenthesis
-      || markdownLineEndingOrSpaceOrComma(code)
-    ) {
-      effects.exit(`${type}Value`);
-      effects.exit(type);
-      effects.exit(attributeType);
-      return between(code);
-    }
-
-    effects.consume(code);
-    return shortcut;
-  }
-
   /** @type {State} */
   /** @type {State} */
   function name(code) {
   function name(code) {
     if (
     if (
@@ -181,9 +104,7 @@ export function factoryAttributes(
         && code !== codes.lineFeed
         && code !== codes.lineFeed
         && code !== codes.carriageReturnLineFeed
         && code !== codes.carriageReturnLineFeed
         && code !== codes.quotationMark
         && code !== codes.quotationMark
-        && code !== codes.numberSign
         && code !== codes.apostrophe
         && code !== codes.apostrophe
-        && code !== codes.dot
         && code !== codes.lessThan
         && code !== codes.lessThan
         && code !== codes.equalsTo
         && code !== codes.equalsTo
         && code !== codes.greaterThan
         && code !== codes.greaterThan

+ 1 - 25
packages/remark-growi-directive/src/micromark-extension-growi-directive/lib/html.js

@@ -49,8 +49,6 @@ export function directiveHtml(options = {}) {
     },
     },
     exit: {
     exit: {
       directiveLeaf: exit,
       directiveLeaf: exit,
-      directiveLeafAttributeClassValue: exitAttributeClassValue,
-      directiveLeafAttributeIdValue: exitAttributeIdValue,
       directiveLeafAttributeName: exitAttributeName,
       directiveLeafAttributeName: exitAttributeName,
       directiveLeafAttributeValue: exitAttributeValue,
       directiveLeafAttributeValue: exitAttributeValue,
       directiveLeafAttributes: exitAttributes,
       directiveLeafAttributes: exitAttributes,
@@ -58,8 +56,6 @@ export function directiveHtml(options = {}) {
       directiveLeafName: exitName,
       directiveLeafName: exitName,
 
 
       directiveText: exit,
       directiveText: exit,
-      directiveTextAttributeClassValue: exitAttributeClassValue,
-      directiveTextAttributeIdValue: exitAttributeIdValue,
       directiveTextAttributeName: exitAttributeName,
       directiveTextAttributeName: exitAttributeName,
       directiveTextAttributeValue: exitAttributeValue,
       directiveTextAttributeValue: exitAttributeValue,
       directiveTextAttributes: exitAttributes,
       directiveTextAttributes: exitAttributes,
@@ -105,21 +101,6 @@ export function directiveHtml(options = {}) {
     this.setData('directiveAttributes', []);
     this.setData('directiveAttributes', []);
   }
   }
 
 
-  /** @type {_Handle} */
-  function exitAttributeIdValue(token) {
-    /** @type {Attribute[]} */
-    const attributes = this.getData('directiveAttributes');
-    attributes.push(['id', parseEntities(this.sliceSerialize(token))]);
-  }
-
-  /** @type {_Handle} */
-  function exitAttributeClassValue(token) {
-    /** @type {Attribute[]} */
-    const attributes = this.getData('directiveAttributes');
-
-    attributes.push(['class', parseEntities(this.sliceSerialize(token))]);
-  }
-
   /** @type {_Handle} */
   /** @type {_Handle} */
   function exitAttributeName(token) {
   function exitAttributeName(token) {
     // Attribute names in CommonMark are significantly limited, so character
     // Attribute names in CommonMark are significantly limited, so character
@@ -154,12 +135,7 @@ export function directiveHtml(options = {}) {
     while (++index < attributes.length) {
     while (++index < attributes.length) {
       attribute = attributes[index];
       attribute = attributes[index];
 
 
-      if (attribute[0] === 'class' && cleaned.class) {
-        cleaned.class += ` ${attribute[1]}`;
-      }
-      else {
-        cleaned[attribute[0]] = attribute[1];
-      }
+      cleaned[attribute[0]] = attribute[1];
     }
     }
 
 
     this.resume();
     this.resume();