Subject: code-block doesn't allow tab-expansion size specification
includeliteral directive provides the tab-width option, which code-block should ideally support as well.N/A
Every tab is expanded to an un-configurable 8 spaces
Ideally, I should be able to specify a tab expansion (or possibly no expansion?) length. My personal preference being '4' in most cases.
.. code-block:: json
{"I got indented too far"}
I think the expanding tabs inside directive is strongly related with parsing reST.
So I have to say it is hard to implement.
How about using tab_width in docutils.conf?
http://docutils.sourceforge.net/docs/user/config.html#tab-width
That looks like it would cover the situation that led me to make this issue, but I do maintain that the use case for setting tab-width on a per-code-block basis exists. For example, if formatting some code-blocks that contain HTML and some code-blocks that contain Javascript, it may be desirable to use 2-space indentation for HTML and 4-space indentation for Javascript (which, incidentally, is actually how my text editor is set up to expand tabs for those syntaxes). Since the tab-width option exists on includeliteral blocks, I would hazard a guess that the issue of when in the parsing process to introduce expansion of tabs in literal code has been addressed, at least somewhat.
Also, note that although sphinx documentation says it will use a docutils.conf in the configuration directory and Docutils reports that it supports the tab_width option in a parser section, placing the following file in the same directory as my conf.py (and naming it docutils.conf) doesn't appear to affect tab width:
[restructuredtext parser]
tab_width: 4
Sorry for late. I try to reproduce the problem. But, on my local, docutils.conf which you wrote above works fine to me with docutils-0.14 and Sphinx-2.1.0.
Since the tab-width option exists on includeliteral blocks, I would hazard a guess that the issue of when in the parsing process to introduce expansion of tabs in literal code has been addressed, at least somewhat.
They are different program. The .rst file is parsed by docutils, and each directives are processed by each directive implementation. Espacially includeliteral directive is implemented by Sphinx team.
So please use includeliteral for each program.
I'm closing this because not reproduced.
Please feel free to reopen if you're still in trouble.
It would be very helpful if you make a reproducible example.
Thanks,
So I think the problem is just with my outdated Sphinx version (v 1.8.5 b/c we build our project on ReadtheDocs). When I build locally with 2.1.2 it seems to be working.