rmdformats icon indicating copy to clipboard operation
rmdformats copied to clipboard

Is it possible to add a small blank box when class.source = 'fold-hide' is called in html_clean to show where code blocks are present?

Open megaraptor1 opened this issue 3 years ago • 3 comments

This is more of a quality-of-life feature request than a specific bug, but it's something that has been a slight issue and I could not find anywhere to submit feature requests for rmdformats so I thought I would submit it here.

I have been greatly enjoying using rmdformats in my work, though I've been running into a minor issue that makes using code difficult. Specifically, I have a very long markdown document, so I have been using the class.source = 'fold-hide' a lot to hide very long stretches of code to make my knitted document more legible. I have been using the rmdformat html_clean in this case.

However, I have been running into a problem. Specifically, the hidden code button is very small and it is often hard to see if the code is present. I was wondering if there was any way to add an option for a small empty box to remain when the code is folded to show there is code present? The issue I am running into is when I have a lot of code blocks in a row without body text in the knitted document to break them up it can be confusing to find the button to unfold the code, and it can get overlooked among all the kables and ggplots. I understand it's supposed to be out of the way and it usually is, it's just in some cases it can get so out of the way it makes the code hard to find. I've seen this done in other formats but I didn't know if it was possible here. If not, no problem, but I just wanted to ask.

Here's what it looks like now...

What it looks like now

And here's what I mean.

What I mean

megaraptor1 avatar Jul 26 '22 13:07 megaraptor1

I don't really see a way to achieve precisely what you describe, but maybe you could change the size of the code folding buttons if you find them too small. The following code in the beginning of your document should increase their font size.

<style>
.code-folding-btn {
  font-size: 15px;
}
</style>

juba avatar Aug 01 '22 15:08 juba

If I found some code elsewhere that did something similar (html and I think probably latex, but maybe not RMarkdown), would that help? I've seen html pages that do something similar, but don't know how to extract the code.

megaraptor1 avatar Aug 01 '22 16:08 megaraptor1

Not really unfortunately, the problem is that the code source is already styled, plus there is some JavaScript to manage folding / unfolding, so preexisting CSS rules would not necessarily apply correctly.

juba avatar Aug 03 '22 14:08 juba