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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>
<h1 id="welcome">Markdown Previewer</h1>
<div id="root" />
              
            
!

CSS

              
                body{
  background: salmon;
}

#welcome{
  margin-top: 0;
  text-align: center;
  font-size: 4vw;
  color: #520000;
}

#container{
  display: flex;
}

#editor{
  background-color: red;
  border: 5px solid darkred;
  width: 40vw;
	height: 80vh;
	padding: 5px;
	font-family: Tahoma, sans-serif;
	background-position: bottom right;
	background-repeat: no-repeat;
  margin-right: 5vw;
  margin-left: 5vw;
  -webkit-box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.75);
box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.75);
}

#preview{
  padding-left: 20px;
  background-color: red;
  border: 5px solid darkred;
  width: 40vw;
  margin: 0;
  -webkit-box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.75);
box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.75);
}

@media only screen and (max-width: 1000px) {
  #container{
    display: block;
  }
  #editor{
    width: 80vw;
    margin-bottom: 10vh;
  }
  #preview{
    margin-left: 5vw;
    width: 80vw;
  }
}
              
            
!

JS

              
                class App extends React.Component{
	constructor(props) {
    super(props)
    this.state = {
      text: `Hello
=====

Welcome to this Markdown Previewer
----------------------------------

[It was created based off a challenge from this website.](https://www.freecodecamp.org/)

\`Part of the challenge is including this preview text\`

<pre>It expects in quite a number of ways.</pre>  

\`\`\`
Admittedly, it does demonstrate what it can do very well.
\`\`\` 

 * At this point, though, I **think** you get the idea.

> This just about does it, though, so have a picture of a cat and try this out.

![A cat](http://myhswm.org/images/sized/images/animals/Leonidas_-256x256.JPG)
`
    }
    this.updateText = this.updateText.bind(this)
	}
  
  updateText(){
    this.setState({
      [event.target.name]: event.target.value
    })
  }
  
	render(){
		return(
      <div id="container">
        <Editor onChange={this.updateText} text={this.state.text} />
        <Preview text={this.state.text} />
      </div>
    )
	}
}

function Editor(props){
		return(
      <div>
        <textarea name="text" id="editor" onChange={props.onChange}>{props.text}</textarea>
      </div>
    )
}

function Preview(props){
  return(
    <div>
      <p id="preview" dangerouslySetInnerHTML={(createMarkup(props.text))}></p>
    </div>
  )
}

function createMarkup(text){
  returnText = marked(text)
  return {__html: returnText}
}


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

Console