Skip to content

Commit

Permalink
make unwarpping possible
Browse files Browse the repository at this point in the history
  • Loading branch information
ckanthony committed Mar 8, 2019
1 parent ac97191 commit 389572b
Show file tree
Hide file tree
Showing 9 changed files with 1,316 additions and 1,115 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

30 changes: 16 additions & 14 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
const prod = process.env.NODE_ENV === 'production';

module.exports = {
plugins: ['emotion'],
presets: [
[
'env',
{
loose: true,
modules: process.env.BABEL_ENV === 'esm' ? false : 'commonjs',
},
],
'react',
'stage-2',
prod && ['minify', { flipComparisons: false }],
].filter(Boolean),
module.exports = function(api) {
api.cache.forever();
return {
plugins: ['emotion'],
presets: [
[
'@babel/preset-env',
{
loose: true,
modules: process.env.BABEL_ENV === 'esm' ? false : 'commonjs',
},
],
'@babel/preset-react',
prod && ['minify', { flipComparisons: false }],
].filter(Boolean),
}
};
2 changes: 1 addition & 1 deletion docs/bundle.js

Large diffs are not rendered by default.

40 changes: 18 additions & 22 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -722,18 +722,22 @@ export function compiler(markdown, options) {

// eslint-disable-next-line no-unused-vars
function h(tag, props, ...children) {
const overrideProps = get(options.overrides, `${tag}.props`, {});

return createElementFn(
getTag(tag, options.overrides),
{
...overrideProps,
...props,
className:
cx(props && props.className, overrideProps.className) || undefined,
},
...children
);
if (typeof (tag) !== 'symbol') {
const overrideProps = get(options.overrides, `${tag}.props`, {});

return createElementFn(
getTag(tag, options.overrides),
{
...overrideProps,
...props,
className:
cx(props && props.className, overrideProps.className) || undefined,
},
...children
);
} else {
return createElementFn(tag, {... props}, ...children);
}
}

function compile(input) {
Expand All @@ -760,17 +764,9 @@ export function compiler(markdown, options) {

let jsx;
if (arr.length > 1) {
jsx = inline ? <span key="outer">{arr}</span> : <div key="outer">{arr}</div>;
jsx = inline ? <span key="outer">{arr}</span> : <>{arr}</>;
} else if (arr.length === 1) {
jsx = arr[0];

// TODO: remove this for React 16
if (typeof jsx === 'string') {
jsx = <span key="outer">{jsx}</span>;
}
} else {
// TODO: return null for React 16
jsx = <span key="outer" />;
}

return jsx;
Expand Down Expand Up @@ -1562,4 +1558,4 @@ if (process.env.NODE_ENV !== 'production') {
children: PropTypes.string.isRequired,
options: PropTypes.object,
};
}
}
32 changes: 15 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "markdown-to-jsx",
"description": "Convert markdown to JSX with ease for React and React-like projects. Super lightweight and highly configurable.",
"name": "@voyagertech/markdown-to-jsx",
"description": "An unwarpped version of orginal markdown-to-jsx.",
"homepage": "https://probablyup.github.io/markdown-to-jsx",
"license": "MIT",
"version": "6.9.0",
"version": "6.9.1a",
"engines": {
"node": ">= 4"
},
Expand All @@ -16,8 +16,9 @@
"html"
],
"author": "Evan Scott <probablyup@gmail.com>",
"repository": "probablyup/markdown-to-jsx",
"bugs": "https://github.com/probablyup/markdown-to-jsx/issues",
"maintainer": "Anthony Chan <ckanthony@gmail.com>",
"repository": "ckanthony/markdown-to-jsx",
"bugs": "https://github.com/ckanthony/markdown-to-jsx/issues",
"files": [
"index.js",
"dist",
Expand All @@ -28,17 +29,16 @@
"jsnext:main": "dist/esm.js",
"module": "dist/esm.js",
"devDependencies": {
"babel-cli": "^6.14.0",
"babel-core": "^6.26.0",
"@babel/cli": "^7.2.3",
"@babel/core": "^7.3.4",
"@babel/plugin-transform-react-jsx": "^7.3.0",
"@babel/preset-react": "^7.0.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"babel-loader": "^7.1.4",
"babel-plugin-emotion": "^9.2.11",
"babel-plugin-transform-react-remove-prop-types": "^0.4.19",
"babel-preset-env": "^1.7.0",
"babel-preset-minify": "^0.5.0",
"babel-preset-react": "^6.11.1",
"babel-preset-stage-2": "^6.13.0",
"benchtable": "^0.1.0",
"codecov": "^3.1.0",
"emotion": "^9.2.12",
Expand All @@ -57,32 +57,30 @@
"preact-compat": "^3.18.4",
"preact-emotion": "^9.2.12",
"prettier": "^1.14.3",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-markdown": "^4.0.3",
"rimraf": "^2.6.2",
"simple-markdown": "^0.4.2",
"size-limit": "^0.20.1",
"uglify-js": "^3.4.9",
"webpack": "^4.21.0",
"webpack-cli": "^3.1.2",
"webpack-cli": "^3.2.3",
"webpack-dev-server": "^3.1.9"
},
"dependencies": {
"@babel/preset-env": "^7.3.4",
"prop-types": "^15.6.2",
"unquote": "^1.1.0"
},
"peerDependencies": {
"react": ">= 0.14.0"
},
"scripts": {
"prepublish": "in-publish && npm run build && npm run release || not-in-publish",
"prepare": "in-publish && npm run build || not-in-publish",
"lint": "eslint .",
"prebuild": "rimraf dist && mkdirp dist",
"build": "NODE_ENV=production babel index.js --out-file dist/cjs.js --source-maps --no-comments && NODE_ENV=production BABEL_ENV=esm babel index.js --out-file dist/esm.js --source-maps --no-comments",
"release": "webpack --config ./webpack.config.prod.babel.js -p --display-optimization-bailout",
"release:debug": "webpack --config ./webpack.config.babel.js --display-optimization-bailout",
"start": "webpack-dev-server --hot --inline --open",
"test": "jest --verbose",
"size": "size-limit",
"benchmark": "node -r esm benchmark.js"
Expand Down
Loading

0 comments on commit 389572b

Please sign in to comment.