Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid babel syntax #20

Open
tauren opened this issue Mar 15, 2017 · 4 comments
Open

Invalid babel syntax #20

tauren opened this issue Mar 15, 2017 · 4 comments

Comments

@tauren
Copy link

tauren commented Mar 15, 2017

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
Copy link

dzoneo commented Jun 5, 2017

same here....

@cassiewang01
Copy link

cassiewang01 commented Aug 19, 2017

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

@hugmanrique
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants