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

Optional int directive option incorrectly passed as empty string, not None #431

Closed
zakhenry opened this issue Sep 21, 2021 · 2 comments · Fixed by #452
Closed

Optional int directive option incorrectly passed as empty string, not None #431

zakhenry opened this issue Sep 21, 2021 · 2 comments · Fixed by #452
Labels
bug Something isn't working

Comments

@zakhenry
Copy link

Describe the problem

I want to use the automatic dedent feature of literalinclude:

```{literalInclude} path/to/my/file
---
linenos: true
lines: 19-36
lineno-match: true
dedent:
---
```

With the above I get the following error:

WARNING: Directive 'literalInclude': Invalid option value: (option: 'dedent'; value: )
invalid literal for int() with base 10: ''

---
linenos: true
lines: 19-36
lineno-match: true
dedent: 
---

In the Sphinx definition the test is using None to test the feature, see https://github.com/sphinx-doc/sphinx/pull/8684/files

however in MyST-Parser, it coerces a None value into a string:

https://github.com/executablebooks/MyST-Parser/blob/master/myst_parser/parse_directives.py#L149-L150

Link to your repository or website

No response

Steps to reproduce

  1. Using a Sphinx with MyST-Parser setup add the following code block
```{code-block} python
---
dedent: True
---
          print("Hello world")
```
  1. See the following error in the console
 WARNING: Directive 'code-block': Invalid option value: (option: 'dedent'; value: )
invalid literal for int() with base 10: ''

---
dedent: True
---
          print("Hello world")

The version of Python you're using

Python 3.9.7

Your operating system

macOS 11.6

Versions of your packages

Sphinx v4.2.0

Additional context

No response

@zakhenry zakhenry added the bug Something isn't working label Sep 21, 2021
@welcome
Copy link

welcome bot commented Sep 21, 2021

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! 🎉

@chrisjsewell
Copy link
Member

thanks, yeh thats a pain, I will try to have a think about what the best way to handle this is

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

Successfully merging a pull request may close this issue.

2 participants