carpentries / sandpaper

User Interface for The Carpentries Workbench
https://carpentries.github.io/sandpaper
Other
42 stars 27 forks source link

Callout body sometimes looks like the callout title #470

Closed bencomp closed 5 months ago

bencomp commented 1 year ago

I don't know why it happens, but sometimes the CSS class callout-title is added to the <h3> element (correctly) and its parent <div> element (incorrectly). When that happens, the body of the callout inherits the CSS directives for the title:

css-inheritance-issue

<div id="prereq2" class="callout prereq">
<div class="callout-square">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-check callout-icon"><polyline points="20 6 9 17 4 12"></polyline></svg>
</div>
<div id="software" class="callout-inner">
<h3 class="callout-title">Software<a class="anchor" aria-label="anchor" href="#prereq2"></a>
</h3>
<div class="callout-content">
<p>For this lesson you will need <strong>OpenRefine</strong> (formerly
Google Refine) and a web browser. Basic installation steps are provided
on this page. The OpenRefine <a href="https://openrefine.org/docs/manual/installing" class="external-link">installation
manual</a> provides more details about installation, upgrades and
configuration.</p>
<p>Note: this is a Java program that runs on your machine (not in the
cloud). It runs inside your browser, but no web connection is needed for
this lesson.</p>
<div id="callout1" class="callout">
<div class="callout-square">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-bell callout-icon"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path><path d="M13.73 21a2 2 0 0 1-3.46 0"></path></svg>
</div>
<div class="section level3 callout-title callout-inner">
<h3 class="callout-title" id="administrator-rights">Administrator rights<a class="anchor" aria-label="anchor" href="#administrator-rights"></a></h3>
<div class="callout-content">
<p>You do not need administrative rights on the computer to
<em>install</em> OpenRefine. However, if anti-malware software blocks
OpenRefine when you try to start it, you may need administrative rights
to allow OpenRefine to <em>run</em>. OpenRefine is safe to run.</p>
</div>
</div>
</div>
</div>
</div>
</div>

(This is from my local build; I see no difference before and after updating to the latest sandpaper.)

I also don't see an immediate pattern – it doesn't happen with every callout or only within nested callouts.

The files that show this error are in https://github.com/datacarpentry/openrefine-socialsci/pull/154, if anyone would like to try to reproduce this issue.

tobyhodges commented 1 year ago

I'm afraid I couldn't recreate this on my side, when I was building locally to preview your changes in https://github.com/datacarpentry/openrefine-socialsci/pull/154, @bencomp. All of the boxes looked okay to me. Further investigation is warranted, I think.

bencomp commented 1 year ago

Thanks for checking, @tobyhodges – let me check if I can get more debugging output, or at least see what versions of package I have installed. I can already tell that the same happens when I build the current main branch and that it doesn't matter if I use serve() or build_lesson(), even after reset_site().

So this could very well be related to my installation. And because I did install with Homebrew, I understand if it is out of scope.

Packages installed in R ``` > pkgs[, c("Version", "Built")] Version Built askpass "1.1" "4.3.0" assertthat "0.2.1" "4.3.0" backports "1.4.1" "4.3.0" base64enc "0.1-3" "4.3.0" bit "4.0.5" "4.3.0" bit64 "4.0.5" "4.3.0" blob "1.2.4" "4.3.0" brio "1.1.3" "4.3.0" broom "1.0.4" "4.3.0" bslib "0.4.2" "4.3.0" cachem "1.0.7" "4.3.0" callr "3.7.3" "4.3.0" cellranger "1.1.0" "4.3.0" cli "3.6.1" "4.3.0" clipr "0.8.0" "4.3.0" colorspace "2.1-0" "4.3.0" commonmark "1.9.0" "4.3.0" conflicted "1.2.0" "4.3.0" cpp11 "0.4.3" "4.3.0" crayon "1.5.2" "4.3.0" credentials "1.3.2" "4.3.0" curl "5.0.0" "4.3.0" data.table "1.14.8" "4.3.0" DBI "1.1.3" "4.3.0" dbplyr "2.3.2" "4.3.0" desc "1.4.2" "4.3.0" digest "0.6.31" "4.3.0" downlit "0.4.2" "4.3.0" dplyr "1.1.2" "4.3.0" dtplyr "1.3.1" "4.3.0" ellipsis "0.3.2" "4.3.0" evaluate "0.20" "4.3.0" fansi "1.0.4" "4.3.0" farver "2.1.1" "4.3.0" fastmap "1.1.1" "4.3.0" fontawesome "0.5.1" "4.3.0" forcats "1.0.0" "4.3.0" fs "1.6.2" "4.3.0" gargle "1.4.0" "4.3.0" generics "0.1.3" "4.3.0" gert "1.9.2" "4.3.0" ggplot2 "3.4.2" "4.3.0" gh "1.4.0" "4.3.0" gitcreds "0.1.2" "4.3.0" glue "1.6.2" "4.3.0" googledrive "2.1.0" "4.3.0" googlesheets4 "1.1.0" "4.3.0" gtable "0.3.3" "4.3.0" haven "2.5.2" "4.3.0" here "1.0.1" "4.3.0" highr "0.10" "4.3.0" hms "1.1.3" "4.3.0" htmltools "0.5.5" "4.3.0" httpuv "1.6.9" "4.3.0" httr "1.4.5" "4.3.0" httr2 "0.2.2" "4.3.0" ids "1.0.1" "4.3.0" ini "0.3.1" "4.3.0" isoband "0.2.7" "4.3.0" jquerylib "0.1.4" "4.3.0" jsonlite "1.8.4" "4.3.0" knitr "1.42" "4.3.0" labeling "0.4.2" "4.3.0" later "1.3.0" "4.3.0" lifecycle "1.0.3" "4.3.0" lubridate "1.9.2" "4.3.0" magrittr "2.0.3" "4.3.0" memoise "2.0.1" "4.3.0" mime "0.12" "4.3.0" modelr "0.1.11" "4.3.0" munsell "0.5.0" "4.3.0" openssl "2.0.6" "4.3.0" pegboard "0.5.2" "4.3.0" pillar "1.9.0" "4.3.0" pkgconfig "2.0.3" "4.3.0" pkgdown "2.0.7" "4.3.0" prettyunits "1.1.1" "4.3.0" processx "3.8.1" "4.3.0" progress "1.2.2" "4.3.0" promises "1.2.0.1" "4.3.0" ps "1.7.5" "4.3.0" purrr "1.0.1" "4.3.0" R6 "2.5.1" "4.3.0" ragg "1.2.5" "4.3.0" rappdirs "0.3.3" "4.3.0" RColorBrewer "1.1-3" "4.3.0" Rcpp "1.0.10" "4.3.0" readr "2.1.4" "4.3.0" readxl "1.4.2" "4.3.0" rematch "1.0.1" "4.3.0" rematch2 "2.1.2" "4.3.0" renv "0.17.3" "4.3.0" reprex "2.0.2" "4.3.0" rlang "1.1.0" "4.3.0" rmarkdown "2.21" "4.3.0" rprojroot "2.0.3" "4.3.0" rstudioapi "0.14" "4.3.0" rvest "1.0.3" "4.3.0" sandpaper "0.12.0" "4.3.0" sass "0.4.5" "4.3.0" scales "1.2.1" "4.3.0" selectr "0.4-2" "4.3.0" servr "0.26" "4.3.0" stringi "1.7.12" "4.3.0" stringr "1.5.0" "4.3.0" sys "3.4.1" "4.3.0" systemfonts "1.0.4" "4.3.0" textshaping "0.3.6" "4.3.0" tibble "3.2.1" "4.3.0" tidyr "1.3.0" "4.3.0" tidyselect "1.2.0" "4.3.0" tidyverse "2.0.0" "4.3.0" timechange "0.2.0" "4.3.0" tinkr "0.2.0" "4.3.0" tinytex "0.45" "4.3.0" tzdb "0.3.0" "4.3.0" usethis "2.1.6" "4.3.0" utf8 "1.2.3" "4.3.0" uuid "1.1-0" "4.3.0" varnish "0.2.16" "4.3.0" vctrs "0.6.2" "4.3.0" viridisLite "0.4.1" "4.3.0" vroom "1.6.1" "4.3.0" whisker "0.4.1" "4.3.0" withr "2.5.0" "4.3.0" xfun "0.39" "4.3.0" xml2 "1.3.4" "4.3.0" xslt "1.4.4" "4.3.0" yaml "2.3.7" "4.3.0" zip "2.3.0" "4.3.0" base "4.3.0" "4.3.0" boot "1.3-28.1" "4.3.0" class "7.3-21" "4.3.0" cluster "2.1.4" "4.3.0" codetools "0.2-19" "4.3.0" compiler "4.3.0" "4.3.0" datasets "4.3.0" "4.3.0" foreign "0.8-84" "4.3.0" graphics "4.3.0" "4.3.0" grDevices "4.3.0" "4.3.0" grid "4.3.0" "4.3.0" KernSmooth "2.23-20" "4.3.0" lattice "0.21-8" "4.3.0" MASS "7.3-58.4" "4.3.0" Matrix "1.5-4" "4.3.0" methods "4.3.0" "4.3.0" mgcv "1.8-42" "4.3.0" nlme "3.1-162" "4.3.0" nnet "7.3-18" "4.3.0" parallel "4.3.0" "4.3.0" rpart "4.1.19" "4.3.0" spatial "7.3-16" "4.3.0" splines "4.3.0" "4.3.0" stats "4.3.0" "4.3.0" stats4 "4.3.0" "4.3.0" survival "3.5-5" "4.3.0" tcltk "4.3.0" "4.3.0" tools "4.3.0" "4.3.0" utils "4.3.0" "4.3.0" ```

Some of the Brewed dependencies (I don't know which are most relevant):

libgit2 1.6.4
libxml2 2.11.2
lua 5.4.5
luajit 2.1.0-beta3-20230430.1
luajit-openresty 2.1-20230410
pandoc 3.1.2
pkg-config 0.29.2_3
r 4.3.0_1
zkamvar commented 1 year ago

This should have been fixed in {sandpaper} 0.12.0 via https://github.com/carpentries/sandpaper/pull/467 and appears to be correct in the live version of the site which was built an hour ago:

screenshot of a callout block embedded within another callout block. The headings and content look normal.

I'm not sure what's going on with your installation, locally though. My suggestion would be to rebuild the site from scratch to see if you are running into a cache issue:

sandpaper::build_lesson(rebuild = TRUE)

For context, this bug is partially because when we were designing the front end, we did not have an example of a callout block embedded within another callout block (with the exception of the solution blocks) as shown in learners/setup.md#L57-L80:

::::::::::::::::::::::::::::::::::::::::::  prereq

## Software

For this lesson you will need **OpenRefine** (formerly Google Refine) and a
web browser. Basic installation steps are provided on this page.
The OpenRefine [installation manual](https://openrefine.org/docs/manual/installing)
provides more details about installation, upgrades and configuration.

Note: this is a Java program that runs on your machine (not in the cloud).
It runs inside your browser, but no web connection is needed for this lesson.

::::::::::::::::::::::::::::::::::::::  callout

### Administrator rights

You do not need administrative rights on the computer to *install* OpenRefine.
However, if anti-malware software blocks OpenRefine when you try to start it,
you may need administrative rights to allow OpenRefine to *run*.
OpenRefine is safe to run.

:::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::

This is also why the styling for the callout block looks like a prereq block.

zkamvar commented 1 year ago

Also, for future, you can give me your session information using the built in sessionInfo() function or the {sessioninfo} package for a more detailed view:

sessionInfo() ```r > sessionInfo() R version 4.3.0 (2023-04-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.6 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0 locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C [10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C time zone: America/Los_Angeles tzcode source: system (glibc) attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] utf8_1.2.3 generics_0.1.3 renv_0.17.3-47 xml2_1.3.4 tinkr_0.2.0 [6] digest_0.6.31 magrittr_2.0.3 evaluate_0.21 fastmap_1.1.1 rprojroot_2.0.3 [11] processx_3.8.1 whisker_0.4.1 ps_1.7.5 purrr_1.0.1 fansi_1.0.4 [16] cli_3.6.1 rlang_1.1.1 commonmark_1.9.0 xslt_1.4.4 withr_2.5.0 [21] cachem_1.0.8 yaml_2.3.7 tools_4.3.0 sandpaper_0.12.0 memoise_2.0.1 [26] dplyr_1.1.2 credentials_1.3.2 assertthat_0.2.1 vctrs_0.6.2 R6_2.5.1 [31] lifecycle_1.0.3 fs_1.6.2 varnish_0.2.16 pkgconfig_2.0.3 desc_1.4.2 [36] callr_3.7.3 pkgdown_2.0.7 pillar_1.9.0 glue_1.6.2 Rcpp_1.0.10 [41] gert_1.9.2 xfun_0.39 tibble_3.2.1 tidyselect_1.2.0 sys_3.4.2 [46] knitr_1.42 htmltools_0.5.5 rmarkdown_2.21 pegboard_0.5.3 compiler_4.3.0 [51] downlit_0.4.2 askpass_1.1 openssl_2.0.6 ```
sessioninfo::session_info() ```r > sessioninfo::session_info() ─ Session info ────────────────────────────────────────────────────────────────────────────────────── setting value version R version 4.3.0 (2023-04-21) os Ubuntu 20.04.6 LTS system x86_64, linux-gnu ui X11 language en_US:en collate en_US.UTF-8 ctype en_US.UTF-8 tz America/Los_Angeles date 2023-05-24 pandoc 2.12 @ /home/zhian/anaconda3/bin/ (via rmarkdown) ─ Packages ────────────────────────────────────────────────────────────────────────────────────────── package * version date (UTC) lib source askpass 1.1 2019-01-13 [1] CRAN (R 4.0.0) assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.0) cachem 1.0.8 2023-05-01 [1] RSPM (R 4.3.0) callr 3.7.3 2022-11-02 [1] RSPM (R 4.2.0) cli 3.6.1 2023-03-23 [1] RSPM (R 4.2.0) commonmark 1.9.0 2023-03-17 [1] RSPM (R 4.2.0) credentials 1.3.2 2021-11-29 [1] CRAN (R 4.1.2) desc 1.4.2 2022-09-08 [1] RSPM (R 4.2.0) digest 0.6.31 2022-12-11 [1] RSPM (R 4.2.0) downlit 0.4.2 2022-07-05 [1] CRAN (R 4.2.1) dplyr 1.1.2 2023-04-20 [1] RSPM (R 4.3.0) evaluate 0.21 2023-05-05 [1] RSPM (R 4.3.0) fansi 1.0.4 2023-01-22 [1] RSPM (R 4.2.0) fastmap 1.1.1 2023-02-24 [1] RSPM (R 4.2.0) fs 1.6.2 2023-04-25 [1] RSPM (R 4.3.0) generics 0.1.3 2022-07-05 [1] RSPM (R 4.2.0) gert 1.9.2 2022-12-05 [1] RSPM (R 4.2.0) glue 1.6.2 2022-02-24 [1] RSPM (R 4.2.0) htmltools 0.5.5 2023-03-23 [1] RSPM (R 4.2.0) knitr 1.42 2023-01-25 [1] CRAN (R 4.2.2) lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.2.1) magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.1.3) memoise 2.0.1 2021-11-26 [1] CRAN (R 4.1.2) openssl 2.0.6 2023-03-09 [1] RSPM (R 4.2.0) pegboard 0.5.3 2023-05-19 [1] Github (carpentries/pegboard@3b06f45) pillar 1.9.0 2023-03-22 [1] RSPM (R 4.2.0) pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.4) pkgdown 2.0.7 2022-12-14 [1] CRAN (R 4.2.2) processx 3.8.1 2023-04-18 [1] RSPM (R 4.3.0) ps 1.7.5 2023-04-18 [1] RSPM (R 4.3.0) purrr 1.0.1 2023-01-10 [1] RSPM (R 4.2.0) R6 2.5.1 2021-08-19 [1] CRAN (R 4.1.1) Rcpp 1.0.10 2023-01-22 [1] RSPM (R 4.2.0) renv 0.17.3-47 2023-05-19 [1] Github (rstudio/renv@4c0cba2) rlang 1.1.1 2023-04-28 [1] RSPM (R 4.3.0) rmarkdown 2.21 2023-03-26 [1] RSPM (R 4.2.0) rprojroot 2.0.3 2022-04-02 [1] CRAN (R 4.1.3) sandpaper 0.12.0 2023-05-24 [1] https://carpentries.r-universe.dev (R 4.3.0) sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.1.2) sys 3.4.2 2023-05-23 [1] CRAN (R 4.3.0) tibble 3.2.1 2023-03-20 [1] RSPM (R 4.2.0) tidyselect 1.2.0 2022-10-10 [1] RSPM (R 4.2.0) tinkr 0.2.0 2023-05-19 [1] Github (ropensci/tinkr@a5dd3dd) utf8 1.2.3 2023-01-31 [1] RSPM (R 4.2.0) varnish 0.2.16 2023-04-10 [1] https://carpentries.r-universe.dev (R 4.2.3) vctrs 0.6.2 2023-04-19 [1] RSPM (R 4.3.0) whisker 0.4.1 2022-12-05 [1] RSPM (R 4.2.0) withr 2.5.0 2022-03-03 [1] CRAN (R 4.1.2) xfun 0.39 2023-04-20 [1] RSPM (R 4.3.0) xml2 1.3.4 2023-04-27 [1] RSPM (R 4.3.0) xslt 1.4.4 2023-02-21 [1] RSPM (R 4.2.0) yaml 2.3.7 2023-01-23 [1] RSPM (R 4.2.0) [1] /home/zhian/R/library [2] /usr/local/lib/R/site-library [3] /usr/lib/R/site-library [4] /usr/lib/R/library ────────────────────────── ```
bencomp commented 1 year ago

Thanks for these function pointers and comments! Perhaps my versions are a tiny bit behind yours (downloaded from the Netherlands mirror, which could be behind?), although I also have packages that you don't.

Looking at https://github.com/carpentries/sandpaper/pull/467/files#diff-b6d0e1001a0e8491b46773f0256ae272453ba38c9f2e666d4f7ce49197c8068dR11-R16 (from #467) I see that this div also has the class callout-title that I think causes the issue. Anyway, you are correct that the issue does not occur on the live website.

I will see if it continues to occur.

zkamvar commented 1 year ago

I think the only way you would have seen this with version 0.12.0 is if you had the development version installed, but even then, I think I only switched it to version 0.12.0 after I fixed the callout blocks anchor IDs (which was an impetus for me to bump the minor version), so it's a bit of a mystery. A slow mirror wouldn't affect that because {sandpaper} only comes from The Carpentries R Universe, not CRAN.

That being said, considering it's no longer a problem on the deployed site, I will close this for now. Please reopen if this is still happening.

zkamvar commented 1 year ago

I'm reopening this because I've discovered that the the source of this issue is due to a change in behaviour between pandoc 2 and 3 in https://github.com/carpentries/workbench/issues/59#issuecomment-1645623167:

lsn <- usethis::create_from_github("zkamvar/test-workbench-59", destdir = tempdir())
#> ℹ Defaulting to 'https' Git protocol
#> ✔ Setting `fork = FALSE`
#> ✔ Creating '/tmp/Rtmp24N1j4/test-workbench-59/'
#> ✔ Cloning repo from 'https://github.com/zkamvar/test-workbench-59.git' into '/tmp/Rtmp24N1j4/test-workbench-59'
#> ✔ Setting active project to '/tmp/Rtmp24N1j4/test-workbench-59'
#> ℹ Default branch is 'main'
#> ✔ Setting active project to '<no active project>'
pandoc::pandoc_activate("3.1.3")
#> ✔ Version '3.1.3' is now the active one.
#> ℹ Pandoc version also activated for rmarkdown functions.
sandpaper::build_lesson(lsn, quiet = TRUE, preview = FALSE)
idx <- xml2::read_html(fs::path(lsn, "site/docs/index.html"))
xml2::xml_find_first(idx, ".//div[starts-with(@class, 'callout')]") |> as.character() |> writeLines()
#> <div id="callout1" class="callout">
#> <div class="callout-square">
#> <i class="callout-icon" data-feather="bell"></i>
#> </div>
#> <div class="section level3 callout-title callout-inner">
#> <h3 class="callout-title" id="being-certain-which-system-your-terminal-is-connected-to">Being certain which system your terminal is
#> connected to<a class="anchor" aria-label="anchor" href="#being-certain-which-system-your-terminal-is-connected-to"></a>
#> </h3>
#> <div class="callout-content">
#> <p>If you ever need to be certain which system a terminal you are using
#> is connected to then use the following command:
#> <code>$ hostname</code>.</p>
#> </div>
#> </div>
#> </div>

Created on 2023-07-21 with reprex v2.0.2

I believe it's coming from this part of the lua filter where we place the callout header (which has the "callout-title" class) inside of the "callout-inner" block:

https://github.com/carpentries/sandpaper/blob/4b2a219522a30132e33fb05aea2bf37bcb9a7f32/inst/rmarkdown/lua/lesson.lua#L278

zkamvar commented 1 year ago

A bit more background for clarification: pandoc operates in this way:

flowchart TB
  input -->|"reader (+[options])"| AST
  AST -->|filter| AST 
  AST -->|"writer (--[options])"| output

The reason why we are seeing the difference in behaviour is because the HTML-writer-specific option --section-divs is applied after the filter transformation. Thus, when pandoc sees the section with a heading that contains a class that is not present in the section class, it the --section-divs in pandoc version 3 will automatically inherit it, causing the CSS rule to be applied to the entire div and not just the header.

The thing is, we already correct for this here and I think the issue is that we are searching for "callout ", when pandoc 3 collapses duplicate classes, so I think the solution is to search that the div starts with callout

https://github.com/carpentries/sandpaper/blob/4b2a219522a30132e33fb05aea2bf37bcb9a7f32/R/utils-xml.R#L98-L100

bencomp commented 1 year ago

You're probably on to something, @zkamvar! A change in Pandoc across major versions would explain such changes in output.

If I read it correctly, --section-divs 'moves' identifiers from the header to the enclosing section, but would it also move or copy classes?

Would a workaround be to adjust the CSS selector from .callout-title to h3.callout-title? Then only the header should be text-transformed.

zkamvar commented 1 year ago

Would a workaround be to adjust the CSS selector from .callout-title to h3.callout-title? Then only the header should be text-transformed.

This indeed would work and it would be a good idea to implement that.

It's important to note that only "callout" blocks (but not "discussion", "keypoints" or any other blocks) are affected because pandoc 3 (rightfully) deduplicates classes, thus my selection of starts-with(@class, 'callout ') does not match <div class='callout'>. in the post-processing step.

If I read it correctly, --section-divs 'moves' identifiers from the header to the enclosing section, but would it also move or copy classes?

Yes. It's been a topic of some debate in pandoc for the past few years: https://github.com/jgm/pandoc/issues/5965, which is probably why I've never gone for the h3.callout-title selector, because I never knew where it was going to end up.

tbooth commented 8 months ago

Hi,

Just wanted to chip in and say I'm seeing this bug when building lessons (I'm currently converting https://github.com/carpentries-incubator/snakemake-novice-bioinformatics from the old format). I've installed all the Sandpaper dependencies, including Pandoc and R, in a fresh Conda environment on Ubuntu.

In my case, every single callout has this problem where callout-title is incorrectly applied to the whole thing.

The quick fix was to force a downgrade of Pandoc in the conda env:

$ conda install pandoc=2.19.2

It might be worth noting this on the requirements document (https://carpentries.github.io/sandpaper-docs/#required) as Pandoc 2.x does seem to be the preferred version just now and is explicitly used in the GitHub actions.

froggleston commented 8 months ago

Apologies as I'm coming fairly new into the Workbench and its maintenance, and my R is very much lapsed!

From my reading through and checking the instructor-training lesson as per Nathaniel's report, the only callouts affected by this are the callout callouts, and not challenge, etc. In the latter, the resulting div has two classes, callout and the name of the block, e.g. using 04-expertise.md as the test case:

<div id="what-is-an-expert" class="callout discussion">

In the former, the resulting div has only one class, callout:

<div id="callout1" class="callout">

This seems to be the reason that the existing fix_callouts() function is not gathering up these callout-only divs.

Is there a reason why we couldn't use an additional XPath selector as:

callouts <- xml2::xml_find_all(idx, ".//div[@class='callout']")

In addition to using the current starts-with? https://github.com/carpentries/sandpaper/blob/eb009faca249bac5b999ac5449990329d3eb7d0d/R/utils-xml.R#L200C41-L200C83

Using the specific class selector seems to grab the correct callout parent divs, and would require no other changes to other code as far as I can tell? I've tested this with pandoc 2.19.2 and 3.11.1 and both seem to produce the same "clean" callout-inner class structure despite the pandoc3 behaviour.

froggleston commented 8 months ago

After a bit more testing this morning, it seems:

callouts <- xml2::xml_find_all(idx, ".//div[starts-with(@class, 'callout ')] | .//div[@class='callout']")

Produces consistent results across pandoc 2.x and 3.x. I'll raise a PR.

froggleston commented 8 months ago

This should now be resolved in #574 so please do test and let us know of any other issues.

ErinBecker commented 5 months ago

Can this issue be closed @froggleston?