executablebooks / mistletoe-ebp

The EPB fork of mistletoe: A fast, extensible and spec-compliant Markdown parser in pure Python.
https://mistletoe-ebp.readthedocs.io
MIT License
4 stars 1 forks source link

Line not progressed after reading Link definition #13

Open chrisjsewell opened 4 years ago

chrisjsewell commented 4 years ago

@phaustin thanks for the feedback

I'm moving one of my courses from nbsphinx to myst-nb, and have hit an issue with a commented link causing myst to hang. Specifically, this line is ignored by nbsphinx, but causes the myst parser to go into an infinite loop printing the message:

"WARNING: /Users/phil/repos/MyST-NB/docs/examples/austin_issue/lab7/lab7.ipynb:2:1 {'cell_index': 28} ignoring duplicate link definition 'lab7:prob:staggered'"

Ok, firstly @choldgraf note how the warning gives the correct notebook cell and line number 😄 (this is currently only for the source -> Markdown AST phase, not the Markdown -> docutils AST phase).

Secondly, going by the warning message, the error actually lies here, not to where you linked to. Checking it with mistletoe (the markdown parser), it does replicate this error:

$ mistletoe
mistletoe [version 0.10.0] (interactive)
Type Ctrl-D to complete input, or Ctrl-C to exit.
>>> [lab7:prob:staggered]:(#Problem-One) 
... > Modify
:2:1 ignoring duplicate link definition 'lab7:prob:staggered'
...

The issue lies in the transition from link definition to quote block , somewhere around here: https://github.com/ExecutableBookProject/mistletoe-ebp/blob/d7247b52df3ff50dc71aef9ec3f8e7b316b03813/mistletoe/block_tokens.py#L821

This is only caused if there is no new line between the link definition and the quote, whereby the line number for some reason is not being progressed (so it reads the same line infinitely)

As a stop gap, if you add a blank line, there should be no problem:

[lab7:prob:staggered]:(#Problem-One)

> ...

Originally posted by @chrisjsewell in https://github.com/ExecutableBookProject/MyST-NB/pull/94

chrisjsewell commented 4 years ago

Actually its more acute than just a block quote.

It is the space after the link definition, i.e. if there is a space after b below (b), then this causes the issue:

[a]: b
c