A drop-in, zero-dependency Markdown parser designed specifically to run natively on the JScript 5.8 engine of Internet Explorer 6.
It preserves the standard marked API, so you can swap out modern marked in your legacy enterprise projects without changing your implementation logic!
Despite being constrained to ES3 JavaScript and overcoming IE6's regex bugs, this engine supports:
- Headers:
# H1to###### H6 - Emphasis:
bold,*italic*,~~strikethrough~~ - Lists: Unordered (
-,*,+) and Ordered (1.) - Links & Images:
[text](url)and - Blockquotes:
> To be, or not to be - Code: Inline
`code`and Fenced blocks (```) - Standard API: Drop-in compatibility with
marked.parseandmarked.setOptions.
- Include the single JavaScript file in your document:
<script type="text/javascript" src="marked-ie6.js"></script>- Use it exactly like the modern
markedlibrary:
// Method 1: Direct call
var html = marked('# Hello IE6');
// Method 2: .parse method
var html2 = marked.parse('Bold text');You can pass options locally per call, or globally using setOptions:
// Global options
marked.setOptions({
breaks: true, // Convert \n to <br>
sanitize: false // Escape HTML tags
});
var content = "Line 1\nLine 2";
document.getElementById('content').innerHTML = marked(content);
// Output: <p>Line 1<br>Line 2</p>
// Local options overrides global
var output = marked.parse("<h1>Stop!</h1>", { sanitize: true });
// Output: <p><h1>Stop!</h1></p>If you try to load the modern marked.js in IE6, it will crash immediately due to const, let, Arrow Functions, and lack of standard trim() or modern RegExp flags.
This script rewrites the Markdown parsing logic using a heavily optimized Cascading Regular Expression approach tailored for JScript 5.8 limits. Fenced code blocks are isolated prior to parsing to prevent syntax conflicts, ensuring decent performance without triggering IE6's "Slow Script" warning.
MIT