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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

āš ļø This feature can only be used by logged in users.

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.

            
              body {
  background-color: #9CEAEF;
}

th, td {
  border: 2px solid black;
  padding: 5px;
}

table {
  margin-bottom: 10px;
}
            
          
!
            
              class Editor extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    const containerStyles = {
      margin: 'auto',
      width: '50%',
      marginTop: '15px'
    }
    const textAreaStyles = {
      fontFamily: 'Inconsolata, monospace',
      outline: 'none',
      width: '75%',
      height: '325px',
      resize: 'vertical',
      backgroundColor: '#C4FFF9',
      boxShadow: '2px 2px 5px 2px #888888'
    }
    const headerStyles = {
      width: '75%', 
      border: '1px solid black', 
      backgroundColor: '#68D8D6',
      boxShadow: '2px 2px 5px 2px #888888'
    }
    return (
      <div style={containerStyles}>
        <div style={headerStyles}>
          <h3 style={{paddingLeft: '5px'}}>Editor</h3>
        </div>
        <textarea 
          style={textAreaStyles} 
          id='editor' 
          value={this.props.input} 
          onChange={this.props.handleChange}
          // autoFocus - enable this at the end
        />
      </div>
    );
  }
}

class Previewer extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    const containerStyles = {
      margin: 'auto',
      width: '75%',
      marginTop: '15px'
    }
    const headerStyles = {
      width: '100%', 
      border: '1px solid black', 
      backgroundColor: '#68D8D6',
      boxShadow: '2px 2px 5px 2px #888888'
    }
    const previewStyles = {
      width: '100%', 
      backgroundColor: '#C4FFF9', 
      paddingTop: '5px',
      paddingLeft: '10px',
      border: '1px solid black',
      boxShadow: '2px 2px 5px 2px #888888',
      marginBottom: '10px'
    }
    marked.setOptions({
      breaks: true
    });
    const renderer = new marked.Renderer();
    renderer.link = (href, title, text) => `<a target="_blank" href="${ href }" title="${ title }">${ text }</a>`;
    return (
      <div style={containerStyles}>
        <div style={headerStyles}>
          <h3 style={{paddingLeft: '5px'}}>Previewer</h3>
        </div>
        <div 
          id='preview' 
          dangerouslySetInnerHTML={{ __html: marked(this.props.input, { renderer: renderer }) }}
          style={previewStyles}>
        </div>
      </div>
    );
  }
}

class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      input: placeholder
    }
  }
  
  handleChange = (e) => {
    this.setState({
      input: e.target.value
    });
  };

  render() {
    return (
      <div>
        <Editor 
          input={this.state.input} 
          handleChange={this.handleChange} 
        />
        <Previewer input={this.state.input} />
      </div>
    );
  }
}

const placeholder = 
`# Welcome to my React Markdown Previewer!
    
## This is a sub-heading...
### And here's some other cool stuff:
    
Here's some code, \`<div></div>\`, between 2 backticks.
\`\`\`

// this is multi-line code:

function anotherExample(firstLine, lastLine) {
  if (firstLine == \`\`\` && lastLine == \`\`\`) {
    return multiLineCode;
  }
}
\`\`\`

You can also make text **bold**... whoa!
Or _italic_.
Or... wait for it... **_both!_**
And feel free to go crazy ~~crossing stuff out~~.

There's also [links](http://www.itscassidy.com), and
> Block Quotes!

And if you want to get really crazy, even tables:


Wild Header | Crazy Header | Another Header?
:------------ | :-------------: | -------------: 
Your content can | be here, and it | can be here....
And here. | Okay. | I think we get it.


- And of course there are lists.
  - Some are bulleted.
    - With different indentation levels.
      - That look like this.


1. And there are numbered lists too.
1. Use just 1s if you want!
1. But the list goes on...
- Even if you use dashes or asterisks.
* And last but not least, let\'s not forget embedded images:
![React Logo w/ Text](https://goo.gl/Umyytc)`

ReactDOM.render(<App/>, document.getElementById('root'));
            
          
!
999px
šŸ•‘ One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console