Alex Pacini's Blog

[Home, All Posts, Tags, Feed, Disclaimer, Contact]

Markdown - StackEdit's HTML export template with highlighting by using Prettify or Highlight.js and personalized markDown.css

StackEdit is a Markdown Extra editor with MathJax (to display formulas using TeX Math syntax) and Prettify or highlight.js (for code highlighting) support. It is a wonderful option when it comes to publishing some HTML, even with a custom CSS!

Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).

If you are interested in more options to try, take a look at the article on Mashable.

The documentation, taken from the official GitHub project (an open-source project), says:

StackEdit
=========

StackEdit is a free, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites.

### StackEdit can:

 - Manage multiple Markdown documents online or offline
 - Export your documents in Markdown or HTML and format it using a template
 - Synchronize your Markdown documents in the Cloud
 - Edit existing Markdown documents from Google Drive, Dropbox and your local hard drive
 - Post your Markdown document on Blogger/Blogspot, WordPress, Tumblr
 - Publish your Markdown document on GitHub, Gist, Google Drive, Dropbox or any SSH server
 - Share a link to a Markdown document that renders it in a nice viewer
 - Show statistics about your document
 - Convert HTML to Markdown

### Features:

 - Real-time HTML preview with Scroll Link feature to bind editor and preview scrollbars
 - Markdown Extra support and Prettify/Highlight.js syntax highlighting
 - LaTeX mathematical expressions using MathJax
 - WYSIWYG control buttons
 - Configurable layout
 - Theming support with multiple themes available
 - A la carte extensions
 - Offline editing
 - Online synchronization using Google Drive and Dropbox
 - One click publish on Blogger, Dropbox, Gist, GitHub, Google Drive, SSH server, Tumblr, WordPress

The wonder comes when you can set a custom template:

> Settings > Publish > Template

This makes it possible to export valid HTML which includes the script to load MathJax, Prettify and a custom CSS by going to:

> Save as... > Save using template

My custom CSS is an extension of the beautiful Markdown.css. If you plan to use this modified style-sheet (the code is in markDown.css), it is better to download and host it by yourself, remembering to change the link in the template to your new location.

The Welcome Document of StackEdit will look like this (live preview on JS Bin).

What follows is my template for StackEdit (Gist):


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><%= documentTitle %></title>

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

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js?skin=desert"></script>

</head>
<body><%= documentHTML %></body>
</html>

The CSS I extended and used is available in markDown.css (Gist). Feel free to use it!