|
27 | 27 | #' accessibility. |
28 | 28 | #' @param use_base64 Logical, whether to base64 encode the content (recommended |
29 | 29 | #' for complex content with special characters or when content includes quotes) |
30 | | -#' @param class Optional CSS class(es) to add to the element. While this works for |
31 | | -#' both span and div elements, it's more commonly used with div elements. |
32 | | -#' @param attrs Named list of additional HTML attributes to add to the element. |
33 | | -#' For example: `list(id = "my-element", title = "Tooltip text")` |
34 | 30 | #' |
35 | 31 | #' @return Character string containing the HTML element with appropriate data-qmd attributes |
36 | 32 | #' |
|
47 | 43 | #' tbl_qmd_span_base64("Complex $\\LaTeX$ content") |
48 | 44 | #' tbl_qmd_span_raw("Simple text") |
49 | 45 | #' |
50 | | -#' # Use with custom attributes |
51 | | -#' tbl_qmd_span("**Important note**", attrs = list(title = "Hover for more info")) |
52 | | -#' tbl_qmd_div("Content here", class = "callout", |
53 | | -#' attrs = list(id = "special-note", tabindex = "0")) |
54 | | -#' |
55 | 46 | #' # Use with different HTML table packages |
56 | 47 | #' \dontrun{ |
57 | 48 | #' # With kableExtra |
|
85 | 76 | invisible(TRUE) |
86 | 77 | } |
87 | 78 |
|
88 | | - |
| 79 | +#' @inheritParams tbl_qmd_elements |
| 80 | +#' @param class Optional CSS class(es) to add to the element. While this works for |
| 81 | +#' both span and div elements, it's more commonly used with div elements. |
| 82 | +#' @param attrs Named list of additional HTML attributes to add to the element. |
| 83 | +#' For example: `list(id = "my-element", title = "Tooltip text")` |
| 84 | +#' @noRd |
89 | 85 | .tbl_qmd_element <- function( |
90 | 86 | tag, |
91 | 87 | content, |
@@ -132,82 +128,64 @@ NULL |
132 | 128 | tbl_qmd_span <- function( |
133 | 129 | content, |
134 | 130 | display = NULL, |
135 | | - use_base64 = TRUE, |
136 | | - class = NULL, |
137 | | - attrs = NULL |
| 131 | + use_base64 = TRUE |
138 | 132 | ) { |
139 | | - .tbl_qmd_element("span", content, display, use_base64, class, attrs) |
| 133 | + .tbl_qmd_element("span", content, display, use_base64) |
140 | 134 | } |
141 | 135 |
|
142 | 136 | #' @rdname tbl_qmd_elements |
143 | 137 | #' @export |
144 | 138 | tbl_qmd_div <- function( |
145 | 139 | content, |
146 | 140 | display = NULL, |
147 | | - use_base64 = TRUE, |
148 | | - class = NULL, |
149 | | - attrs = NULL |
| 141 | + use_base64 = TRUE |
150 | 142 | ) { |
151 | | - .tbl_qmd_element("div", content, display, use_base64, class, attrs) |
| 143 | + .tbl_qmd_element("div", content, display, use_base64) |
152 | 144 | } |
153 | 145 | #' @rdname tbl_qmd_elements |
154 | 146 | #' @export |
155 | 147 | tbl_qmd_span_base64 <- function( |
156 | 148 | content, |
157 | | - display = NULL, |
158 | | - class = NULL, |
159 | | - attrs = NULL |
| 149 | + display = NULL |
160 | 150 | ) { |
161 | 151 | tbl_qmd_span( |
162 | 152 | content, |
163 | 153 | display, |
164 | | - use_base64 = TRUE, |
165 | | - class = class, |
166 | | - attrs = attrs |
| 154 | + use_base64 = TRUE |
167 | 155 | ) |
168 | 156 | } |
169 | 157 |
|
170 | 158 | #' @rdname tbl_qmd_elements |
171 | 159 | #' @export |
172 | 160 | tbl_qmd_div_base64 <- function( |
173 | 161 | content, |
174 | | - display = NULL, |
175 | | - class = NULL, |
176 | | - attrs = NULL |
| 162 | + display = NULL |
177 | 163 | ) { |
178 | | - tbl_qmd_div(content, display, use_base64 = TRUE, class = class, attrs = attrs) |
| 164 | + tbl_qmd_div(content, display, use_base64 = TRUE) |
179 | 165 | } |
180 | 166 |
|
181 | 167 | #' @rdname tbl_qmd_elements |
182 | 168 | #' @export |
183 | 169 | tbl_qmd_span_raw <- function( |
184 | 170 | content, |
185 | | - display = NULL, |
186 | | - class = NULL, |
187 | | - attrs = NULL |
| 171 | + display = NULL |
188 | 172 | ) { |
189 | 173 | tbl_qmd_span( |
190 | 174 | content, |
191 | 175 | display, |
192 | | - use_base64 = FALSE, |
193 | | - class = class, |
194 | | - attrs = attrs |
| 176 | + use_base64 = FALSE |
195 | 177 | ) |
196 | 178 | } |
197 | 179 |
|
198 | 180 | #' @rdname tbl_qmd_elements |
199 | 181 | #' @export |
200 | 182 | tbl_qmd_div_raw <- function( |
201 | 183 | content, |
202 | | - display = NULL, |
203 | | - class = NULL, |
204 | | - attrs = NULL |
| 184 | + display = NULL |
205 | 185 | ) { |
206 | 186 | tbl_qmd_div( |
207 | 187 | content, |
208 | 188 | display, |
209 | | - use_base64 = FALSE, |
210 | | - class = class, |
211 | | - attrs = attrs |
| 189 | + use_base64 = FALSE |
212 | 190 | ) |
213 | 191 | } |
0 commit comments