@readme/markdown 6.75.0-beta.74 → 6.75.0-beta.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -65251,6 +65251,8 @@ const variables = ({ asMdx } = { asMdx: true }) => tree => {
65251
65251
 
65252
65252
 
65253
65253
  const alignToStyle = (align) => {
65254
+ if (!align)
65255
+ return align;
65254
65256
  return {
65255
65257
  type: 'mdxJsxAttribute',
65256
65258
  name: 'style',
@@ -65263,7 +65265,10 @@ const alignToStyle = (align) => {
65263
65265
  const visitor = (table, index, parent) => {
65264
65266
  let hasFlowContent = false;
65265
65267
  const tableCellVisitor = (cell) => {
65266
- if (!phrasing(cell.children[0])) {
65268
+ const content = cell.children.length === 1 && cell.children[0].type === 'paragraph'
65269
+ ? cell.children[0].children[0]
65270
+ : cell.children[0];
65271
+ if (!phrasing(content)) {
65267
65272
  hasFlowContent = true;
65268
65273
  return EXIT;
65269
65274
  }
@@ -65275,8 +65280,10 @@ const visitor = (table, index, parent) => {
65275
65280
  });
65276
65281
  };
65277
65282
  visit(table, 'tableCell', tableCellVisitor);
65278
- if (!hasFlowContent)
65283
+ if (!hasFlowContent) {
65284
+ table.type = 'table';
65279
65285
  return;
65286
+ }
65280
65287
  const styles = table.align.map(alignToStyle);
65281
65288
  const head = {
65282
65289
  type: 'mdxJsxFlowElement',
@@ -65286,12 +65293,7 @@ const visitor = (table, index, parent) => {
65286
65293
  type: 'mdxJsxFlowElement',
65287
65294
  name: 'tr',
65288
65295
  children: table.children[0].children.map((cell, index) => {
65289
- return {
65290
- type: 'mdxJsxFlowElement',
65291
- name: 'th',
65292
- children: cell.children,
65293
- attributes: [styles[index]],
65294
- };
65296
+ return Object.assign({ type: 'mdxJsxFlowElement', name: 'th', children: cell.children }, (styles[index] && { attributes: [styles[index]] }));
65295
65297
  }),
65296
65298
  },
65297
65299
  ],
@@ -65304,12 +65306,7 @@ const visitor = (table, index, parent) => {
65304
65306
  type: 'mdxJsxFlowElement',
65305
65307
  name: 'tr',
65306
65308
  children: row.children.map((cell, index) => {
65307
- return {
65308
- type: 'mdxJsxFlowElement',
65309
- name: 'td',
65310
- children: cell.children,
65311
- attributes: [styles[index]],
65312
- };
65309
+ return Object.assign({ type: 'mdxJsxFlowElement', name: 'td', children: cell.children }, (styles[index] && { attributes: [styles[index]] }));
65313
65310
  }),
65314
65311
  };
65315
65312
  }),
@@ -65324,17 +65321,13 @@ const visitor = (table, index, parent) => {
65324
65321
  },
65325
65322
  },
65326
65323
  ];
65327
- const jsx = {
65328
- type: 'mdxJsxFlowElement',
65329
- name: 'Table',
65330
- attributes,
65331
- children: [head, body],
65332
- };
65324
+ const jsx = Object.assign(Object.assign({ type: 'mdxJsxFlowElement', name: 'Table' }, (table.align.find(a => a) && { attributes })), { children: [head, body] });
65333
65325
  // @ts-ignore
65334
65326
  parent.children[index] = jsx;
65335
65327
  };
65328
+ const isTable = (node) => ['table', 'tableau'].includes(node.type);
65336
65329
  const tablesToJsx = () => tree => {
65337
- visit(tree, 'table', visitor);
65330
+ visit(tree, isTable, visitor);
65338
65331
  return tree;
65339
65332
  };
65340
65333
  /* harmony default export */ const tables_to_jsx = (tablesToJsx);
package/dist/main.node.js CHANGED
@@ -66238,6 +66238,8 @@ const variables = ({ asMdx } = { asMdx: true }) => tree => {
66238
66238
 
66239
66239
 
66240
66240
  const alignToStyle = (align) => {
66241
+ if (!align)
66242
+ return align;
66241
66243
  return {
66242
66244
  type: 'mdxJsxAttribute',
66243
66245
  name: 'style',
@@ -66250,7 +66252,10 @@ const alignToStyle = (align) => {
66250
66252
  const visitor = (table, index, parent) => {
66251
66253
  let hasFlowContent = false;
66252
66254
  const tableCellVisitor = (cell) => {
66253
- if (!phrasing(cell.children[0])) {
66255
+ const content = cell.children.length === 1 && cell.children[0].type === 'paragraph'
66256
+ ? cell.children[0].children[0]
66257
+ : cell.children[0];
66258
+ if (!phrasing(content)) {
66254
66259
  hasFlowContent = true;
66255
66260
  return EXIT;
66256
66261
  }
@@ -66262,8 +66267,10 @@ const visitor = (table, index, parent) => {
66262
66267
  });
66263
66268
  };
66264
66269
  visit(table, 'tableCell', tableCellVisitor);
66265
- if (!hasFlowContent)
66270
+ if (!hasFlowContent) {
66271
+ table.type = 'table';
66266
66272
  return;
66273
+ }
66267
66274
  const styles = table.align.map(alignToStyle);
66268
66275
  const head = {
66269
66276
  type: 'mdxJsxFlowElement',
@@ -66273,12 +66280,7 @@ const visitor = (table, index, parent) => {
66273
66280
  type: 'mdxJsxFlowElement',
66274
66281
  name: 'tr',
66275
66282
  children: table.children[0].children.map((cell, index) => {
66276
- return {
66277
- type: 'mdxJsxFlowElement',
66278
- name: 'th',
66279
- children: cell.children,
66280
- attributes: [styles[index]],
66281
- };
66283
+ return Object.assign({ type: 'mdxJsxFlowElement', name: 'th', children: cell.children }, (styles[index] && { attributes: [styles[index]] }));
66282
66284
  }),
66283
66285
  },
66284
66286
  ],
@@ -66291,12 +66293,7 @@ const visitor = (table, index, parent) => {
66291
66293
  type: 'mdxJsxFlowElement',
66292
66294
  name: 'tr',
66293
66295
  children: row.children.map((cell, index) => {
66294
- return {
66295
- type: 'mdxJsxFlowElement',
66296
- name: 'td',
66297
- children: cell.children,
66298
- attributes: [styles[index]],
66299
- };
66296
+ return Object.assign({ type: 'mdxJsxFlowElement', name: 'td', children: cell.children }, (styles[index] && { attributes: [styles[index]] }));
66300
66297
  }),
66301
66298
  };
66302
66299
  }),
@@ -66311,17 +66308,13 @@ const visitor = (table, index, parent) => {
66311
66308
  },
66312
66309
  },
66313
66310
  ];
66314
- const jsx = {
66315
- type: 'mdxJsxFlowElement',
66316
- name: 'Table',
66317
- attributes,
66318
- children: [head, body],
66319
- };
66311
+ const jsx = Object.assign(Object.assign({ type: 'mdxJsxFlowElement', name: 'Table' }, (table.align.find(a => a) && { attributes })), { children: [head, body] });
66320
66312
  // @ts-ignore
66321
66313
  parent.children[index] = jsx;
66322
66314
  };
66315
+ const isTable = (node) => ['table', 'tableau'].includes(node.type);
66323
66316
  const tablesToJsx = () => tree => {
66324
- visit(tree, 'table', visitor);
66317
+ visit(tree, isTable, visitor);
66325
66318
  return tree;
66326
66319
  };
66327
66320
  /* harmony default export */ const tables_to_jsx = (tablesToJsx);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@readme/markdown",
3
3
  "description": "ReadMe's React-based Markdown parser",
4
4
  "author": "Rafe Goldberg <rafe@readme.io>",
5
- "version": "6.75.0-beta.74",
5
+ "version": "6.75.0-beta.76",
6
6
  "main": "dist/main.node.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "browser": "dist/main.js",