Percent scripts: accept raw-string (r""") and '''-delimited markdown cells, as jupytext writes them
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 84/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- jupyter, python, typescript
Hướng nghiên cứu
Bắt đầu trong src/core/jupyter/percent.ts tại markdownFromJupyterPercentScript và kiểm tra việc phát hiện dấu ngoặc kép ba lần được nêu trong issue. Sử dụng ví dụ doc.py tối thiểu với quarto render để xác minh rằng các dấu phân cách raw-string và single-quote được phân tích cú pháp dưới dạng markdown. Hoàn tất khi r""", R""", """ và các dạng ''' không còn render các dấu phân cách của chúng dưới dạng văn xuôi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
Quarto renders Python percent scripts and the docs name jupytext as the reference implementation of the format, with markdown cells written either as # comments or as a multi-line string (""").
Jupytext writes markdown cells as strings when cell_markers = '"""' is set, and since 1.13.0 it prefixes the string with r whenever the cell contains a backslash, so that LaTeX such as \frac is not read as a Python escape sequence (changelog entry for jupytext/jupytext#836; src/jupytext/cell_to_text.py, "Markdown cells that contain a backslash should be encoded as raw strings"; expected output in tests/functional/others/test_raw_strings.py). Its reader accepts """, r""", R""" and the ''' forms (src/jupytext/cell_reader.py).
Quarto's parser recognises only a bare """ line:
// src/core/jupyter/percent.ts, markdownFromJupyterPercentScript
const isTripleQuote = (line: string) => !!line.match(/^"{3,}\s*$/);
so a cell jupytext wrote falls into the comment branch, which only strips a leading #, and both delimiter lines are rendered as prose. The same applies to a cell a user writes as r""" by hand to keep Python from interpreting the backslashes (a plain """ cell containing \xi or \underline is a syntax error in Python, so the raw prefix is the only way to keep such a file importable or runnable).
Minimal example
doc.py:
# %% [markdown]
# ---
# title: "Raw-string markdown cell"
# ---
# %% [markdown]
r"""
# A heading
Display math: $\frac{a}{b}$
"""
quarto render doc.py (1.8.25; the parser is unchanged in 1.10.18, 1.11.3 and main) produces a document whose body, as plain text, reads
r”“” A heading
Display math: \(\frac{a}{b}\) ““”
The heading is lost (the # was stripped as a comment prefix) and both delimiters appear as text, smart-quoted by Pandoc. Replacing r""" by """ renders correctly, which confirms the cause.
Proposed change
Accept an optional r/R prefix on the opening delimiter, and the single-quote form, matching jupytext's reader:
const isTripleQuoteOpen = (line: string) => !!line.match(/^[rR]?("{3,}|'{3,})\s*$/);
const isTripleQuoteClose = (line: string) => !!line.match(/^("{3,}|'{3,})\s*$/);
No other part of the pipeline is affected: the cell content is taken as markdown source either way.
Quarto version
1.8.25 on Windows 11; the relevant code is identical at tags v1.10.18 and v1.11.3 and on main.
- Ngôn ngữ chính
- JavaScript
- Star
- 6k
- Fork
- 458
- Merge trung bình
- 1 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 42
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của quarto-dev/quarto-cli
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
quarto-dev/quarto-cli#14915 ·
-
binder bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
quarto-dev/quarto-cli#14907 · 3 bình luận · 1 reaction ·
-
brand bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
quarto-dev/quarto-cli#14891 ·
-
brand bug html revealjs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
quarto-dev/quarto-cli#14882 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
quarto-dev/quarto-cli#14875 ·
Tất cả issue của quarto-dev/quarto-cli
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Daemon passes --experimental-wasm-jspi unconditionally on Node >= 24; Node 26 rejects the flag Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Automattic/studio#4908 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
sugarlabs/musicblocks#8847 ·