GithubHelp home page GithubHelp logo

Highlighting - how? about react-markdown HOT 4 CLOSED

remarkjs avatar remarkjs commented on May 16, 2024 1
Highlighting - how?

from react-markdown.

Comments (4)

rexxars avatar rexxars commented on May 16, 2024 4

With version 4, this is now much easier, the demo is updated with an example:

https://github.com/rexxars/react-markdown/blob/master/demo/src/demo.js#L61-L69
https://github.com/rexxars/react-markdown/blob/master/demo/src/code-block.js

There are better libraries for doing this than highlight.js, I'll see if I can update the demo to use that at some time later.

from react-markdown.

rexxars avatar rexxars commented on May 16, 2024

Good question. I think the intention was that you would pass a React component here that would handle the rendering of the source. However, I see that I never got around to actually implementing it.

In the demo, I'm using highlight.js with a fairly ugly componentDidUpdate() +

var els = document.querySelectorAll('pre code');
for (var i = 0; i < els.length; i++) {
    if (!els[i].classList.contains('hljs')) {
        window.hljs.highlightBlock(els[i]);
    }
}

... this is obviously far from ideal. I'll keep this issue open and see if I can find the time at some point to implement this as it was intended (up for grabs if anyone else wants to address it, obviously).

from react-markdown.

garrilla avatar garrilla commented on May 16, 2024

Thanks for quick response...

I couldn't work it out from your demo as it had been minified...

from react-markdown.

rexxars avatar rexxars commented on May 16, 2024

Ah, sorry. The demo/src folder holds the unminified code, if you want to take a look.

from react-markdown.

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.