aaren / notedown

Markdown <=> IPython Notebook
BSD 2-Clause "Simplified" License
855 stars 115 forks source link

Support for multi paragraph itemize / crash with --match=strict #67

Open nthiery opened 6 years ago

nthiery commented 6 years ago

With the following example, the second paragraph "Contrairement ..." gets interpreted by notedown as a code block instead of a second paragraph of the first item:

1.  Donner un exemple de drapeau infini décroissant; c'est-à-dire une suite infinie ... de sous-modules strictement emboîtés.

    Contrairement aux espaces vectoriels, deux sous-modules emboîtés de même dimension ne sont pas forcément égaux.

2.  Existe-t'il des drapeaux croissants infinis?

Since all my code blocks are fenced, I tried to work around this issue using match=strict, but this led to a crash:

mistral-/tmp>notedown --match=strict algebre_lineaire_anneaux.md >! algebre_lineaire_anneaux.ipynb
Traceback (most recent call last):
  File "/opt/miniconda3/lib/python3.6/site-packages/nbformat/validator.py", line 256, in validate
    return validator.validate(nbjson, {'$ref' : '#/definitions/%s' % ref})
  File "/opt/miniconda3/lib/python3.6/site-packages/jsonschema/validators.py", line 130, in validate
    raise error
jsonschema.exceptions.ValidationError: None is not valid under any of the given schemas

Failed validating 'oneOf' in schema['properties']['source']:
    {'oneOf': [{'type': 'string'},
               {'items': {'type': 'string'}, 'type': 'array'}]}

On instance['source']:
    None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/miniconda3/bin/notedown", line 11, in <module>
    sys.exit(app())
  File "/opt/miniconda3/lib/python3.6/site-packages/notedown/main.py", line 312, in app
    main(args, help=parser.format_help())
  File "/opt/miniconda3/lib/python3.6/site-packages/notedown/main.py", line 275, in main
    notebook = reader.read(ip, as_version=4)
  File "/opt/miniconda3/lib/python3.6/site-packages/nbformat/v4/rwbase.py", line 114, in read
    return self.reads(nbs, **kwargs)
  File "/opt/miniconda3/lib/python3.6/site-packages/notedown/notedown.py", line 376, in reads
    return self.to_notebook(s, **kwargs)
  File "/opt/miniconda3/lib/python3.6/site-packages/notedown/notedown.py", line 368, in to_notebook
    cells = self.create_cells(blocks)
  File "/opt/miniconda3/lib/python3.6/site-packages/notedown/notedown.py", line 347, in create_cells
    markdown_cell = self.create_markdown_cell(block)
  File "/opt/miniconda3/lib/python3.6/site-packages/notedown/notedown.py", line 323, in create_markdown_cell
    markdown_cell = nbbase.new_markdown_cell(**kwargs)
  File "/opt/miniconda3/lib/python3.6/site-packages/nbformat/v4/nbbase.py", line 112, in new_markdown_cell
    validate(cell, 'markdown_cell')
  File "/opt/miniconda3/lib/python3.6/site-packages/nbformat/v4/nbbase.py", line 23, in validate
    return validate(node, ref=ref, version=nbformat)
  File "/opt/miniconda3/lib/python3.6/site-packages/nbformat/validator.py", line 260, in validate
    raise better_validation_error(e, version, version_minor)
nbformat.validator.NotebookValidationError: None is not valid under any of the given schemas

Failed validating 'oneOf' in notebook['properties']['source']:

On instance['source']:
None

Thanks!