mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
Add the ability to render html and linkify links (#208)
Marked had the ability to display html code. This is useful if you want to embed iframes, set size to images... This allows arbitrary html to be embedded with no sanitization, so `<script>alert()</script>` will be executed. This isn't such a big issue since the markdown is written only by contributors. I also removed the componentWillUpdate call since it's not used (and wrong).
This commit is contained in:
parent
2849cc86cf
commit
d5f26a52d4
1 changed files with 4 additions and 9 deletions
|
@ -18,12 +18,6 @@ function anchors(md) {
|
|||
}
|
||||
|
||||
class Remarkable extends React.Component {
|
||||
componentWillUpdate(nextProps, nextState) {
|
||||
if (nextProps.options !== this.props.options) {
|
||||
this.md = new Markdown(nextProps.options);
|
||||
}
|
||||
}
|
||||
|
||||
content() {
|
||||
if (this.props.source) {
|
||||
return <span dangerouslySetInnerHTML={{ __html: this.renderMarkdown(this.props.source) }} />;
|
||||
|
@ -61,7 +55,9 @@ class Remarkable extends React.Component {
|
|||
} catch (err) {}
|
||||
|
||||
return '';
|
||||
}
|
||||
},
|
||||
html: true,
|
||||
linkify: true,
|
||||
});
|
||||
|
||||
// Register anchors plugin
|
||||
|
@ -90,12 +86,11 @@ class Remarkable extends React.Component {
|
|||
{this.content()}
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Remarkable.defaultProps = {
|
||||
container: 'div',
|
||||
options: {},
|
||||
};
|
||||
|
||||
module.exports = Remarkable;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue