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 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

              
                <!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />

    <!-- Marked Down API -->
    <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js" type="text/javascript"></script>

    <!--JQuery-->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <title>FCC: Markdown Previewer</title>


    <link href="style.css" rel="stylesheet" type="text/css" />

    <script src="script.js" type="text/javascript"></script>
  </head>

  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>

    <div class="container" style="height: 100vh;">

      <div class="row" style="height: 15%;">
        <div class="col-sm-12 text-center" id="page-title">
          freecodecamp Project: Markdown Previewer
        </div>
      </div>

      <div class="row">
        

        
      </div>

      <div class="row">
        <!-- <div class="col-sm-1"></div> -->
        <div id="editor-wrap" class="col-sm-6" style="height: 100%;">
            <div id="editor-title" class="title">Editor</div>
            <textarea id="editor"></textarea>
        </div>

        <div class="col-sm-6" id="preview-wrap">
          <div id="previewer-title" class="title">Previewer</div>
          <div id="preview"></div>
        </div>

        <!-- <div class="col-sm-1"></div> -->
      </div>
    </div>
    <!--Test Script-->
    <script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>
  </body>
</html>

              
            
!

CSS

              
                body {
    background: rgb(203, 216, 213);
}

#page-title{
    margin-bottom: 1%;
    padding-top: 1%;
    background: rgb(79, 83, 94);
    border-radius: 15px;
    box-shadow: 5px 5px 1px 1px silver,;
    font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
    font-size: 30px;
    color: white;
}

textarea {
    resize: none;
    width: 100%;
    height: 70vh;
    overflow-y: auto;
    
    white-space: pre;

    border-style: outset;
    box-shadow:  5px 5px 5px 5px silver;
    padding: 10px;
    background: rgba(220, 235, 191, 0.377);
}

#preview {
    height: 70vh;
    word-wrap: break-word;
    overflow-y: auto;
    
    border-style: outset;
    box-shadow:  5px 5px 5px 5px silver;
    padding: 10px;
    background: rgba(245, 244, 192, 0.411);
}

img {
    max-width: 300px;
    height: auto;
}

table {
    border-collapse: collapse;
  }

 table td,th {
    border: 2px solid black;
    padding-left: 5px;
    padding-right: 5px;
}

blockquote {
    border-left-style: solid;
    border-width: 5px;
    margin-left: 5px;
    padding-left: 5px;
    background: rgb(240, 241, 229);
}

pre {
    background: rgb(220, 221, 214);
    border-style: inset;
    padding: 5px;
    margin-left: 5px;
}

code {
    background: rgb(220, 221, 214);
}

h1, h2, h3, h4, h5, h6 {
    border-bottom: 1px solid black;
}

.title {
    background: rgb(54, 161, 111);
    margin-bottom: 10px;
    padding: 5px;
    text-align: center;
    border-left: 2px double black;
    border-right: 2px double black;
    border-radius: 20px;
    font-weight: bold;
}
              
            
!

JS

              
                const mark = window.marked

//Intepret carriage returns as <br/>
marked.setOptions({
    breaks: true,
});

//Override link renderer, add target _blank
const renderer = new marked.Renderer();
renderer.link = function (href, title, text) {
  return `<a target="_blank" href="${href}">${text}` + '</a>';
}

$(document).ready(function(){
    $("#editor").val(defaultText)

    $("#editor").on('keyup click change',function(){
        document.getElementById('preview').innerHTML = (mark(document.getElementById("editor").value, {renderer: renderer}
        ))  
    });

    //Trigger a one-time render at page load.
    $("#editor").trigger("click")

});

let defaultText = 
`# Welcome to my Markdown Previewer!

## This is a sub-heading...
### And here's some other cool stuff:
  
Heres some code, \`<div></div>\`, between 2 backticks.

\`\`\`
// this is multi-line code:

function anotherExample(firstLine, lastLine) {
  if (firstLine == '\`\`\`' && lastLine == '\`\`\`') {
    return multiLineCode;
  }
}
\`\`\`
  
You can also make text **bold**... whoa!
Or _italic_.
Or... wait for it... **_both!_**
And feel free to go crazy ~~crossing stuff out~~.

There's also [links](https://www.freecodecamp.com), and
> Block Quotes!

And if you want to get really crazy, even tables:

Wild Header | Crazy Header | Another Header?
------------ | ------------- | ------------- 
Your content can | be here, and it | can be here....
And here. | Okay. | I think we get it.

- And of course there are lists.
  - Some are bulleted.
     - With different indentation levels.
        - That look like this.


1. And there are numbererd lists too.
1. Use just 1s if you want! 

* And last but not least, let's not forget embedded images:

![React Logo w/ Text](https://goo.gl/Umyytc)
`
              
            
!
999px

Console