react-markdown-loader icon indicating copy to clipboard operation
react-markdown-loader copied to clipboard

Invalid babel syntax

Open tauren opened this issue 7 years ago • 4 comments

I'd like to display some code samples within the page, not actually render it. But I'm getting an error.

I'm not quite sure if the problem is in this loader or not. When I add the following to a markdown file that is processed through this loader and then through babel, I get a BabelLoaderError: SyntaxError: Unexpected token (46:227) error.

​```js
function Sample () {
  return 'hi'
}
​```

Here is the full error:

ERROR in ./src/elements/Hello/readme.md
Module build failed: SyntaxError: Unexpected token (46:227)

  44 |     </code></pre>
  45 |   </div>
> 46 | </div><pre><code className="language-js"><span className="token keyword" >function</span> Sample <span className="token punctuation" >(</span><span className="token punctuation" >)</span> <span className="token punctuation" >{</span>
     |                                                                                                                                                                                                                                    ^
  47 |   <span className="token keyword" >return</span> <span className="token string" >'hi'</span>
  48 | <span className="token punctuation" >}</span>
  49 | </code></pre>

BabelLoaderError: SyntaxError: Unexpected token (46:227)

  44 |     </code></pre>
  45 |   </div>
> 46 | </div><pre><code className="language-js"><span className="token keyword" >function</span> Sample <span className="token punctuation" >(</span><span className="token punctuation" >)</span> <span className="token punctuation" >{</span>
     |                                                                                                                                                                                                                                    ^
  47 |   <span className="token keyword" >return</span> <span className="token string" >'hi'</span>
  48 | <span className="token punctuation" >}</span>
  49 | </code></pre>

    at transpile (/Users/tauren/repos/component-lab/node_modules/babel-loader/lib/index.js:61:13)
    at Object.module.exports (/Users/tauren/repos/component-lab/node_modules/babel-loader/lib/index.js:155:20)
 @ ./src/elements/index.js 14:0-44
 @ ./src/app/Main/index.js
 @ ./src/app/App/index.js
 @ ./src/app/Root/index.js
 @ ./src/index.js
 @ multi ./~/react-hot-loader/patch.js ./~/babel-polyfill/lib/index.js ./src/index.js webpack-dev-server/client?http://localhost:5000/ webpack/hot/dev-server

tauren avatar Mar 15 '17 00:03 tauren

same here....

dzoneo avatar Jun 05 '17 07:06 dzoneo

same here ... @tauren @FrendKao How did you solve this problem?

cassiewang01 avatar Aug 19 '17 05:08 cassiewang01

Having the same problem, I chose this project because it supports code highlighting, but not being able to use braces is a major issue right now.

hugmanrique avatar Feb 16 '18 19:02 hugmanrique

solved, by switching to jsxtreme-markdown-loader relevant gist: https://gist.github.com/alexvish/73a52e03ddd7919da3eb1dfd2630493a

alexvish avatar Mar 27 '18 23:03 alexvish