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

Expose code highlight extend point to use other highlight tools. #1300

Closed
hackwaly opened this issue May 27, 2015 · 9 comments
Closed

Expose code highlight extend point to use other highlight tools. #1300

hackwaly opened this issue May 27, 2015 · 9 comments

Comments

@hackwaly
Copy link

I'd like to use CodeMirror or other static analyze tools for generate semantic code highlight.
Other users may prefer prism.js over highlight.js.

@hackwaly hackwaly changed the title Export code highlight extend point to use other highlight tools. Expose code highlight extend point to use other highlight tools. May 27, 2015
@borisschapira
Copy link
Contributor

What's stopping you from adding one of these library to your theme ?

@hackwaly
Copy link
Author

hackwaly commented Jun 3, 2015

Actually I've made it by "adding one of these library to my theme". see here. But It's ugly hack I think.

I've tried that highlight it by use codemirror on server side. But many things need care. Scripts in theme or plugin doesn't have a good hook point to replace hexo's builtin code highlight generation. Maybe monkey patch the highlight method in hexo-util module is a good choose. But it's hard to do it. So I dropped this idea. I use client side code highlighting now.

@borisschapira
Copy link
Contributor

Server-side highlight may be good because it doesn't depend on JavaScript at all, transforming your source code into valid HTML code, but client-side is fine too : it does not alter your source code, making it easier to index by search engine. Also, copy-paste is easier for your visitors.

I think we could debate on that, but as you may have already understand, I'm rather found of client-side code hightlighting myself.

@hackwaly
Copy link
Author

hackwaly commented Jun 4, 2015

Client side highlight is almost good.
I just want to point that server side highlight has an advantage is that it can offer highlight feature to some browser that does not support Javascript.
So in my idea, server side is a fallback method.

@tommy351
Copy link
Member

tommy351 commented Jun 5, 2015

Maybe we can add another filter named highlight and make use of it.

@borisschapira
Copy link
Contributor

If you use the Markdown-It renderer, you can decorate it with the markdown-it-highlightjs plugin, and your code will be higlighted by HighlightJS server-side.

I've proposed a Pull-Request : hexojs/hexo-renderer-markdown-it#15

@tommy351 tommy351 added this to the 3.2 milestone Jun 11, 2015
@tommy351 tommy351 mentioned this issue Jun 11, 2015
8 tasks
@leesei
Copy link
Member

leesei commented Apr 13, 2016

It is pretty easy to integrate Google Prettify (suggested by @liuzc #1718 (comment))
Hexo优化之使用Google Prettify高亮代码 | 柳志超博客

@Jamling
Copy link

Jamling commented Aug 15, 2016

@hackwaly I had meet the same problem as yours. I think it's good idea for highlighting at front-end.
It's more freely, and I wrote a plugin name hexo-filter-highlight to do this. It may resolve your problem

@stevenjoezhang
Copy link
Member

stevenjoezhang commented Mar 19, 2020

I'm closing this issue. Please join the discussion here #4010 :)

See also #1891

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

No branches or pull requests

7 participants