Skip to content

Commit f4e6120

Browse files
committed
Can't use unicode directly in the code and help
1 parent d15b40b commit f4e6120

File tree

3 files changed

+48
-48
lines changed

3 files changed

+48
-48
lines changed

R/convert-bookdown.R

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
#' ## Detected Cross-Reference Types
2626
#'
2727
#' **Auto-detectable conversions:**
28-
#' - Figures: `\@ref(fig:label)` `@fig-label`
29-
#' - Tables: `\@ref(tab:label)` `@tbl-label`
30-
#' - Equations: `\@ref(eq:label)` `@eq-label`
31-
#' - Sections: `\@ref(label)` `@sec-label`
32-
#' - Theorems: `\@ref(thm:label)` `@thm-label` (also lem, cor, prp, def, exm, exr)
28+
#' - Figures: `\@ref(fig:label)`-> `@fig-label`
29+
#' - Tables: `\@ref(tab:label)` -> `@tbl-label`
30+
#' - Equations: `\@ref(eq:label)` -> `@eq-label`
31+
#' - Sections: `\@ref(label)` -> `@sec-label`
32+
#' - Theorems: `\@ref(thm:label)` -> `@thm-label` (also lem, cor, prp, def, exm, exr)
3333
#'
3434
#' **Manual conversion required:**
35-
#' - Numbered equations: `(\#eq:label)` requires equation restructuring
35+
#' - Numbered equations: `(\#eq:label)` -> requires equation restructuring
3636
#' - Theorem blocks: Need explicit Quarto div syntax conversion
3737
#' All three formats from several bookdown versions are supported:
3838
#' - Old syntax with label: `{theorem, label="thm:label"}`
@@ -61,7 +61,7 @@
6161
#'
6262
#' **Verbose (`verbose = TRUE`):**
6363
#' - Detailed line-by-line breakdown
64-
#' - Exact bookdown Quarto syntax transformations
64+
#' - Exact bookdown -> Quarto syntax transformations
6565
#' - Context-aware conversion guidance showing only relevant syntax patterns
6666
#' - Comprehensive examples with documentation links
6767
#'
@@ -167,11 +167,11 @@ crossref_prefix <- c(
167167
alert = "Section reference detected - requires manual header updates:",
168168
details = c(
169169
"Bookdown automatically generates IDs from headers like:",
170-
" {.red {.code # Hello World}} auto-generated ID: {.red {.code hello-world}}",
170+
" {.red {.code # Hello World}} -> auto-generated ID: {.red {.code hello-world}}",
171171
" referenced with {.red {.code \\@ref(hello-world)}}",
172172
"",
173173
"Quarto requires explicit header IDs:",
174-
" {.green {.code # Hello World {{#sec-hello-world}}}} explicit ID: {.green {.code sec-hello-world }}",
174+
" {.green {.code # Hello World {{#sec-hello-world}}}} -> explicit ID: {.green {.code sec-hello-world }}",
175175
" referenced with {.green {.code @sec-hello-world}}"
176176
)
177177
),
@@ -181,7 +181,7 @@ crossref_prefix <- c(
181181
"Bookdown automatically generates table IDs from kable/knitr functions based on cell label:",
182182
" {.red ```{{r mylabel}} }",
183183
" {.red kable(mtcars, caption = 'My Table')}",
184-
" {.red ```} auto-generated ID: {.red {.code tab:mylabel}}",
184+
" {.red ```} -> auto-generated ID: {.red {.code tab:mylabel}}",
185185
" referenced with {.red {.code \\@ref(tab:mylabel)}}",
186186
"",
187187
"Quarto requires explicit table IDs with tbl prefix in R code chunks:",
@@ -203,7 +203,7 @@ crossref_prefix <- c(
203203
"Bookdown automatically generates figure IDs from code chunk labels:",
204204
" {.red ```{{r mylabel, fig.cap='My Figure'}} }",
205205
" {.red plot(mtcars)}",
206-
" {.red ```} auto-generated ID: {.red {.code fig:mylabel}}",
206+
" {.red ```} -> auto-generated ID: {.red {.code fig:mylabel}}",
207207
" referenced with {.red {.code \\@ref(fig:mylabel)}}",
208208
"",
209209
"Quarto requires explicit figure IDs with fig prefix:",
@@ -248,19 +248,19 @@ crossref_prefix <- c(
248248
details = c(
249249
"",
250250
"The following bookdown cross-reference types are not supported in Quarto:",
251-
# {.red Conjecture (cnj) }"
251+
# {.red Conjecture (cnj) }"
252252
paste0(
253-
" {.red ",
253+
"* {.red ",
254254
tools::toTitleCase(names(bookdown_unsupported_types)),
255255
" (",
256256
bookdown_unsupported_types,
257257
") }"
258258
),
259259
"",
260260
"Consider these alternatives:",
261-
" Convert to regular text without cross-references",
262-
" Use supported theorem types (theorem, lemma, corollary, etc.)",
263-
" Create custom callout blocks with manual numbering"
261+
"* Convert to regular text without cross-references",
262+
"* Use supported theorem types (theorem, lemma, corollary, etc.)",
263+
"* Create custom callout blocks with manual numbering"
264264
)
265265
)
266266
)
@@ -692,7 +692,7 @@ crossref_prefix <- c(
692692

693693
for (result in type_results) {
694694
cli::cli_li(
695-
"Line {result$line} ({.file {paste0(fs::path_rel(file_path, project_path), ':', result$line)}}): {.red {.code {result$bookdown_syntax}}} {.green {.code {result$quarto_syntax}}}"
695+
"Line {result$line} ({.file {paste0(fs::path_rel(file_path, project_path), ':', result$line)}}): {.red {.code {result$bookdown_syntax}}} -> {.green {.code {result$quarto_syntax}}}"
696696
)
697697
.display_detection_message(result)
698698
}

man/detect_bookdown_crossrefs.Rd

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/_snaps/convert-bookdown.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,18 @@
118118
-- File: '<test_file_basename>' --
119119
120120
-- Fig references:
121-
* Line 2 ('<test_file_basename>:2'): `\@ref(fig:plot1)` `@fig-plot1`
121+
* Line 2 ('<test_file_basename>:2'): `\@ref(fig:plot1)` -> `@fig-plot1`
122122
i Note: Also ensure the corresponding code chunk has `#| label: fig-plot1`
123123
124124
-- Eq references:
125-
* Line 4 ('<test_file_basename>:4'): `\@ref(eq:mean)` `@eq-mean`
125+
* Line 4 ('<test_file_basename>:4'): `\@ref(eq:mean)` -> `@eq-mean`
126126
127127
-- Tab references:
128-
* Line 3 ('<test_file_basename>:3'): `\@ref(tab:data)` `@tbl-data`
128+
* Line 3 ('<test_file_basename>:3'): `\@ref(tab:data)` -> `@tbl-data`
129129
i Note: Also ensure the corresponding table has tbl prefxed id, either `{#tbl-data}` or `label="tbl-data"` in the r cell.
130130
131131
-- Sec references:
132-
* Line 5 ('<test_file_basename>:5'): `\@ref(methods)` `@sec-methods`
132+
* Line 5 ('<test_file_basename>:5'): `\@ref(methods)` -> `@sec-methods`
133133
i Note: Also ensure the corresponding header has `{#sec-methods}`
134134
135135
i Summary of conversion requirements:
@@ -139,18 +139,18 @@
139139
* 1 Tab reference
140140
! Section reference detected - requires manual header updates:
141141
Bookdown automatically generates IDs from headers like:
142-
`# Hello World` auto-generated ID: `hello-world`
142+
`# Hello World` -> auto-generated ID: `hello-world`
143143
referenced with `\@ref(hello-world)`
144144
145145
Quarto requires explicit header IDs:
146-
`# Hello World {#sec-hello-world}` explicit ID: `sec-hello-world `
146+
`# Hello World {#sec-hello-world}` -> explicit ID: `sec-hello-world `
147147
referenced with `@sec-hello-world`
148148
149149
! Figure reference detected - requires manual figure labeling:
150150
Bookdown automatically generates figure IDs from code chunk labels:
151151
```{r mylabel, fig.cap='My Figure'}
152152
plot(mtcars)
153-
``` auto-generated ID: `fig:mylabel`
153+
``` -> auto-generated ID: `fig:mylabel`
154154
referenced with `\@ref(fig:mylabel)`
155155
156156
Quarto requires explicit figure IDs with fig prefix:
@@ -170,7 +170,7 @@
170170
cell label:
171171
```{r mylabel}
172172
kable(mtcars, caption = 'My Table')
173-
``` auto-generated ID: `tab:mylabel`
173+
``` -> auto-generated ID: `tab:mylabel`
174174
referenced with `\@ref(tab:mylabel)`
175175
176176
Quarto requires explicit table IDs with tbl prefix in R code chunks:
@@ -225,7 +225,7 @@
225225
-- File: '<test_file_basename>' --
226226
227227
-- Fig references:
228-
* Line 2 ('<test_file_basename>:2'): `\@ref(fig:plot1)` `@fig-plot1`
228+
* Line 2 ('<test_file_basename>:2'): `\@ref(fig:plot1)` -> `@fig-plot1`
229229
i Note: Also ensure the corresponding code chunk has `#| label: fig-plot1`
230230
231231
i Summary of conversion requirements:
@@ -234,7 +234,7 @@
234234
Bookdown automatically generates figure IDs from code chunk labels:
235235
```{r mylabel, fig.cap='My Figure'}
236236
plot(mtcars)
237-
``` auto-generated ID: `fig:mylabel`
237+
``` -> auto-generated ID: `fig:mylabel`
238238
referenced with `\@ref(fig:mylabel)`
239239
240240
Quarto requires explicit figure IDs with fig prefix:
@@ -281,7 +281,7 @@
281281
-- File: '<test_file_basename>' --
282282
283283
-- Tab references:
284-
* Line 2 ('<test_file_basename>:2'): `\@ref(tab:data)` `@tbl-data`
284+
* Line 2 ('<test_file_basename>:2'): `\@ref(tab:data)` -> `@tbl-data`
285285
i Note: Also ensure the corresponding table has tbl prefxed id, either `{#tbl-data}` or `label="tbl-data"` in the r cell.
286286
287287
i Summary of conversion requirements:
@@ -291,7 +291,7 @@
291291
cell label:
292292
```{r mylabel}
293293
kable(mtcars, caption = 'My Table')
294-
``` auto-generated ID: `tab:mylabel`
294+
``` -> auto-generated ID: `tab:mylabel`
295295
referenced with `\@ref(tab:mylabel)`
296296
297297
Quarto requires explicit table IDs with tbl prefix in R code chunks:
@@ -338,7 +338,7 @@
338338
-- File: '<test_file_basename>' --
339339
340340
-- Numbered Equation references:
341-
* Line 4 ('<test_file_basename>:4'): `(\#eq:binom)` `{#eq-binom}`
341+
* Line 4 ('<test_file_basename>:4'): `(\#eq:binom)` -> `{#eq-binom}`
342342
! Requires manual conversion: Equation structure must be changed
343343
344344
i Summary of conversion requirements:
@@ -389,7 +389,7 @@
389389
-- File: '<test_file_basename>' --
390390
391391
-- Cnj references (NOT SUPPORTED IN QUARTO):
392-
* Line 2 ('<test_file_basename>:2'): `\@ref(cnj:guess)` `NOT SUPPORTED IN
392+
* Line 2 ('<test_file_basename>:2'): `\@ref(cnj:guess)` -> `NOT SUPPORTED IN
393393
QUARTO`
394394
x Not supported in Quarto: Consider custom cross-references (<https://quarto.org/docs/authoring/cross-references-custom.html>) or supported theorem types.
395395
@@ -398,13 +398,13 @@
398398
x Cross-references to types not supported in Quarto
399399
400400
The following bookdown cross-reference types are not supported in Quarto:
401-
Conjecture (cnj)
402-
Hypothesis (hyp)
401+
* Conjecture (cnj)
402+
* Hypothesis (hyp)
403403
404404
Consider these alternatives:
405-
Convert to regular text without cross-references
406-
Use supported theorem types (theorem, lemma, corollary, etc.)
407-
Create custom callout blocks with manual numbering
405+
* Convert to regular text without cross-references
406+
* Use supported theorem types (theorem, lemma, corollary, etc.)
407+
* Create custom callout blocks with manual numbering
408408
409409

410410
# detects theorem block with label correctly
@@ -441,10 +441,10 @@
441441
442442
-- Lemma Block Labeled references:
443443
* Line 2 ('<test_file_basename>:2'): `` ```{lemma label="important",
444-
name="Helper Lemma"} `` `:::{#lemma-important}`
444+
name="Helper Lemma"} `` -> `:::{#lemma-important}`
445445
446446
-- Lem references:
447-
* Line 5 ('<test_file_basename>:5'): `\@ref(lem:important)` `@lem-important`
447+
* Line 5 ('<test_file_basename>:5'): `\@ref(lem:important)` -> `@lem-important`
448448
449449
i Summary of conversion requirements:
450450
* 1 Lem reference
@@ -488,7 +488,7 @@
488488
489489
-- Theorem Block Unlabeled references:
490490
* Line 2 ('<test_file_basename>:2'): `` ```{theorem name="Pythagorean theorem"}
491-
`` `Manual conversion required: Use ::: {#thm-<id>} syntax. See
491+
`` -> `Manual conversion required: Use ::: {#thm-<id>} syntax. See
492492
https://quarto.org/docs/authoring/cross-references.html#theorems-and-proofs`
493493
494494
i Summary of conversion requirements:
@@ -534,10 +534,10 @@
534534
535535
-- Theorem Div references:
536536
* Line 2 ('<test_file_basename>:2'): `::: {.theorem #pyth-new name="Pythagorean
537-
theorem"}` `:::{#thm-pyth-new}`
537+
theorem"}` -> `:::{#thm-pyth-new}`
538538
539539
-- Thm references:
540-
* Line 7 ('<test_file_basename>:7'): `\@ref(thm:pyth-new)` `@thm-pyth-new`
540+
* Line 7 ('<test_file_basename>:7'): `\@ref(thm:pyth-new)` -> `@thm-pyth-new`
541541
542542
i Summary of conversion requirements:
543543
* 1 Theorem Div reference

0 commit comments

Comments
 (0)