Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mdx-js/mdx
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.19.0
Choose a base ref
...
head repository: mdx-js/mdx
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.20.0
Choose a head ref
  • 6 commits
  • 11 files changed
  • 3 contributors

Commits on Mar 1, 2019

  1. Copy the full SHA
    9d3cf30 View commit details
  2. Add github repo link (#428)

    johno authored Mar 1, 2019
    1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f9f31b5 View commit details

Commits on Mar 2, 2019

  1. Enable remark plugins that insert JSX and HTML (#429)

    Changed `html`-to-`jsx` node relabelling to happen before remark
    plugins are applied instead of after remark plugins are applied. This,
    combined with the parsing of `raw` nodes in `HAST`, allows remark
    plugins to insert `jsx` nodes AND `html` nodes.
    
    Previously, all `html` nodes were indiscriminately relabelled as
    `jsx`, which should only be true for the user-layer when manually
    writing MDX and not when `operating on the MDX ASTs with plugins.
    ChristopherBiscardi authored and johno committed Mar 2, 2019
    1
    Copy the full SHA
    eeaa979 View commit details
  2. v0.20.0-alpha.0

    johno committed Mar 2, 2019
    1
    Copy the full SHA
    ce21ee6 View commit details
  3. Copy the full SHA
    d5c3404 View commit details
  4. v0.20.0

    johno committed Mar 2, 2019
    1
    Copy the full SHA
    83fa08f View commit details
Showing with 127 additions and 16 deletions.
  1. +20 −1 docs/_ui.js
  2. +1 −1 docs/projects.md
  3. +1 −1 lerna.json
  4. +2 −2 packages/loader/package.json
  5. +15 −1 packages/mdx/index.js
  6. +3 −1 packages/mdx/mdx-ast-to-mdx-hast.js
  7. +2 −1 packages/mdx/package.json
  8. +2 −2 packages/parcel-plugin-mdx/package.json
  9. +2 −2 packages/runtime/package.json
  10. +1 −1 readme.md
  11. +78 −3 yarn.lock
21 changes: 20 additions & 1 deletion docs/_ui.js
Original file line number Diff line number Diff line change
@@ -2,7 +2,26 @@ import React from 'react'
import {Pre} from 'rebass'
import {LiveEditor as Editor, LivePreview} from '@compositor/x0/components'

export const Logo = () => <img src="https://mdx-logo.now.sh" width="70" />
export const Logo = () => (
<div>
<img src="https://mdx-logo.now.sh" width="70" alt="MDX logo" />

<a
style={{
position: 'absolute',
right: 11,
top: 13
}}
href="https://github.com/mdx-js/mdx"
>
<img
src="https://icon.now.sh/github/0067ee"
alt="github logo"
width="20"
/>
</a>
</div>
)

export const LiveEditor = props => {
const lang = (props.className || '').replace(/^language-/, '')
2 changes: 1 addition & 1 deletion docs/projects.md
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@

[prisma]: https://www.prisma.io/docs

[mxstbr]: https://mxstbr.com/blog
[mxstbr]: https://mxstbr.com

[awesome-mdx]: https://github.com/transitive-bullshit/awesome-mdx

2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"lerna": "3.4.0",
"version": "0.19.0",
"version": "0.20.0",
"packages": [
"packages/*"
],
4 changes: 2 additions & 2 deletions packages/loader/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mdx-js/loader",
"version": "0.19.0",
"version": "0.20.0",
"description": "Loader for MDX",
"license": "MIT",
"keywords": [
@@ -27,7 +27,7 @@
"index.js"
],
"dependencies": {
"@mdx-js/mdx": "^0.19.0",
"@mdx-js/mdx": "^0.20.0",
"@mdx-js/tag": "^0.18.0",
"loader-utils": "^1.1.0"
},
16 changes: 15 additions & 1 deletion packages/mdx/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const unified = require('unified')
const toMDAST = require('remark-parse')
const squeeze = require('remark-squeeze-paragraphs')
const visit = require('unist-util-visit')
const raw = require('hast-util-raw')
const toMDXAST = require('./md-ast-to-mdx-ast')
const mdxAstToMdxHast = require('./mdx-ast-to-mdx-hast')
const mdxHastToJsx = require('./mdx-hast-to-jsx')
@@ -59,6 +61,7 @@ function createMdxAstCompiler(options) {
.use(toMDAST, options)
.use(esSyntax)
.use(squeeze, options)
.use(toMDXAST, options)

mdPlugins.forEach(plugin => {
// Handle [plugin, pluginOptions] syntax
@@ -69,7 +72,7 @@ function createMdxAstCompiler(options) {
}
})

fn.use(toMDXAST, options).use(mdxAstToMdxHast, options)
fn.use(mdxAstToMdxHast, options)

return fn
}
@@ -78,6 +81,17 @@ function applyHastPluginsAndCompilers(compiler, options) {
const hastPlugins = options.hastPlugins
const compilers = options.compilers

// Convert raw nodes into HAST
compiler.use(() => ast => {
visit(ast, 'raw', node => {
const {type, children, tagName, properties} = raw(node)
node.type = type
node.children = children
node.tagName = tagName
node.properties = properties
})
})

hastPlugins.forEach(plugin => {
// Handle [plugin, pluginOptions] syntax
if (Array.isArray(plugin) && plugin.length > 1) {
4 changes: 3 additions & 1 deletion packages/mdx/mdx-ast-to-mdx-hast.js
Original file line number Diff line number Diff line change
@@ -78,7 +78,9 @@ function mdxAstToMdxHast() {
}

const hast = toHAST(tree, {
handlers
handlers,
// Enable passing of html nodes to HAST as raw nodes
allowDangerousHTML: true
})

return hast
3 changes: 2 additions & 1 deletion packages/mdx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mdx-js/mdx",
"version": "0.19.0",
"version": "0.20.0",
"description": "Parse MDX and transpile to JSX",
"license": "MIT",
"keywords": [
@@ -33,6 +33,7 @@
"@babel/plugin-syntax-jsx": "^7.2.0",
"change-case": "^3.0.2",
"detab": "^2.0.0",
"hast-util-raw": "^5.0.0",
"mdast-util-to-hast": "^4.0.0",
"remark-parse": "^6.0.0",
"remark-squeeze-paragraphs": "^3.0.1",
4 changes: 2 additions & 2 deletions packages/parcel-plugin-mdx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mdx-js/parcel-plugin-mdx",
"version": "0.19.0",
"version": "0.20.0",
"description": "Parcel plugin for MDX",
"license": "MIT",
"keywords": [
@@ -27,7 +27,7 @@
"src"
],
"dependencies": {
"@mdx-js/mdx": "^0.19.0",
"@mdx-js/mdx": "^0.20.0",
"parcel-bundler": "^1.4.1"
},
"peerDependencies": {
4 changes: 2 additions & 2 deletions packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mdx-js/runtime",
"version": "0.19.0",
"version": "0.20.0",
"description": "Parse and render MDX in a runtime environment",
"license": "MIT",
"keywords": [
@@ -33,7 +33,7 @@
"src/"
],
"dependencies": {
"@mdx-js/mdx": "^0.19.0",
"@mdx-js/mdx": "^0.20.0",
"@mdx-js/tag": "^0.18.0",
"buble": "^0.19.6"
},
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

> Markdown for the component era.
MDX is a format that lets you seamlessly use JSX in your markdown documents.
MDX is an authorable format that lets you seamlessly use JSX in your markdown documents.
You can import components, like interactive charts or notifications, and export
metadata.
This makes writing long-form content with components a blast. 🚀
81 changes: 78 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -3193,7 +3193,7 @@ caseless@~0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"

ccount@^1.0.0:
ccount@^1.0.0, ccount@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/ccount/-/ccount-1.0.3.tgz#f1cec43f332e2ea5a569fd46f9f5bde4e6102aff"

@@ -3941,6 +3941,16 @@ css-what@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/css-what/-/css-what-2.1.2.tgz#c0876d9d0480927d7d4920dcd72af3595649554d"

css@2.2.4:
version "2.2.4"
resolved "https://registry.yarnpkg.com/css/-/css-2.2.4.tgz#c646755c73971f2bba6a601e2cf2fd71b1298929"
integrity sha512-oUnjmWpy0niI3x/mPL8dVEI1l7MnG3+HHyRPHf+YFSbK+svOhXpmSOcDURUh2aOCgl2grzrOPt1nHLuCVFULLw==
dependencies:
inherits "^2.0.3"
source-map "^0.6.1"
source-map-resolve "^0.5.2"
urix "^0.1.0"

cssesc@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-2.0.0.tgz#3b13bd1bb1cb36e1bcb5a4dcd27f54c5dcb35703"
@@ -5704,6 +5714,18 @@ hash.js@^1.0.0, hash.js@^1.0.3:
inherits "^2.0.3"
minimalistic-assert "^1.0.1"

hast-to-hyperscript@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/hast-to-hyperscript/-/hast-to-hyperscript-6.0.0.tgz#051ee17d41b30da8c5ceb001189adf70226f12f4"
integrity sha512-QnJbXddVGNJ5v3KegK1MY6luTkNDBcJnCQZcekt7AkES2z4tYy85pbFUXx7Mb0iXZBKfwoVdgfxU12GbmlwbbQ==
dependencies:
comma-separated-tokens "^1.0.0"
property-information "^5.0.0"
space-separated-tokens "^1.0.0"
style-to-object "^0.2.1"
unist-util-is "^2.0.0"
web-namespaces "^1.1.2"

hast-util-from-parse5@^1.0.0:
version "1.1.0"
resolved "http://registry.npmjs.org/hast-util-from-parse5/-/hast-util-from-parse5-1.1.0.tgz#359cc339dc8ccf1dfaca41915ad63fd546130acd"
@@ -5714,6 +5736,17 @@ hast-util-from-parse5@^1.0.0:
property-information "^3.1.0"
vfile-location "^2.0.0"

hast-util-from-parse5@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/hast-util-from-parse5/-/hast-util-from-parse5-5.0.0.tgz#a505a05766e0f96e389bfb0b1dd809eeefcef47b"
integrity sha512-A7ev5OseS/J15214cvDdcI62uwovJO2PB60Xhnq7kaxvvQRFDEccuqbkrFXU03GPBGopdPqlpQBRqIcDS/Fjbg==
dependencies:
ccount "^1.0.3"
hastscript "^5.0.0"
property-information "^5.0.0"
web-namespaces "^1.1.2"
xtend "^4.0.1"

hast-util-has-property@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/hast-util-has-property/-/hast-util-has-property-1.0.2.tgz#4c9c3c6122fcc84a5b7c40a573940aaa4b8a8278"
@@ -5726,6 +5759,20 @@ hast-util-parse-selector@^2.0.0, hast-util-parse-selector@^2.2.0:
version "2.2.1"
resolved "https://registry.yarnpkg.com/hast-util-parse-selector/-/hast-util-parse-selector-2.2.1.tgz#4ddbae1ae12c124e3eb91b581d2556441766f0ab"

hast-util-raw@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/hast-util-raw/-/hast-util-raw-5.0.0.tgz#7a7186faba220120349c2f373b839c1fa9090b5f"
integrity sha512-X8sogDDaCkqj+Ghia0+TRD2AQDXeNRpYDTm9Z2mJ1Pzy/Nb4p20YJVfbPwIRU0U7XXU0GrhPhEMZvnfV69/igA==
dependencies:
hast-util-from-parse5 "^5.0.0"
hast-util-to-parse5 "^5.0.0"
html-void-elements "^1.0.1"
parse5 "^5.0.0"
unist-util-position "^3.0.0"
web-namespaces "^1.0.0"
xtend "^4.0.1"
zwitch "^1.0.0"

hast-util-select@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/hast-util-select/-/hast-util-select-1.0.1.tgz#9f1591efa62ba0bdf5ea4298b301aaae1dad612d"
@@ -5777,6 +5824,17 @@ hast-util-to-html@^3.0.0:
unist-util-is "^2.0.0"
xtend "^4.0.1"

hast-util-to-parse5@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/hast-util-to-parse5/-/hast-util-to-parse5-5.0.0.tgz#1041df0d57e60210bd3e4b97596397500223399a"
integrity sha512-1BG07SLp9RHnAy/A2Fugza5YCo45Ter8csOGbxL7a7f9Rvq9aE64/4hlqc083M8yLLp7J5tYxmiFWYbD0zQJnA==
dependencies:
hast-to-hyperscript "^6.0.0"
property-information "^5.0.0"
web-namespaces "^1.0.0"
xtend "^4.0.1"
zwitch "^1.0.0"

hast-util-to-string@^1.0.0, hast-util-to-string@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/hast-util-to-string/-/hast-util-to-string-1.0.1.tgz#b28055cdca012d3c8fd048757c8483d0de0d002c"
@@ -5898,7 +5956,7 @@ html-tokenize@^2.0.0:
readable-stream "~1.0.27-1"
through2 "~0.4.1"

html-void-elements@^1.0.0:
html-void-elements@^1.0.0, html-void-elements@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/html-void-elements/-/html-void-elements-1.0.3.tgz#956707dbecd10cf658c92c5d27fee763aa6aa982"

@@ -8906,6 +8964,11 @@ parse5@^2.1.5:
version "2.2.3"
resolved "https://registry.yarnpkg.com/parse5/-/parse5-2.2.3.tgz#0c4fc41c1000c5e6b93d48b03f8083837834e9f6"

parse5@^5.0.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/parse5/-/parse5-5.1.0.tgz#c59341c9723f414c452975564c7c00a68d58acd2"
integrity sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ==

parseurl@^1.3.2, parseurl@~1.3.2:
version "1.3.2"
resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3"
@@ -11606,7 +11669,7 @@ source-list-map@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34"

source-map-resolve@^0.5.0:
source-map-resolve@^0.5.0, source-map-resolve@^0.5.2:
version "0.5.2"
resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.2.tgz#72e2cc34095543e43b2c62b2c4c10d4a9054f259"
dependencies:
@@ -11917,6 +11980,13 @@ strong-log-transformer@^2.0.0:
minimist "^1.2.0"
through "^2.3.4"

style-to-object@^0.2.1:
version "0.2.2"
resolved "https://registry.yarnpkg.com/style-to-object/-/style-to-object-0.2.2.tgz#3ea3b276bd3fa9da1195fcdcdd03bc52aa2aae01"
integrity sha512-GcbtvfsqyKmIPpHeOHZ5Rmwsx2MDJct4W9apmTGcbPTbpA2FcgTFl2Z43Hm4Qb61MWGPNK8Chki7ITiY7lLOow==
dependencies:
css "2.2.4"

styled-components@>=3.3.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/styled-components/-/styled-components-4.1.1.tgz#943922048fae556e286bcbfdd29da4f1399446bc"
@@ -12872,6 +12942,11 @@ wcwidth@^1.0.0, wcwidth@^1.0.1:
dependencies:
defaults "^1.0.3"

web-namespaces@^1.0.0, web-namespaces@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/web-namespaces/-/web-namespaces-1.1.2.tgz#c8dc267ab639505276bae19e129dbd6ae72b22b4"
integrity sha512-II+n2ms4mPxK+RnIxRPOw3zwF2jRscdJIUE9BfkKHm4FYEg9+biIoTMnaZF5MpemE3T+VhMLrhbyD4ilkPCSbg==

webidl-conversions@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad"