---
title: "Another CSS parsing example"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Another CSS parsing example}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = FALSE,
  comment = "#>"
)
```

```{r setup}
library(cssparser)
```


## Read the sample CSS Stylesheet included in the `tsuka` package


```{r}
tsuka_example <- "
/* Applies to the entire body of the HTML document (except where overridden by more specific
selectors). */
body {
  margin: 25px;
  background-color: rgb(240,240,240);
  font-family: arial, sans-serif;
  font-size: 14px;
}

/* Applies to all <h1>...</h1> elements. */
h1 {
  font-size: 35px;
  font-weight: normal;
  margin-top: 5px;
}

/* Applies to all elements with <... class='someclass'> specified. */
.someclass { color: red; }

/* Applies to the element with <... id='someid'> specified. */
#someid { color: green; }
"
```


```{r}
css <- cssparser::read_css(tsuka_example)
cssparser::css_pretty_print(css)
cssparser::css_colour_to_hex(css$body$`background-color`)
```
