In python's case, the pygmentize command (CLI of pygments) recognizes
">>>" as a prompt and gives <span class="o"> style to it.

$ echo '>>> A prompt' | pygmentize -l python -f html
<div class="highlight"><pre><span></span><span
class="o">&gt;&gt;&gt;</span> <span class="n">A</span> <span
class="n">prompt</span>
</pre></div>

On the other hand, in bash's case, it can't recognizes "$" as a
prompt. So there is no special styles on the output.

$ echo '$ A prompt' | pygmentize -l bash -f html
<div class="highlight"><pre><span></span>$ A prompt
</pre></div>

So some contribution would be needed for pygments, I think.

Note: I used pygments-2.10.0

$ pygmentize -V
Pygments version 2.10.0, (c) 2006-2021 by Georg Brandl, Matthäus
Chajdas and contributors.

2021年9月15日(水) 0:03 Ron Stone <ronstone2...@gmail.com>:
>
> Thanks again. That sounds simple enough from a user perspective. With:
>
> .. code-block:: bash
>
>    $ A prompt?
>
> The '$' should be unelectable in the output, but this is pasted from the html:
>
> $ A prompt?
>
> I am using 4.2
>
> On Tuesday, September 14, 2021 at 10:54:56 AM UTC-4 i.tk...@gmail.com wrote:
>>
>> Ah, sorry. I had to describe that. We use highlighting library
>> pygments to detect prompts. It can parse the code-block and can
>> recognize the kind of each token.
>>
>> 2021年9月14日(火) 23:22 Ron Stone <ronsto...@gmail.com>:
>> >
>> > Thanks, but I am still missing something here. How does the system 
>> > distinguish between a prompt and non-prompt in a code block?
>> >
>> > 1. Is there a new mechanism to specify a prompt, similar to the 
>> > sphinx-prompts extension?
>> > 2. Is there some markup within the block to identify the prompt?
>> > 3. Are certain characters at the front of a line detected and treated as 
>> > prompts, such as '$' for bash?
>> >
>> > R.
>> >
>> > It would be useful to see a minimal working example of this.
>> >
>> > On Tuesday, September 14, 2021 at 9:48:51 AM UTC-4 i.tk...@gmail.com wrote:
>> >>
>> >> Hi,
>> >>
>> >> >Can someone please explain how this is configured and invoked?
>> >>
>> >> The latest Sphinx uses CSS to make prompts unselectable.
>> >> refs: https://developer.mozilla.org/en-US/docs/Web/CSS/user-select
>> >>
>> >> Thanks,
>> >> Takeshi KOMIYA
>> >>
>> >> 2021年9月14日(火) 18:42 Ron Stone <ronsto...@gmail.com>:
>> >> >
>> >> > Hi,
>> >> >
>> >> > I originally posted this to sphinx-dev but now believe it belongs here. 
>> >> > Apologies for cross-posting.
>> >> >
>> >> > I am using Sphinx 4.2. I see this merge re making prompts in code 
>> >> > blocks unelectable.
>> >> >
>> >> > https://github.com/sphinx-doc/sphinx/pull/9120
>> >> >
>> >> > I don't see any documentation of how this works here:
>> >> > https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html?highlight=code-block
>> >> >
>> >> > and building a typical code-block such as the following does not 
>> >> > demonstrate changed behaviour.
>> >> >
>> >> > .. code-block:: bash
>> >> >
>> >> > ls
>> >> >
>> >> > or
>> >> >
>> >> > .. code-block:: bash
>> >> >
>> >> > $ ls
>> >> >
>> >> > Can someone please explain how this is configured and invoked?
>> >> >
>> >> > Thanks.
>> >> >
>> >> > --
>> >> > You received this message because you are subscribed to the Google 
>> >> > Groups "sphinx-users" group.
>> >> > To unsubscribe from this group and stop receiving emails from it, send 
>> >> > an email to sphinx-users...@googlegroups.com.
>> >> > To view this discussion on the web visit 
>> >> > https://groups.google.com/d/msgid/sphinx-users/29b9917f-6e18-430a-9765-42553f74a687n%40googlegroups.com.
>> >
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "sphinx-users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send an 
>> > email to sphinx-users...@googlegroups.com.
>> > To view this discussion on the web visit 
>> > https://groups.google.com/d/msgid/sphinx-users/fd008e21-fca1-4e0b-8686-0f4b4180a04dn%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sphinx-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sphinx-users/b88e9e00-e69e-4654-8d2c-146832831640n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sphinx-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sphinx-users/CAFmkQAOOXk9GxFB31%3D6feLnyGf%3DcgEvArmDL%3DHXN%2B%2B0kdFaTYA%40mail.gmail.com.

Reply via email to