Skip to content

Commit

Permalink
Simplified fail-safe #116
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Oct 29, 2018
1 parent 09c17f8 commit efc0360
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions jupytext/cell_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,17 +319,14 @@ def is_active(ext, metadata):
def double_percent_options_to_metadata(options):
"""Parse double percent options"""
matches = _PERCENT_CELL.findall('# %%' + options)
if matches == []: ## didn't match with options
matches = _PERCENT_CELL.findall('# %%')
## assume a code cell, with extra stuff
if matches == []: ## didn't match at all
return {}
else:
## Put rest of line in title metadata:
matches = list(matches[0])
matches[1] = options
else:
matches = matches[0]

# Fail safe when regexp matching fails #116
# (occurs e.g. if square brackets are found in the title)
if not matches:
return {'title': options.strip()}

matches = matches[0]

# Fifth match are JSON metadata
if matches[4]:
metadata = json_options_to_metadata(matches[4], add_brackets=False)
Expand Down

0 comments on commit efc0360

Please sign in to comment.