Replies: 12 comments
-
Yes, I can reproduce. You are right, it sounds like admonition directives like https://docutils.sourceforge.io/docs/ref/rst/directives.html#admonitions It probably won't affect performance, if we can exclude it somehow from the standard directive formatting rules. |
Beta Was this translation helpful? Give feedback.
-
I've made a fix (madjxatw@c267fec) for this issue. If you think it's OK, i could send you a PR. |
Beta Was this translation helpful? Give feedback.
-
@madjxatw I had thought the issue was that admonition blocks needed to be highlighted as regular reST-formatted text.
I haven't yet read carefully what exactly an admonition block is, but I think what is wanted here is to "disable" the standard directive block highlighting and just handle the entire block as regular reST formatting when it is one of those specific admonition directives ( I could be misinterpreting how this ought to look, so let's continue the discussion. |
Beta Was this translation helpful? Give feedback.
-
Sorry, there was a mistake in my previous post. I was using @idnsunset's There is still the question whether all code blocks ought to be handled this way, or just admonition blocks, but it otherwise does look quite good at the moment. |
Beta Was this translation helpful? Give feedback.
-
An admonition block just groups a couple of paragraphs, and these paragraphs are usually styled differently from regular text in exported format, e.g., outlined, shaded, or an eye-catching background color used. All the text within an admonition block should keep their semantics and get highlighted properly. As I know, quite a few RST directives do not support directive content (body) so there is no problem with nested elements for them. For those that support directive content, most of them should be handled the same way as admonition blocks. The exceptions I could think of right now are Here are some simple examples. .. raw:: html
raw content Anything within a
.. line-block::
line1
line2 is equivalent to | line1
| line2 The line-block syntax implies that only inline markups are allowed, so any other directive blocks within a line block should not be highlighted. We could create two groups dedicated to Refer to https://docutils.sourceforge.io/docs/ref/rst/directives.html for more info |
Beta Was this translation helpful? Give feedback.
-
Sorry for the slow reply. I agree with your conclusion, that some sort of distinction ought to be made between directives with formatted bodies like admonitions ( It does seem that most directives containing a body expect the content to be formatted. Many do not expect a body, like These are the questions that come to mind:
I think you are suggesting that we treat all text inside of directives as reST-formatted, and define exceptions for the ones which do not, such as At some point, I'd like to go through them more carefully and see what each one does and doesn't expect. Your current patch also highlights the unformatted content of the block, which I think looks good, but perhaps this is not what people want? |
Beta Was this translation helpful? Give feedback.
-
Any example of a directive (except for For directives such as Additional directives introduced by Sphinx should be treated in the same way as RST directives. Some of them (e.g., |
Beta Was this translation helpful? Give feedback.
-
I think you are right, there are a very few directives which do not support unformatted text. I also agree that directives which do not support a body can be ignored for now. (We don't do much to indicate explicitly incorrect syntax at the moment.) Even As far as I can tell, these are the exceptions:
The rest are either reST formatted or do not support content. Additional directives supported by Sphinx (or otherwise) can be handled in a "Sphinx-mode", which we've discussed in some other issues. So your original assertion, that most blocks should be reST formatted, seems like a good one. Hopefully you don't mind me talking through it, I just wanted to establish that we wouldn't be breaking any assumptions about other directives, most of which I've never used or even looked at before! |
Beta Was this translation helpful? Give feedback.
-
The exceptions listed above do not seem to have been handled specially in the syntax file, most of them are matched against the generic I agree that the The .. table:: table example
+------------+--------------------+
| language | sample |
+============+====================+
| python | .. sourcecode:: py |
| | |
| | import sys |
+------------+--------------------+ The
I have no idea what base role would make the |
Beta Was this translation helpful? Give feedback.
-
@madjxatw I think your PR (madjxatw@c267fec) is an improvement. I've been using it for a while and have not yet seen any problems. Could you send it to the repository? It doesn't solve every case, such as @idnsunset 's table example, but it feels much closer to what we want. I am starting to think that |
Beta Was this translation helpful? Give feedback.
-
Ah one thing... The one problematic cases would seem to be math (which could potentially use all sorts of formatting tokens) and raw. Is there an easy way to exclude these? |
Beta Was this translation helpful? Give feedback.
-
(Yes, I accidentally commented on the wrong issue, repeating comment below) @madjxatw I've just applied your patch, which I should have done ages ago. Very sorry about that, sometimes I get too comfortable with the GitHub PR process. While the particular problem has been solved, I think the discussion here is a good one and still unresolved, so I'm going to turn on Discussion and move this over there. |
Beta Was this translation helpful? Give feedback.
-
Interpreted text enclosed in quotes and sphinx code-block are not highlighted when nested within an admonition block.
By the way, when placed in a table cell, the code-block is not highlighted either (interpreted text works). I am not sure whether it will introduce additional performance problem when matching code blocks in table.
Beta Was this translation helpful? Give feedback.
All reactions