Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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="app"></div>
              
            
!

CSS

              
                html
  height: 100%

body
  height: 100%
  margin: 0

#app
  display: flex
  min-height: 100%
  
#editor
  width: 50%
  font-size: clamp(1rem, .78vw, 1.25rem)
  color: limegreen
  background-color: rgb(10, 15, 20)
  resize: horizontal
  box-sizing: border-box
  scrollbar-color: DarkSlateGray transparent
  border: none
  margin: 0
  &:focus
    outline: none
  
#preview
  flex: 1
  overflow: auto
  border: 1px solid rgb(30, 30, 40)
  
#editor, #preview
  padding: 2em
  
$breakpoint: 1280px
  
@media(min-width: $breakpoint)
  #editor
    height: auto !important

@media(max-width: $breakpoint - 1px)
  #app
    flex-direction: column
  #editor
    font-size: 14px
    width: 100% !important
    height: 50vh
    resize: vertical
  #editor, #preview
    padding: 1rem
              
            
!

JS

              
                const projectName = "markdown-previewer";


marked.setOptions({
  highlight(code, lang) {
    return hljs.highlight(code, {
      language: hljs.getLanguage(lang) ? lang : "plaintext"
    }).value;
  },
  breaks: true,
  sanitizer: DOMPurify.sanitize,
  smartLists: true
});


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

## This is an example

\`\`\`javascript
function salute() {
  return "Hello there!";
}

salute();
\`\`\`

My favorite foods:
1. Pizza
2. Pasta
3. Bananas

> “People say nothing is impossible, but I do nothing every day.” —A. A. Milne

![Duck](https://i.ibb.co/nBkpZ8J/rsz-12cd43b-3ed5ea12e6644d7d8186aa2a0d8b2abf-mv2-d-2535-2901-s-4-2.png)

[Created By **\`SSbit01\`**](https://github.com/SSbit01)
`
    }
    this.change = this.change.bind(this);
  }
  
  change() {
    this.setState({
      text: event.target.value
    });
  }
  
  render() {
    return (
      <>
        <textarea 
          id="editor" 
          spellcheck="false"
          value={this.state.text}
          onChange={this.change}
        />
        <div id="preview" className="markdown-body" dangerouslySetInnerHTML={{__html: marked.parse(this.state.text)}}/>
      </>
    );
  }
}


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

Console