[![BackersonOpenCollective](https://opencollective.com/markdown-to-jsx/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/markdown-to-jsx/sponsors/badge.svg)](#sponsors)
`markdown-to-jsx`usesaheavily-modifiedforkof[simple-markdown](https://github.com/Khan/simple-markdown) as its parsing engine and extends it in a number of ways to make your life easier. Notably, this package offers the following additional benefits:
Bydefault,thecompilerwilltrytomakeanintelligentguessaboutthecontentpassedandwrapitina`<div>`, `<p>`, or `<span>`asneededtosatisfythe"inline"-nessofthemarkdown.Forinstance,thisstringwouldbeconsidered"inline":
Passthe`options.overrides` prop to the compiler or `<Markdown>`componenttoseamlesslyrevisetherenderedrepresentationofanyHTMLtag.Youcanchoosetochangethecomponentitself,add/changeprops,orboth.
`markdown-to-jsx` also handles JSX interpolation syntax, but in a minimal way to not introduce a potential attack vector. Interpolations are sent to the component as their raw string, which the consumer can then `eval()`orprocessasdesiredtotheirsecurityneeds.
Inthefollowingcase,`DatePicker` could simply run `parseInt()` on the passed `startTime`forexample:
```jsx
importMarkdownfrom'markdown-to-jsx';
importReactfrom'react';
import{render}from'react-dom';
importDatePickerfrom'./date-picker';
constmd=`
#DatePicker
TheDatePickerworksbysupplyingadatetobiastowards,
aswellasadefaulttimezone.
<DatePicker
biasTowardDateTime="2017-12-05T07:39:36.091Z"
timezone="UTC+5"
startTime={1514579720511}
/>
`;
render(
<Markdown
children={md}
options={{
overrides:{
DatePicker:{
component:DatePicker,
},
},
}}
/>,
document.body
);
```
Anotherpossibilityistousesomethinglike[recompose's`withProps()`HOC](https://github.com/acdlite/recompose/blob/master/docs/API.md#withprops) to create various pregenerated scenarios and then reference them by name in the markdown:
Sometimes,youmightwanttooverridethe`React.createElement` default behavior to hook into the rendering process before the JSX gets rendered. This might be useful to add extra children or modify some props based on runtime conditions. The function mirrors the `React.createElement` function, so the params are [`type, [props], [...children]`](https://reactjs.org/docs/react-api.html#createelement):
```javascript
importMarkdownfrom'markdown-to-jsx';
importReactfrom'react';
import{render}from'react-dom';
constmd=`
#Helloworld
`;
render(
<Markdown
children={md}
options={{
createElement(type,props,children){
return(
<divclassName="parent">
{React.createElement(type,props,children)}
</div>
);
},
}}
/>,
document.body
);
```
####options.slugify
Bydefault,a[lightweightdeburringfunction](https://github.com/probablyup/markdown-to-jsx/blob/bc2f57412332dc670f066320c0f38d0252e0f057/index.js#L261-L275) is used to generate an HTML id from headings. You can override this by passing a function to `options.slugify`. This is helpful when you are using non-alphanumeric characters (e.g. Chinese or Japanese characters) in headings. For example:
Everythingwillworkjustfine!Simply[Alias`react` to `preact-compat`](https://github.com/developit/preact-compat#usage-with-webpack) like you probably already are doing.