Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breakage with the latest version of knitr #621

Closed
yihui opened this issue Apr 4, 2024 · 4 comments
Closed

Breakage with the latest version of knitr #621

yihui opened this issue Apr 4, 2024 · 4 comments

Comments

@yihui
Copy link
Contributor

yihui commented Apr 4, 2024

To reproduce, remotes::install_github('yihui/knitr') and run tests in flextable or do R CMD check:

  Running the tests in ‘tests/testthat.R’ failed.
  Complete output:
    > library(testthat)
    > library(flextable)
    > library(officer)
    >
    > test_check("flextable")
    [ FAIL 4 | WARN 1 | SKIP 4 | PASS 245 ]

    ══ Skipped tests (4) ═══════════════════════════════════════════════════════════
    • On CRAN (4): 'test-as_flextable.R:3:1', 'test-borders.R:3:1',
      'test-captions-rmd.R:195:3', 'test-md-captions.R:3:1'

    ══ Failed tests ════════════════════════════════════════════════════════════════
    ── Failure ('test-captions-rmd.R:72:3'): with html_document2 ───────────────────
    grepl(...) is not TRUE

    `actual`:   FALSE
    `expected`: TRUE
    ── Failure ('test-captions-rmd.R:73:3'): with html_document2 ───────────────────
    grepl("Table [0-9]+\\: azerty querty", xml_text(xml_parent(caption_id2))) is not TRUE

    `actual`:   FALSE
    `expected`: TRUE
    ── Failure ('test-captions-rmd.R:83:3'): with html_document2 ───────────────────
    inherits(id_chunk, "xml_missing") is not FALSE

    `actual`:   TRUE
    `expected`: FALSE
    ── Failure ('test-captions-rmd.R:86:3'): with html_document2 ───────────────────
    grepl("Table 2:", xml_text(caption)) is not TRUE

    `actual`:   FALSE
    `expected`: TRUE

    [ FAIL 4 | WARN 1 | SKIP 4 | PASS 245 ]
    Error: Test failures
    Execution halted

This is due to a change in knitr::raw_block(): yihui/knitr@5435c52#diff-60bef5af43a1bd541299ce9bceeb226afb23deaa5e637b145c85e05ffd552b0c

Previously, knitr::raw_block() always uses three backticks in the fences. Now it will look at its content first. If the content contains three backticks, it will use four in the fences. I didn't look closely into the flextable codebase, but I guess it might be easier for you to figure out a proper fix. The above tests were failing because they generated something like this:

````{=html}
HTML code
```

```{=html}
HTML code
````

which should have been

```{=html}
HTML code
```

```{=html}
HTML code
```

Thanks!

yihui added a commit to yihui/knitr that referenced this issue Apr 4, 2024
@davidgohel
Copy link
Owner

Hello

I believe that the problem does not appear in the dev version - work on the tests is in progress and seems to have eliminated this problem (by chance). I will double check to be sure and let you know soon.

When do you plan a submission? If I can submit before your submission, you could delete the workaround. On my side, I have to wait for the submission of a reverse dependency and then it can be done.

@yihui
Copy link
Contributor Author

yihui commented Apr 5, 2024

I plan to make a submission today. No hurry for you to release a new version. I can remove the hack on my side next time. Thank you!

@yihui
Copy link
Contributor Author

yihui commented Apr 5, 2024

I can confirm that the dev version of flextable works fine with knitr without the workaround.

@yihui yihui closed this as completed Apr 5, 2024
clrpackages pushed a commit to clearlinux-pkgs/R-knitr that referenced this issue Apr 9, 2024
Kyle F Butts (2):
      Add support for `# %%` for chunk demarcation in `knitr::spin` (#2307)
      make spin() recognize `#|` comments as code chunks (#2320)

Lee Mendelowitz (1):
      Fix the error when kable()'s caption value is of length > 1 (#2312)

Max Schmit (1):
      add ALTER as sql statment, that is not returning anything (#2330)

Yihui Xie (53):
      start the next version
      fix #2304: shouldn't have used `return(meta)` since `meta` is not the `citation()` but `packageDescription()`
      fix rstudio/rmarkdown#2526 by reverting bebf117 since the `cairo_pdf` device has been explicitly supported in chunk_device(); now all possible `pdf()` arguments are supported, including `family`
      Disallow unbalanced chunk delimiters (#2306)
      close #1679: obtain the caption from the chunk option `tab.cap` for `kable()`
      also try the chunk option tbl.cap when tab.cap is NULL (quarto-dev/quarto-cli#7555)
      tweak R Markdown v1 vignettes
      move mailing list link and use https in ref card
      move css and js to jsdelivr for html_vignette
      use jsdelivr for the Rhtml template
      rewrite the docco classic style using JS instead of R
      standardize the docco linear format
      new version of funmediation is on CRAN now
      support the ... argument in chunk hooks
      optimize PNG images in package vignettes via optipng and pngquant if they are installed
      use R Markdown v1 for the knitr-intro vignette, too
      delete some files that are no longer needed in inst/examples and also ignore some files
      fix #2308: don't trim trailing spaces escaped by `\`
      support in-body chunk options for ojs and mermaid (quarto-dev/quarto-cli#7799)
      amend 3dcfac4780accc3791855b298a556297f62dc73d to fix quarto-dev/quarto-cli#5994: add YAML options to code for dot/mermaid/ojs chunks so that the full chunk content can be returned to Quarto
      add trailing slashes to URLs
      use the `assert(fact, {})` syntax for all tests
      revert c9473ad: map the chunk option `tbl-cap` to `tab.cap`
      leave tbl.cap alone; don't convert it to tab.cap, since Quarto has its own special handling of `tbl-cap`
      Create FUNDING.yml
      use xfun::decimal_dot() to ensure dot as the decimal separator
      fix rstudio/rmarkdown#2525: ensure the dot is used as the decimal separator even when options(OutDec) is not `.` or `LC_NUMERIC` is inappropriate
      factor out code to xfun::csv_options() and xfun::divide_chunk()
      get_option_comment() has been moved to xfun
      roxygenize
      bump xfun version
      xfun 0.42 is on CRAN now
      revert 87d094a6c593c31a3667821865e91b4a530018ec per request from CRAN maintainers, since _R_CHECK_VIGNETTES_SKIP_RUN_MAYBE_=true has been made the default
      fix rstudio/tinytex#435: adjust PATH temporarily for pdf_crop() to be able to find the command `pdfcrop` from TinyTeX
      RStudio IDE still calls parse_params(): https://github.com/rstudio/rstudio/blob/9a6196233d8eae5aa365b73eaafba04f7714190c/src/cpp/session/modules/SessionRmdNotebook.R#L666
      a follow-up on #2331: use xfun::fenced_block() from yihui/xfun@22a97ce
      xfun 0.43 is on CRAN now
      not sure what's wrong with pak
      `knitr::imgur_upload()` is now simply a wrapper function of `xfun::upload_imgur()` (#2325)
      too many ways to do the same thing... drop support for `#-` in spin()
      make spin() work again with input that can't be parsed as R code
      use xfun::check_old_package()
      markdown no longer sets this option internally, so no need to empty it now
      better detection of Rmd v2 input in knit2html(), so it no longer warns against documents that use markdown:: or litedown:: output formats
      make regex a little stricter so it won't match rmarkdown::
      the loo issue has been fixed (#2306)
      roxygen2 requires _PACKAGE now
      rename class names 'block' to 'knitr_block', and 'inline' to 'knitr_inline' since I need to export the print() methods and the names 'block' and 'inline' are too general
      preserve trailing \n in source code by doubling it, because later we will remove trailing \n in fenced_block()
      a temporary workaround for davidgohel/flextable#621
      StructFDR has been updated on CRAN but unfortunately the maintainer didn't seem to have seen my email about #2306
      I can't use knitr_block/knitr_inline as class names since it would break the lightparser package; let me just get rid of these S3 methods, which are unnecessarily advanced---just use normal functions instead (i.e., use inherits() to do the dispatch by myself)
      CRAN release v1.46

knokknok (1):
      fix #2318: faster processing of dependencies in dep_auto() (#2321)
clrpackages pushed a commit to clearlinux-pkgs/R-knitr that referenced this issue Jun 6, 2024
David Cser (1):
      Update themes to be consistent with Andrew Simon's highlight. (#2341)

Yihui Xie (15):
      just break the rest of packages in #2306 (CRAN will be fine with the breakage since I have notified package maintainers multiple times and well in advance)
      use options(knitr.kable.max_rows) for kable() to control the maximum number of rows to be generated in the table
      factor out the code to divide input lines into code/text chunks
      add news for d0d1b47 since some package authors have been puzzled by `R CMD check` failures
      find_globals() has been moved to xfun long ago
      301 redirect
      adjust test for xfun 0.44
      handle_error() in xfun 0.44 requires only one argument in the handler function
      use internal functions find_globals() and find_locals() in xfun 0.44
      flextable 0.9.6 is on CRAN; presumably this hack can be removed now (davidgohel/flextable#621)
      fix #2343: remove anything after comma or white spaces (including \n) in package URL
      disable tangle for vignettes
      highr 0.11 is on CRAN
      there are packages that rely on \hlstr and \hlstd commands (such as FuzzyNumbers and pandocfilters), so define them for backward compatibility
      CRAN release v1.47

atusy (1):
      close #2335: escape & in as many fields as possible in write_bib() (#2342)
Copy link

github-actions bot commented Oct 3, 2024

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants