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 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

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 id="app"></div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.6.2/marked.js"></script>
<!-- <script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script> -->
              
            
!

CSS

              
                body {
  color: #3C3F59;
  font-family: 'Raleway', sans-serif;
  font-size: 18px;
}

#container {
  text-align: center;
  display: flex;
  justify-content: center;
  background: #9CA2E5;
}

#content {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: #7F77AE;
  max-width: 85vw;
  min-width: 450px;
}

#header {
  min-width: 400px;
  max-width: 85%;
}

#header h1 {
  font-size: 45px;  
  
}

#header p {
  font-size: 18px;
  font-weight: 500;
  font-style: italic;
}

#header a {
  color: #3C3F59;
  font-weight: 700;
}

#editor-bar, #preview-bar {
  background: #4EA699;
  border: 5px solid #49607B;
  border-bottom: none;
  padding: 5px;
  border-radius: 8px 8px 0 0;
  font-weight: 700;
}

#editor-container {
  padding: 30px 0;
  width: 90%;
  max-width: 1000px;
  display: flex;
  flex-direction: column;  
}

textarea {
  max-width: 100%; 
  min-width: 400px;
  border: 5px solid #49607B;
  border-radius: 0 0 8px 8px;
  padding: 10px;
  background-color: #7296C1;
}

textarea::-webkit-scrollbar {
  background-color: #7296C1;
  border-left: 2px solid #49607B;
  border-top:2px solid #49607B;
  border-bottom: 2px solid #49607B;;
}

textarea::-webkit-scrollbar-thumb {
  background-color: #49607B;
}


#preview-container {
    width: 85vw;
  max-width: 70%;
  min-width: 400px;
}

#preview {
  border: 5px solid #49607B;
  border-radius: 0 0 8px 8px;
  background-color: #7296C1;
  padding: 10px;
  text-align: left;
}

img {
  max-width: 90%;
}

footer {
  background: #7296C1;
  padding: 10px 0;
  margin-top: 25px;
  width: 100%;
}

footer a {
  color: #3C3F59;
  font-weight: 700;
}
              
            
!

JS

              
                class App extends React.Component {
  constructor(props){
    super(props);
    this.state = { 
      inputText: `
# This is a header

## This is a subheading

Here is [a link](https://www.wildlifetrusts.org/wildlife-explorer/mammals/european-badger) to a thing you might be interested in.

Perhaps you\'d be more interested in seeing some inline code: \`<div>Check out this code</div>\`

Here is a bit more code:

\`\`\`
<h1>Hello, World!</h1>
<p>Welcome to my lovely code block</p>
\`\`\`

Sometimes you might want to include a block-quote, and as Roosevelt once said:
> Markdown is, in a sense, no different from magic.

At this stage in the proceedings, I like to throw in a list of the reasons why badgers are great:

* Snuffling sounds
* Seriously, just look at their cute little faces!
* They look great wearing a monocle

Text can be bold if you think it is **really important**.

And finally, here's a picture of a badger:

![badger shot](https://raw.githubusercontent.com/paul-duvall/website_images/master/badger.jpg)

`
    };
    this.handleUpdateEditor = this.handleUpdateEditor.bind(this);
  }
  
  handleUpdateEditor(e){
    const text = e.target.value;
    this.setState({ inputText: e.target.value });
  }
  
  render() {
    return (
      <div id="container">
        <div id="content">
          <div id="header">
            <h1>Markdown previewer</h1>
            <p>Type your markdown into the box below and you'll see a preview underneath. </p><p>Find out how to style markdown <a href="https://guides.github.com/features/mastering-markdown/" target="_blank">here</a>.</p>
          </div>
          <Editor 
            handleUpdateEditor={this.handleUpdateEditor}
            text={this.state.inputText}
          />
          <div id="preview-container">
            <div id="preview-bar">Preview</div>
            <div id="preview" dangerouslySetInnerHTML={{__html:marked(this.state.inputText)}}></div>
          </div>
          <footer><a href="https://www.pjdwebsdesign.com" target="_blank">www.pjdwebdesign.com</a></footer>
          
        </div>
      </div>
    );
  }
}

const Editor = (props) => {
  return (
    <div id="editor-container">
      <div id="editor-bar">Editor</div>
      <textarea 
        id="editor"
        rows="20"
        cols="90"
        onKeyUp={props.handleUpdateEditor}>{props.text}</textarea>
    </div>
  );    
};

marked.setOptions({
  breaks: true
});

ReactDOM.render(<App/>, document.getElementById('app'));
              
            
!
999px

Console