Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

match argument handling #40

Closed
izahn opened this issue Mar 23, 2016 · 6 comments
Closed

match argument handling #40

izahn opened this issue Mar 23, 2016 · 6 comments
Assignees

Comments

@izahn
Copy link

izahn commented Mar 23, 2016

I'm having trouble setting the match argument to a specific language. For example

notedown --nomagic --match=stata StataIntro.md > StataIntro.ipynb
Traceback (most recent call last):
  File "/home/izahn/.local/bin/notedown", line 11, in <module>
    sys.exit(app())
  File "/home/izahn/.local/lib/python3.5/site-packages/notedown/main.py", line 312, in app
    main(args, help=parser.format_help())
  File "/home/izahn/.local/lib/python3.5/site-packages/notedown/main.py", line 275, in main
    notebook = reader.read(ip, as_version=4)
  File "/usr/lib/python3.5/site-packages/nbformat/v4/rwbase.py", line 89, in read
    return self.reads(nbs, **kwargs)
  File "/home/izahn/.local/lib/python3.5/site-packages/notedown/notedown.py", line 376, in reads
    return self.to_notebook(s, **kwargs)
  File "/home/izahn/.local/lib/python3.5/site-packages/notedown/notedown.py", line 368, in to_notebook
    cells = self.create_cells(blocks)
  File "/home/izahn/.local/lib/python3.5/site-packages/notedown/notedown.py", line 347, in create_cells
    markdown_cell = self.create_markdown_cell(block)
  File "/home/izahn/.local/lib/python3.5/site-packages/notedown/notedown.py", line 323, in create_markdown_cell
    markdown_cell = nbbase.new_markdown_cell(**kwargs)
  File "/usr/lib/python3.5/site-packages/nbformat/v4/nbbase.py", line 112, in new_markdown_cell
    validate(cell, 'markdown_cell')
  File "/usr/lib/python3.5/site-packages/nbformat/v4/nbbase.py", line 23, in validate
    return validate(node, ref=ref, version=nbformat)
  File "/usr/lib/python3.5/site-packages/nbformat/validator.py", line 156, in validate
    raise better_validation_error(e, version, version_minor)
  File "/usr/lib/python3.5/site-packages/nbformat/validator.py", line 152, in validate
    return validator.validate(nbjson, {'$ref' : '#/definitions/%s' % ref})
  File "/usr/lib/python3.5/site-packages/jsonschema/validators.py", line 123, 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

Any help will be appreciated.

@aaren
Copy link
Owner

aaren commented Mar 23, 2016

That's because I hard coded in a small set of languages and didn't fix the general case. Will make a fix. Your code blocks start with something like ```stata right?

@aaren aaren self-assigned this Mar 23, 2016
@izahn
Copy link
Author

izahn commented Mar 24, 2016

Yes, I have org-mode files converted to markdown via pandoc, which produces stata code blocks just as you describe. I also have a bunch ofexample blocks that should not be converted to inputs, hence my attempt to set match=stata.

Thanks for looking into it, let me know if there is anything I can help with.

@izahn
Copy link
Author

izahn commented Mar 24, 2016

As I noted in 7cb0f22 line 200 of notedown.py has print 'jazz', which breaks python 3. I corrected that in a local branch but I still get

notedown --nomagic --match=stata StataIntro.org 
Traceback (most recent call last):
  File "/home/izahn/.local/bin/notedown", line 9, in <module>
    load_entry_point('notedown==1.5.0', 'console_scripts', 'notedown')()
  File "/home/izahn/.local/lib/python3.5/site-packages/notedown/main.py", line 312, in app
    main(args, help=parser.format_help())
  File "/home/izahn/.local/lib/python3.5/site-packages/notedown/main.py", line 275, in main
    notebook = reader.read(ip, as_version=4)
  File "/usr/lib/python3.5/site-packages/nbformat/v4/rwbase.py", line 89, in read
    return self.reads(nbs, **kwargs)
  File "/home/izahn/.local/lib/python3.5/site-packages/notedown/notedown.py", line 380, in reads
    return self.to_notebook(s, **kwargs)
  File "/home/izahn/.local/lib/python3.5/site-packages/notedown/notedown.py", line 372, in to_notebook
    cells = self.create_cells(blocks)
  File "/home/izahn/.local/lib/python3.5/site-packages/notedown/notedown.py", line 351, in create_cells
    markdown_cell = self.create_markdown_cell(block)
  File "/home/izahn/.local/lib/python3.5/site-packages/notedown/notedown.py", line 327, in create_markdown_cell
    markdown_cell = nbbase.new_markdown_cell(**kwargs)
  File "/usr/lib/python3.5/site-packages/nbformat/v4/nbbase.py", line 112, in new_markdown_cell
    validate(cell, 'markdown_cell')
  File "/usr/lib/python3.5/site-packages/nbformat/v4/nbbase.py", line 23, in validate
    return validate(node, ref=ref, version=nbformat)
  File "/usr/lib/python3.5/site-packages/nbformat/validator.py", line 156, in validate
    raise better_validation_error(e, version, version_minor)
  File "/usr/lib/python3.5/site-packages/nbformat/validator.py", line 152, in validate
    return validator.validate(nbjson, {'$ref' : '#/definitions/%s' % ref})
  File "/usr/lib/python3.5/site-packages/jsonschema/validators.py", line 123, 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

@aaren
Copy link
Owner

aaren commented Mar 24, 2016

Can you provide a minimal example input that reproduces the error?

@izahn
Copy link
Author

izahn commented Mar 24, 2016

Oops, my mistake, I messed up the input file. It runs without errors now, thank you!

@izahn izahn closed this as completed Mar 24, 2016
@aaren
Copy link
Owner

aaren commented Mar 24, 2016

No problem.

The fix is merged to master now. I'll probably make a release soon but you can install from master in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants