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

Adding (necessary) lines to what is copied #112

Open
dbitouze opened this issue Dec 26, 2020 · 1 comment
Open

Adding (necessary) lines to what is copied #112

dbitouze opened this issue Dec 26, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@dbitouze
Copy link
Contributor

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
Adding (necessary) lines to what is copied.

More precisely, I'd like to use sphinx-copybutton for a LaTeX FAQ. It is common for such a FAQ:

  • to give examples with only code blocks that should go in the "document body" (which is between \begin{document} and \end{document}),
  • to not display the necessary:
    • preamble (\documentclass{article}, many occurrences of \usepackage{...}, etc.),
    • pair \begin{document} and \end{document}.

For instance, instead of:

\documentclass{article}
\usepackage{xcolor}
\begin{document}
This a \textcolor{red}{text in red}.
\end{document}

only:

This a \textcolor{red}{text in red}.

is given (with a mention to the necessary xcolor package).

But if the user just copy and paste the latter and compile it, he will go into troubles. On the other hand, giving the whole code for each example would be tedious to read.

So what could be nice is to display only:

This a \textcolor{red}{text in red}.

and the actual copied text would be:

\documentclass{article}
\usepackage{xcolor}
\begin{document}
This a \textcolor{red}{text in red}.
\end{document}

Additional context

I'm aware this could be considered as unsafe but maybe a pop up could warn the user the actual content of what has been copied.

@dbitouze dbitouze added the enhancement New feature or request label Dec 26, 2020
@welcome
Copy link

welcome bot commented Dec 26, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant