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
Quarto render error #7029
Comments
I can't reproduce by
They all render fine. I am on
Can you update knitr and rmarkdown just in case ? Possibly related to encoding issue, or maybe a Locale issue... 🤔 |
update knitr and rmarkdown:
t2.qmd still render failed I added another three example at https://github.com/Damonsoul/quartotest t5.qmd render success but the result(t5.html also at https://github.com/Damonsoul/quartotest) has something wrong The error occurred on a Windows machine with codepage 936. However, when I rendered the documents on a Windows computer with utf-8, all of them were rendered correctly and produced the correct results. |
From what you are saying the issue is that you are not using UTF-8 which is the encoding used for both input and output by Pandoc thus Quarto, see < https://pandoc.org/MANUAL.html#character-encoding>. |
The encoding of my qmd document is utf-8. The issue I'm facing is that when rendering using Quarto in a non-utf-8 encoded Windows system, it can be successfully rendered and produces the correct results in some cases (such as t1.qmd), but not in others (such as t2.qmd). The iconv program is used to convert the encoding of text,but my document is already in utf-8 format. |
Thanks for the additional information @Damonsoul. Codepage 936 is for chinese character on Windows I believe. Can you share results of On my Windows, checking
What do you mean by utf-8 computer ? What is the codepage there ? |
Thanks for reply @cderv All documents are encoded UTF-8.
The codepage is 65001,Windows 10 |
My win10 system default codepage is 936,and cause the issue I mentioned above.windows 10 offer a way to change codpage, |
Thanks for digging through this. My code page is not UTF-8 and I don't have this option activated. so there must be something we could do. I would like to understand what part of our code is throwing this. It is possible that this is not link to Pandoc UTF-8 requirement at all. Can you run again after activating stack trace ? https://quarto.org/docs/troubleshooting/#get-a-stack-trace This will tell us where this fail exactly; The error seems linked to a JSON parsing issue |
Thanks @cderv |
@cderv I changed the 'rmd.R' in Quarto 1.4.527 at line 140 from " input <- readLines(stdin, warn = FALSE")" to " input <- readLines(stdin, warn = FALSE,encoding = "UTF-8")",and it works well |
Oh interesting ! Let me check that ! |
@Damonsoul I opened a PR with a change. Are you able to try dev version of Quarto ? (https://github.com/quarto-dev/quarto-cli#development-version) Otherwise, we'll do a built, or you can add my change locally as you did. I do think we need to set encoding to the |
@cderv It raised error as follow if I add "encoding = "UTF-8"" to file() |
Oh ok. Thank you for trying. Could it be that the |
@cderv
and my sys encoding is cp936 as follow: |
Thanks a lot. I did tweak to simple
Hopefully it works. I see you are using |
@cderv I tested the configuration of stdin <- file("stdin", "r", encoding = "") and input <- readLines(stdin, warn = FALSE, encoding = "UTF-8") on R4.05, and it ran successfully.Thank you for fixing |
Awesome! Thanks for confirming ! And really thanks for the report. We may have other bad side effect due to encoding, so please do not hesitate to open new issues to warn us. Thank you ! |
Bug description
Quarto render error when qmd document contain Chinese at some situation
Steps to reproduce
https://github.com/Damonsoul/quartotest
Expected behavior
both t1.qmd and t2.qmd render successful
Actual behavior
t1.qmd render failed and return ����: lexical error: invalid char in json text.
{r}\r\nt = "娴嬭瘯娴媆"\r\n```\r\n"},"results":"C:\Us
(right here) ------^
ִֹͣ��
t2.qmd render successful
Your environment
"Mountain Hydrangea" Release (583b465e, 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
Quarto check output
$ quarto check
Quarto 1.4.386
[>] Checking versions of quarto binary dependencies...
Pandoc version 3.1.8: OK
Dart Sass version 1.55.0: OK
Deno version 1.33.4: OK
[>] Checking versions of quarto dependencies......OK
[>] Checking Quarto installation......OK
Version: 1.4.386
Path: C:\Program Files\Quarto\bin
CodePage: 936
[>] Checking tools....................OK
TinyTeX: (external install)
Chromium: 869685
[>] Checking LaTeX....................OK
Using: TinyTex
Path: C:\Users\Administrator\AppData\Roaming\TinyTeX\bin\windows
Version: 2023
[>] Checking basic markdown render....OK
[>] Checking Python 3 installation....OK
Version: 3.9.16 (Conda)
Path: E:/SoftwareENU/Anaconda/python.exe
Jupyter: 5.3.0
Kernels: python3
[>] Checking Jupyter engine render....OK
[>] Checking R installation...........OK
Version: 4.3.1
Path: E:/SoftwareENU/R
LibPaths:
- E:/SoftwareENU/R/library
knitr: 1.43
rmarkdown: 2.23
[>] Checking Knitr engine render......OK
The text was updated successfully, but these errors were encountered: