Skip to content

Commit

Permalink
fix: add missing node props to the prism branch
Browse files Browse the repository at this point in the history
add include jsx test cases
  • Loading branch information
sergioramos committed Nov 14, 2020
1 parent 793ab18 commit de05c22
Show file tree
Hide file tree
Showing 33 changed files with 4,334 additions and 94 deletions.
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@
"unist-util-map": "^2.0.1"
},
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/preset-react": "^7.12.5",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@mdx-js/mdx": "^1.6.21",
"@rollup/plugin-virtual": "^2.0.3",
"apr-parallel": "^3.0.3",
"ava": "^3.13.0",
"c8": "^7.3.5",
"eslint": "^7.13.0",
Expand All @@ -46,9 +51,13 @@
"npm-run-all": "^4.1.5",
"prettier": "^2.1.2",
"puppeteer": "^5.4.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"rehype-format": "^3.1.0",
"rehype-stringify": "^8.0.0",
"remark-parse": "^9.0.0",
"rollup": "^2.33.1",
"rollup-plugin-babel": "^4.4.0",
"serve": "^11.3.2",
"to-vfile": "^6.1.0",
"unified": "^9.2.0"
Expand Down
12 changes: 9 additions & 3 deletions src/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,20 @@ const deserialize = (html) => {
const toHast = ({ type, name, attribs = {}, data: value, children = [] }) => {
const { class: className = '', ...attrs } = attribs;

const properties = {
...attrs,
className: className.split(/\s/),
};

return {
type: type === 'tag' ? 'element' : 'text',
value,
tagName: name,
properties: {
...attrs,
className: className.split(/\s/),
data: {
hName: name,
hProperties: properties,
},
properties,
children: children.map(toHast),
};
};
Expand Down
Loading

0 comments on commit de05c22

Please sign in to comment.