Repository navigation
sync: dev to extern-contrib - #1032
Conversation
…-copy fix: preserve problem Markdown and add full-statement copying
Deploying xmoj-script-dev-channel with
|
| Latest commit: |
973262c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://737e1453.xmoj-script-dev-channel.pages.dev |
Reviewer's GuideThis synchronization adds a reusable, language-aware Markdown-copy pipeline that extracts math source, preserves code and table structure, and exposes full-statement and section-level controls across modern and legacy problem pages. It also adds extensive Playwright browser regression tests, updates CI to provision Chromium, and bumps the release metadata. Sequence diagram for language-aware Markdown copyingsequenceDiagram
actor User
participant Button as Copy button
participant Init as InitializeProblemMarkdownCopy
participant Markdown as GetProblemStatementMarkdown
participant Section as GetProblemSectionMarkdown
participant Text as GetMDText
participant Clipboard as GM_setClipboard
User->>Button: Click copy
Button->>Markdown: Build statement Markdown
Markdown->>Section: Extract problem sections
Section->>Text: Convert section content
Text-->>Section: Markdown with math, code, and tables
Section-->>Markdown: Section Markdown
Markdown-->>Button: Complete Markdown
Button->>Clipboard: GM_setClipboard(markdown)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="XMOJ.user.js" line_range="7948-7950" />
<code_context>
+ for (const child of body.children) Visit(child);
+ content = parts.join("\n\n");
+ } else {
+ const translated = body.querySelector(language === "en" ? ".content.lang_en" : ".content.lang_cn");
+ const fallback = body.querySelector(".content.lang_cn") || body.querySelector(".content");
+ content = GetMDText(translated || fallback || body).trim();
}
+ return content ? "## " + heading + "\n\n" + content : "";
+}
</code_context>
<issue_to_address>
**issue (bug_risk):** When English is selected but a section has no `.content.lang_en`, `translated` is null and the fallback explicitly selects `.content.lang_cn`, so the copied English statement contains Chinese content for that section.
**Triggers:** When a bilingual problem has an English title or other English sections but one section lacks an English translation.
**Suggested fix:** For `language === "en"`, omit the section or use an unlabelled content fallback before falling back to Chinese; do not silently copy `.content.lang_cn`.
```suggestion
const translated = body.querySelector(language === "en" ? ".content.lang_en" : ".content.lang_cn");
const fallback = language === "en"
? body.querySelector(".content:not(.lang_en):not(.lang_cn)")
: body.querySelector(".content.lang_cn") || body.querySelector(".content");
content = translated || fallback ? GetMDText(translated || fallback).trim() : "";
```
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: XMOJ.user.js:7950
| const translated = body.querySelector(language === "en" ? ".content.lang_en" : ".content.lang_cn"); | ||
| const fallback = body.querySelector(".content.lang_cn") || body.querySelector(".content"); | ||
| content = GetMDText(translated || fallback || body).trim(); |
There was a problem hiding this comment.
issue (bug_risk): When English is selected but a section has no .content.lang_en, translated is null and the fallback explicitly selects .content.lang_cn, so the copied English statement contains Chinese content for that section.
Triggers: When a bilingual problem has an English title or other English sections but one section lacks an English translation.
Suggested fix: For language === "en", omit the section or use an unlabelled content fallback before falling back to Chinese; do not silently copy .content.lang_cn.
| const translated = body.querySelector(language === "en" ? ".content.lang_en" : ".content.lang_cn"); | |
| const fallback = body.querySelector(".content.lang_cn") || body.querySelector(".content"); | |
| content = GetMDText(translated || fallback || body).trim(); | |
| const translated = body.querySelector(language === "en" ? ".content.lang_en" : ".content.lang_cn"); | |
| const fallback = language === "en" | |
| ? body.querySelector(".content:not(.lang_en):not(.lang_cn)") | |
| : body.querySelector(".content.lang_cn") || body.querySelector(".content"); | |
| content = translated || fallback ? GetMDText(translated || fallback).trim() : ""; |
Update to release 3.8.0
sync-branches: New code has just landed in dev, so let's bring extern-contrib up to speed!
Summary by Sourcery
Improve problem-statement Markdown copying while preserving source formatting and add comprehensive browser regression coverage.
New Features:
Bug Fixes:
Enhancements:
CI:
Tests:
Chores:
Summary by cubic
Syncs
devintoextern-contrib, bringing the 3.8.0 release: it restores the userscript on pages broken by recent layout changes, makes copy controls work on the new/web/contestpages, and adds problem Markdown copying that preserves TeX math source, code fence language, table layout, and link destinations.TypeErroron abnormal pages and reuses the copy controls across the new and legacy contest pages.Update.json.Written for commit 973262c. Summary will update on new commits.