sphinx-copybutton
sphinx-copybutton copied to clipboard
Improvement: support also parsed-literal blocks
It would be nice if it was possible to also copy text from parsed-literal blocks too.
Could you give an example of a page w/ a parsed-literal block? It would make it easier for folks to implement a selector to add buttons to this
https://doc.dovecot.org/configuration_manual/protocols/lmtp_server/#lmtp-proxying
Sounds good 👍 I think the fix would need to be here for anyone interested in implementing this:
https://github.com/choldgraf/sphinx-copybutton/blob/master/sphinx_copybutton/init.py#L28
Seems like parsed_literal
would be reasonable to add to the list of default selectors.
FWIW the suggestion in this comment can be used as a workaround: https://github.com/sphinx-doc/sphinx/issues/4054#issuecomment-329097229
I hope this helps!
I think this is a Sphinx bug, see also https://github.com/sphinx-doc/sphinx/issues/2167.
IMHO Sphinx should generate nested highlight-none
and highlight
<div>
s for parsed-literal
blocks. This would automatically solve the issue here.
Strangely, if you don't use any special formatting (which is against the whole purpose of parsed-literal
), the resulting code block is properly wrapped (but default-syntax-highlighted, which is probably not expected).
Hello,
On my end, (like @mgeier said I think) the issue is that:
.. parsed-literal::
has the div.highlight pre
selector like any other code block when not used with special formatting.
But when used with special formatting (i.e. a |version| variable in my case), it loses the div.highlight pre
selector and gets a new one pre#codecell0.litteral-block
.
I found a simple fix worth trying:
.. raw:: html
<div class=highlight>
.. parsed-literal::
# env_deploy_version: |version|
.. raw:: html
</div>
*the 3 directives must be on the same indentation level.
With this syntax, you force a div.highlight pre
selector on your code block.
It does not support syntax highlighting (in the form .. parsed-literal:: bash
) though.
LMK if it works and if you have any suggestion !
Linking issue https://github.com/executablebooks/sphinx-copybutton/issues/115 as it seems to be the same problem.