cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div id="app"></div>
<div id="credit">Coded by <a href="http://lukewalker.org">Luke Walker</a>
            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Rubik+One);
@import url(https://fonts.googleapis.com/css?family=Space+Mono);
@import url(https://fonts.googleapis.com/css?family=Neuton);

$width: 100%;
$size: 16px;
$base-color: #D3D3D3;

@media only screen and (min-width: 1000px) {
  .container {
    display: flex;
    height: 700px;
    max-width: 1000px;
  }
  
  .input, .output {
     width: 50%;
  }
  
  .input>textarea, #outputbox {
    height: 560px;
  }
  
  #outputbox {
    overflow: scroll;
  }
}

@media only screen and (max-width: 999px) {
  .container {
    display: block;
    padding: 10px;
    position: relative;
  }
  
  .input {
    height: 300px;
  }
  
  .output {
    height: auto;
  }
  
  .input, .output {  
    display: block;
    position: relative;
    margin-right: 10px;
    
  }
  
  .input>textarea {
    height: 220px;
  }
}

body {
  width: $width;
  display: block;
  margin: 10px, auto;
}

#title {
  font-family: 'Rubik One', sans-serif;  
  font-size: $size*3;
  text-align: center;
  width: 100%;
  display: block;
}  

.input>h2, .output>h2 {
  font-family: 'Rubik One', sans-serif;
  font-size: $size*2;
  margin-top: 0;
}

.container {
  width: 100%;
  margin: 0 auto;
  background: darken($base-color, 20%);
}

.input, .output {
  background: $base-color;
  margin: 10px;
  padding: 10px;
}

.input > textarea {
  width: 100%;
  font-family: 'Space Mono', monospace;
  font-size: $size;
}

.output > div {
  font-family: Neuton, serif;
  font-size: $size;
}

#credit {
  font-family: 'Space mono', monospace;
  font-size: 0.9*$size;
  text-align: center;
  width: 100%;
}
            
          
!
            
              var App = React.createClass({
  getInitialState: function() {
    var value = '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 line break  \n \nText attributes *italic*, **bold**, `monospace`, ~~strikethrough~~ . \n\nShopping list: \n* apples \n* oranges \n* pears \n\nNumbered list: \n\n1. apples \n2. oranges \n3. pears  \n\nThe rain---not the reign---in Spain.  \n\n *Text borrowed from [Herman Fassett](https://freecodecamp.com/hermanfassett)*';
    return { value: value, html: marked(value, {sanitize: true}) };
 
  },
  parseText: function(newText) {
    var parsed = marked(newText, {sanitize: true});
    this.setState({ value: newText, html: parsed });
  },
  render: function() {
    var html = this.state.html;
    return (
      <div>
        <h1 id="title">Luke's Markdown Previewer</h1>
        <div className="container">
          <InputBox 
            value={this.state.value} 
            onChange={this.parseText} 
          />
          <OutputBox value={this.state.html} />
        </div>
      </div>
    );
  }
});

var InputBox = React.createClass({
  handleChange: function (e) {
    var inputText = e.target.value;
    this.props.onChange(inputText);
  },
  render: function() {
    return (
      <div className="input">
        <h2>Input</h2>
        <textarea 
          value={this.props.value} 
          onChange={this.handleChange}
        />
      </div>
    );  
  }
});

var OutputBox = React.createClass({
  render: function() {
    var html = this.props.value;
    return (
      <div className="output">
        <h2>Output</h2>
        <div id="outputbox" dangerouslySetInnerHTML={{ __html: html }} />
      </div>
    );
  }
});
        
ReactDOM.render(
  <App />,
  document.getElementById('app')
);
            
          
!
999px
Loading ..................

Console