Created
March 23, 2017 09:55
-
-
Save furball514/7d2547908d0c63444e598cd801eafb60 to your computer and use it in GitHub Desktop.
Github flavoured markdown
This file contains hidden or 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
.container | |
#container |
This file contains hidden or 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
var Markdown = React.createClass({getInitialState: function(){return {userInput: 'Heading\n=======\n\nSub-heading\n-----------\n \n### Another deeper heading\n \nParagraphs are separated\nby a blank line.\n\nLeave 2 spaces at the end of a line to do a \nline break\n\nText attributes *italic*, **bold**, \n`monospace`, ~~strikethrough~~ .\n\nShopping list:\n\n * apples\n * oranges\n * pears\n\nNumbered list:\n\n 1. apples\n 2. oranges\n 3. pears\n\nThe rain---not the reign---in\nSpain.\n\n *[Karthik N](codepen.io/furball)*'};}, | |
rawMarkup: function(value) { | |
var rawMarkup = marked(value, {sanitize: true}); | |
return { __html: rawMarkup };}, render: function(){return (<div className="row"><div className="col-md-6"><textarea rows="22" type="text" className="form-control" value={this.state.userInput} onChange={this.handleUserInput} /></div><div className="col-md-6"><span dangerouslySetInnerHTML ={this.rawMarkup(this.state.userInput)} /></div></div>);}, | |
handleUserInput: function(event){this.setState({userInput: event.target.value})} }); | |
ReactDOM.render(<Markdown />,document.getElementById('container')); |
This file contains hidden or 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
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react-dom.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.6/marked.min.js"></script> |
This file contains hidden or 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
.container | |
margin-top: 15px | |
background: yellow | |
textarea | |
resize: vertical | |
height: 100% | |
box-shadow: 0 3px 0 0 #222121, inset -1px -3px 10px 1px #515151 |
This file contains hidden or 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
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment