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.18.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.18.1
Choose a head ref
  • 2 commits
  • 7 files changed
  • 1 contributor

Commits on Feb 26, 2019

  1. Fix newline issue in paragraphs (#413)

    In paragraph nodes newlines were being removed which causes
    issues when there are two subsequent nodes like links, spans,
    emphasis, bold, etc.
    
    Now, if the parent node is a paragraph tag, we preserve the
    newline since it's significant and results in a space that
    separates two inline nodes on render.
    
    ---
    
    Closes #412
    johno authored Feb 26, 2019
    1
    Copy the full SHA
    23b1e94 View commit details
  2. v0.18.1

    johno committed Feb 26, 2019
    1
    Copy the full SHA
    3913c39 View commit details
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.18.0",
"version": "0.18.1",
"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.18.0",
"version": "0.18.1",
"description": "Loader for MDX",
"license": "MIT",
"keywords": [
@@ -27,7 +27,7 @@
"index.js"
],
"dependencies": {
"@mdx-js/mdx": "^0.18.0",
"@mdx-js/mdx": "^0.18.1",
"@mdx-js/tag": "^0.18.0",
"loader-utils": "^1.1.0"
},
6 changes: 5 additions & 1 deletion packages/mdx/mdx-hast-to-jsx.js
Original file line number Diff line number Diff line change
@@ -168,9 +168,13 @@ MDXContent.isMDXComponent = true`
if (node.type === 'text') {
// Don't wrap newlines unless specifically instructed to by the flag,
// to avoid issues like React warnings caused by text nodes in tables.
if (node.value === '\n' && !preserveNewlines) {
const shouldPreserveNewlines =
preserveNewlines || parentNode.tagName === 'p'

if (node.value === '\n' && !shouldPreserveNewlines) {
return node.value
}

return '{`' + node.value.replace(/`/g, '\\`').replace(/\$/g, '\\$') + '`}'
}

2 changes: 1 addition & 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.18.0",
"version": "0.18.1",
"description": "Parse MDX and transpile to JSX",
"license": "MIT",
"keywords": [
18 changes: 18 additions & 0 deletions packages/mdx/test/index.test.js
Original file line number Diff line number Diff line change
@@ -204,6 +204,24 @@ Some text <!-- an inline comment -->
expect(result).toContain('<!-- a template literal -->')
})

it('Should turn a newline into a space with adjacent anchors', async () => {
const result = await renderWithReact(`
[foo](/foo)
[bar](/bar)
`)

expect(result).toContain('<a href="/foo">foo</a>\n<a href="/bar">bar</a>')
})

it('Should turn a newline into a space with other adjacent phrasing content', async () => {
const result = await renderWithReact(`
*foo*
\`bar\`
`)

expect(result).toContain('<em>foo</em>\n<code>bar</code>')
})

it('Should convert style strings to camelized objects', async () => {
const result = await mdx(
`
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.18.0",
"version": "0.18.1",
"description": "Parcel plugin for MDX",
"license": "MIT",
"keywords": [
@@ -27,7 +27,7 @@
"src"
],
"dependencies": {
"@mdx-js/mdx": "^0.18.0",
"@mdx-js/mdx": "^0.18.1",
"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.18.0",
"version": "0.18.1",
"description": "Parse and render MDX in a runtime environment",
"license": "MIT",
"keywords": [
@@ -33,7 +33,7 @@
"src/"
],
"dependencies": {
"@mdx-js/mdx": "^0.18.0",
"@mdx-js/mdx": "^0.18.1",
"@mdx-js/tag": "^0.18.0",
"buble": "^0.19.6"
},