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

Issue with nested block-quote md syntax #50

Closed
mmcky opened this issue Sep 21, 2020 · 5 comments
Closed

Issue with nested block-quote md syntax #50

mmcky opened this issue Sep 21, 2020 · 5 comments
Labels
bug Something isn't working

Comments

@mmcky
Copy link
Member

mmcky commented Sep 21, 2020

Describe the bug

The following markdown snippet causes jupytext conversion to fail with error (IndexError: list index out of range)

> `!conda install quantecon`

Is this an issue with nested literals?

It appears to be valid md using https://spec.commonmark.org/dingus/.

To Reproduce

Add snippet to any md document

run

jupytext doc.md --to ipynb

Expected behavior

successful transfer to ipynb

Environment

  • markdown_it_py = 0.5.4
@mmcky mmcky added the bug Something isn't working label Sep 21, 2020
@welcome
Copy link

welcome bot commented Sep 21, 2020

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

@choldgraf
Copy link
Member

does markdown-it-py parse that string properly as well? Does this error only pop up when used in conjunction with jupytext?

@chrisjsewell
Copy link
Member

I'll copy the traceback you added on slack:

  File "/Users/matthewmckay/anaconda3/envs/tomyst/lib/python3.8/site-packages/markdown_it/parser_block.py", line 58, in tokenize
    state.line = line = state.skipEmptyLines(line)
  File "/Users/matthewmckay/anaconda3/envs/tomyst/lib/python3.8/site-packages/markdown_it/rules_block/state_block.py", line 134, in skipEmptyLines
    if (self.bMarks[from_pos] + self.tShift[from_pos]) < self.eMarks[from_pos]:
IndexError: list index out of range

This is likely due to a porting issue in JS->Python whereby markdown-it works IMO a bit through luck rather than judgement in some places, in that JS does not raise an IndexError when retrieving an index larger than the length of the array but instead just returns undefined, and on top of that does not raise a TypeError when evaluating undefined against a number, e.g.

>> a = [1, 2, 3]
>> console.log(a[4])
undefined
>> console.log(a[4] > 1)
false

so the fix will be something along the lines of:

if from_pos < len(self.eMarks) and (self.bMarks[from_pos] + self.tShift[from_pos]) < self.eMarks[from_pos]:

@chrisjsewell
Copy link
Member

@mmcky I've created a PR just with the snippet you gave, but this passes: #51

Can you work out the minimal preceding/following text from your full file, which can recreate the IndexError?

(tip: if you recreate this PR, you can just run tox -- -k #50 to run the single test)

@mmcky
Copy link
Member Author

mmcky commented Sep 24, 2020

thanks @chrisjsewell -- that syntax was the only change in a revision build of the migration for lecture-python-programming through https://github.com/QuantEcon/sphinxcontrib-tomyst/pull/61/files.

I can't replicate this in a seperate test run so must have been an interaction with some other markup. I will close this PR for now and reopen if it crops up again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants