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

              
                

<div id="root"></div>



              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=Carter+One|Montserrat");

/* font-family: "Carter One", cursive; */
body {
  width: 100%;
  height: 100%;
}
.App {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-content: stretch;
  height: 100%;
  width: 100%;
  color: red;
  font-family: "Montserrat", sans-serif;
}

.header,
.footer {
  font-family: "Carter One", cursive;
  width: 100%;
  background-color: black;
  color: #9ef;
  padding: 5px;

  text-align: center;
}

.footer {
  /* position: absolute;
  bottom: 0; */
}
.body {
  display: flex;
  width: 100%;
  padding: 50px 5px;
  justify-content: center;
  align-items: stretch;
  align-content: space-around;
  height: 100%;
  min-height: 600px;
  background-color: #222;
}

.editSide {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 45%;
  min-height: 50%;
  border-radius: 10px 0px 0px 10px;
  border: solid black 2px;
  border-right: 0px;
 background-color: #9ef
}

.editorTop {
  display: flex;
  align-items: center;
  flex-direction: column;
  border-radius: 10px 0px 0px 0px;
}

.editorTop,
.previewTop {
  height: 100px;
  width: 100%;
  text-align: center;

  margin-bottom: 5px;
  font-family: "Carter One", cursive;
  color: white;
  background-color: rgb(104, 90, 102);
}

.editorTop h1,
.previewTop h1 {
  margin: 0px;
}
.previewTop {
  margin-top: 0px;
  border-radius: 0px 10px 0px 0px;
}
#editor {
  width: 90%;
  max-width: 95%;
  height: 500px;
  font-size: 1em;
  font-weight: 500;
  background-color: #9ef;
  padding: 10px;
 }

.button {
  /* margin-bottom: 10px; */

  width: 20%;
  border: solid black 2px;
  border-radius: 5px;
  font-family: "Carter One", cursive;
  padding: 3px 10px;
}

code {
  background-color: #222;
}
#preview {
  padding: 0px 20px;
}
.previewSide {
  display: flex;
  flex-direction: column;
  width: 45%;
  border: solid black 2px;
  min-height: 50%;
  font-size: 1.2em;
  background-color: #999;
  color: white;
  border-radius: 0px 10px 10px 0px;
  border-left: 0px;
}

.previewSide a {
  color: #99eeff;
}

.markdownJSLink img {
  width: 100px;
  height: 100px;
  object-fit: fill;
  overflow: hidden;
 
}

.markdownJSLink {
  display: flex;
  align-content: center;
  justify-content: center;
  color: white;
 padding-left: 35px;
 
}
.footer i {
  font-size: 2em;
  margin: 0px 10px;
  color: #9ef;
 display: flex;
/*  flex-direction: column; */
}

.footer {
 display: flex;
 flex-direction: column;
 justify-content: center;
 align-content: center;
 justify-items: center;
 align-items: center;
}



.socialLinks  {
 display: flex;
 justify-content: center;
/*    font-size: 1.25em; */
  margin: 20px 0px;
  color: #9ef;

}

.socialLinks a {
 text-decoration: none;
}




              
            
!

JS

              
                const marked = window.marked;

marked.setOptions({
  breaks: true,
  gfm: true,
  pedantic: false
});

const renderer = new marked.Renderer();
const linkRenderer = renderer.link;
renderer.link = (href, title, text) => {
  const html = linkRenderer.call(renderer, href, title, text);
  return html.replace(/^<a /, '<a target="_blank" rel="nofollow" ');
};

class App extends React.Component{
 constructor(props) {
    super(props);
    this.state = {
      text: "",
      previewText: ""
    };
    this.onChange = this.onChange.bind(this);
    this.clearText = this.clearText.bind(this);
  }
  componentDidMount = () => {
    const previewDefault = marked(defaultMkDwn, { renderer });

    this.setState({ text: defaultMkDwn, previewText: previewDefault });
  };

  onChange(e) {
    const markdown = marked(e.target.value, { renderer });
    this.setState({ text: e.target.value, previewText: markdown });

    autoExpand();
  }
  clearText() {
    this.setState({ text: "", previewText: "" });
  }

  render() {
   return (
      <div className="App">
        <Header />
        <div className="body">
          <Editor
            onChange={this.onChange}
            clearText={this.clearText}
            text={this.state.text}
          />
          <Preview previewText={this.state.previewText} />
        </div>
        <Footer />
      </div>
    );
  }
};

class Editor extends React.Component {
  render() {
    return (
      <div className="editSide">
        <div className="editorTop">
          <h1>Editor</h1>
          <button className="button" onClick={this.props.clearText}>
            Clear
          </button>
        </div>

        <textarea
          className="autoExpand"
          name="editor"
          id="editor"
          data-min-rows="5"
          rows="5"
          onChange={this.props.onChange}
          value={this.props.text}
        />
      </div>
    );
  }
}


class Preview extends React.Component {
  render() {
    const rawMarkup = this.props.previewText;
    function createMarkup() {
      return { __html: rawMarkup };
    }

    return (
      <div className="previewSide">
        <div className="previewTop">
          <h1>Preview</h1>
        </div>

        <div id="preview" dangerouslySetInnerHTML={createMarkup()} />
      </div>
    );
  }
}

class Header extends React.Component {
  render() {
    return (
      <div className="header">
        <h1>Markdown Code Previewer</h1>
        <p>
          Enter your Markdown code on the left and see how it will render on the
          right
        </p>
      </div>
    );
  }
}

class Footer extends React.Component {
  render() {
    return (
      <div className="footer">
       
        <div className="socialLinks">
             
                <a href="https://github.com/REAOrlando" target="_blank">
                  <i className="fab fa-github" />
                </a>
                <a href="https://www.linkedin.com/in/christopheralbanesefl/" target="_blank">
                  <i className="fab fa-linkedin" />
                </a>
                <a href="https://twitter.com/albanesechris" target="_blank">
                  <i className="fab fa-twitter" />
                </a> 
           
             
        </div>
 <p>© Christopher Albanese 2018</p>
         
    

        <div className="markdownJSLink">
          <h3>Powered by MarkedJS.org</h3>
          <a href="https://marked.js.org/#/README.md#README.md" target="_blank">
            <img src="https://marked.js.org/img/logo-black.svg" alt="" />
          </a>
        </div>
      </div>
    );
  }
}

const defaultMkDwn = `# This is what h1 looks like
## Here is a h2 sub-heading
[I'm a link to google ](www.google.com  target="_blank")
this is \`inline  code\`
 Here is code block
  \`\`\`javascript
  function codeBlock() {\n
  console.log("I'm a code block")\n
  }\`\`\`
Next is an image
![logo](https://source.unsplash.com/random/100x100)
1. I'm a list item 
1. So am I
2. Me too (the number doesn't matter) 
> I'm a Blockquote

**See how bold I can be!**
~~Sometimes we all make mistakes~~
`;
const autoExpand = () => {
  $(document)
    .on("focus.autoExpand", "textarea.autoExpand", function() {
      var savedValue = this.value;
      this.value = "";
      this.baseScrollHeight = this.scrollHeight;
      this.value = savedValue;
    })
    .on("input.autoExpand", "textarea.autoExpand", function() {
      var minRows = this.getAttribute("data-min-rows") | 0,
        rows;
      this.rows = minRows;
      rows = Math.ceil((this.scrollHeight - this.baseScrollHeight) / 16);
      this.rows = minRows + rows;
    });
};


ReactDOM.render(<App />, document.getElementById('root'));





              
            
!
999px

Console