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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

            
              <body>
  <div id="app"></div>
</body>
            
          
!

CSS

            
              body {
  background: #e5e5e5;
  font-family: Helvetica Neue, Helvetica, sans-serif;
  * {
    box-sizing: border-box;
  }
  h1, h2 {
    margin: 0 auto 18px;
    font-weight: 400;
  }
  .header {
    text-align: center;
    margin-top: 24px;
    font-weight: 400;
    display: table;
    margin: 0 auto 32px;
    padding-bottom: 12px;
    border-bottom: 2px solid #5f5f5f;
    color: #3f3f3f;
  }
  .one-half {
    float: left;
    margin: 0 2%;
    width: 46%;
    padding: 15px;
    min-height: 80vh;
  }
  textarea, .content {
    background: #f5f5f5;
    font-size: 16px;
    border: none;
    color: #3f3f3f;
    &:focus {
      outline: none;
    }
  }
  @media screen and (max-width: 600px) {
    .one-half {
      width: 96%;
    }
  }
  img {
    display: block;
    margin: 6px auto;
  }
}
            
          
!

JS

            
              var PropTypes = React.PropTypes;
// Add all business logic to main component
var Editor = React.createClass({
  // set default text required by MdInput component
  getInitialState: function() {
    // Add potentially dangerous pepe
    return {
      text: '##Type your *markdown* here!  ![pepe](https://66.media.tumblr.com/2a62809f53d0a566bcbbfad85da66600/tumblr_nqbo02EJx51us00yto1_250.gif)'
    }
  },
  // pass textarea content to parent 
  handleChange: function(e) {
    e.preventDefault();
    this.setState({text: event.target.value});
  },
  // provide function for raw html trusting Marked library
  rawMarkup: function() {
    return {__html: marked(this.state.text)};
  },
  render: function() {
    return (
      <div>
        <h1 className="header">MarkdownPad</h1>
        <MdInput
          /* Pass text value to output */
          text={this.state.text}
          /* Make functions available to children */
          onHandleChange={this.handleChange}
        />
        <HtmlOutput
          /* Make functions available to children */
          showHtml={this.rawMarkup}
        />
      </div>
    );
  }
});

// Create input / output as stateless components
function MdInput(props) {
  return (
    <textarea
      // Use logic from parent component to handle input
      onChange={props.onHandleChange}
      defaultValue={props.text}
      // make value available to parent's state
      value={props.text}
      className="one-half"
    />
  )
}
// Require default text and input-handling function
MdInput.propTypes = {
  text: PropTypes.string.isRequired,
  onHandleChange: PropTypes.func.isRequired
}
// Assume Marked library as trusted
function HtmlOutput(props) {
  return (
    <div
      className="content one-half"
      dangerouslySetInnerHTML={props.showHtml()}
    />
  )
}
// Require html-rendering function
HtmlOutput.propTypes = {
  showHtml: PropTypes.func.isRequired
}

// Render parent container
ReactDOM.render(
  <Editor />,
  document.getElementById('app')
);
            
          
!
999px

Console