Skip to content

Make type definition copy-pastable with hidden comment delimiters. #626

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

Merged
merged 1 commit into from
Mar 11, 2021

Conversation

Drup
Copy link
Contributor

@Drup Drup commented Mar 9, 2021

This is an alternative take on the copy paste problem mentioned in #296. It inserts comment delimiters (in ocaml, (* *)) around documentation, but hide them while keeping them in the text selection with some CSS trickery. The trickery in question seems rather standard (it's used in bootstrap as a way to have text only for screen-readers, which is rather consistent with what we want). It also has the advantage that people can style it to keep the delimiters in their own CSS, if they like that.

cc @dbuenzli

@dbuenzli
Copy link
Contributor

dbuenzli commented Mar 9, 2021

I don't understand the CSS trickery but if it does not bring rendering problems and will continue to work with #614, it is certainly a nicer solution.

(Sorry I don't have the time to look into this further right now)

@Drup
Copy link
Contributor Author

Drup commented Mar 9, 2021

My understanding is that the CSS use absolute positioning on the element so that it doesn't take space in the normal layout, and then put it as 0 size/margin/padding with no overflow to hide it. All those are ignored by text selection.

This delimiters are hidden, yet text-selected, thanks to some CSS-trickery.
@jonludlam jonludlam merged commit 139efd1 into ocaml:master Mar 11, 2021
@Drup Drup deleted the copypaste branch March 12, 2021 13:29
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FTR I personally dislike cargo-culting CSS, that usually leads to pains down the road :-) But based on @Drup understanding it seems that in odig's stylesheets you can boil that down to:

.spec .def-doc .comment-delim /* make them invisible yet copy-pastable */
{ position: absolute; width: 1px; height: 1px; overflow: hidden; }

(Tested in all browsers major browsers)

Copy link
Contributor Author

@Drup Drup Mar 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I also think we can shorten it, but there is a "belt and braces" aspect: we make it invisible and put it somewhere else. :)

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

Successfully merging this pull request may close these issues.

3 participants