Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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 id="mount-point"></div>
              
            
!

CSS

              
                body
  margin: 0
  overflow: hidden

#markdownEdit textarea
  font-family: 'VT323'
  font-size: 1.75em
  word-wrap: break-word
  width: 94%
  height: 100%
  resize: none
  background-color: #222
  color: #2c2
  border: none
  padding: 3%
  
#markdownView div
  font-size: 1.25em
  font-family: 'Architects Daughter'
  word-wrap: break-word
  padding: 1em

#markdownView p
  margin: 0
  
#markdownView
  right: 0
  background-color: #fff2ae
  background-image: url(http://demilked.uuuploads.com/free-paper-textures/free-paper-texture-10.jpg)
  background-repeat: repeat-y
  background-size: cover
  color: #191811
  overflow-y: scroll
  
#markdownEdit, #markdownView
  display: inline-block
  width: 50%
  height: 100%
  position: absolute
  top: 0
  
              
            
!

JS

              
                var initialMarkdown = `Heading
=======

Sub-heading
-----------

### Another deeper heading

Paragraphs are separated by a blank line.

leave 2 spaces at the end of a line to do a  
line break.

Text attributes *italic*, **bold**, \`monospace\`, ~~strikethrough~~.

Shopping List
- apples
- oranges
- bananas`;

var MarkdownEdit = React.createClass({
  getInitialState: function() {
    return {text: initialMarkdown};
  },
  handleTextChange: function(e) {
    var text = e.target.value
    this.setState({text: text});
    this.props.onTextChange({text: text.trim()});
  },
  render: function() {
    return (
      <div id="markdownEdit">
        <textarea type="text"
          autofocus="autofocus"
          placeholder="Type some Markdown Here"
          value={this.state.text}
          onChange={this.handleTextChange}
        ></textarea>
      </div>
    );
  }
});

var MarkdownView = React.createClass({
  rawMarkup: function() {
    const markdownString = this.props.data.text.toString();
    const markdownText = markdownString.length === 0 ? 
          `Don't know what markdown is? Read MarkdownGuide.org for a primer.` : markdownString;
    var rawMarkup = marked(markdownText, {sanitize: true});
    return { __html: rawMarkup };
  },
  render: function() {
    return (
      <div id="markdownView">
         <div dangerouslySetInnerHTML={this.rawMarkup()} />
      </div>
    );
  }
});

var MarkdownPreviewer = React.createClass({
  getInitialState: function() {
    return {text: {text: initialMarkdown}};
  },
  handleTextChange: function(text) {
    this.setState({text: text});
  },
  render: function() {
    return (
      <div id="markdownPreviewer">
        <MarkdownEdit onTextChange={this.handleTextChange} />
        <MarkdownView data={this.state.text}/>
      </div>
    );
  }
});

ReactDOM.render(
  <MarkdownPreviewer />,
  document.getElementById('mount-point')
);


              
            
!
999px

Console