https://github.com/hrbrmstr/tsuka
📃CSS Parser for R [Concept]
https://github.com/hrbrmstr/tsuka
css-parser r rstats
Last synced: 5 months ago
JSON representation
📃CSS Parser for R [Concept]
- Host: GitHub
- URL: https://github.com/hrbrmstr/tsuka
- Owner: hrbrmstr
- License: other
- Created: 2019-08-09T20:45:41.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-10T10:36:46.000Z (almost 6 years ago)
- Last Synced: 2024-12-25T04:24:39.603Z (7 months ago)
- Topics: css-parser, r, rstats
- Language: C
- Homepage:
- Size: 36.1 KB
- Stars: 13
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
README
---
output:
rmarkdown::github_document:
df_print: kable
---
```{r pkg-knitr-opts, include=FALSE}
hrbrpkghelpr::global_opts()
``````{r badges, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::stinking_badges(repo_status = "Concept")
``````{r description, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::yank_title_and_description()
```## SOME IMPORTANT DETAILS
Threw this together for [\@clauswilke](https://github.com/clauswilke) & [{ggtext}](https://github.com/clauswilke/ggtext) based on [this Twitter convo](https://twitter.com/hrbrmstr/status/1159920814801731586). I am unlikely to work on this more w/o serious prodding. It only handles CSS style rules and need 7 other enums covered from [`katana`](https://github.com/hackers-painters/katana-parser/blob/master/src/katana.h#L38-L48), plus the core cpp code need to be refactored into functions. Claus is more than capable of riffing off of the `katana` source (and I'll gladly PR into that if needed), plus I've no desire to spend time building a massively general purpose R pacakge that has a chance of being steamrolled over by corporate-backed package development.
You need to install the [`katana`](https://github.com/hackers-painters/katana-parser) C99 parser as a system library that is reachable by the R source package compilation defaults. It looks to be pretty straightforward to embed the `katana` source into a C[++]-backed R package but that wasn't the point of this exercise.
In `src/` there are some header files copied from the `katana` src which enable use of the same utility functions they use.
## What's Inside The Tin
The following functions are implemented:
```{r ingredients, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::describe_ingredients()
```## Installation
```{r install-ex, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::install_block()
```
## Usage```{r lib-ex}
library(tsuka)# current version
packageVersion("tsuka")```
```{r ex1}
"
/* 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
...
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; }
" -> css_exparse_css_text(css_ex)
``````{r ex2}
parse_css_file(system.file("extdat/sample.css", package = "tsuka"))
```## tsuka Metrics
```{r cloc, echo=FALSE}
cloc::cloc_pkg_md()
```## Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md).
By participating in this project you agree to abide by its terms.