Optimized the concatenation of Twee story fragments

The main thing is to avoid adding to a string repeatedly, since this
requires an increasing number of bytes to be copied again and again
as the string grows. Instead, pass a generator to join().
Commit 3914ac50 does something similar for HTML fragments.

Added "order" argument to docstring.

Changed the "not order" check to "order is None": if the user passes
an empty sequence for "order", the correct output is the empty string.
Add "untwee" command line tool

This is similar to the old Twee "untwee" tool: it reads a story
in HTML format and outputs in Twee format.

The code is derived from the "twee" script though rather than from
the original "untwee" script.
untwee: Order passages in output

Split the story passages from the info passages and put the story
passages at the end.

Within those two categories nothing clever is done yet, so for now
I just sort the passages by name alphabetically; that's at least
more helpful to human readers than using Python's hash order.
untwee: Try to put info passages in a meaningful order

The special passages are in the order that SugarCane/Cube display them
in the side bar. Annotations were put last since they could be related
to either the info passages or the story passages, so having them on
the boundary between info passages and story passages made sense.
untwee: Added passage reorder command line option

This controls whether the output passage order is equal to the HTML
order (order preserved) or whether untwee should compute a passage
order (reorder).

The default is to autodetect whether the passage order in the HTML
is likely to be meaningful. Currently this happens by determining
which compiler created the HTML: iff the compiler preserves the
input passage order, untwee will preserve the order as well.
Fixed <style> elements in passages

Previously, <style> and <script> elements' contents would be converted
to charspans. This should no longer be the case.
Put code to determine default passage text in a method by itself

This avoids duplication and simplifies the createInfoPassage() method.
Make StorySettingsFrame and ImageFrame inherit directly from wx.Frame

Previously, they inherited from PassageFrame, but they didn't call the
constructor of PassageFrame and don't seem to be using any of its
methods either.
Remove latest test build in window close handler instead of destructor

It is hard to predict when destructors run, or even if they run at all:
the documentation states "It is not guaranteed that __del__() methods
are called for objects that still exist when the interpreter exits."
  http://docs.python.org/2/reference/datamodel.html
So it is more reliable to do cleanup actions on window close.

Note that the original code failed to call the superclass destructor.
Fix missing import in Replace Across Story
Fixed a few unterminated RTF control words

In an RTF control word that ends with a digit, a following space is
considered part of the control word. So to make sure spaces in the
following text are not swallowed by the control word, a space should
be output after the digit.

Reported in point 3 of this post:
  http://twinery.org/forum/index.php/topic,1503.0.html
Merge pull request #133 from mthuurne/various_cleanup

Various cleanups
Merge pull request #132 from mthuurne/untwee

Untwee
Enhanced Tweelexer and external passages.
* Populate externalPassages set using existing buildIncludes method.
* Lexer highlights link to found external passage as good.
* Remove found external passages from broken links list.
* Dont show broken link emblem if all internal and external passages
found.
Merge branch 'master' of https://github.com/webbedspace/twine
Conditional charspan generation

* Now, charspans are only generated if the story passages contain either
".char" or "[data-char", which should be enough to sniff for
charspan-selecting CSS. I didn't think charspan generation was all that
much of a performance hit, but OK.
* Reverted the <br> removal, on the basis that using only white-space:
pre-line messes with text copied from passages. Hrm.
* Added the "hidden" HTML attribute to the storeArea div.
Variables in image syntax + other fixes

* It should now be possible to supply variables to the image syntax, as
an image passage name - for instance [img[$pictureName]].
* Shorthand <<display>>: variable default was causing $vars provided as
arguments to mess up horridly.  This should fix this.
* Made a number of macro error messages a little better - displaying "$"
instead of "state.history[0].variables." when referring to the macro
invocation.
* StorySettings: fixed the Obfuscate checkbox using "on" instead of
"swap".
Added system for encoding functions applied when converting to HTML

At the moment only obfuscation is done with such function, but other
functions can be added in the future.
Simplified creation of HTML tag for a tiddler

Use join and interpolation instead of appending to a string. This is
faster and (in my opinion) clearer as well.

'self.pos' is always defined, no need to test for it.
'now' wasn't used at all.
Made position parsing more robust

Check that there are 2 coordinates.
If one of them is not an integer, ignore them instead of breaking.