Markdown processing tools, including mdmerge
Project description
MarkdownTools
MarkdownTools is a collection of command line utilities for processing Markdown text files. At the moment the collection includes only one utility: mdmerge. Over time additional utilities will be added to support Markdown workflows.
Note: if you are using Python 2, then you need the MarkdownTools2 package.
mdmerge
mdmerge is a command line utility that produces a single Markdown document by merging a set of Markdown documents. The merge can be accomplished by expanding include declarations found in the input files, by concatenating a list of files found in an index file, or both.
Wait, doesn’t Marked 2 already do that?
Brett Terpstra’s Marked 2 application is a GUI product that runs on OS X; it watches Markdown text and displays the formatted output; it has extensive support for multi-file Markdown documents. Marked is my tool of choice for viewing formatted Markdown. I use it whenever I’m creating or reviewing Markdown content on my OS X machine. The invaluable multi-file document support in Marked is what drove me to create mdmerge.
mdmerge brings multi-file Markdown document processing to the command line. It is useful in any automated scripting environment where Markdown is processed. For example, I use it in automated build scripts (e.g., using gmake or Grunt) to produce documentation for the software I’m building. It is cross-platform; you can pre-process the Markdown files on any common OS that has a recent version of Python.
What kinds of Markdown does it work with?
mdmerge has been tested with documents containing these Markdown syntax variants:
classic (John Gruber’s Markdown syntax)
MultiMarkdown (Fletcher Penny’s syntax, MultiMarkdown version 4)
GHF (GitHub Flavored Markdown)
How do files get included?
mdmerge accepts include declarations in these styles:
MultiMarkdown transclusions
LeanPub index files (also known as book files)
Includes can be nested; that is, a file can include another file that itself include other files, and so on. Index (or book) files are only processed as such when they are the primary input; they cannot be nested – files listed in the index file are treated as normal input files (including expanding include specifications found within).
Command Line Syntax
The command line looks like this:
mdmerge [options] [-o outputfile] inputfiles mdmerge [options] [-o outputfile] -
Options
- options
One or more of –book, –export-target, –ignore-transclusions, –just-raw, –leanpub, –version, –help, -h.
- --book
Treat STDIN as an index file (a “book” file).
- --export-target [html|latex|lyx|opml|rtf|odf]
Indicates the ultimate output target of the markdown processor, but primarily impacts wildcard substitution in Marked inclusion.
- --help
Help information
- -h
Help information
- --ignore-transclusions
Leave any MultiMarkdown transclusion specifications alone; do not include the specified file. Useful if you want to mix Marked/LeanPub includes and MultiMarkdown includes, but have MultiMarkdown handline the transclusions.
- --just-raw
Ignore all include specifications except for raw includes; useful for processing the output of the Markdown processor to pick up the raw file include specifications that should have passed through untouched.
- --leanpub
Indicates that any input file named book.txt should be treated as a LeanPub index file.
- --version
Gives the version information about the utility.
- -o outputfile
The filepath in which to store the merged text. If not specified, then STDOUT is used.
- --outfile outputfile
same as -o.
- inputfiles
A list of space separated input files that can be merged together. If multiple files are given, they are treated as if they were specified in a LeanPub index file.
- -
The input comes from STDIN.
Installation
Note: Requires Python 3.3 or later. For Python 2 environments use the MarkdownTools2 package.
Install with:
pip install MarkdownTools
This will create the command mdmerge. Use mdmerge --version and mdmerge --help to confirm the installation.
For developers
License and Copyright
MarkdownTools is licensed with the Mozilla Public License Version 2.0.
Copyright 2015 Dave Hein
Source code
The source for this project can be found on GitHub at:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file MarkdownTools-1.0.1.tar.gz
.
File metadata
- Download URL: MarkdownTools-1.0.1.tar.gz
- Upload date:
- Size: 29.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e058361ab789ba6672a0a558a830a5e6b5a5a72242a9df17b72c4d3c6e06757 |
|
MD5 | 9d3c0e6a62050718c2f8fec4b225de19 |
|
BLAKE2b-256 | 803f056bc7e7c0c8fbff92dd9c0a92eed40dd633f8a4698ba8aa5570829e940a |