forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Doc Enhancement] Introduce MarkdownElement mui#2224
- Loading branch information
Frank Fischer
committed
Nov 24, 2015
1 parent
fa860d8
commit 995ac02
Showing
6 changed files
with
110 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const React = require('react'); | ||
let { Paper } = require('material-ui'); | ||
require('github-markdown-css/github-markdown.css'); | ||
import marked from 'marked'; | ||
|
||
const MarkdownElement = React.createClass({ | ||
propTypes: { | ||
text: React.PropTypes.string.isRequired, | ||
}, | ||
getDefaultProps() { | ||
return { | ||
text: '', | ||
}; | ||
}, | ||
|
||
|
||
componentWillMount() { | ||
marked.setOptions({ | ||
gfm: true, | ||
tables: true, | ||
breaks: false, | ||
pedantic: false, | ||
sanitize: true, | ||
smartLists: true, | ||
smartypants: false, | ||
highlight: function (code) { | ||
return require('highlight.js').highlightAuto(code).value; | ||
}, | ||
}); | ||
}, | ||
|
||
render() { | ||
const { text } = this.props, | ||
html = marked(text || ''); | ||
|
||
return ( | ||
<Paper style = {{marginBottom: '22px', padding: '0 24px 24px 24px'}}> | ||
<div className="markdown-body"> | ||
<div dangerouslySetInnerHTML={{__html: html}} /> | ||
</div> | ||
</Paper>); | ||
}, | ||
}); | ||
|
||
module.exports = MarkdownElement; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Headline 1 | ||
|
||
This is a paragraph describing something. | ||
|
||
## Subheadline | ||
|
||
Detailes description here. And some code: | ||
```javascript | ||
const FileFolder = require('svg-icons/file/folder'); | ||
const MoreVertIcon = require('svg-icons/navigation/more-vert'); | ||
|
||
``` | ||
|
||
|
||
```javascript | ||
export default class Login extends React.Component { | ||
|
||
constructor() { | ||
super() | ||
this.state = { | ||
user: '', | ||
password: '' | ||
}; | ||
} | ||
} | ||
function fancyAlert(arg) { | ||
if(arg) { | ||
$.facebox({div:'#foo'}) | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters