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

              
                <head>
  <meta charset='UTF-8'>
  <meta name="description" content="Mark Down Previewer">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">
  
  <script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>
  
</head>
<body id="">
<div class="container">
  <div id="root"></div>
</div>
</body>
              
            
!

CSS

              
                body{
  background-color:#15454E;
}

 #editor{
  margin-top:0px;
  width:100%;
     box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
} 
 
#toolbar{
  position:relative;
  margin-top:70px;
  background:#9DD991;
  margin-bottom:-1px;
  text-align:center;
}

#preview{
  background-color:white;
  height:50%;
  padding-left:14px;
    box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
}

i{
  float:right;
  padding:1px 3px 1px 1px;
}
i:hover{
  color:#3BA183;
}

.buttons{
  height:190px;
}

.toggled{
  height:900px;
}


/* <Prev  marker={prev()} /> */
              
            
!

JS

              
                var renderer = new marked.Renderer();

marked.setOptions({
  breaks:true
});


renderer.link = (address = "#", title = "", content = "") => (
   `<a target="_blank" href=${address} title=${title}>${content}</a>`
)



class MyApp extends React.Component {
  constructor(props) {
    super(props);
    
const defaulttext =  `# This is a h1 element!
## This is a h2 element!
\`\`\`
This is multi-line code
More multi-line code
Even more multi-line code!
\`\`\`
This is \`inline code\`

> This is a Blockquote

* This is a list item
* This is a second list item
* We can have as many as we like!

9 out of 10 Doctors recommend the React Library

![image](https://i1.wp.com/technoetics.in/wp-content/uploads/2016/09/reactlogo2.png?fit=391%2C377)

__We can even apply styles like bold!__

[This is a link to all the information about the world!](https://www.google.com/ "google.com")`
    
    this.state = {
      input: defaulttext,
      condition:false
    }
    this.handleChange = this.handleChange.bind(this);
    this.handleClick = this.handleClick.bind(this);
  }
  handleChange(event) {
    this.setState({input: event.target.value})
  }
  
  handleClick() {
    this.setState(prevState => ({
      condition:!this.state.condition
    }))
  }

  render() {
     const marking = marked(this.state.input,{renderer});
    function prev() {return{ __html:marking}};
    
    return (
      <div>
        <Tool
          handleClick={this.handleClick}
          condition={this.state.condition}/>
      <Editor 
        input = {this.state.input}
        handleChange={this.handleChange}
        condition={this.state.condition}/>
      <Prev  marker={prev()} /> 
      </div>

    );
  }
}

class Tool extends React.Component {
  constructor(props) {
    super(props)
  }
  render(){
    return (
      <div>
   <div id="toolbar">Editor<i onClick={this.props.handleClick} className={this.props.condition ? " fas fa-angry far fa-window-maximize":"far fa-window-maximize"}></i></div>
    </div>
      )
  }
}

class Editor extends React.Component {
  constructor(props) {
    super(props) 
  }
  render() {
    return (
      <div>
      <textarea id="editor" className={this.props.condition ? 'toggled buttons' : "buttons"}  onChange={this.props.handleChange} value={this.props.input} ></textarea>
      </div>
    )
  }
}

class Prev extends React.Component {
  constructor(props) {
    super(props)
  }
  render() {
    return(
      <div>
      <div  id="toolbar">Preview</div>
      <div id="preview"  dangerouslySetInnerHTML={this.props.marker}></div>
      </div>
    )
  }
}




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

Console