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.

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

              
                <!-- <script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script> -->

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"
    />
    <meta name="theme-color" content="#000000" />

    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />

    <title>Markdown Previewer</title>
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
  </body>
</html>

              
            
!

CSS

              
                $bg-color: #f6f8fa;
$light-color: #daf6ff;
$shadow-light: 0 0 20px rgba(10, 175, 230, 1), 0 0 20px rgba(10, 175, 230, 0);
$deep-blue: #282c34;

html,
body {
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
  background-color: #282c34;
  min-height: 100vh;
}

* {
  box-sizing: border-box;
}

.App {
  text-align: center;
  background-color: #282c34;
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
}

.viewer-container {
  margin-right: auto;
}

.editor-container,
.viewer-container {
  height: 70vh;
  width: 45vw;
  text-align: left;
  margin-left: auto;

  .container-header {
    padding-left: 1rem;
    margin: 0;
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid $light-color;
    border-radius: 5px 5px 0 0;
    font-size: 1rem;
    text-transform: uppercase;
    color: $light-color;
    text-shadow: $shadow-light;
    box-shadow: $shadow-light;
  }

  #editor,
  #preview {
    border: 1px solid $light-color;
    background: $bg-color;
    padding: 1.5em;
    padding-top: 1em;
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 0 0 0 7px;
    // overflow-x: hidden;
    overflow-y: scroll;
    box-shadow: $shadow-light;

    &::-webkit-scrollbar {
      width: 5px;
    }

    &::-webkit-scrollbar-track {
      background: #f1f1f1;
    }

    &::-webkit-scrollbar-thumb {
      background: $deep-blue;
    }

    &::-webkit-scrollbar-thumb:hover {
      background: $deep-blue;
    }
  }

  #editor {
    resize: none;
    padding: 3rem 1.5rem;
    font-size: 1.1rem;
  }
}

#preview {
  font-family: Arial, Helvetica, sans-serif;

  h1:not(.container-header) {
    font-size: 1.7rem;
    color: $deep-blue;
  }
  h2 {
    color: darken($light-color, 60);
  }
  h3 {
    color: green;
  }
  code {
    padding: 0.5rem 1rem;
    border-radius: 7px;
    display: inline-block;
    background: $deep-blue;
    color: $light-color;
    text-shadow: $shadow-light;
  }
  a {
    color: green;
  }
  blockquote {
    border-left: 3px solid darken($light-color, 60);
    padding-left: 0.5rem;
  }
  table {
    border-collapse: collapse;
  }
  td,
  th {
    border: 3px solid darken($light-color, 60);
    padding: 0.5rem;
  }
  img {
    width: 250px;
    height: auto;
    display: inline-block;
    text-align: right;
    padding: 0.5rem;
  }
}

@media screen and (max-width: 900px) {
  .App {
    flex-direction: column;

    .editor-container,
    .viewer-container {
      width: 90vw;
      padding: 0 1.5rem;
      margin: 50px 70px;
      margin-top: 50px;
      margin-bottom: 50px;
    }
  }
}

              
            
!

JS

              
                const startText = `# Welcome to my React MarkViewer!

## This is a sub-heading...
### And this is a H3...
  
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](https://github.com/alina-balteanu), 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 numbererd 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:

![](https://res.cloudinary.com/dshmwg7vw/image/upload/v1552079984/purple2.png)
`;

class MarkdownEditor extends React.Component {
  render() {
    return (
      <div className="editor-container">
        <h1 className="container-header">editor</h1>
        <textarea
          name="editor"
          id="editor"
          value={this.props.value}
          onChange={this.props.onChange}
          spellCheck="false"
        />
      </div>
    );
  }
}

class MarkdownViewer extends React.Component {
  render() {
    return (
      <div className="viewer-container">
        <h1 className="container-header">viewer</h1>
        <div id="preview" dangerouslySetInnerHTML={this.props.displayMarkup} />
      </div>
    );
  }
}



class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      text: startText
    };
  }
  onChange = e => {
    this.setState({
      text: e.target.value
    });
  };

  convertToHTML() {
    var options = { sanitize: true,breaks: true };
    return { __html: marked(this.state.text, options) };
  }
  render() {
    return (
      <div className="App">
        <MarkdownEditor value={this.state.text} onChange={this.onChange} />
        <MarkdownViewer displayMarkup={this.convertToHTML()} />
      </div>
    );
  }
}

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

Console