diff --git a/packages/gatsby-remark-embed-snippet/src/__tests__/__snapshots__/index.js.snap b/packages/gatsby-remark-embed-snippet/src/__tests__/__snapshots__/index.js.snap index b3f972f103836..471f54dd08c9d 100644 --- a/packages/gatsby-remark-embed-snippet/src/__tests__/__snapshots__/index.js.snap +++ b/packages/gatsby-remark-embed-snippet/src/__tests__/__snapshots__/index.js.snap @@ -79,12 +79,10 @@ Object { "type": "html", "value": "
html {
-height: 100%;
-}
+height: 100%;}
 
 * {
-box-sizing: border-box;
-}
+box-sizing: border-box;}
", }, ], @@ -142,9 +140,7 @@ Object { "type": "html", "value": "
html {
-height: 100%;
-width: 100%;
-}
+height: 100%;width: 100%;}
", }, ], @@ -260,10 +256,8 @@ Object { "value": "
<html>
 <body>
-<h1>highlighted</h1>
-<p>
-highlighted
-</p>
+<h1>highlighted</h1><p>
+highlighted</p>
 </body>
 </html>
", @@ -325,8 +319,7 @@ Object {
<html>
 <body>
 <p>
-highlighted
-</p>
+highlighted</p>
 </body>
 </html>
", @@ -443,14 +436,12 @@ Object { "type": "html", "value": "
<div>
-<button>Add Item</button> 
-
+<button>Add Item</button> 
 <ReactCSSTransitionGroup
 transitionName=\\"example\\"
 transitionEnterTimeout={500}
 transitionLeaveTimeout={300}>
-{items}
-</ReactCSSTransitionGroup>
+{items}</ReactCSSTransitionGroup>
 </div>
", }, @@ -511,11 +502,9 @@ Object {
import React from 'react';
 import ReactDOM from 'react-dom';
 
-ReactDOM.render(
-<h1>Hello, world!</h1>,
+ReactDOM.render(<h1>Hello, world!</h1>,
 document.getElementById('root')
-);
-
+); ", }, ], @@ -573,9 +562,7 @@ Object { "type": "html", "value": "
ReactDOM.render(
-<h1>Hello, world!</h1>,
-document.getElementById('root')
-);
+<h1>Hello, world!</h1>,document.getElementById('root'));
", }, ], @@ -634,10 +621,7 @@ Object { "value": "
<ul>
 <li>Not highlighted</li>
-<li>Highlighted</li>
-<li>Highlighted</li>
-<li>Highlighted</li>
-<li>Not highlighted</li>
+<li>Highlighted</li><li>Highlighted</li><li>Highlighted</li><li>Not highlighted</li>
 </div>
", }, @@ -696,15 +680,12 @@ Object { "type": "html", "value": "
let notHighlighted;
-let highlighted;
-
+let highlighted;
 notHighlighted = 1;
 
-highlighted = 2;
-
+highlighted = 2;
 notHighlighted = 3;
-highlighted = 4;
-
+highlighted = 4;
", }, ], @@ -875,10 +856,8 @@ Object { }, "type": "html", "value": "
-
foo: \\"highlighted\\"
-bar: \\"not highlighted\\"
-baz: \\"highlighted\\"
-qux: \\"not highlighted\\"
+
foo: \\"highlighted\\"bar: \\"not highlighted\\"
+baz: \\"highlighted\\"qux: \\"not highlighted\\"
", }, ], @@ -935,10 +914,8 @@ Object { }, "type": "html", "value": "
-
foo: \\"highlighted\\"
-bar: \\"not highlighted\\"
-baz: \\"highlighted\\"
-
+
foo: \\"highlighted\\"bar: \\"not highlighted\\"
+baz: \\"highlighted\\"
", }, ], @@ -1054,12 +1031,10 @@ Object { "value": "
# Yarn
 yarn init
-yarn add react react-dom
-
+yarn add react react-dom
 # NPM
 npm init
-npm install --save react react-dom
-
+npm install --save react react-dom
", }, ], @@ -1117,9 +1092,7 @@ Object { "type": "html", "value": "
echo \\"not highlighted\\"
-echo \\"highlighted\\"
-echo \\"highlighted\\"
-echo \\"not highlighted\\"
+echo \\"highlighted\\"echo \\"highlighted\\"echo \\"not highlighted\\"
", }, ], diff --git a/packages/gatsby-remark-prismjs/src/__tests__/__snapshots__/highlight-code.js.snap b/packages/gatsby-remark-prismjs/src/__tests__/__snapshots__/highlight-code.js.snap index 7829320580221..d741cd7491b34 100644 --- a/packages/gatsby-remark-prismjs/src/__tests__/__snapshots__/highlight-code.js.snap +++ b/packages/gatsby-remark-prismjs/src/__tests__/__snapshots__/highlight-code.js.snap @@ -1,9 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`highlight code and lines with PrismJS for language cpp 1`] = ` -" -int sum(a, b) { - return a + b; +"int sum(a, b) { return a + b; } " `; @@ -20,11 +18,8 @@ exports[`highlight code and lines with PrismJS for language jsx 1`] = ` render() { return ( - <div> - <h1>Counter</h1> - <p>current count: {this.state.count}</p> - <button onClick={() => this.setState({ count: this.state.count + 1 })}> - plus + <div> <h1>Counter</h1> <p>current count: {this.state.count}</p> + <button onClick={() => this.setState({ count: this.state.count + 1 })}> plus </button> <button onClick={() => this.setState({ count: this.state.count - 1 })}> minus diff --git a/packages/gatsby-remark-prismjs/src/__tests__/__snapshots__/highlight-line-range.js.snap b/packages/gatsby-remark-prismjs/src/__tests__/__snapshots__/highlight-line-range.js.snap index b0eb94aad0543..da5f0b4180ffe 100644 --- a/packages/gatsby-remark-prismjs/src/__tests__/__snapshots__/highlight-line-range.js.snap +++ b/packages/gatsby-remark-prismjs/src/__tests__/__snapshots__/highlight-line-range.js.snap @@ -1,87 +1,50 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`highlighting a line range highlight-line highlights line 1`] = ` -" return \\"hello world\\" -" -`; +exports[`highlighting a line range highlight-line highlights line 1`] = `" return \\"hello world\\""`; -exports[`highlighting a line range highlight-next-line highlights correct line 1`] = ` -" return \\"hello world\\" -" -`; +exports[`highlighting a line range highlight-next-line highlights correct line 1`] = `" return \\"hello world\\""`; exports[`highlighting a line range highlight-range does not highlight and warns if range is invalid 1`] = `""`; exports[`highlighting a line range highlight-range highlights correct lines 1`] = ` -" a = 1 + 1 - - b = 2 + 2 - - return \\"hello world\\" -" +" a = 1 + 1 + b = 2 + 2 + return \\"hello world\\"" `; exports[`highlighting a line range highlight-range highlights until end of code block if ranges goes farther 1`] = ` -" a = 1 + 1 - - b = 2 + 2 - - return \\"hello world\\" - -} - - -" +" a = 1 + 1 + b = 2 + 2 + return \\"hello world\\" +} +" `; exports[`highlighting a line range highlight-start / highlight-end highlights correct lines 1`] = ` -" var a = \\"b\\" - - return a + \\"hello world\\" -" +" var a = \\"b\\" + return a + \\"hello world\\"" `; exports[`highlighting a line range highlight-start / highlight-end highlights without end directive 1`] = ` -"var a = \\"b\\" - -return a + \\"hello world\\" - - -" +"var a = \\"b\\" +return a + \\"hello world\\" +" `; -exports[`highlighting a line range jsx comment highlights comment line 1`] = ` -" -" -`; +exports[`highlighting a line range jsx comment highlights comment line 1`] = `" "`; -exports[`highlighting a line range jsx comment highlights comment line after Prism highlighting 1`] = ` -" <button>sup</button> -" -`; +exports[`highlighting a line range jsx comment highlights comment line after Prism highlighting 1`] = `" <button>sup</button>"`; exports[`highlighting a line range kitchen sink highlights multiple directives 1`] = ` -"import React, { Component } from \\"react\\" - - state = { - - count: 0, - - } - - count: state.count + 1, - - render() { - - const { count } = this.state - - - - -" -`; - -exports[`highlighting a line range yaml highlights yaml 1`] = ` -"- title: catorce -" -`; +"import React, { Component } from \\"react\\" + state = { + count: 0, + } + count: state.count + 1, + render() { + const { count } = this.state + + " +`; + +exports[`highlighting a line range yaml highlights yaml 1`] = `"- title: catorce"`; diff --git a/packages/gatsby-remark-prismjs/src/highlight-line-range.js b/packages/gatsby-remark-prismjs/src/highlight-line-range.js index 211d84e8d82e9..2c04883837a82 100644 --- a/packages/gatsby-remark-prismjs/src/highlight-line-range.js +++ b/packages/gatsby-remark-prismjs/src/highlight-line-range.js @@ -47,7 +47,7 @@ const stripComment = line => ) const wrap = line => - [``, `${line}\n`, ``].join(``) + [``, line, ``].join(``) const wrapAndStripComment = line => wrap(stripComment(line)) @@ -149,7 +149,7 @@ module.exports = function highlightLineRange(code, highlights = []) { const split = code.split(`\n`) // If a highlight range is passed with the language declaration, e.g. - // ```jsx{1, 3-4} + // ``jsx{1, 3-4} // we only use that and do not try to parse highlight directives if (highlights.length > 0) { return split.map((line, i) => {