Quarto render error with chinese docs and knitr opts_chunk set in YAML heading

A minimal demo:

---
title: "demo"
lang: zh
knitr:
  opts_chunk:
    collapse: false
format:
  gfm: default
---

第一行

第二行

-   第三行

-   第四行

-   第五行

The output

# demo

第一行二行 第三行 第四行 第五行

However, the expected output is

# demo

第一行

第二行

-   第三行

-   第四行

-   第五行

There are more strange behaviors when redering chinese docs with opts_chunk set. For example

  • Spaces must not preseed or follow digits, otherwise a compile error or disappear of several chinese characters.

  • Spaces must not appear at the end of a paragraph, otherwise may end up strange characters like �\<8c\>

  • For unkown reasons, the final few sections or paragraphs may no be rendered.

It seems the problem is assosicated with two factors Chinese docs, and, opts_chunk seting, since:

  • When rendering en docs (no Chinese character. lang does not matter ), no problem.

  • When rendering chinese docs (including Chinese character. lang does not matter ), with no opts_chunk settings, no problem.

  • When rendering chinese docs (including Chinese character. lang does not matter ), with opts_chunk set, the output messed up, including the following that I tried:

    • collapse: true

    • collapse: false

    • echo: true

    • echo: false

Some version and environment information:

  • R version 4.1.3 (2022-03-10)

  • RStudio 2023.06.0+421 "Mountain Hydrangea" Release (583b465ecc45e60ee9de085148cd2f9741cc5214, 2023-06-05) for windows
    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2023.06.0+421 Chrome/110.0.5481.208 Electron/23.3.0 Safari/537.36

  • knitr 1.43

  • seesion info

R version 4.1.3 (2022-03-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936  LC_CTYPE=Chinese (Simplified)_China.936   
[3] LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C                              
[5] LC_TIME=Chinese (Simplified)_China.936    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] knitr_1.43

loaded via a namespace (and not attached):
 [1] compiler_4.1.3         RColorBrewer_1.1-3     GenomeInfoDb_1.30.1    XVector_0.34.0        
 [5] bitops_1.0-7           tools_4.1.3            zlibbioc_1.40.0        bit_4.0.5             
 [9] RSQLite_2.3.1          memoise_2.0.1          lifecycle_1.0.3        gtable_0.3.3          
[13] png_0.1-8              rlang_1.1.0            DBI_1.1.3              cli_3.6.1             
[17] rstudioapi_0.14        xfun_0.39              fastmap_1.1.1          GenomeInfoDbData_1.2.7
[21] httr_1.4.6             Biostrings_2.62.0      S4Vectors_0.32.4       vctrs_0.6.1           
[25] IRanges_2.28.0         stats4_4.1.3           bit64_4.0.5            grid_4.1.3            
[29] glue_1.6.2             Biobase_2.54.0         R6_2.5.1               AnnotationDbi_1.56.2  
[33] pheatmap_1.0.12        blob_1.2.4             scales_1.2.1           BiocGenerics_0.40.0   
[37] KEGGREST_1.34.0        colorspace_2.1-0       RCurl_1.98-1.12        munsell_0.5.0         
[41] cachem_1.0.8           crayon_1.5.2  

Thank you for your reading.

All problems are solved when I switch to R version 4.3.1 (2023-06-16 ucrt)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.