Comments (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.
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.
Thanks for quick response...
I couldn't work it out from your demo as it had been minified...
from react-markdown.
Ah, sorry. The demo/src
folder holds the unminified code, if you want to take a look.
from react-markdown.
Related Issues (20)
- ERR_PNPM_NO_MATCHING_VERSION No matching version found for html-url-attributes@^3.0.0 HOT 2
- Link URL getting encoded in react-markdown v9 HOT 12
- Package dependencies error: ./node_modules/mdast-util-to-hast/lib/index.js Module not found: Can't resolve 'devlop' HOT 7
- Bug on old safari(14.1.1) macos 11.4 HOT 2
- Unable to resolve "devlop" from "node_modules/react-markdown/lib/index.js HOT 10
- Classname is always `undefined` HOT 8
- request refactoring HOT 3
- Usage of `Object.hasOwn` breaks web pages on iPad OS (iPad Air, Safari & Chrome) HOT 4
- rehypeKatex with remarkMath is not working for latex math HOT 1
- Does not parse ordered list from markdown correctly, HOT 6
- Code highliting with react-syntax-highlighter bug HOT 7
- Unnecessarily narrow range for React peer deps HOT 7
- Support for inapp links HOT 5
- text not created as hyperlink HOT 6
- Possible inconsistency with handling emphasis and strong when immediately followed by emphasis HOT 3
- p component overriding img component HOT 4
- A 11k star makrdown widget can not have a copy button at code block?
- How render image in cneter? HOT 3
- rermarkgfm showing tasklist wrong HOT 21
- \n Doesn't work properly HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-markdown.