Tests for HR insertion
Font lock fix for small Setext headers
Avoid modified buffer queries during testing
Kill temporary buffers created during export tests
Improve multi-line font lock at beginning of buffer
Generalize point position calculations after removing markup

New function markdown-point-after-unwrap with tests.
Generalized functions for wrapping, unwrapping, and positioning

Rewrite insertion functions for italics, bold, and code so that they
use the new functions markdown-point-after-unwrap,
markdown-unwrap-thing-at-point, and
markdown-unwrap-things-in-region.

These commands will now wrap the region, if there is an active region.
In this case, they will remove existing markup of the same kind from
the region (since one can't have double italics, for instance).

If there is no active region, but the point is at a word, the markup
will be toggled (removed if it exists, or else added).

Otherwise, empty markup of the specified type will be inserted.

Includes unit tests for markdown-unwrap-things-in-region
and markdown-unwrap-thing-at-point.
New function markdown-bounds-of-thing-at-point

Factor out newline handling in markdown-wrap-or-insert, to be
used elsewhere.
Improve markdown-point-after-unwrap behavior
Allow skipping match step in markdown-unwrap-thing-at-point

For efficiency, when match data is already set, pass nil regexp.
Test cases for toggling bold, italics, and code
Unify header insertion functions

Header insertion is now handled by one function:
markdown-insert-header.  It handles interactive and noninteractive
calls as well as atx and setext headers.  It obtains the header text
by first looking for an active region, then looking for a non-blank
line, then either prompting the user (setext) or inserting empty
markup with the cursor in position to enter text (atx).

Also introduced in this commit is a new header removal function:
markdown-remove-header.  It removes both setext and atx headers
and is used by markdown-insert-header to allow replacing one
header level or type with another.  The key sequence C-c C-t 0
is now bound to this function.

Functions of the form markdown-insert-header-n were renamed to
markdown-insert-header-atx-n.  The functions markdown-insert-title and
markdown-insert-section have been renamed to
markdown-insert-header-setext-1 and markdown-insert-header-setext-2.

Finally, a new function markdown-compress-whitespace-string has been
added for removing leading and trailing whitespace from strings and
"compressing" multiple whitespace characters, replacing them by a
single space.  The header insertion function now uses this to process
header text to remove extraneous whitespace.
Font lock fix for preformatted text following list items

markdown-new-baseline-p now returns t when the current line
has zero indentation, is not a list item, and the previous
line is blank (starting a new block at baseline).  This fixes
a problem in determining the list level in the functionmarkdown-match-pre-blocks
List item bounds should always be nil outside of lists

Fix logic of markdown-cur-list-item-bounds to avoid evaluating
markdown-cur-list-item-end with a nil value for nonlist-indent.

Includes a new unit test.
Don't check mark-active when explicitly working on region

We should only be calling markdown-block-region noninteractively,
with specified bounds, so there is no need to check mark-active.

Includes unit tests for markdown-pre-region and
markdown-blockquote-region when called interactively and
noninteractively.
Factor out list level calculations

New function: markdown-calculate-list-levels
Pass over pre blocks when calculating list levels

Previously, markdown-calculate-list-levels and
markdown-update-list-levels were only called from
markdown-match-pre-blocks, so it they did not need to be aware of
lines that matched markdown-regex-list that reside inside pre blocks.
This patch makes them pass over such lines, so that these functions
may be called at an arbitrary point in the buffer to establish the
level and indentation of nested list items.

Includes two unit tests.

Note that these functions currently strictly enforce the four space
rule for nested lists.  Nested item list markers must be positioned
exactly four spaces from the list marker for the parent item, no more
or no less.  This is "safe" for most all Markdown processors, whereas
there is much variation in behavior for other types of spacing.  This
is important because in order for a block to be recognized as a pre
block within a nested list by markdown-mode, it must be indented four
additional spaces for each list level.  For example, in a second-level
list item, a pre block needs to be indented 4 + 2*4 = 12 spaces.
Smart pre block insertion in lists

Insert a sufficient number of spaces to make a pre block
in lists and nested lists (e.g., eight spaces in a toplevel
list item).

New function: markdown-pre-indentation.

Includes two unit tests.