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

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

              
            
!

CSS

              
                body{
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

.App{
/*     border: rgb(241, 245, 9) solid 3px; */
    min-height: 100vh;
    background-color: rgb(68, 52, 83);
}

header{
    min-height: 10vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: whitesmoke;
/*     border: rgb(96, 245, 9) solid 3px; */
}

.main{
    display: flex;
    height: 90vh;
}

.editor-div{
/*     border: red solid 1px; */
    width: 50%;
    display: flex;
    flex-direction: column;
    /* align-items: center; */
    justify-content: flex-start;
}

.header-editor{
/*     border: yellow solid 1px; */
}

.editor{
    height: 80%;
    width: 80%;
    overflow: auto;
    align-self: center;
    padding: 1rem;
}

.preview-div{
/*     border: white solid 1px; */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    height: 100%;
    width: 50%;
}

.header-preview{
/*     border: yellow solid 1px; */
}

.preview{
    width: 80%;
    height: 80%;
    padding: 0;
    background-color: white;
    word-wrap: break-word;
    word-break: break-word;
    overflow: auto;
    align-self: center;
    padding: 1rem;
}

li{
  margin-left: 20px;
}
              
            
!

JS

              
                import * as React from "https://cdn.skypack.dev/react@17.0.1";
import * as ReactDOM from "https://cdn.skypack.dev/react-dom";

const initialText = "# Header \n## Subheader \n### Sub-subheader \n\nIn-line code, `<div></div>`, between 2 backticks. \n\n``` \n// this is a code block: \nfunction anotherExample(firstLine, lastLine) { \n  if (firstLine == '```' && lastLine == '```') {\n     return multiLineCode;\n  }\n}\n```\n\nYou can also make text **bold**... whoa!\nOr _italic_.\nOr... wait for it... **_both!_**\nAnd feel free to go crazy ~~crossing stuff out~~.\nThere's also [links](https://www.freecodecamp.com), and\n> Block Quotes!\n\n- And of course there are lists.\n  - Some are bulleted.\n    - With different indentation levels.\n      - That look like this.\n\n1. And there are numbered lists too.\n1. Use just 1s if you want!\n1. And last but not least, let's not forget embedded images:\n\n![React Logo w/ Text](https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse1.mm.bing.net%2Fth%3Fid%3DOIP.ZmV_XcNHA9rOtiy4DPL31AAAAA%26pid%3DApi&f=1)"

marked.setOptions({breaks: true})

function App() {

  const [text, setText] = React.useState('')
  
  const handleChange = (e) => {
    setText(e.target.value)
  }

  React.useEffect(() => {
    setText(initialText)
  }, [])

  const markdown = marked(text)

  return (
    <div className="App">
      <header className="header-top">
        <h2>Markdown Previewer</h2>
      </header>
      <div className="main">
        <div className="editor-div">
          <header className="header-editor">
            <h2>Markdown</h2>
          </header>
          <textarea
            className="editor rounded"
            id="editor"
            onChange={(e) => handleChange(e)}
            placeholder="Enter markdown here..."
            value={text}
          ></textarea>
        </div>
        <div className="preview-div">
          <header className="header-preview">
            <h2>Preview</h2>
          </header>
          <div
            className="preview rounded" id="preview"
            dangerouslySetInnerHTML={{ __html: markdown }}
          ></div>
        </div>
      </div>
    </div>
  );
}

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


              
            
!
999px

Console