Browse Source

allow spaces in attribute names within lsx.ts

Hiroki Aihara 1 week ago
parent
commit
2eaeb8d2ca

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

@@ -111,6 +111,7 @@ export function factoryAttributes(
       code !== codes.greaterThan &&
       code !== codes.graveAccent &&
       code !== codes.rightParenthesis &&
+      code !== codes.space &&
       code !== codes.comma
     ) {
       effects.consume(code);

+ 8 - 1
packages/remark-lsx/src/client/services/renderer/lsx.ts

@@ -63,7 +63,14 @@ export const remarkPlugin: Plugin = () => (tree) => {
             firstAttrValue === '' &&
             !SUPPORTED_ATTRIBUTES.includes(firstAttrKey)
           ) {
-            attributes.prefix = firstAttrKey.trim();
+            const prefixParts: string[] = [];
+            for (const [key, value] of attrEntries) {
+              if (value !== '' || SUPPORTED_ATTRIBUTES.includes(key)) {
+                break;
+              }
+              prefixParts.push(key);
+            }
+            attributes.prefix = prefixParts.join(' ');
           }
         }
       }