Git Product home page Git Product logo

Comments (8)

Mottie avatar Mottie commented on May 21, 2024 4

Just to update this thread...

So in the past year, Pygments is no longer used as GitHub's main syntax highlighter. Although it is still in use on their help, api and Jupyter notebook pages.

GitHub has changed to using PrettyLights. A syntax highlighter which hasn't been publicly released. It is pretty much impossible to find themes for it.

GitHub created a github-syntax-theme-generator under their "Primer" organization. To use it, you will need to define a JSON file with color definitions. The resulting CSS file can be found in the github-syntax-light and github-syntax-dark repositories. The generator also creates themes for Ace, Atom and TextMate.

In addition, if you need GitHub Flavored Markdown styles, there is also a separate repository for generating that CSS from SCSS: https://github.com/primer/markdown.

from github-markdown-css.

simov avatar simov commented on May 21, 2024

GitHub uses pygments for syntax highlighting, which is a Python library used on their servers. Marked on the other hand is a Javascript parser, used in the browser in your case.

The easiest way would be to use the GitHub's REST API to convert your makrdown files to HTML (just don't forget to supply access token for better quota limits).

from github-markdown-css.

asadovsky avatar asadovsky commented on May 21, 2024

Is there any way to do the highlighting client-side, without any HTTP requests?
E.g. is it possible to configure https://highlightjs.org/ to generate the right class names?

from github-markdown-css.

simov avatar simov commented on May 21, 2024

Yes you can do highlighting in the browser. Take a look at how I do it in my markdown extension :) I'm using http://prismjs.com/

E.g. is it possible to configure https://highlightjs.org/ to generate the right class names?

I doubt so (unless you find a JS port of the Pygments highlighter). But you don't need it, because you are using Marked to compile your markdown anyway (btw I'm using it too).

from github-markdown-css.

asadovsky avatar asadovsky commented on May 21, 2024

Thanks @simov! Looks like we had the same idea. :) Maybe I'll try out your extension. (I wrote my own b/c I didn't trust the closed-source ones I'd found.)

Using a client-side JS lib for syntax highlighting (effectively ignoring the syntax highlighting CSS from this module) sounds like a reasonable strategy.

I'll leave this issue as open for @sindresorhus since it'd be nice to mention something in the documentation for this module.

from github-markdown-css.

simov avatar simov commented on May 21, 2024

@asadovsky you can take a look at the code of your extensions. On Linux they are located in ~/.config/google-chrome/Default/Extensions you can search where are they located in any other OS. But yeah, same reasons here :) also I'm using my extension while editing the readme files for my repositories, so the syntax highlighting is fine (you just have to use a fenced code blocks, like in GitHub - ```js)

from github-markdown-css.

auscompgeek avatar auscompgeek commented on May 21, 2024

GitHub uses pygments for syntax highlighting

Actually, that hasn't been true for quite a while now. As of December 2014, GitHub has been using Atom's grammars, via Linguist, for syntax highlighting.

from github-markdown-css.

weblancaster avatar weblancaster commented on May 21, 2024

Node wrapper around the pygments
https://github.com/rvagg/node-pygmentize-bundled

from github-markdown-css.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.