Skip to content

Conversation

@cderv
Copy link
Collaborator

@cderv cderv commented Jul 21, 2025

Scan a bookdown book and report all the ref and blocks that needs editing.

Scan a bookdown book and report all the ref and blocks that needs
editing.
@cderv cderv marked this pull request as draft July 21, 2025 17:15
@cderv cderv marked this pull request as ready for review July 22, 2025 09:20
@cderv
Copy link
Collaborator Author

cderv commented Jul 22, 2025

Function applied to bookdown Book that inside the bookdown R 📦

Summary mode

> detect_bookdown_crossrefs("~/Documents/DEV_R/bookdown/inst/examples"verbose = FALSE)
ℹ Scanning for bookdown cross-references in 12 .Rmd files...
! Found 110 bookdown cross-references that should be converted:01-introduction.Rmd: 3 references
- 3 Sec02-components.Rmd: 52 references
- 5 Eq
- 7 Fig
- 1 Lem
- 1 Lemma Div
- 7 Numbered Equation
- 17 Sec
- 5 Tab
- 5 Theorem Div
- 4 Thm03-formats.Rmd: 20 references
- 4 Fig
- 16 Sec04-customization.Rmd: 5 references
- 5 Sec05-editing.Rmd: 8 references
- 3 Fig
- 5 Sec06-publishing.Rmd: 8 references
- 3 Fig
- 5 Sec08-usage.Rmd: 3 references
- 3 Secindex.Rmd: 11 references
- 11 SecSummary of conversion requirements:5 Eq reference17 Fig reference1 Lem reference1 Lemma Div reference7 Numbered Equation reference65 Sec reference5 Tab reference5 Theorem Div reference4 Thm referenceManual conversion requirements:Section headers: 65 references need manual attentionFigure labels: 17 references need manual attentionTable labels: 5 references need manual attentionEquation structure: 7 references need manual attentionTheorem blocks: 6 references need manual attentionFor detailed conversion guidance, run: quarto::detect_bookdown_crossrefs("~/Documents/DEV_R/bookdown/inst/examples", verbose = TRUE)

Detailed mode

> quarto::detect_bookdown_crossrefs("~/Documents/DEV_R/bookdown/inst/examples"verbose = TRUE)
ℹ Scanning for bookdown cross-references in 12 .Rmd files...
! Found 110 bookdown cross-references that should be converted:


── File: 01-introduction.Rmd ──

── Sec references:Line 112 (01-introduction.Rmd:112): `\@ref(r-markdown)` -> `@sec-r-markdown`Note: Also ensure the corresponding header has `{#sec-r-markdown}`Line 153 (01-introduction.Rmd:153): `\@ref(configuration)` -> `@sec-configuration`Note: Also ensure the corresponding header has `{#sec-configuration}`Line 194 (01-introduction.Rmd:194): `\@ref(editing)` -> `@sec-editing`Note: Also ensure the corresponding header has `{#sec-editing}`


── File: 02-components.Rmd ──

── Numbered Equation references:Line 151 (02-components.Rmd:151): `(\#eq:label)` -> `{#eq-label}`
!   Requires manual conversion: Equation structure must be changedLine 156 (02-components.Rmd:156): `(\#eq:binom)` -> `{#eq-binom}`
!   Requires manual conversion: Equation structure must be changedLine 163 (02-components.Rmd:163): `(\#eq:binom)` -> `{#eq-binom}`
!   Requires manual conversion: Equation structure must be changedLine 190 (02-components.Rmd:190): `(\#eq:align)` -> `{#eq-align}`
!   Requires manual conversion: Equation structure must be changedLine 197 (02-components.Rmd:197): `(\#eq:align)` -> `{#eq-align}`
!   Requires manual conversion: Equation structure must be changedLine 211 (02-components.Rmd:211): `(\#eq:var-beta)` -> `{#eq-var-beta}`
!   Requires manual conversion: Equation structure must be changedLine 223 (02-components.Rmd:223): `(\#eq:var-beta)` -> `{#eq-var-beta}`
!   Requires manual conversion: Equation structure must be changed

── Theorem Div references:Line 267 (02-components.Rmd:267): `::: {.theorem #foo}` -> `:::{#thm-foo}`Line 275 (02-components.Rmd:275): `::: {.theorem #pyth name="Pythagorean theorem"}` -> `:::{#thm-pyth}`Line 283 (02-components.Rmd:283): `::: {.theorem #pyth name="Pythagorean theorem"}` -> `:::{#thm-pyth}`Line 337 (02-components.Rmd:337): `::: {.theorem #chf-sum}` -> `:::{#thm-chf-sum}`Line 405 (02-components.Rmd:405): `::: {.theorem #pyth name="Pythagorean theorem"}` -> `:::{#thm-pyth}`

── Lemma Div references:Line 331 (02-components.Rmd:331): `::: {.lemma #chf-pdf}` -> `:::{#lem-chf-pdf}`

── Fig references:Line 511 (02-components.Rmd:511): `\@ref(fig:pressure-plot)` -> `@fig-pressure-plot`Note: Also ensure the corresponding code chunk has `#| label: fig-pressure-plot`Line 518 (02-components.Rmd:518): `\@ref(fig:cars-plot)` -> `@fig-cars-plot`Note: Also ensure the corresponding code chunk has `#| label: fig-cars-plot`Line 525 (02-components.Rmd:525): `\@ref(fig:multi-plots)` -> `@fig-multi-plots`Note: Also ensure the corresponding code chunk has `#| label: fig-multi-plots`Line 533 (02-components.Rmd:533): `\@ref(fig:knitr-logo)` -> `@fig-knitr-logo`Note: Also ensure the corresponding code chunk has `#| label: fig-knitr-logo`Line 603 (02-components.Rmd:603): `\@ref(fig:does-not-exist)` -> `@fig-does-not-exist`Note: Also ensure the corresponding code chunk has `#| label: fig-does-not-exist`Line 616 (02-components.Rmd:616): `\@ref(fig:knitr-logo)` -> `@fig-knitr-logo`Note: Also ensure the corresponding code chunk has `#| label: fig-knitr-logo`Line 795 (02-components.Rmd:795): `\@ref(fig:miniUI)` -> `@fig-miniUI`Note: Also ensure the corresponding code chunk has `#| label: fig-miniUI`

── Eq references:Line 166 (02-components.Rmd:166): `\@ref(eq:binom)` -> `@eq-binom`Line 166 (02-components.Rmd:166): `\@ref(eq:binom)` -> `@eq-binom`Line 184 (02-components.Rmd:184): `\@ref(eq:align)` -> `@eq-align`Line 200 (02-components.Rmd:200): `\@ref(eq:var-beta)` -> `@eq-var-beta`Line 616 (02-components.Rmd:616): `\@ref(eq:binom)` -> `@eq-binom`

── Thm references:Line 272 (02-components.Rmd:272): `\@ref(thm:pyth)` -> `@thm-pyth`Line 272 (02-components.Rmd:272): `\@ref(thm:pyth)` -> `@thm-pyth`Line 348 (02-components.Rmd:348): `\@ref(thm:chf-sum)` -> `@thm-chf-sum`Line 376 (02-components.Rmd:376): `\@ref(thm:chf-sum)` -> `@thm-chf-sum`

── Lem references:Line 358 (02-components.Rmd:358): `\@ref(lem:chf-pdf)` -> `@lem-chf-pdf`

── Tab references:Line 230 (02-components.Rmd:230): `\@ref(tab:theorem-envs)` -> `@tbl-theorem-envs`Note: Also ensure the corresponding table has tbl prefxed id, either `{#tbl-theorem-envs}` or `label="tbl-theorem-envs"` in the r cell.Line 252 (02-components.Rmd:252): `\@ref(tab:theorem-envs)` -> `@tbl-theorem-envs`Note: Also ensure the corresponding table has tbl prefxed id, either `{#tbl-theorem-envs}` or `label="tbl-theorem-envs"` in the r cell.Line 272 (02-components.Rmd:272): `\@ref(tab:theorem-envs)` -> `@tbl-theorem-envs`Note: Also ensure the corresponding table has tbl prefxed id, either `{#tbl-theorem-envs}` or `label="tbl-theorem-envs"` in the r cell.Line 550 (02-components.Rmd:550): `\@ref(tab:table-single)` -> `@tbl-table-single`Note: Also ensure the corresponding table has tbl prefxed id, either `{#tbl-table-single}` or `label="tbl-table-single"` in the r cell.Line 559 (02-components.Rmd:559): `\@ref(tab:table-multi)` -> `@tbl-table-multi`Note: Also ensure the corresponding table has tbl prefxed id, either `{#tbl-table-multi}` or `label="tbl-table-multi"` in the r cell.

── Sec references:Line 11 (02-components.Rmd:11): `\@ref(citations)` -> `@sec-citations`Note: Also ensure the corresponding header has `{#sec-citations}`Line 292 (02-components.Rmd:292): `\@ref(customization)` -> `@sec-customization`Note: Also ensure the corresponding header has `{#sec-customization}`Line 292 (02-components.Rmd:292): `\@ref(a-single-document)` -> `@sec-a-single-document`Note: Also ensure the corresponding header has `{#sec-a-single-document}`Line 457 (02-components.Rmd:457): `\@ref(figures)` -> `@sec-figures`Note: Also ensure the corresponding header has `{#sec-figures}`Line 457 (02-components.Rmd:457): `\@ref(tables)` -> `@sec-tables`Note: Also ensure the corresponding header has `{#sec-tables}`Line 491 (02-components.Rmd:491): `\@ref(configuration)` -> `@sec-configuration`Note: Also ensure the corresponding header has `{#sec-configuration}`Line 502 (02-components.Rmd:502): `\@ref(label)` -> `@sec-label`Note: Also ensure the corresponding header has `{#sec-label}`Line 504 (02-components.Rmd:504): `\@ref(text-references)` -> `@sec-text-references`Note: Also ensure the corresponding header has `{#sec-text-references}`Line 550 (02-components.Rmd:550): `\@ref(label)` -> `@sec-label`Note: Also ensure the corresponding header has `{#sec-label}`Line 571 (02-components.Rmd:571): `\@ref(yaml-options)` -> `@sec-yaml-options`Note: Also ensure the corresponding header has `{#sec-yaml-options}`Line 601 (02-components.Rmd:601): `\@ref(equations)` -> `@sec-equations`Note: Also ensure the corresponding header has `{#sec-equations}`Line 601 (02-components.Rmd:601): `\@ref(theorems)` -> `@sec-theorems`Note: Also ensure the corresponding header has `{#sec-theorems}`Line 601 (02-components.Rmd:601): `\@ref(figures)` -> `@sec-figures`Note: Also ensure the corresponding header has `{#sec-figures}`Line 601 (02-components.Rmd:601): `\@ref(tables)` -> `@sec-tables`Note: Also ensure the corresponding header has `{#sec-tables}`Line 601 (02-components.Rmd:601): `\@ref(label)` -> `@sec-label`Note: Also ensure the corresponding header has `{#sec-label}`Line 622 (02-components.Rmd:622): `\@ref(bs4-book)` -> `@sec-bs4-book`Note: Also ensure the corresponding header has `{#sec-bs4-book}`Line 696 (02-components.Rmd:696): `\@ref(yaml-options)` -> `@sec-yaml-options`Note: Also ensure the corresponding header has `{#sec-yaml-options}`


── File: 03-formats.Rmd ──

── Fig references:Line 54 (03-formats.Rmd:54): `\@ref(fig:new-bs4-book)` -> `@fig-new-bs4-book`Note: Also ensure the corresponding code chunk has `#| label: fig-new-bs4-book`Line 154 (03-formats.Rmd:154): `\@ref(fig:gitbook-toolbar)` -> `@fig-gitbook-toolbar`Note: Also ensure the corresponding code chunk has `#| label: fig-gitbook-toolbar`Line 273 (03-formats.Rmd:273): `\@ref(fig:new-bs4-book)` -> `@fig-new-bs4-book`Note: Also ensure the corresponding code chunk has `#| label: fig-new-bs4-book`Line 366 (03-formats.Rmd:366): `\@ref(fig:bs4-note)` -> `@fig-bs4-note`Note: Also ensure the corresponding code chunk has `#| label: fig-bs4-note`

── Sec references:Line 45 (03-formats.Rmd:45): `\@ref(gitbook-style)` -> `@sec-gitbook-style`Note: Also ensure the corresponding header has `{#sec-gitbook-style}`Line 46 (03-formats.Rmd:46): `\@ref(bs4-book)` -> `@sec-bs4-book`Note: Also ensure the corresponding header has `{#sec-bs4-book}`Line 47 (03-formats.Rmd:47): `\@ref(bootstrap-style)` -> `@sec-bootstrap-style`Note: Also ensure the corresponding header has `{#sec-bootstrap-style}`Line 48 (03-formats.Rmd:48): `\@ref(tufte-style)` -> `@sec-tufte-style`Note: Also ensure the corresponding header has `{#sec-tufte-style}`Line 170 (03-formats.Rmd:170): `\@ref(configuration)` -> `@sec-configuration`Note: Also ensure the corresponding header has `{#sec-configuration}`Line 180 (03-formats.Rmd:180): `\@ref(configuration)` -> `@sec-configuration`Note: Also ensure the corresponding header has `{#sec-configuration}`Line 238 (03-formats.Rmd:238): `\@ref(components)` -> `@sec-components`Note: Also ensure the corresponding header has `{#sec-components}`Line 388 (03-formats.Rmd:388): `\@ref(metadata-for-sharing)` -> `@sec-metadata-for-sharing`Note: Also ensure the corresponding header has `{#sec-metadata-for-sharing}`Line 579 (03-formats.Rmd:579): `\@ref(figures)` -> `@sec-figures`Note: Also ensure the corresponding header has `{#sec-figures}`Line 579 (03-formats.Rmd:579): `\@ref(tables)` -> `@sec-tables`Note: Also ensure the corresponding header has `{#sec-tables}`Line 579 (03-formats.Rmd:579): `\@ref(cross-references)` -> `@sec-cross-references`Note: Also ensure the corresponding header has `{#sec-cross-references}`Line 579 (03-formats.Rmd:579): `\@ref(label)` -> `@sec-label`Note: Also ensure the corresponding header has `{#sec-label}`Line 616 (03-formats.Rmd:616): `\@ref(html)` -> `@sec-html`Note: Also ensure the corresponding header has `{#sec-html}`Line 619 (03-formats.Rmd:619): `\@ref(components)` -> `@sec-components`Note: Also ensure the corresponding header has `{#sec-components}`Line 631 (03-formats.Rmd:631): `\@ref(components)` -> `@sec-components`Note: Also ensure the corresponding header has `{#sec-components}`Line 658 (03-formats.Rmd:658): `\@ref(components)` -> `@sec-components`Note: Also ensure the corresponding header has `{#sec-components}`


── File: 04-customization.Rmd ──

── Sec references:Line 73 (04-customization.Rmd:73): `\@ref(collaboration)` -> `@sec-collaboration`Note: Also ensure the corresponding header has `{#sec-collaboration}`Line 111 (04-customization.Rmd:111): `\@ref(bootstrap-style)` -> `@sec-bootstrap-style`Note: Also ensure the corresponding header has `{#sec-bootstrap-style}`Line 193 (04-customization.Rmd:193): `\@ref(bootstrap-style)` -> `@sec-bootstrap-style`Note: Also ensure the corresponding header has `{#sec-bootstrap-style}`Line 198 (04-customization.Rmd:198): `\@ref(usage)` -> `@sec-usage`Note: Also ensure the corresponding header has `{#sec-usage}`Line 249 (04-customization.Rmd:249): `\@ref(configuration)` -> `@sec-configuration`Note: Also ensure the corresponding header has `{#sec-configuration}`


── File: 05-editing.Rmd ──

── Fig references:Line 80 (05-editing.Rmd:80): `\@ref(fig:mathquill)` -> `@fig-mathquill`Note: Also ensure the corresponding code chunk has `#| label: fig-mathquill`Line 86 (05-editing.Rmd:86): `\@ref(fig:citr)` -> `@fig-citr`Note: Also ensure the corresponding code chunk has `#| label: fig-citr`Line 117 (05-editing.Rmd:117): `\@ref(fig:disqus)` -> `@fig-disqus`Note: Also ensure the corresponding code chunk has `#| label: fig-disqus`

── Sec references:Line 12 (05-editing.Rmd:12): `\@ref(configuration)` -> `@sec-configuration`Note: Also ensure the corresponding header has `{#sec-configuration}`Line 27 (05-editing.Rmd:27): `\@ref(new-session)` -> `@sec-new-session`Note: Also ensure the corresponding header has `{#sec-new-session}`Line 61 (05-editing.Rmd:61): `\@ref(usage)` -> `@sec-usage`Note: Also ensure the corresponding header has `{#sec-usage}`Line 98 (05-editing.Rmd:98): `\@ref(gitbook-style)` -> `@sec-gitbook-style`Note: Also ensure the corresponding header has `{#sec-gitbook-style}`Line 100 (05-editing.Rmd:100): `\@ref(yaml-options)` -> `@sec-yaml-options`Note: Also ensure the corresponding header has `{#sec-yaml-options}`


── File: 06-publishing.Rmd ──

── Fig references:Line 41 (06-publishing.Rmd:41): `\@ref(fig:new-bs4-book)` -> `@fig-new-bs4-book`Note: Also ensure the corresponding code chunk has `#| label: fig-new-bs4-book`Line 57 (06-publishing.Rmd:57): `\@ref(fig:netlify-drag-drop)` -> `@fig-netlify-drag-drop`Note: Also ensure the corresponding code chunk has `#| label: fig-netlify-drag-drop`Line 194 (06-publishing.Rmd:194): `\@ref(fig:404-page)` -> `@fig-404-page`Note: Also ensure the corresponding code chunk has `#| label: fig-404-page`

── Sec references:Line 45 (06-publishing.Rmd:45): `\@ref(build-the-book)` -> `@sec-build-the-book`Note: Also ensure the corresponding header has `{#sec-build-the-book}`Line 139 (06-publishing.Rmd:139): `\@ref(build-the-book)` -> `@sec-build-the-book`Note: Also ensure the corresponding header has `{#sec-build-the-book}`Line 241 (06-publishing.Rmd:241): `\@ref(yaml-options)` -> `@sec-yaml-options`Note: Also ensure the corresponding header has `{#sec-yaml-options}`Line 258 (06-publishing.Rmd:258): `\@ref(markdown-syntax)` -> `@sec-markdown-syntax`Note: Also ensure the corresponding header has `{#sec-markdown-syntax}`Line 305 (06-publishing.Rmd:305): `\@ref(latex-index)` -> `@sec-latex-index`Note: Also ensure the corresponding header has `{#sec-latex-index}`


── File: 08-usage.Rmd ──

── Sec references:Line 3 (08-usage.Rmd:3): `\@ref(introduction)` -> `@sec-introduction`Note: Also ensure the corresponding header has `{#sec-introduction}`Line 7 (08-usage.Rmd:7): `\@ref(r-code)` -> `@sec-r-code`Note: Also ensure the corresponding header has `{#sec-r-code}`Line 42 (08-usage.Rmd:42): `\@ref(components)` -> `@sec-components`Note: Also ensure the corresponding header has `{#sec-components}`


── File: index.Rmd ──

── Sec references:Line 54 (index.Rmd:54): `\@ref(markdown-syntax)` -> `@sec-markdown-syntax`Note: Also ensure the corresponding header has `{#sec-markdown-syntax}`Line 60 (index.Rmd:60): `\@ref(a-single-document)` -> `@sec-a-single-document`Note: Also ensure the corresponding header has `{#sec-a-single-document}`Line 81 (index.Rmd:81): `\@ref(introduction)` -> `@sec-introduction`Note: Also ensure the corresponding header has `{#sec-introduction}`Line 81 (index.Rmd:81): `\@ref(components)` -> `@sec-components`Note: Also ensure the corresponding header has `{#sec-components}`Line 81 (index.Rmd:81): `\@ref(output-formats)` -> `@sec-output-formats`Note: Also ensure the corresponding header has `{#sec-output-formats}`Line 81 (index.Rmd:81): `\@ref(customization)` -> `@sec-customization`Note: Also ensure the corresponding header has `{#sec-customization}`Line 81 (index.Rmd:81): `\@ref(editing)` -> `@sec-editing`Note: Also ensure the corresponding header has `{#sec-editing}`Line 81 (index.Rmd:81): `\@ref(rstudio-ide)` -> `@sec-rstudio-ide`Note: Also ensure the corresponding header has `{#sec-rstudio-ide}`Line 81 (index.Rmd:81): `\@ref(publishing)` -> `@sec-publishing`Note: Also ensure the corresponding header has `{#sec-publishing}`Line 87 (index.Rmd:87): `\@ref(software-usage)` -> `@sec-software-usage`Note: Also ensure the corresponding header has `{#sec-software-usage}`Line 87 (index.Rmd:87): `\@ref(software-tools)` -> `@sec-software-tools`Note: Also ensure the corresponding header has `{#sec-software-tools}`Summary of conversion requirements:5 Eq reference17 Fig reference1 Lem reference1 Lemma Div reference7 Numbered Equation reference65 Sec reference5 Tab reference5 Theorem Div reference4 Thm reference
! Section reference detected - requires manual header updates:
Bookdown automatically generates IDs from headers like:
`# Hello World` -> auto-generated ID: `hello-world`
referenced with `\@ref(hello-world)`

Quarto requires explicit header IDs:
`# Hello World {#sec-hello-world}` -> explicit ID: `sec-hello-world `
referenced with `@sec-hello-world`

! Figure reference detected - requires manual figure labeling:
Bookdown automatically generates figure IDs from code chunk labels:
```{r mylabel, fig.cap='My Figure'}
plot(mtcars)
``` -> auto-generated ID: `fig:mylabel`
referenced with `\@ref(fig:mylabel)`

Quarto requires explicit figure IDs with fig prefix:
```{r}
#| label: fig-mylabel
#| fig-cap: 'My Figure'
plot(mtcars)
```
referenced with `@fig-mylabel`

See documentation:
Bookdown: <https://bookdown.org/yihui/bookdown/figures.html>
Quarto: <https://quarto.org/docs/authoring/figures.html#cross-references>

! Table reference detected - requires manual table labeling:
Bookdown automatically generates table IDs from kable/knitr functions based on cell label:
```{r mylabel}
kable(mtcars, caption = 'My Table')
``` -> auto-generated ID: `tab:mylabel`
referenced with `\@ref(tab:mylabel)`

Quarto requires explicit table IDs with tbl prefix in R code chunks:
```{r}
#| label: tbl-mylabel
#| tbl-cap: 'My Table'
kable(mtcars)
```
referenced with `@tbl-mylabel`

See documentation:
Bookdown: <https://bookdown.org/yihui/bookdown/tables.html>
Quarto: <https://quarto.org/docs/authoring/tables.html#cross-references>

! Numbered equation detected - requires manual restructuring:
Bookdown numbered equations:
\begin{equation}
f\left(k\right) = \binom{n}{k} p^k\left(1-p\right)^{n-k}
(\#eq:binom)
\end{equation}
Quarto numbered equations:
$$\bar{X} = \frac{1}{n} \sum_{i=1}^{n} X_i$$ {#eq-mean}

See documentation:
Bookdown: <https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html#equations>
Quarto: <https://quarto.org/docs/authoring/cross-references.html#equations>

! Theorem environments require manual restructuring
Bookdown new div syntax: :::{.theorem #thm-label}
Quarto syntax: :::{#thm-label}
See: <https://quarto.org/docs/authoring/cross-references.html#theorems-and-proofs>

@cderv cderv linked an issue Jul 22, 2025 that may be closed by this pull request
@cderv cderv merged commit 55708b7 into main Jul 22, 2025
16 checks passed
@cderv cderv deleted the detect-bookdown-ref branch July 22, 2025 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

offer converter helper for bookdown cross reference

2 participants