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

              
                <noscript>
  You need to enable JavaScript to run this app.
</noscript>
<div id="root">
  <header class="main-header">
    <p class="header-title">Markdown Previewer</p>
    <p>Made by <a href="https://gustavoguarino.com">Gustavo</a></p>
  </header>
  <div class="container">
    <markdown-input v-show="!fullscreen" @update-input="updateInput"></markdown-input>
    <markdown-output @toggle-fullscreen="toggleFullscreen" :fullscreen="fullscreen" :incoming-text="input"></markdown-output>
  </div>
</div>
              
            
!

CSS

              
                $headerHeight: 50px

body
  margin: 0
  font-family: 'Open Sans', serif
  
a
  &:link
    text-decoration: none
  &:hover
    text-decoration: underline
  
main
  margin: 0 20px
  
.container
  display: flex
  width: 100%
  height: calc( 100vh - #{$headerHeight} )
  
.main-header, .controls
  height: $headerHeight
  display: flex
  align-items: center
  
  a
    color: #67b645
    
.main-header
  margin: 0 30px
  
.controls
  button
    margin-left: 10px
    
.header-title
  text-transform: capitalize
  margin: 0
  margin-right: auto
  font-size: 1.5em
  
.input, .output
  display: flex
  flex-direction: column
  flex: 1 1 50%
  min-width: 200px
  margin: 0 12px 12px
  
  button
    height: 50%
    border: none
    background: orange
    color: #333
    font-size: 14px
    border-radius: 5px
  
#editor, #preview
  height: calc(100% - 2em)
  width: calc(100% - 2em)
  padding: 1em
  border: 1px solid #AAA
  
$editorBg: #e4e4e4
  
#editor
  font-family: monospace
  border: 1px solid darken($editorBg, 10)
  background: $editorBg
  resize: none
  &:focus
    outline: 1px solid skyblue
  
#preview
  word-wrap: break-word
  overflow-y: auto
  background: white
  & > :first-child
    margin-top: 0
  
  blockquote
    background: white
    padding: 1em 1em 0.5em
    border-radius: 12px
    box-shadow: 0 4px 8px 2px rgba(0,0,0,0.5)
    margin-bottom: 2em
    
  pre, code
    background: #262626
    color: #fff
    padding: 0.25em
    
  pre
    padding: 1em
    overflow-x: auto
    
  code
    display: inline-block
    
@media screen and (max-width: 800px)
  .container
    flex-direction: column
              
            
!

JS

              
                /*
// The introductory text presented to viewers on page load.
// Stored inside an array in order to allow collapsing on Brackets.
// Strongly recommend making a single string for production.
*/
const startingText = `
The Amazing(ly simple) Markdown Previewer!
===

1. [What is markdown?](#what-is-markdown-)
1. [How to use](#how-to-use)
  1. [The Basics](#the-basics)
  1. [Headings](#headings)
  1. [Images and links](#images-and-links)
  1. [Lists](#lists)
  1. [Blockquotes](#blockquotes)
  1. [Code Blocks and Inline Code](#code-blocks-and-inline-code)
  1. [Extras](#extras)
1. [How it works](#how-it-works)


What is Markdown?
---

Markdown could be one of these things:

a) Markdown is a plain text syntax that provides formatting via semantic character usage.

b) Markdown is a conversion tool that converts input into HTML.

The answer? C) Both!

[Markdown](https://daringfireball.net/projects/markdown/) is a plain-text to HTML syntax that is easily legible on its own, and can also be converted into perfectly valid HTML (or XHTML). It's a powerful tool that's used all over the web on sites like Github, allowing users to easily create documents from scratch.

How to use
---

### The basics

Simply start typing, and text will simply appear, automatically wrapped in \`<p>\` tags. Hitting the return key once will insert a line break, and a second press will start a brand new paragraph.

If you want to add *italics* to certain words, wrap them in asterisks like so: \\*this will be italicized\\*. Using two asterisks, \\*\\*like so\\*\\*, will create **bold** text.

### Headings

Adding octothorpes(#) before a block of text will create a heading. The amount of octothorpeswill dictate the resulting heading size.

    # H1 heading
    ## H2 heading
    ### H3 heading
    #### H4 heading
    ##### H5 heading
    ###### H6 heading

Alternatively, the following formatting will also create heading tags

    This creates an H1 heading
    ===
    
    This creates an H2 heading
    ---

Finally, all headings are given an id that matches their name. Any non-alphanumerical characters are replaced with hyphens (-). These ids can then be hyperlinked to in order to help readers bounce around the final product, as seen above in the table of contents.

### Images and links

The syntax to link is as follows:

    [Hyperlink text](link-to-page.html)

[The above creates this link.](#images-and-links)

Alternatively, you can create a reference-style link with the following syntax:

    [Hyperlink text][link reference]
    
    ...
    
    [link reference] actual link "hover text"

[Which results in this kind of link][test]

[test]:#images-and-links "Notice my hover text."

By preceding a link with an exclamation point (!), that link becomes an image. In this case, the hyperlink text then becomes the image's alt tag. Notice that when making links this way, the reference link doesn't immediately have to follow where it's being used. This means you can group them together at the bottom of the file, if you'd like. You can also reuse the links instead of retyping them!

![A random picture of a dog](https://png.pngtree.com/element_origin_min_pic/16/05/23/195742f032cf0f7.jpg)

### Lists

Lists are fairly straightforward. Much like headers, simply precede each list item with one of the following characters: * + -. Each will then be converted to an unordered list item, and you can even use them interchangeably.

    * First item
    - Second item
    + Third item

becomes

* First item
- Second item
+ Third item

Ordered list items work identically. By preceeding a list item with "1.", it will become an ordered list item. You don't have to manually follow numbers after one another.

    1. First item
    1. Second item
    151. Third item

becomes 

1. First item
1. Second item
151. Third item

### Blockquotes

Putting a right angle bracket (>) before the start of a paragraph converts it into a blockquote. Preferably, you should place > at the start of every new line within a blockquote, but in most cases a single one at the start will suffice. Don't quote me on that, as this occasionally may lead to buggy behavior in certain scenarios, so it's probably best to do it all at once.

> Preferably, you should place > at the start of every new line within a blockquote, but in most cases a single one at the start will suffice. Don't quote me on that.
<span style="display: block; text-align: right; color: gray; margin-top: 1em;">&mdash; Gustavo, 2018</span>

Blockquotes can contain other elements inside them, even other blockquotes!

### Code Blocks and Inline Code

By putting four spaces before a line of text, you can convert it into a code block. This strips all formatting from the text, and also reveals characters that might otherwise be hidden.

    function example() {
      printf('** are visible');
    }

### Extras

- You can use a backslash character () to escape out of other special characters. No more **accidentally** overemphasizing things!
- ~~Strikeout~~ text by surrounding it with double tildes (~)
- HTML span tags can be used for custom styling. For the sake of legibility, however, try not to go too <span style="font-size: 1.75em"><span style="color: red;">c</span><span style="color: orange;">r</span><span style="color: yellow;">a</span><span style="color: green;">z</span><span style="color: blue;">y</span>.</span>


How it works
---

This page, you mean? Very, very easily. Most of the hard work has been done by Markdown, as well as the creators of [Marked.js.](https://github.com/markedjs/marked/) Marked.js automatically converts from plain text to HTML, with little input on my end aside from some configuration. For those curious, the config is as follows:

    options = {
      breaks: true,
      smartLists: true,
      smartyPants: true
    }
`;

Vue.component('markdown-input', {
  template: `
  <section class="input">
      <header class="controls">
        <p class='header-title'>Input</p>
        <button @click="clear">Clear</button>
        <button @click="reset">Show Sample</button>
      </header>
      <textarea id="editor" @input="updateText" v-model='inputText'></textarea>
    </section>
`,
  data() {
    return {
      inputText: startingText
  }
  },
  methods: {
    clear() {
      this.inputText = '';
      this.updateText(this.inputText);
    },
    reset() {
      this.inputText = startingText;
      this.updateText();
    },
    updateText() {
      this.$emit('update-input', this.inputText);
    }
  }
});

Vue.component('markdown-output', {
  props: {
    incomingText: {
      type: String,
      required: true
    },
    fullscreen: {
      type: Boolean,
      default: false
    }
  },
  template: `
  <section class="output">
    <header class="controls">
      <p class='header-title'>Output</p>
      <button @click="toggleFullscreen">{{ this.fullscreen ? 'Hide Editor' : 'Show Editor' }}</button>
    </header>
    <div id="preview" v-html="markdown">
    </div>
  </section>
`,
  methods: {
    toggleFullscreen() {
      this.$emit('toggle-fullscreen', this.fullscreen);
    }
  },
  computed: {
    markdown() {
      return marked(this.incomingText);
    }
  }
});

const app = new Vue({
  el: '#root',
  data: {
    input: startingText,
    fullscreen: false
  },
  methods: {
    updateInput(text) {
      this.input = text;
    },
    toggleFullscreen() {
      this.fullscreen = !this.fullscreen
    }
  }
});
              
            
!
999px

Console