Percent scripts: accept raw-string (r""") and '''-delimited markdown cells, as jupytext writes them
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 84/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- jupyter, python, typescript
調査の方向性
src/core/jupyter/percent.ts の markdownFromJupyterPercentScript から始め、issue に示されている三重引用符の検出を調べます。最小限の doc.py 例と quarto render を使って、raw-string と single-quote の区切り文字が markdown として解析されることを確認します。r"""、R"""、"""、および ''' 形式の区切り文字が、文章としてレンダリングされなくなれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- JavaScript
- スター
- 6k
- フォーク
- 458
- 平均マージ
- 1日 9時間
- マージ済み PR(30日)
- 41
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
quarto-dev/quarto-cli のほかの issue
-
binder bug
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
quarto-dev/quarto-cli#14907 · コメント 3 件 ·
-
brand bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
quarto-dev/quarto-cli#14891 ·
-
brand bug html revealjs
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
quarto-dev/quarto-cli#14882 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
quarto-dev/quarto-cli#14875 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
quarto-dev/quarto-cli#14844 · リアクション 1 件 ·
quarto-dev/quarto-cli の issue をすべて見る
似ている issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
babalae/bettergi-scripts-list#3674 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
vadimdemedes/ink#1029 ·
-
code-quality refactoring
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
langchain-ai/deepagents#6450 ·
-
optimization optimization:agents-md-curator
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
githubnext/gh-aw-cao#13143 ·