-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.qmd
122 lines (92 loc) · 3.47 KB
/
README.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# html-colors
```{r}
#| eval: false
#| include: false
library(dplyr, quietly = TRUE)
library(here, quietly = TRUE)
library(knitr, quietly = TRUE)
library(magrittr, quietly = TRUE)
library(purrr, quietly = TRUE)
library(readr, quietly = TRUE)
library(simplermarkdown, quietly = TRUE)
library(yaml, quietly = TRUE)
```
```{r}
#| include: false
library(magrittr)
```
<!-- badges: start -->
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Espanso Hub](https://img.shields.io/badge/Espanso%20Hub-0.1.0-%2300A595.svg)](https://hub.espanso.org/html-colors)
[![License: MIT](https://img.shields.io/badge/license-MIT-green)](https://choosealicense.com/licenses/mit/)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
<!-- badges: end -->
## Overview
`html-colors` is an [Espanso](https://espanso.org) package that allows you to insert HTML color codes into your text seamlessly. By using this package, shortcuts like `##red` are automatically replaced with their corresponding hex color codes (e.g., `#FF0000`). You can also retrieve RGB color codes and the color family. It is designed to work in conjunction with the [`html-utils-package`](https://hub.espanso.org/html-utils-package).
This package is inspired by [Jenny Knuth's gist](https://gist.github.com/jennyknuth/e2d9ee930303d5a5fe8862c6e31819c5). A big thank you to Jenny!
## Installation
To install the latest released version of `html-colors`, use [Espanso Hub](https://hub.espanso.org/):
``` sh
espanso install html-colors
```
To install the development version directly from GitHub, use:
``` sh
espanso install html-colors --git https://github.com/danielvartan/html-colors/ --external
```
## Usage
Once installed, `html-colors` will replace the specified shortcuts with their corresponding character as you type.
```{r}
#| echo: false
match_file <- here::here("src", "package.yml")
```
```{r}
#| echo: false
data <-
match_file |>
readr::read_lines(skip = 1) %>%
yaml::read_yaml(text = .) |>
purrr::map_dfr(tibble::as_tibble) |>
dplyr::mutate(
hex_code = dplyr::case_when(
stringr::str_detect(trigger, "rgb-") ~ dplyr::lag(replace, n = 1),
stringr::str_detect(trigger, "families-") ~ dplyr::lag(replace, n = 2),
TRUE ~ replace
)
) |>
dplyr::mutate(
hex_code = stringr::str_replace(hex_code, "#", ""),
color = paste0(
"![#",
hex_code,
"](images/",
hex_code,
".png)"
),
trigger = paste0("`", trigger, "`"),
replace = paste0("`", replace, "`")
)
```
```{r}
#| echo: false
data <-
data |>
dplyr::select(trigger, replace, color) |>
dplyr::rename(
Trigger = trigger,
Result = replace,
Color = color
)
```
```{r}
#| echo: false
#| output: "asis"
simplermarkdown::md_table(data)
```
## Prefix
The `##` prefix was used to avoid conflicts with social media hashtags and the [`html-utils-package`](https://hub.espanso.org/html-utils-package).
## Contributing
If you feel like there's any important tag/snippet missing, feel free to create a Pull Request or open an [Issue](https://github.com/danielvartan/html-colors/issues/new).
## License
[![License:
MIT](https://img.shields.io/badge/license-MIT-green)](https://opensource.org/license/mit/)
`html-colors` code is released under the [MIT license](https://opensource.org/license/mit/).