This class is fairly similar to Section 10.4, “class Htmler: State machine for HTML
markup”: it is a small state machine for converting double-quote
characters to their paired form, and for interpreting underbar
characters as italic-start and italic-end characters.
The narrative for this class will be minimal, as it uses the
same mechanism as the Htmler class; only the
markup characters are different.
# - - - - - c l a s s T e x e r
class Texer(object):
'''State machine for TeX markup of English names.
Exports:
Texer():
[ return a new Texer instance, not in quotes or italics ]
.quotes:
[ if self is between quotes -> True
else -> False ]
.italics:
[ if self is between underbars -> True
else -> False ]
.convert(c):
[ if c is a double-quote ->
if self.quotes ->
self.quotes := False
return TEX_RQ
else ->
self.quotes := True
return TEX_LQ
else if c is an underbar ->
if self.italics ->
self.italics := False
return TEX_ITAL_END
else ->
self.italics := False
return TEX_ITAL_START
else -> return c ]
'''