MyST-Parser icon indicating copy to clipboard operation
MyST-Parser copied to clipboard

Incorrect "line 1, column 1" in an "Invalid options YAML: while parsing a block mapping" error

Open feorlen opened this issue 4 years ago • 2 comments

This is an informational maybe-bug, I was not able to reproduce it. One of my novice contributors ran into it but resolved it on their own. Perhaps this report will be helpful.

They received the following error, and there was legitimately something wrong with the directive. But it wasn't on "line 1, column 1" as the message stated. It was several lines into the document and indented.

WARNING: Directive 'image': Invalid options YAML: while parsing a block mapping
 in "<unicode string>", line 1, column 1:
  width: 650px
  ^

I was expecting it to say "line 10, column 4" or whatever.

The md file contained something approximately like this. (I was not able to inspect the broken file.) The problem line, or perhaps something nearby, may have contained unexpected whitespace (like a tab?)

## some heading

1. some list item

   '''{image} image.png
       :width: 650px
       :alt: image description
       '''

Environment:

MacOS, probably Catalina

requirements.txt:

sphinx==3.4.0
six>=1.10.0
sphinxcontrib.mermaid>=0.5.0
myst-parser==0.13.3
furo==2021.02.21.beta25
sphinx-copybutton>=0.3.1
sphinx-inline-tabs==2020.10.19b4

feorlen avatar May 22 '21 16:05 feorlen

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
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! :tada:

welcome[bot] avatar May 22 '21 16:05 welcome[bot]

Thanks for the feedback! Yeh that's a bit of a pain; the error message comes from the pyyaml package, and it is not possible to parse the line number "offset" to it. I guess the only potential solution would be to have it pass yaml with a number of blank lines added, so that the error line would line up with the line in the document

chrisjsewell avatar Sep 30 '21 22:09 chrisjsewell