Skip to content

Commit

Permalink
Merge e234d9e into 18fb67b
Browse files Browse the repository at this point in the history
  • Loading branch information
mgedmin committed Dec 5, 2014
2 parents 18fb67b + e234d9e commit 5b5864c
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions mgp2pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,6 @@ def __init__(self, file=None, title=None, unsafe=False):
self.tabDirectives = {}
self.fonts = Fonts()
self.slides = []
self._directives_used_in_this_line = set()
self.title = title
self.unsafe = unsafe
self.basedir = ''
Expand Down Expand Up @@ -776,7 +775,6 @@ def _handleDirective(self, directive):
log.debug("Ignoring empty directive on line {0}".format(self.lineno))
return
word = parts[0]
self._directives_used_in_this_line.add(word)
handler = getattr(self, '_handleDirective_%s' % word,
self._handleUnknownDirective)
handler(parts)
Expand All @@ -798,7 +796,7 @@ def _handleDirective_page(self, parts):
self._lastlineno = 0
self._use_defaults = True
self._continuing = False
self._directives_used_in_this_line = set()
self._alignment_overridden = False
self.mark = None

def _handleDirective_nodefault(self, parts):
Expand Down Expand Up @@ -828,7 +826,7 @@ def _handleDirective_font(self, parts):
def _handleDirective_prefix(self, parts):
"""Handle %prefix <prefix>.
Specifies left indentation (in percent of the slide area size) or a
Specifies indentation (in percent of the slide area size) or a
string to be prepended to each line of text.
"""
prefix, = self._parseArgs(parts, "S")
Expand Down Expand Up @@ -864,26 +862,23 @@ def _handleDirective_left(self, parts):
Specifies left-adjustment.
"""
self.slides[-1].setAlignment(Left)
self._directives_used_in_this_line.add('right')
self._directives_used_in_this_line.add('center')
self._alignment_overridden = True

def _handleDirective_right(self, parts):
"""Handle %right.
Specifies right-adjustment.
"""
self.slides[-1].setAlignment(Right)
self._directives_used_in_this_line.add('left')
self._directives_used_in_this_line.add('center')
self._alignment_overridden = True

def _handleDirective_center(self, parts):
"""Handle %center.
Specifies center-adjustment.
"""
self.slides[-1].setAlignment(Center)
self._directives_used_in_this_line.add('left')
self._directives_used_in_this_line.add('right')
self._alignment_overridden = True

def _handleDirective_cont(self, parts):
"""Handle %cont.
Expand Down Expand Up @@ -1027,12 +1022,13 @@ def _handleText(self, line):
if self._use_defaults:
for part in self.defaultDirectives.get(self._lastlineno, []):
word = self._splitArgs(part)[0]
if word not in self._directives_used_in_this_line:
self._handleDirective(part)
if self._alignment_overridden and word in ('left', 'center', 'right'):
continue
self._handleDirective(part)
line = line.rstrip('\n').replace(r'\#', '#').replace(r'\\', '\\')
self.slides[-1].addText(line)
self._continuing = False
self._directives_used_in_this_line = set()
self._alignment_overridden = False

def __str__(self):
"""Represent the contents of the presentation as text."""
Expand Down

0 comments on commit 5b5864c

Please sign in to comment.