15 Markdown is a text-to-HTML conversion tool for web writers. Markdown
16 allows you to write using an easy-to-read, easy-to-write plain text
17 format, then convert it to structurally valid XHTML (or HTML).
19 Thus, "Markdown" is two things: a plain text markup syntax, and a
20 software tool, written in Perl, that converts the plain text markup
23 Markdown works both as a Movable Type plug-in and as a standalone Perl
24 script -- which means it can also be used as a text filter in BBEdit
25 (or any other application that supporst filters written in Perl).
27 Full documentation of Markdown's syntax and configuration options is
28 available in the `basics.md` and `syntax.md` files.
29 (Note: this readme file and the basics and syntax files are formatted
33 -----------------------------
34 Installation and Requirements
35 -----------------------------
37 Markdown requires Perl 5.8.0 or later. Welcome to the 21st Century.
38 Markdown also requires the standard Perl library module `Digest::MD5`.
40 As of version 1.1.1, Markdown auto-detects the character set of the
41 input (US-ASCII, ISO-8859-1 and UTF-8 are supported) and always
42 converts the input to UTF-8 when writing the output.
48 Markdown works with Movable Type version 2.6 or later (including
51 1. Copy the "Markdown.pl" file into your Movable Type "plugins"
52 directory. The "plugins" directory should be in the same directory
53 as "mt.cgi"; if the "plugins" directory doesn't already exist, use
54 your FTP program to create it. Your installation should look like
57 (mt home)/plugins/Markdown.pl
59 2. Once installed, Markdown will appear as an option in Movable Type's
60 Text Formatting pop-up menu. This is selectable on a per-post basis.
61 Markdown translates your posts to HTML when you publish; the posts
62 themselves are stored in your MT database in Markdown format.
64 3. If you also install SmartyPants 1.5 (or later), Markdown will offer
65 a second text formatting option: "Markdown with SmartyPants". This
66 option is the same as the regular "Markdown" formatter, except that
67 automatically uses SmartyPants to create typographically correct
68 curly quotes, em-dashes, and ellipses. See the SmartyPants web page
69 for more information: <https://daringfireball.net/projects/smartypants/>
71 4. To make Markdown (or "Markdown with SmartyPants") your default
72 text formatting option for new posts, go to Weblog Config ->
75 Note that by default, Markdown produces XHTML output. To configure
76 Markdown to produce HTML 4 output, see "Configuration", below.
82 Markdown works with Blosxom version 2.x.
84 1. Rename the "Markdown.pl" plug-in to "Markdown" (case is
85 important). Movable Type requires plug-ins to have a ".pl"
86 extension; Blosxom forbids it.
88 2. Copy the "Markdown" plug-in file to your Blosxom plug-ins folder.
89 If you're not sure where your Blosxom plug-ins folder is, see the
90 Blosxom documentation for information.
92 3. That's it. The entries in your weblog will now automatically be
93 processed by Markdown.
95 4. If you'd like to apply Markdown formatting only to certain posts,
96 rather than all of them, see Jason Clark's instructions for using
97 Markdown in conjunction with Blosxom's Meta plugin:
99 <https://jclark.org/weblog/WebDev/Blosxom/Markdown.html>
105 Markdown works with BBEdit 6.1 or later on Mac OS X. (It also works
106 with BBEdit 5.1 or later and MacPerl 5.6.1 on Mac OS 8.6 or later.)
108 1. Copy the "Markdown.pl" file to appropriate filters folder in your
109 "BBEdit Support" folder. On Mac OS X, this should be:
111 BBEdit Support/Unix Support/Unix Filters/
113 See the BBEdit documentation for more details on the location of
116 You can rename "Markdown.pl" to whatever you wish.
118 2. That's it. To use Markdown, select some text in a BBEdit document,
119 then choose Markdown from the Filters sub-menu in the "#!" menu, or
120 the Filters floating palette
127 By default, Markdown produces XHTML output for tags with empty elements.
132 Markdown can be configured to produce HTML-style tags; e.g.:
140 You need to use a special `MTMarkdownOptions` container tag in each
141 Movable Type template where you want HTML 4-style output:
143 <MTMarkdownOptions output='html4'>
144 ... put your entry content here ...
147 The easiest way to use MTMarkdownOptions is probably to put the
148 opening tag right after your `<body>` tag, and the closing tag right
151 To suppress Markdown processing in a particular template, i.e. to
152 publish the raw Markdown-formatted text without translation into
153 (X)HTML, set the `output` attribute to 'raw':
155 <MTMarkdownOptions output='raw'>
156 ... put your entry content here ...
163 Use the `--html4tags` command-line switch to produce HTML output from a
164 Unix-style command line. E.g.:
166 $ perl Markdown.pl --html4tags foo.txt
168 Type `perldoc Markdown.pl`, or read the POD documentation within the
169 Markdown.pl source code for more information.
175 If w3m is available, a Markdown-formatted text file can be viewed like so
176 (change `README` to the actual name of the Markdown-formatted file to view):
178 $ perl Markdown.pl --stub README | w3m -T text/html
185 1.1.15 (15 Aug 2021):
187 + allow '/' in auto-quoted attribute values
189 + add new --us-ascii option for 7-bit output
192 1.1.14 (14 Jun 2021):
194 + do not start sublist in list marker line
197 1.1.13 (13 Jun 2021):
199 + adjust strip-comments options and defaults
201 + allow backticks-delimited code blocks in lists
203 + support `\` EOL to generate a `<br />`
205 + do not mistake table for code block
208 1.1.12 (17 Mar 2021):
210 + allow some overlooked table attributes
212 + do not choke on \n inside attribute values
214 + better sanitization of href and src attributes
216 + add more comment stripping options
218 + clean up closing tag whitespace
220 + do not choke on `<br></br>` etc.
222 + add limited tilde-delimited code block support
224 + allow target="_blank" rel="nofollow"
226 + add missing space to implied attributes
229 1.1.11 (05 Mar 2021):
231 + new --strip-comments option
233 + new --keep-abs option
235 + new --raw-xml and --raw-html options
237 + new --auto-number option for headers
239 + new --div option to wrap output in `<div>...</div>`
241 + convert named character entities to numeric by default
243 + add XML comments section to syntax.md
245 + detail API and ability to "use" Markdown module
247 + support floating images and `<br clear=all>`
249 + recognize wiki style image links
251 + YAML front matter support
253 + make -i/-r work on top-level raw html blocks
255 + avoid accidentally creating nested `<a>` elements
257 + ignore junk on end of backticks-delimited code block start line
259 + strip markup out of implicit anchors
262 1.1.10 (08 Jul 2020):
264 + enhance --wiki "s" option operation
266 + support new --absroot=prefix option
268 + document ability to split link references
270 + hook up fragment only link definitions
272 + remove markup from <title> value
274 + update links to https where possible
279 + improve bare fragment URL link handling and add fragment `--base` option
281 + match block tags case-insensitively and relax `<hr>` matching rules
286 + correct a number of issues with improperly nested markup involving
287 links, blockquotes, strong and emphasis etc.
289 + parse nested `[`...`]` and `(`...`)` properly when inside links
291 + avoid getting confused by nested lists
293 + allow first blockquote line to be empty
295 + as-documented single-quote titles in link definitions now work
297 + when escaping a single-quote use `'` instead of `'`
299 + ignore control characters in input (other than whitespace)
301 + wiki links can be processed by providing a new `--wiki` option
303 + an empty table header row is omitted from the output
305 + table rows can be joined with a trailing `\` (see syntax.md)
307 + add several new XML validation options
309 + perform XML validation and tag sanitation by default (see help)
311 + tab expansion in shifted backticks-delimited code blocks has
312 been adjusted to better match expected behavior
314 + all atx-style header levels now get anchors not just levels 1-3
316 + internal document "fragment" links `[...](#section)` hook up to
317 the target section much more reliably now
319 + backticks-delimited code blocks can now specify a syntax language
320 name that ends with a `#` character
322 + more lists that were not being recognized before because they did
323 not have a preceding blank line are now recognized
328 + _PrefixURL more intelligently
333 + be more flexible parsing backticks-delimited code blocks
335 + improve XML comment parsing
337 + correct .svg extension matching rule
339 + apply -i and -r options to a and img tags
346 + make sure all alt= and title= text is escaped
351 + disallow <dir> and <menu> without --deprecated
356 + auto escape '<' of non-tags
358 + do not overlook sibling list items
363 + usually (i), (v) and (x) are roman
365 + retain square brackets around footnotes
367 + treat '*' in `<ol>` like last marker
369 + normalize link white space
371 + do not mishandle double list markers redux
373 + recognize two ```-delimited blocks in a row
375 + allow trailing '[]' to be omitted
377 + tweak code block output again
382 + support lower-greek ol lists
384 + auto-detect latin-1/utf-8 input always output utf-8
385 The minimum version of Perl required is now 5.8.0.
390 + handle some limited [[wiki style links]]
392 + add --stub, --stylesheet and --tabwidth options
394 + support more list markers
396 + format fancy checkboxes
398 + add anchors and definitions for headers
400 + do not mishandle double list markers
402 + handle non-backticks-delimited code blocks properly
404 + recognize top-level lists better
406 + output deterministic documents
408 + auto linkify without '<'...'>'
413 + Markdown.pl can now be require'd and the Markdown function called
414 repeatedly by external code.
416 + Backticks (```) delimited code blocks are now handled better and are
417 no longer subject to any further accidental processing.
422 + Added support for --htmlroot option to set a URL prefix.
424 + Relaxed matching rule for non-indented code blocks.
426 + Added support for --imageroot option to set an img URL prefix.
431 + Added support for -h and --help to display Markdown.pl help.
433 + Added support for third-level headers using setext-like
434 underlining using tildes (`~`'s).
436 + Added support for an optional overline using the same character
437 as the underline when using setext-style headers.
439 + Stopped recognizing `_` within words. The `*` character is still
440 recognized within words.
442 + Added support for strike through text using `~~` similarly to the
443 way strong works using `**`.
445 + Added support for non-indended code blocks by preceding and following
446 them with a line consisting of 3 backtick quotes (`` ` ``) or more.
451 + Changed the syntax rules for code blocks and spans. Previously,
452 backslash escapes for special Markdown characters were processed
453 everywhere other than within inline HTML tags. Now, the contents
454 of code blocks and spans are no longer processed for backslash
455 escapes. This means that code blocks and spans are now treated
456 literally, with no special rules to worry about regarding
459 **NOTE**: This changes the syntax from all previous versions of
460 Markdown. Code blocks and spans involving backslash characters
461 will now generate different output than before.
463 + Tweaked the rules for link definitions so that they must occur
464 within three spaces of the left margin. Thus if you indent a link
465 definition by four spaces or a tab, it will now be a code block.
467 [a]: /url/ "Indented 3 spaces, this is a link def"
469 [b]: /url/ "Indented 4 spaces, this is a code block"
471 **IMPORTANT**: This may affect existing Markdown content if it
472 contains link definitions indented by 4 or more spaces.
474 + Added `>`, `+`, and `-` to the list of backslash-escapable
475 characters. These should have been done when these characters
476 were added as unordered list item markers.
478 + Trailing spaces and tabs following HTML comments and `<hr/>` tags
481 + Inline links using `<` and `>` URL delimiters weren't working:
483 like [this](<http://example.com/>)
485 + Added a bit of tolerance for trailing spaces and tabs after
488 + Fixed bug where auto-links were being processed within code spans:
490 like this: `<http://example.com/>`
492 + Sort-of fixed a bug where lines in the middle of hard-wrapped
493 paragraphs, which lines look like the start of a list item,
494 would accidentally trigger the creation of a list. E.g. a
495 paragraph that looked like this:
497 I recommend upgrading to version
498 8. Oops, now this line is treated
501 This is fixed for top-level lists, but it can still happen for
502 sub-lists. E.g., the following list item will not be parsed
505 + I recommend upgrading to version
506 8. Oops, now this line is treated
509 Given Markdown's list-creation rules, I'm not sure this can
512 + Standalone HTML comments are now handled; previously, they'd get
513 wrapped in a spurious `<p>` tag.
515 + Fix for horizontal rules preceded by 2 or 3 spaces.
517 + `<hr>` HTML tags in must occur within three spaces of left
518 margin. (With 4 spaces or a tab, they should be code blocks, but
519 weren't before this fix.)
521 + Capitalized "With" in "Markdown With SmartyPants" for
522 consistency with the same string label in SmartyPants.pl.
523 (This fix is specific to the MT plug-in interface.)
525 + Auto-linked email address can now optionally contain
526 a 'mailto:' protocol. I.e. these are equivalent:
528 <mailto:user@example.com>
531 + Fixed annoying bug where nested lists would wind up with
532 spurious (and invalid) `<p>` tags.
534 + You can now write empty links:
538 and they'll be turned into anchor tags with empty href attributes.
539 This should have worked before, but didn't.
541 + `***this***` and `___this___` are now turned into
543 <strong><em>this</em></strong>
547 <strong><em>this</strong></em>
549 which isn't valid. (Thanks to Michel Fortin for the fix.)
551 + Added a new substitution in `_EncodeCode()`: `s/\$/$/g`;
552 this is only for the benefit of Blosxom users, because Blosxom
553 (sometimes?) interpolates Perl scalars in your article bodies.
555 + Fixed problem for links defined with urls that include parens, e.g.:
557 [1]: https://sources.wikipedia.org/wiki/Middle_East_Policy_(Chomsky)
559 "Chomsky" was being erroneously treated as the URL's title.
561 + At some point during 1.0's beta cycle, I changed every sub's
562 argument fetching from this idiom:
568 my $text = shift || return '';
570 The idea was to keep Markdown from doing any work in a sub
571 if the input was empty. This introduced a bug, though:
572 if the input to any function was the single-character string
573 "0", it would also evaluate as false and return immediately.
574 How silly. Now fixed.
577 ---------------------
578 Copyright and License
579 ---------------------
581 Copyright (C) 2003-2004 John Gruber
582 Copyright (C) 2015-2021 Kyle J. McKay
585 Redistribution and use in source and binary forms, with or without
586 modification, are permitted provided that the following conditions are
589 * Redistributions of source code must retain the above copyright notice,
590 this list of conditions and the following disclaimer.
592 * Redistributions in binary form must reproduce the above copyright
593 notice, this list of conditions and the following disclaimer in the
594 documentation and/or other materials provided with the distribution.
596 * Neither the name "Markdown" nor the names of its contributors may
597 be used to endorse or promote products derived from this software
598 without specific prior written permission.
600 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
601 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
602 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
603 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
604 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
605 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
606 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
607 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
608 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
609 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
610 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.