Interface BaseMarkdownProps

Hierarchy

Properties

getLanguage?: GetCodeLanguage

A function that can be used to get the language for a block of code or allow different aliases.

Returns

The language to use

highlightCode?: DangerouslyHighlightCode

This 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.

Returns

the html to dangerously set within a <code> tag

highlightElement?: HighlightElement

A function that should highlight all the code within an HTMLElement. This should normally just be something like Prism.highlightElement or HighlightJS.highlightElement.

markdown: string

The markdown to be parsed by marked and rendered in react components.

options?: Readonly<MarkdownOptions>

Any options to use while parsing the markdown string.

See

DEFAULT_MARKDOWN_OPTIONS

Default Value

DEFAULT_MARKDOWN_OPTIONS

renderers?: Readonly<MarkdownRenderers>
slugger?: Slugger

An 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.

Example

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")
);

Default Value

= new marked.Slugger()

Generated using TypeDoc