diff --git a/patacrep/plastex_chord.py b/patacrep/plastex_chord.py index 5f901d22..2f6e48ed 100644 --- a/patacrep/plastex_chord.py +++ b/patacrep/plastex_chord.py @@ -128,13 +128,11 @@ class BeginChordOrDisplayMath(BeginDisplayMath): ) self.ownerDocument.context.pop() #pylint: disable=no-member - token = None - for token in tex: - end = True - if not match_space(token): - end = False - break - if end: + token = next(iter(tex), None) + if token is None: + return [chord] + elif match_space(token): + chord.appendChild(token) return [chord] elif ( isinstance(token, Verse)