Markdown Script - mdscript.py
What is it?
Markdown is a
simplified syntax that can be compiled into true XHTML-compliant
markup. This script will take a Markdown text file, process it using
markdown.pl, then finally add a title and the appropriate DOCTYPE
tags so that the W3
Validator will report valid XHTML code.
The current version is 0.1.4.
Please note: I very rarely update this. Updating only happens when I think of a feature that would be useful to me. As such, the code is also relatively messy. It does what I want; nothing more, nothing less.
Changelog
0.1.4:
- Headers and footers are now pure html (i.e., no processing by Markdown occurs). Header and footer filenames (header.txt and footer.txt, respectively) remain the same.
0.1.3:
- Support for headers and footers to be added to each page. If header.txt (footer.txt) doesn't exist, mdscript.py doesn't add a header (footer). The --noheader (--no-footer) option is given, headers (footers) are ignored even if the files exist.
0.1.2:
- Options added for background color, text color, link color, and visited link color. Modifications made by John R. Dowdle.
0.1.1:
- Automatically appends date last modified unless the '-d' option is specified.
0.1.0:
- First version. Nothing special, but it gets the job done.
Usage
mdscript.py is very easy to use. Say you have a Markdown file called
index.txt. If you want the title of the resultant html file to be
"My Homepage," you would type this:
python mdscript.py -t"My Homepage" index.txt
That's it! mdscript.py will produce the appropriate html file and
save it as index.html (in the above example). If index.html
already exists, you don't even need to use the -t option if you're
fine with the existing title:
python mdscript.py index.txt
This will take the existing index.html file and make sure that the
current title is preserved.
There are a couple of other options available; use python mdscript.py
-h to see them.
Download
Just grab mdscript.py. The only other thing you'll have to do is make sure that you have Python and the Markdown script.
Alternatively, a full tarball can be downloaded containing the script, changelog, and the textfile used to generate this page.
Note that I have only tested this on my own Linux machines, and have not made any efforts towards verifying that it works on other platforms.
Configuration and Caveats
It is worth noting that you should look at the script to change the few constants that you might need to. Ubuntu has Markdown in its repositories, and renames markdown.pl as markdown. If you prefer to keep the extension, you should correct the appropriate constant.
Another caveat: Some of this script was done a little sloppy. For example, you currently have to use the .html extension.
Basically, it comes down to the fact that I primarily made this script for myself and for my own purposes. It does exactly what I want it to, and thus most of the things that probably should have command line options don't since I have no use for them. However, if there is ever a large clamor for particular features, I would be more than happy to add them.
Feedback
If you find this useful, or have any comments, requests, or complaints, feel free to let me know.
License
This is free software. You may redistribute it under the terms of the GNU GPL.

