Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ The fill tag takes up all the space available to it. For example, if you have a
### Markdown Tag

<a name="markdown"></a>
#### Markdown
#### Markdown (Base)

The Markdown tag is used to add inline markdown to your slide. You can provide markdown source via the `source` prop, or as children. You can also provide a custom [mdast configuration](https://github.com/wooorm/mdast) via the `mdastConfig` prop.

Expand Down
23 changes: 19 additions & 4 deletions src/components/markdown.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { getStyles } from '../utils/base';
import marksy from 'marksy';
import styled from 'react-emotion';

import BlockQuote from './block-quote';
import CodePane from './code-pane';
Expand All @@ -22,6 +24,8 @@ import TableBody from './table-body';
import TableItem from './table-item';


const Container = styled.div(props => props.styles);

const _Heading = size => {
const component = ({ children }) => <Heading size={size}>{children}</Heading>;
component.propTypes = { children: PropTypes.node };
Expand Down Expand Up @@ -74,23 +78,34 @@ export default class Markdown extends Component {
style: PropTypes.object
};

static contextTypes = {
styles: PropTypes.object,
store: PropTypes.object,
typeface: PropTypes.object
};

static defaultProps = {
style: {},
};

render() {
const { style, children, source } = this.props;
const styleComputed = [
getStyles.call(this),
style
];

if (source) {
return (
<div style={style}>
<Container styles={styleComputed}>
{compile(source).tree}
</div>
</Container>
);
}
return (
<div style={style}>
<Container styles={styleComputed}>
{compile(children).tree}
</div>
</Container>
);
}
}