Repository navigation
fix: preserve problem Markdown and add full-statement copying - #1031
Conversation
Reviewer's GuideUpdates Markdown extraction to recover source TeX from KaTeX and both legacy/current MathJax representations, preserve paragraph spacing, hard breaks, and preformatted whitespace without mutating the DOM, and adds ten browser regressions plus version metadata updates. Flow diagram for Markdown copy extractionflowchart TD
A[Contest content element] --> B[GetMDText]
B --> C[Collect MathJax expressions]
C --> D{Math source available}
D -->|MathJax| E[AppendMath with source and display delimiters]
D -->|KaTeX annotation| E
D -->|No| F[Traverse DOM nodes]
F --> G{Node formatting}
G -->|BR| H[Append hard break or preformatted newline]
G -->|Block| I[Append paragraph or list spacing]
G -->|PRE| J[Preserve whitespace]
G -->|Other text| K[Append text content]
E --> L[Markdown result]
H --> L
I --> L
J --> L
K --> L
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Deploying xmoj-script-dev-channel with
|
| Latest commit: |
461e353
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://70a97966.xmoj-script-dev-channel.pages.dev |
| Branch Preview URL: | https://codex-fix-1030-markdown-copy.xmoj-script-dev-channel.pages.dev |
bcbf199 to
b2a7504
Compare
b2a7504 to
ddad45a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 32945a4e16
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
All reported issues were addressed
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.
Re-trigger cubic
|
@boomzero TeX 好了但是换行还是坏的 |
Working on it |
|
#1011 too |
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Sourcery withdrew this approval because it has stopped reviewing this pull request.
|
Sourcery has withdrawn its approval of this pull request. It auto-reviews a pull request 5 times, and this push is past that limit, so the approval no longer reflects code Sourcery has read. Comment |
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
|
Works in my tests. |
zsTree0830
left a comment
There was a problem hiding this comment.
我说真的
这个还是坏的:
## 样例输入输出
### 样例输入 #1
```plain
3
2 5
3 10
1 5
```
### 样例输出 #1
```plain
19
```
### 样例说明 #1
一开始的状况是:
人 123
123 座位
第一秒,每个人向右移动一个位置,$3$ 到了自己的座位 $1$。然后 $3$ 要花 $5$ 秒放行李,$1$ 和 $2$ 跟着等待。
人 12
123 座位
之后 $1$ 和 $2$ 花 $3$ 秒同时移动到自己的座位,分别要花 $5$ 秒和 $10$ 秒放行李,总共放行李的时间是 $10$ 秒。
总时间是:$1+5+3+10=19$ 秒。
代码块没有了
还有每段之间多了一个换行
除了第一段,其他段的段首都多了一个 Tab
|
@zsTree0830 前面漏看了你这条正式 review,抱歉。你指出的三个问题已在 e37be7b 中处理:
新增了按你贴出的登机样例构造的回归用例,同时验证「样例输入输出」和整题复制按钮。旧实现能重现多余换行和 Tab;修复后 35 个浏览器用例全部通过。另用脚本已有的 Marked 4.3.0 渲染复制结果,确认得到 4 个代码块,两幅座位图内容完全保留,说明段落没有额外空行或段首 Tab。请用最新提交复测原题。 |
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
|
@zsTree0830 表格已在 9dd0add 中处理。之前确实只是把单元格连接成 Tab 分隔文本,粘贴后不会渲染成表格。 现在有表头的普通表格会生成 Markdown 表格,保留列对齐,单元格内的换行用 新增并更新了表格回归用例,同时检查分节复制和整题复制。全部 43 个浏览器用例通过;另用 Marked 4.3.0 渲染 13 个表格示例,验证了行列、竖线、公式、单元格换行、合并/嵌套表格和代码块空白。请用最新提交复测。 |
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
What does this PR aim to accomplish?:
Fix copied problem Markdown losing TeX expressions and paragraph/line breaks, and add the requested section, sample, and full-statement copying controls. Closes #1030. Closes #1011.
How does this PR accomplish the above?:
##heading.#title, ordered section headings, numbered sample headings andplaincode fences, sample explanations, data ranges and hints. Omit absent/empty sections and preserve sample whitespace.npm testand the Test workflow. Playwright remains test tooling; no userscript runtime dependency is added.Validation:
node --check XMOJ.user.jsandgit diff --checkpassed.npm test: all 15 Node test entries passed, including 44 browser fixture cases, the existing contest tests, and missing/duplicate extraction-anchor checks.npm install,npx playwright install chromium, andnpm test.XMOJ_CHROMIUMcan select an existing Chromium executable.By submitting this pull request, I confirm the following:
dev.Summary by Sourcery
Preserve formulas and Markdown formatting when copying content from contest problem and solution pages.
Bug Fixes:
Enhancements:
CI:
Tests:
Chores:
Summary by cubic
Preserves TeX source and Markdown formatting when copying contest problem and solution content, and adds copy buttons for full statements, titled sections, and samples. Closes #1030 and #1011.
preandcodeclasses and outlast backtick runs in the source.#and##headings, numbered samples withplainfences, explanations, ranges, and hints, omitting empty sections.npm testand the Test workflow, and bumps the version to 3.7.2.Written for commit 461e353. Summary will update on new commits.