javiercf / react-markdown-loader

This loader parses markdown files and converts them to a React Stateless Component. It will also parse FrontMatter to import dependencies and render components along with it’s source code. We developed this loader in order to make the process of creating styleguides for React components easier
145 stars 33 forks source link

Invalid babel syntax #20

Open tauren opened 7 years ago

tauren commented 7 years ago

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
dzoneo commented 7 years ago

same here....

cassiewang01 commented 7 years ago

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

hugmanrique commented 6 years ago

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.

alexvish commented 6 years ago

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