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

why jsx syntax doesn't highlighted in hexo #2720

Closed
Jaycexx opened this issue Aug 20, 2017 · 2 comments · Fixed by #4119
Closed

why jsx syntax doesn't highlighted in hexo #2720

Jaycexx opened this issue Aug 20, 2017 · 2 comments · Fixed by #4119
Labels
bug Something isn't working highlight

Comments

@Jaycexx
Copy link

Jaycexx commented Aug 20, 2017

Environment Info

Node version(node -v): v6.9.2

Your theme _config.yml (Optional): next

For question

I specified code block as follow. But when i deploy the site and found syntax highlight doesn't work. I guess it 's the reason of dom element in jsx. How can i fix it?

//use ```javascript (or try: jsx) doesn't work
let items = ['textA', 'textB', 'textC'];
let list = items => items.map( text => <li>{ text }</li>);
let foo = (
    <div id="foo">
        zhi zhi zhi!
        <ul>
            {list(items)}
        </ul>    
    </div>
);
let items = ['textA', 'textB', 'textC'];
let list = items => items.map(text => Object(__WEBPACK_IMPORTED_MODULE_0__preact__["a" /* h */])(
    'li',
    null,
    text
));
let foo = Object(__WEBPACK_IMPORTED_MODULE_0__preact__["a" /* h */])(
    'div',
    { id: 'foo' },
    'zhi zhi zhi!',
    Object(__WEBPACK_IMPORTED_MODULE_0__preact__["a" /* h */])(
        'ul',
        null,
        list(items)
    )
);
@JLHwung JLHwung added the bug Something isn't working label Aug 20, 2017
@JLHwung
Copy link
Collaborator

JLHwung commented Aug 20, 2017

highlight.js does not support JSX syntax, see highlightjs/highlight.js#931. So there is not much thing hexo can do about.

@NoahDragon Maybe we can consider switching highlight to prism? It brings better support on JSX. I think most of our users will prefer showcasing JS, TS, JSX codes since we are a node.js project. Any thoughts?

I doubt github also use prism to render JSX snippets, see http://prismjs.com/test.html.

@Jaycexx
Copy link
Author

Jaycexx commented Aug 21, 2017

I found someone has worked with prism in hexo. hexo-prism-plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working highlight
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants