diff --git a/README.md b/README.md index 8edec3a..52b54ff 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,29 @@ Example: ``` +### `rules` + +The Markdown will apply its rules by default. However you can pass a `rules` prop to add your own. + +Exemple: + +```js + ( + + ), + }, + }} +> + ![Alt text](/path/to/img.jpg) + +``` + ### Features - `br` (``) diff --git a/index.js b/index.js index ec65a6b..2738351 100644 --- a/index.js +++ b/index.js @@ -10,6 +10,7 @@ import styles from './styles' type Props = { styles: any, children?: string, + rules: Object, } type DefaultProps = Props & { @@ -23,11 +24,12 @@ class Markdown extends Component { static defaultProps: DefaultProps = { styles: styles, children: '', + rules: {}, } renderContent = (children: string) => { const mergedStyles = Object.assign(styles, this.props.styles) - const rules = _.merge({}, SimpleMarkdown.defaultRules, initialRules(mergedStyles)) + const rules = _.merge({}, SimpleMarkdown.defaultRules, initialRules(mergedStyles), this.props.rules) const child = Array.isArray(this.props.children) ? this.props.children.join('') : this.props.children