123

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

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.

            
              <br />
 <h1 class="text-center">Markdown Previewer</h1>
 <br />
 <div id="root" class="container"></div>
            
          
!
            
              $bg-color1: #ec96a4 15%;
$bg-color2: #336b87 100%;
$bg-color3: #cdcdc0;
$box-shadow: 4px 4px 4px 4px rgba(0,0,0,0.4);
$width: 600px;
$height: 600px;
$borer-radius: 10px;

/* width */
.fancyScrollBar::-webkit-scrollbar {
    width: 8px;
}

/* Handle */
::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 8px;
}

body {
  background: linear-gradient(to top left, $bg-color1, $bg-color2);
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

textarea, .MarkdownDiv {
  width: 100%;
  height: $height;
  min-height: $height;
  max-height: $height;
  overflow-y: auto;
  background-color: $bg-color3;
  border-radius: 10px;
  box-shadow: $box-shadow;
  padding: 5px;
}

textarea:focus {
  outline: none !important;
}

.Footer {
  padding-top: 90px;
}

#footer-ul li {
  font-size: 24px;
  display: inline-block;
  padding-right: 3.5%;
}

.fa-code, .fa-heart {
  -webkit-text-stroke: 1px;
}

@media (max-width: 767px) {
  .Footer {
    padding-top: 750px;
  }
  
  .helperButtons {
    .col-xs-12 {
      margin-bottom: 10px;
    }
  }
  
  .textCol1 {
    margin-bottom: 20px;
  }
  
  .textCol2 {
    margin-top: 40px;
  }
}

.App, .textRow, .textCol1, .textCol2 {
  height: $height;
  min-height: $height;
  max-height: $height;
}

.btn, .btn:hover {
  width: 100%;
  color: black;
  cursor: pointer;
}

.btn:focus, .btn:active {
  outline: none !important;
}

.moreInfoA, .moreInfoA:hover, .moreInfoA:active {
  color: black;
  text-decoration: none !important;
}
            
          
!
            
              class TextArea extends React.Component {

  constructor() {
    super()
    this.onTextChange = this.onTextChange.bind(this);
  }

  onTextChange(e) {
    this.props.onChange(e.target.value);
  }

  render() {
    return (
      <textarea className="fancyScrollBar" value={this.props.text} onChange={this.onTextChange}></textarea>
    );
  }
}

function Markdown(props) {
  var myText = marked(props.text, {sanitize: true});
  return (
    <div className="MarkdownDiv fancyScrollBar" dangerouslySetInnerHTML={{__html: myText}}></div>
  );
}

function Footer() {
  return (
    <div className="text-center Footer">
      &nbsp;
      <i className="fa fa-code text-dark fa-lg"></i>
      &nbsp;with&nbsp;
      <i className="fa fa-heart text-danger"></i>
      &nbsp;By Hemakshi Sachdev, 2018
      <ul className="text-center" id="footer-ul">
        <li><a href="https://github.com/hemakshis" title="GitHub"><i className="fa fa-github"></i></a></li>
        <li><a href="https://www.freecodecamp.org/hemakshis" title="FreeCodeCamp"><i className="fa fa-free-code-camp"></i></a></li>
        <li><a href="https://www.linkedin.com/in/hemakshis" title="LinkedIn"><i className="fa fa-linkedin"></i></a></li>
      </ul>
    </div>
  );
}

class App extends React.Component {

  constructor(props) {
    super(props)
    this.state = {
      text: ''
    };
    
    this.handleTextChange = this.handleTextChange.bind(this);
    this.onClearButtonClick = this.onClearButtonClick.bind(this);
    this.onHelpButtonClick = this.onHelpButtonClick.bind(this);
    this.setDefaultValue = this.setDefaultValue.bind(this);
  }

  componentWillMount() {
    this.setDefaultValue();
  }

  componentDidMount() {
    console.log('Component Mounted!');
  }

  setDefaultValue() {
    this.setState({
      text: '# H1\n## H2\n### H3\n#### H4\n##### H5\n###### H6\n\n------\n\n### Emphasis\n\nEmphasis, aka italics, with *asterisks* or _underscores_.\n\nStrong emphasis, aka bold, with **asterisks** or __underscores__.\n\nCombined emphasis with\n\n**asterisks and _underscores_**.\n\nStrikethrough uses two tildes. ~~Scratch this.~~\n\nShopping list:\n  * apples\n  * oranges\n  * pears\n\nNumbered list:\n\n  1. apples\n  2. oranges\n  3. pears\n\n* Unordered list can also use asterisks\n- Or minuses\n+ Or pluses\n\n[I\'m an inline-style link](https://www.google.com)\n\n[I\'m an inline-style link with title](https://www.google.com "Google\'s Homepage")\n\nInline `code` has `back-ticks around` it.'
    })
  }

  handleTextChange(text) {
    this.setState({
      text: text
    });
  }

  onClearButtonClick() {
    this.setState({
      text: ''
    });
  }

  onHelpButtonClick() {
    this.setDefaultValue();
  }

  render() {
    return (
      <div className="App">
        <div className="container">
          <div className="row helperButtons">
            <div className="col-xs-12 col-md-3 col-lg-3 text-center">
              <button className="btn btn-primary" onClick={this.onClearButtonClick}>Clear</button>
            </div>
            <div className="col-xs-12 col-md-3 col-lg-3 text-center">
              <button className="btn btn-info" onClick={this.onHelpButtonClick}>Help</button>
            </div>
            <div className="col-xs-12 col-md-6 col-lg-6 text-center">
              <a className="btn btn-primary moreInfoA" rel="noopener noreferrer" href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank">
                Complete Markdown Cheat Sheet
                &nbsp;
                <i className="fa fa-external-link"></i>
              </a>
            </div>
          </div>
        </div>
        <div className="container">
          <div className="row textRow">
            <div className="col-xs-12 col-md-6 col-lg-6 textCol1">
              <br />
              <div className="headline"><h3>You type here....</h3></div>
              <TextArea text={this.state.text} onChange={this.handleTextChange} />
            </div>
            <div className="col-xs-12 col-md-6 col-lg-6 textCol2">
              <br />
              <div className="headline"><h3>Get the results here....</h3></div>
              <Markdown text={this.state.text} />
            </div>
          </div>
        </div>
        <div className="container">
          <div className="row footerRow">
            <div className="col-xs-12 col-md-12 col-lg-12">
              <Footer />
            </div>
          </div>
        </div>
      </div>
    );
  }
}

ReactDOM.render(<App />,
                document.getElementById('root'));
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console