quarto-clean

本条目面向Word/PDF 文档处理场景,提供“quarto-clean”技能的目录入口。公开标签:learning、Quarto、LaTeX、文档清理。请通过固定上游版本核对实际功能、依赖与权限;此页为 Skillπ 独立编写的用途介绍和原站链接,不代表运行安全保证。原文与附件依各自许可开放。

仓库
brycewang-stanford/Auto-Empirical-Research-Skills
仓库最近推送
Stars
5,023
Forks
578
Issues / PRs
0

安装方式

先用 Prompt 核对来源,也可切换到安装命令或下载可用的安装包。

安装方式

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "quarto-clean":https://skillpi.com/zh/skills/deepskill-53e6467dd67ddb09491f57a5d295d97ecd00caf76e0f19ab07c793261fec4628。安装前核对上游来源和版本:https://github.com/brycewang-stanford/Auto-Empirical-Research-Skills/blob/bfa0a6e5a843babbf45a1ef1663fd5dc4f07c0ba/skills/22-christopherkenny-skills/skills/quarto-clean/SKILL.md。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

此命令从 GitHub 来源仓库获取指定技能。运行前请先查看源文件。

运行工具
npx skills add https://github.com/brycewang-stanford/Auto-Empirical-Research-Skills/tree/bfa0a6e5a843babbf45a1ef1663fd5dc4f07c0ba/skills/22-christopherkenny-skills/skills/quarto-clean --skill quarto-clean
许可协议: —

来源与配置

查看 GitHub 源码

brycewang-stanford/Auto-Empirical-Research-Skills固定提交 bfa0a6e5a843babbf45a1ef1663fd5dc4f07c0ba

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

本条目面向Word/PDF 文档处理场景,提供“quarto-clean”技能的目录入口。公开标签:learning、Quarto、LaTeX、文档清理。请通过固定上游版本核对实际功能、依赖与权限;此页为 Skillπ 独立编写的用途介绍和原站链接,不代表运行安全保证。原文与附件依各自许可开放。

↓ 0 下载 ↗ 0 分享点击

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
---
name: quarto-clean
description: 'Cleans a Quarto (.qmd) file by replacing LaTeX holdovers with proper Quarto/Pandoc syntax so the document renders correctly to HTML, PDF (Typst/LaTeX), and Word. Fixes citations (\citep → [@key]), cross-references (\ref → @label), figures (\includegraphics → markdown), tables, text formatting (\textbf → **bold**), inline math (\( \) → $ $), hyperlinks (\href → [text](url)), footnotes (\footnote → ^[]), list environments, section headings, and R Markdown chunk options (dot-style → #| YAML). Use when asked to clean, fix, modernize, or port a Quarto or R Markdown document; when LaTeX commands appear in a .qmd file; when a document fails to render to Word or Typst; or when citations/cross-references do not appear in non-LaTeX output.'
metadata:
  author: Christopher T. Kenny
  version: 1.1
---

# Quarto Clean

You clean a Quarto (`.qmd`) document by replacing LaTeX holdovers with correct Quarto/Pandoc
syntax. Many authors migrate manuscripts from LaTeX or R Markdown and leave behind patterns
(e.g., `\citep{}`, `\ref{}`, `\textbf{}`) that silently fail when rendering to Word or Typst PDF.
This skill finds and fixes them all in a single pass.

**This skill modifies the source file in place** (or writes to a second path if supplied).
Before writing, tell the user what file will be changed and remind them that `git diff` or
file history can recover the original.

---

## Input Arguments

| Position | Required | Description |
|----------|----------|-------------|
| 1 | **Yes** | Path to the `.qmd` file to clean (e.g., `paper/paper.qmd`). Cleaned in place by default. |
| 2 | No | Output path. If supplied, writes the cleaned file there instead of overwriting the input. |

**Example invocations:**
```
/quarto-clean paper/paper.qmd
/quarto-clean paper/paper.qmd drafts/paper-clean.qmd
```

---

## Step-by-Step Workflow

### 1. Parse Arguments

Identify the input `.qmd` path (arg 1) and output path (arg 2, or same as arg 1 if omitted).

### 2. Read the File

Use the `Read` tool to load the entire file. Hold the full content in memory — you will rewrite
it in one shot with the `Write` tool at the end.

### 3. Apply All Transformations

Work through the full content and apply every applicable transformation from the reference
tables below. Key principles:

- **Preserve protected regions**: Never modify content inside fenced code blocks (` ``` ` or
  `~~~`), inline code (`` ` `` ), display math (`$$...$$`), inline math (`$...$`), or YAML
  front matter (`---` to `---`). Treat these regions as opaque.
- **Handle nesting correctly**: Because you understand the full document structure, handle nested
  commands naturally. `\textbf{something \cite{key}}` → `**something [@key]**`.
  `\footnote{See \cite{key} for details}` → `^[See [@key] for details]`.
- **Apply all categories**: Work through every category in the reference below. A single command
  (`\textbf{\emph{text}}`) may require multiple rules (`***text***`).
- **Be complete**: Scan the entire file. Do not stop after the first occurrence of a pattern —
  fix every instance.

### 4. Write the Cleaned File

Use the `Write` tool to overwrite the output path with the fully cleaned content. Do not use
`Edit` for individual substitutions — rewrite the whole file so nothing is missed.

### 5. Report to the User

Tell the user:
- **Output path** written
- **Summary of fixes** by category (how many of each type were converted)
- **Items requiring manual review** — any patterns you could not safely convert automatically
  (list with approximate line numbers so the user can find them)
- **Reminder** to run `quarto render` to verify

---

## Transformation Reference

Apply every applicable rule. Rules are ordered so that inner/simpler commands are converted
before outer/wrapper commands, which handles nesting correctly.

### Citations

Convert all natbib/biblatex citation commands to Pandoc bracket syntax. These must work in
all output formats (HTML, Word, Typst PDF).

| LaTeX | Quarto | Notes |
|-------|--------|-------|
| `\cite{key}` | `[@key]` | |
| `\citep{key}` | `[@key]` | |
| `\citep{a,b}` | `[@a; @b]` | Split comma-separated keys |
| `\citep[p.~5]{key}` | `[@key, p. 5]` | Locator (suffix only) |
| `\citep[see][p.~5]{key}` | `[see @key, p. 5]` | Prefix + locator |
| `\citet{key}` | `@key` | Narrative / in-text citation |
| `\citet{a,b}` | `@a and @b` | Multiple narrative keys |
| `\citealt{key}` | `@key` | No parentheses |
| `\citeauthor{key}` | `@key` | Loses "author-only" semantics; flag in report |
| `\citeyear{key}` | `[-@key]` | Year only; suppresses author |
| `\nocite{key}` | Move to YAML `nocite: '@key'` | Remove from body; add to front matter |
| `\nocite{*}` | Move to YAML `nocite: '@*'` | |

### Cross-References

Convert `\label` and `\ref` commands. The label prefix maps directly:

| LaTeX prefix | Quarto prefix | Example LaTeX | Example Quarto |
|--------------|--------------|---------------|----------------|
| `fig:` | `fig-` | `\label{fig:map}` → `{#fig-map}` | `\ref{fig:map}` → `@fig-map` |
| `tab:` or `table:` | `tbl-` | `\label{tab:results}` | `@tbl-results` |
| `sec:` or `section:` | `sec-` | `\label{sec:intro}` | `@sec-intro` |
| `eq:` or `eqn:` | `eq-` | `\label{eq:ols}` | `@eq-ols` |
| `lst:` | `lst-` | | |
| `thm:`, `lem:`, `prop:`, etc. | same with `-` | | |

Rules:
- `\ref{type:name}` → `@type-name` (replace `:` with `-`, map prefix per table)
- `\autoref{type:name}` → `@type-name`
- `\eqref{eq:name}` → `@eq-name`
- **Drop redundant type words**: `Figure \ref{fig:x}` → `@fig-x` (Quarto auto-generates
  "Figure N"). Same for "Table", "Section", "Equation", "Appendix".
- `\label{type:name}` must be moved to the appropriate Quarto element as `{#type-name}`:
  - On a figure: `![Caption](file){#fig-name}`
  - On a table caption: `: Caption {#tbl-name}`
  - On a heading: `## Title {#sec-name}`
  - On display math: `$$...$$ {#eq-name}` (on the line after `$$`)
- Replace underscores with hyphens in the name part: `fig:my_fig` → `{#fig-my-fig}`

### R Markdown Chunk Options

Convert old-style inline chunk options to `#|` YAML comments. The fence header becomes bare
(language only), and each option becomes a `#|` line inside the chunk.

**Before:**
```
```{r my-label, echo=FALSE, fig.cap="My figure", fig.width=6, out.width="80%"}
```

**After:**
```
```{r}
#| label: my-label
#| echo: false
#| fig-cap: "My figure"
#| fig-width: 6
#| out-width: "80%"
```

Option name mapping (dots → dashes, booleans → lowercase):

| Old | New |
|-----|-----|
| `fig.cap` | `fig-cap` |
| `fig.width` | `fig-width` |
| `fig.height` | `fig-height` |
| `fig.align` | `fig-align` |
| `fig.alt` | `fig-alt` |
| `fig.subcap` | `fig-subcap` |
| `fig.pos` | `fig-pos` |
| `fig.env` | `fig-env` |
| `out.width` | `out-width` |
| `out.height` | `out-height` |
| `echo=FALSE` | `echo: false` |
| `eval=FALSE` | `eval: false` |
| `warning=FALSE` | `warning: false` |
| `message=FALSE` | `message: false` |
| `include=FALSE` | `include: false` |
| `cache=TRUE` | `cache: true` |
| `results='hide'` | `output: false` |
| `results='asis'` | `output: asis` |
| `tidy=TRUE` | *(remove — deprecated)* |

The first unnamed token in the old header is the label: `{r my-label, echo=FALSE}` → `#| label: my-label`.

### Figures

| LaTeX | Quarto |
|-------|--------|
| `\includegraphics{file}` | `![](file)` |
| `\includegraphics[width=0.8\textwidth]{file}` | `![](file){width=80%}` |
| `\includegraphics[width=5cm]{file}` | `![](file){width=5cm}` |
| `\centering` inside figure env | `fig-align="center"` attribute on the figure |

**Full figure environment:**
```latex
\begin{figure}[h]
  \centering
  \includegraphics[width=0.8\textwidth]{figs/map.pdf}
  \caption{A map of the study region.}
  \label{fig:map}
\end{figure}
```
Becomes:
```markdown
![A map of the study region.](figs/map.pdf){#fig-map width=80% fig-align="center"}
```

- `\begin{figure*}` → add `fig-env="figure*"` to the attribute block
- For computational figures in code chunks, use `#| fig-cap:` and `#| label: fig-...`

### Tables

**Markdown / pipe tables:**
```markdown
| Col A | Col B |
|:------|------:|
| val   | 1.23  |

: My table caption. {#tbl-results}
```

- Column alignment from tabular spec: `l` → `:---`, `r` → `---:`, `c` → `:---:`
- Caption goes *below* the table, after `: `, with `{#tbl-label}` at the end
- For computational tables (knitr/kable output), add chunk options instead:
  ```
  #| label: tbl-results
  #| tbl-cap: "My table caption."
  ```

**LaTeX table environment → Quarto pipe table:**
```latex
\begin{table}
  \caption{My table caption.}
  \label{tab:results}
  \begin{tabular}{lrr}
    \hline
    Method & Estimate & SE \\
    \hline
    OLS & 1.23 & 0.45 \\
    IV  & 1.89 & 0.67 \\
    \hline
  \end{tabular}
\end{table}
```
Becomes:
```markdown
| Method | Estimate |   SE |
|:-------|--------:|-----:|
| OLS    |    1.23 | 0.45 |
| IV     |    1.89 | 0.67 |

: My table caption. {#tbl-results}
```

### Text Formatting

Handle nesting: `\textbf{\emph{text}}` → `***text***`.

| LaTeX | Quarto |
|-------|--------|
| `\textbf{text}` | `**text**` |
| `\textit{text}` | `*text*` |
| `\emph{text}` | `*text*` |
| `\texttt{text}` | `` `text` `` |
| `\underline{text}` | `[text]{.underline}` |
| `\textsc{text}` | `[text]{.smallcaps}` |
| `\textsuperscript{x}` | `^x^` |
| `\textsubscript{x}` | `~x~` |
| `\sout{text}` | `~~text~~` |
| `\footnote{text}` | `^[text]` |

### Math

| LaTeX | Quarto |
|-------|--------|
| `\(x + y\)` | `$x + y$` |
| `\[x + y\]` | `$$x + y$$` |
| `\begin{equation}` / `\end{equation}` | `$$` / `$$` with `{#eq-name}` after closing `$$` |
| `\begin{align}` / `\end{align}` | `$$\begin{aligned}` / `\end{aligned}$$` |
| `\label{eq:name}` inside math | Remove from math body; add `{#eq-name}` after closing `$$` |

### Hyperlinks

| LaTeX | Quarto |
|-------|--------|
| `\url{https://...}` | `<https://...>` |
| `\href{url}{text}` | `[text](url)` |

### Special Characters and Spacing

| LaTeX | Quarto | Notes |
|-------|--------|-------|
| `\&` | `&` | Outside math |
| `\%` | `%` | Outside math |
| `\ldots` or `\dots` | `...` | |
| `\footnote{text}` | `^[text]` | (also in Text Formatting above) |
| `\noindent` | *(remove)* | |
| `\par` | blank line | |
| `\newline` or `\\` | blank line or two trailing spaces | Paragraph break in prose |
| `\newpage` or `\clearpage` | `{{< pagebreak >}}` | |
| `~` (tie space) | ` ` or `&nbsp;` | Context-dependent |

### Section Headings

| LaTeX | Quarto |
|-------|--------|
| `\section{Title}` | `# Title` |
| `\subsection{Title}` | `## Title` |
| `\subsubsection{Title}` | `### Title` |
| `\paragraph{Title}` | `#### Title` |
| `\section*{Title}` | `# Title {.unnumbered}` |
| `\section{Title}\label{sec:x}` | `# Title {#sec-x}` |

If a `\label{sec:x}` appears on the line following a heading, merge it into the heading's
attribute block: `## Methods {#sec-methods}`.

### List Environments

| LaTeX | Quarto |
|-------|--------|
| `\begin{itemize}` / `\item` | Unordered list with `-` |
| `\begin{enumerate}` / `\item` | Ordered list with `1.` |
| `\begin{description}` / `\item[Term]` | `: Term\n:   definition` |

Nested lists: indent continuation lines by two spaces per level.

### Abstract and Front Matter

Move these from the document body to YAML:

```latex
\begin{abstract}
  We study the effect of X on Y...
\end{abstract}
```
→ YAML field:
```yaml
abstract: |
  We study the effect of X on Y...
```

Similarly for `\title{}`, `\author{}`, `\date{}` appearing in the body — move to YAML
`title:`, `author:`, `date:` fields.

---

## Patterns That Need Judgment

Flag these in your report if you encounter them, with a suggested fix but no automatic
conversion (the content depends too much on context):

- **Custom LaTeX environments** (`\begin{theorem}`, `\begin{proof}`, `\begin{lemma}`,
  `\begin{frame}`, etc.) → suggest converting to `::: {.callout-note}` or a theorem div
- **`\vspace{}` / `\hspace{}`** → no direct Quarto equivalent; suggest removing or using CSS
- **`\multicolumn{}{}{}` in tables** → requires restructuring the table manually
- **`\citeauthor{key}`** → converted to `@key` but the "author only" rendering is lost;
  suggest rephrasing (e.g., "Smith [-@smith2020]")
- **`cite-method: natbib` or `cite-method: biblatex` in YAML** → should likely be removed
  for non-LaTeX output formats; flag for user decision
- **`\\[6pt]` or `\\[1em]`** (spacing in math display) → the spacing argument is not valid
  in Quarto; convert to `\\` and note the spacing is lost

---

## What to Preserve Unchanged

- All content inside ` ```...``` ` fenced code blocks (including chunk body code)
- All content inside `` `...` `` inline code
- All content inside `$...$` inline math and `$$...$$` display math (except `\label{}` which
  must be moved outside, and `\( \)` / `\[ \]` delimiters which must be converted)
- YAML front matter between `---` delimiters
- Quarto shortcodes `{{< ... >}}`
- Existing `@ref` cross-references and `[@citation]` citations that are already correct
- Pandoc div/span syntax `:::` and `[]{}` that is already valid Quarto

版本历史

  1. v2026.07 GitHub ↗
    原版更新说明

    ## Highlights - **First tagged release.** Every gate is green: `make check` (validate + 183 unit tests + eval-harness + numeric benchmarks), validate-catalog, quality-evals, and OpenSSF Scorecard on `main`. - **Rigor double loop at 13 method families.** Each family closes taxonomy tag → eval scenario (does the agent avoid the method's known traps?) → deterministic numeric benchmark (does it recover the true effect?). New this cycle: heterogeneous treatment effects (CATE) and quantile treatment effects (QTE). - **Paper-WorkFlow flagship at 29/29 executable rigor gates**, now merged to its `main` with a drift-gated README badge — the credibility artifact is checked by CI, so it can never silently go stale ([RIGOR.md](https://github.com/brycewang-stanford/Paper-WorkFlow/blob/main/RIGOR.md)). - **1,150 vendored skills / 69 collections**, all license-audited, security-scanned, tracked in a machine-readable catalog with CI-enforced freshness, and importable as a single whole-repo router skill. - **Hardened weekly upstream syncs**: synced trees must pass the full gate before merge; this cycle both sync PRs were verified, patched (StatsPAI's SkillOpt execution-gate card restored), and merged. - **First-party plugin marketplace** (Python / R / Stata empirical-analysis plugins + guide) shipped in the previous cycle, now under a tagged version. ## Known Follow-Ups - Ecosystem benchmark comparison (AERS vs econometrics agents on the shared benchmark suite) — [PLAN-2026-07 week 3](https://github.com/brycewang-stanford/Auto-Empirical-Research-Skills/blob/main/docs/PLAN-2026-07.md). - Decomposition (Oaxaca–Blinder) and shift-share (Bartik) method families (weeks 3–4). - GitHub Pages catalog site, README demo screenshots, five-language README consistency script (week 4). ## Catalog - Top-level collections: **69** - `SKILL.md` files: **1150** - Cataloged agent tools: **335** ([`tools/CATALOG.md`](../tools/CATALOG.md)) ## Methodological rigor - Method families in the coverage map: **13** ([`RIGOR_COVERAGE.md`](RIGOR_COVERAGE.md)) - Eval scenarios: **26** (138 rubric items, 122 auto-checkable) ([`../eval-harness/`](../eval-harness/README.md)) - Benchmark tasks: **13** (70 gold checks, 58 required) ([`../benchmark/`](../benchmark/README.md)) ### Method families (skills tagged) - `iv`: 27 - `rdd`: 25 - `panel-fe`: 19 - `staggered-did`: 17 - `bayesian`: 13 - `did`: 10 - `event-study`: 10 - `matching`: 10 - `synthetic-control`: 10 - `cate`: 8 - `dml`: 8 - `survival`: 3 - `quantile`: 2 ### Eval scenarios by category - `causal-identification`: 14 - `citation-hygiene`: 1 - `reproducibility`: 2 - `research-integrity`: 1 - `runtime-safety`: 1 - `statistical-validity`: 2 - `writing-compliance`: 3 - `writing-style`: 2 ## License buckets - AGPL-3.0: 1 - Apache-2.0: 1 - CC-BY-NC-4.0 (non-commercial): 1 - CC-BY-SA-4.0: 1 - CC-BY-SA-4.0 (repository default): 4 - GPL-3.0: 1 - MIT: 35 - MIT Non-Commercial: 1 - Mixed (per-skill; see folder): 2 - UNKNOWN - check upstream: 22 ## Quality gates - `make check` — catalog/provenance/audit/eval freshness, repo hygiene, Paper-WorkFlow gates, stdlib unit tests, eval-harness lint + graded smoke, and the strict numeric benchmark (reference-gold drift fails the build). - External links and OpenSSF Scorecard run on their scheduled workflows.

当前收录版本

0.0.1

核对来源版本 ↗

质量评测

满分 100。前四项来自 DeepSkill 收录的质量报告。

场景价值85/100
评分依据

解决 Quarto 文档中 LaTeX 遗留语法的自动化清理问题,提升多格式(HTML/PDF/Word)渲染兼容性

触发精准90/100
评分依据

触发描述清晰完整,覆盖多种用户意图(clean, fix, modernize, port)和典型故障场景(渲染失败、LaTeX 命令残留)

结构规范95/100
评分依据

结构完整,包含输入参数、分步工作流、转换参考、示例和注意事项

执行可靠90/100
评分依据

强调保护代码块、数学公式等关键区域,避免误修改

证据可验 (前四项均值)90/100
计算方式

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

文档引用的域名或地址

这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。

  • ...

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

risk · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。

来源与使用声明 SkillPi 的部分技能资料来自公开来源或创作者提交。第三方内容的权利归各自权利人所有。安装或运行前,请查看原站的许可、权限要求和使用风险。

来源与使用

请按详情页的作者、原始来源和许可证核对使用条件,运行前检查技能需要的权限。目录收录不等于已验证安装或安全性。