Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container">
	<div class="row">
		<div class="col-md-12 text-center">
			<h2 class="heading">Markdown Previewer</h2>
		</div>
	</div>
	<!-- This is where we will inject our content -->
	<div id="myMarkdown"></div>
</div>

              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Bitter')

$background-color: #00bcd4
$text-color: #343435

body
	margin-top: 20px
	color: white
	font-family: 'Bitter', serif
	background: $background-color

.panel
	color: $text-color

.heading
	margin-bottom: 20px
              
            
!

JS

              
                // Thanks to https://github.com/StephenMayeux for his basic walk through of react
class Layout extends React.Component {
	// Constructor function to set the state of the component
	constructor(props) {
		super(props);
		this.state = {
			// Lets set some default markdown for our users
			markdown: 'Here are some example markdown options: \n#A Heading 1\n##A Heading 2\n###A Heading 3\n####A Heading 4\n#####A Heading 5'
		};
	}
	
	// Function to handle changes to the page
	updateMarkdown(event) {
		this.setState({ markdown: event.target.value });
	}
	
	// Create the markdown string to be injected into the view
	createMarkdown(string){
		return { __html: marked(this.state.markdown) }
	}
	
	// Render the component
	render(){
		return (
			<div className="row">
				<div className="col-sm-6">
					<div className="panel panel-default">
						<div className="panel-heading"><h4>Markdown</h4></div>
						<div className="panel-body">
							<textarea onChange={this.updateMarkdown.bind(this)} value={this.state.markdown} className="form-control" rows="16"></textarea>
						</div>
					</div>
				</div>
				<div className="col-sm-6">
					<div className="panel panel-default">
					<div className="panel-heading"><h4>Preview</h4></div>
						<div className="panel-body">
							<div dangerouslySetInnerHTML={this.createMarkdown(this.state.markdown)}></div>
						</div>
					</div>
				</div>
			</div>
		);
	}
}

// Send it all to the view
const Markdown = document.getElementById('myMarkdown');
ReactDOM.render(<Layout />, Markdown);
              
            
!
999px

Console