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

R Dev Container: restrict copy-paste to code input in mkdocs documentation #60

Open
hturner opened this issue Sep 5, 2024 · 1 comment
Labels
Documentation Issues in the documentation RSECon24

Comments

@hturner
Copy link
Member

hturner commented Sep 5, 2024

This is issue 106 on the R Dev Container repo.

An example of where it would be helpful to restrict input is in the Example Contribution Workflow:

> askYesNo("Is this a good example?")
Is this a good example? (Yes/no/cancel) Yes
[1] TRUE 

It would be good if the copy-to-clipboard function only copied askYesNo("Is this a good example?").

Code to implement this is linked in the above issue, but you will need to work out how to integrate this with our current process for building the docs from source. The docs are built with mkdocs using Python, as described in the Contributing to docs section.

@hturner hturner added Documentation Issues in the documentation RSECon24 labels Sep 5, 2024
@tim-band
Copy link

tim-band commented Sep 5, 2024

Some findings from the RSEcon24 hackathon:

Firstly, this is not R, and should not be fenced with ```R. It should be fenced with ```Rconsole and the indentation should be removed.

Sadly, this does not fix the actual issue here.

I do not like the Issue 106 fix. The idea is to add this wodge of code to every page, which installs an onload handler for the page. It will scan the page and do the following things:

  1. Find code within code blocks that begins with # and mark it with the CSS user-select: none.
  2. Find code that begins with $ and mark the $ with user-select: none.
  3. Find code that begins with << and mark it with user-select: none.
  4. Find code that begins with << and delete the <<.
  5. Gather all the code that is still user-selectable and add a data-clipboard-text attribute with this text to the box.

I would argue that this isn't what we want.

What we really want is essentially just number 5 (we are using clipboard.js and this data-clipboard-text attribute is how to make the text whatever we want). I don't think that making a mouse drag fail to select the prompt or the output is right -- if people want to copy that why not let them? The copy text button is the thing. But ideally this shouldn't be done by post-processing every page onload. But how to do it? Not with a new Pygments lexer, not with a renderer, maybe a filter?

Sadly, I have not managed to find out where best to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Issues in the documentation RSECon24
Projects
None yet
Development

No branches or pull requests

2 participants