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

              
                <main class="markdown-body">
  <script type="text/markdown">

    Stylish Markdown
    ----------------

    I love Markdown... I mean, who doesn't?  I use it for everything: wiki pages, release notes, API documentation, deployment guides, to do lists for my wife.  Ok maybe not that last one, I'm usually *the recipient* of the to do lists!

    When distributing documentation as part of a release, we tend to convert the Markdown into HTML with hyperlinks, logos, fonts and colour schemes; then use [wkhtmltopdf](https://wkhtmltopdf.org/) to convert it into a PDF.

    Recently I've been trialing a different approach - wrapping the Markdown inside a thin layer of HTML, then converting it into HTML on the fly using JavaScript.  The advantage is that the document remains *diff-able*, so the recipient can compare the current document with a previous version by using standard text-based differencing tools on the HTML source code (which is mainly Markdown).

    This approach is really useful for things like API specifications, were every small change needs to be carefully scrutinised. With PDF documents you usually only have a few short entries in a version table (if you're lucky).

  </script>
</main>
              
            
!

CSS

              
                
              
            
!

JS

              
                var converter = new showdown.Converter();
var elements = document.querySelectorAll("script[type='text/markdown']");

elements.forEach(function (element) {
  var markdown = unindent(element.innerHTML);
  var html = converter.makeHtml(markdown);

  var div = document.createElement('div');
  div.innerHTML = html;
  element.replaceWith(div);
});

function unindent(value) {
  var indent = value.match(/^( +)\S/m);
  if (indent) { 
    value = value.replace(new RegExp('^' + indent[1], 'gm'), '');
  }
  return value.trim();
}
              
            
!
999px

Console