Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

fix/table-parse-optional-chaining #697

Merged
merged 4 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/markdown/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
],
"@babel/preset-react"
],
"plugins": ["@babel/plugin-proposal-class-properties", "@babel/plugin-proposal-object-rest-spread"]
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-proposal-optional-chaining"
]
}
1 change: 1 addition & 0 deletions packages/markdown/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"@readme/eslint-config",
"@readme/eslint-config/react"
],
"parser": "babel-eslint",
"root": true
}
90 changes: 36 additions & 54 deletions packages/markdown/dist/main.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions packages/markdown/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/markdown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"license": "ISC",
"repository": "https://github.com/readmeio/api-explorer/tree/master/packages/markdown",
"devDependencies": {
"@babel/plugin-proposal-optional-chaining": "^7.9.0",
"@readme/eslint-config": "^2.0.0",
"css-loader": "^3.4.2",
"eslint": "^6.5.0",
Expand Down
9 changes: 4 additions & 5 deletions packages/markdown/processor/plugin/table-flattening.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ function transformer(ast) {
// This is necessary to pullout all the relevant strings

// Parse Header Values
const headerChildren = header.children && header.children.length ? header.children[0].children : [];
const headerValue = headerChildren.map(hc => (hc.children.length && hc.children[0].value) || '').join(' ');
const headerChildren = header?.children?.[0]?.children || [];
const headerValue = headerChildren.map(hc => hc?.children?.[0]?.value || '').join(' ');
// Parse Body Values
const bodyChildren =
(body.children && body.children.map(bc => bc && bc.children).reduce((a, b) => a.concat(b), [])) || [];
const bodyValue = bodyChildren.map(bc => (bc.children.length && bc.children[0].value) || '').join(' ');
const bodyChildren = body?.children?.map(bc => bc?.children).reduce((a, b) => a.concat(b), []) || [];
const bodyValue = bodyChildren.map(bc => bc?.children?.[0]?.value || '').join(' ');

return [
{
Expand Down