Optional
getThe language to use
Optional
highlightThis function is mostly used if you'd like to be able to have the code
highlighted via dangerouslySetInnerHTML
so that the code can be highlighted
in node environments.
the html to dangerously set within a <code>
tag
Optional
highlightA function that should highlight all the code within an HTMLElement
. This
should normally just be something like Prism.highlightElement
or
HighlightJS.highlightElement
.
The markdown to be parsed by marked and rendered in react components.
Optional
optionsAny options to use while parsing the markdown string.
Optional
renderersOptional
sluggerAn optional slugger to provide that generates unique ids for different components. You'll most likely never need to use this prop unless you are rendering multiple Markdown components on the same page that have a change of having the same ids.
Preventing Duplicated Ids
import { render } from "react-dom";
import { Markdown, Slugger } from "react-marked-renderer";
const slugger = new Slugger();
// Without providing the same slugger, both headings would have the same id
const markdown = "# Heading"
function App() {
return (
<>
<Markdown markdown={markdown} slugger={slugger} />
<Markdown markdown={markdown} slugger={slugger} />
</>
);
}
render(
<App />,
document.getElementById("root")
);
= new marked.Slugger()
Generated using TypeDoc
A function that can be used to get the language for a block of code or allow different aliases.