yixuan / prettydoc

Creating Pretty HTML From R Markdown
https://prettydoc.statr.me/
471 stars 77 forks source link

Change styling attributes for code messages/warnings? #30

Closed ayushnoori closed 3 years ago

ayushnoori commented 3 years ago

Is it possible to change the background color or other styling attributes for the div containing the code output/messages/warnings? Please see below - both the code and the corresponding message look similar. Thanks!

image

maybegeek commented 3 years ago

Hi @ayushnoori ,

I wanted this changed too. For the moment I am using these lines in my additional css file for cayman:

div.sourceCode {
  margin-bottom: 0;
}
div.sourceCode ~ pre {
  margin-bottom: 1.2em;
  background-color: white;
  font-size: 0.7em;
}
div.sourceCode ~ pre::before {
  content: "R {message|warning|error} ...";
  display: block;
  font-style: italic;
  text-decoration: underline;
  padding-bottom: 0.3em;
}

cayman theme, additional css for R messages ...

perhaps that that helps. christoph

ayushnoori commented 3 years ago

Hi @maybegeek - thanks, this is a great idea. Would you be willing to share your extra CSS file? I'm interested in any additional enhancements to the base Cayman theme.

Or, any recommendations for where to find a good theme file that can be used out-of-the-box to knit my document? I'm willing to use rmarkdown::html_document rather than prettydoc as I'm not concerned about increased file size, but wasn't able to find a Bootswatch theme that could rival the aesthetic appeal of the prettydoc implementation of the Cayman theme.

maybegeek commented 3 years ago

Hi @ayushnoori , my opinionated css edits (for prettydoc 0.4.1, cayman) are here:

https://github.com/maybegeek/css-prettydoc-cayman-anpassungen

have fun with your docs!

Christoph

ayushnoori commented 3 years ago

Thanks Christoph! I appreciate it.

yixuan commented 3 years ago

Thank you @ayushnoori @maybegeek for the discussion. I apologize that I'm quite busy this month and cannot find time to look at this carefully. This seems to be a good feature for prettydoc, and I will think about it when I get some time.

ayushnoori commented 3 years ago

@yixuan, no worries - thanks for developing such a great package which makes writing good documentation so much easier. Inspired by @maybegeek, I am working on my own style sheet to supplement the Cayman theme, am happy to contribute or make available at my own repo if that would be helpful. For example, below is a rough draft of my implementation for a Table of Contents header:

/* TABLE OF CONTENTS */

div.toc-box {
  margin-top: 1rem;
}

div.toc::before {
  content: "Table of Contents";
  margin-top: 2rem;
  font-weight: 400;
  color: #159957;
  font-size: 1.5em;
}

div.toc {
  padding-top: 4rem;
}
ayushnoori commented 3 years ago

Hi @yixuan - wanted to follow-up about potentially making this a permanent feature of prettydoc. I've found that Christoph's solution doesn't always work for all languages (adds extra space w/ bash, for example). Thanks!