`arc` + space + trig name is not merged
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/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ệ
- rust
- Lĩnh vực
- accessibility, testing
Hướng nghiên cứu
Start in src/canonicalize.rs at merge_arc_trig and read the existing canonicalization tests around clean_up_arc_lookalike_mrow. Run the proposed clean_up_arc_mspace case to check how the spaced MathML is canonicalized. Done means arc plus a space and trig name merges correctly while arc followed by a cosine function stays separate; the Spanish workaround in Rules/Languages/es/SharedRules/general.yaml can then be removed.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
babel (Spanish) writes \arcsen as arc\,sen, and arc\,cos gives the same in English:
<math><mi>arc</mi><mi>cos</mi><mi>x</mi></math>
<math><mi>arc</mi><mspace width="0.167em"/><mi>cos</mi><mspace width="0.167em"/><mi>x</mi></math>
- without space: arccos of x
- with space: arc of cosine x
merge_arc_trig runs while the mspace is still a sibling. Skipping whitespace before checking the next sibling should fix it. Spanish has a temporary rule for this in general.yaml (from #945), to be removed once fixed.
Proposed patch (tested: cargo test passes; adds the test clean_up_arc_mspace):
diff --git a/src/canonicalize.rs b/src/canonicalize.rs
index 00a5165b..4f34bfd8 100644
--- a/src/canonicalize.rs
+++ b/src/canonicalize.rs
@@ -1793,12 +1793,21 @@ impl CanonicalizeContext {
return None;
}
+ // skip whitespace between "arc" and the trig name (e.g., babel writes \arcsen as arc\,sen)
let following_siblings = leaf.following_siblings();
- if following_siblings.is_empty() {
- return None;
+ let mut whitespace = Vec::new();
+ let mut following_sibling = None;
+ for &child in &following_siblings {
+ let child = as_element(child);
+ let child_name = name(child);
+ if child_name == "mspace" || (child_name == "mtext" && as_text(child).trim().is_empty()) {
+ whitespace.push(child);
+ } else {
+ following_sibling = Some(child);
+ break;
+ }
}
-
- let following_sibling = as_element(following_siblings[0]);
+ let following_sibling = following_sibling?;
let following_sibling_name = name(following_sibling);
if !(following_sibling_name == "mi" || following_sibling_name == "mo" || following_sibling_name == "mtext") {
return None;
@@ -1811,6 +1820,7 @@ impl CanonicalizeContext {
let new_text = "arc".to_string() + as_str!(following_text);
set_mathml_name(leaf, "mi");
leaf.set_text(&new_text);
+ whitespace.iter().for_each(|ws| ws.remove_from_parent());
following_sibling.remove_from_parent();
return Some(leaf);
}
@@ -6207,6 +6217,14 @@ mod canonicalize_tests {
are_strs_canonically_equal_result(test_str, target_str, &[])
}
+ #[test]
+ fn clean_up_arc_mspace() -> Result<()> {
+ // babel writes \arcsen as arc\,sen
+ let test_str = "<math><mi>arc</mi><mspace width='0.167em'/><mi>cos</mi><mspace width='0.167em'/><mi>x</mi></math>";
+ let target_str = "<math><mrow data-changed='added'><mi>arccos</mi><mo data-changed='added'>⁡</mo><mi data-previous-space-width='0.167'>x</mi></mrow></math>";
+ are_strs_canonically_equal_result(test_str, target_str, &[])
+ }
+
#[test]
fn clean_up_arc_lookalike_mrow() -> Result<()> {
// Frown over two capital identifiers is rewritten to the arc operator (U+2312)
With this, the Spanish workaround in Rules/Languages/es/SharedRules/general.yaml (the three arc-trig-separado* rules) can be removed. I have that change ready too: one Spanish test changes a pause (arco tangente; → arco tangente,, now the same as arctg), and if the Spanish navigation PR is merged first, zoom_in_all_babel_arc should expect acercado al máximo; arco seno instead of …; arc.
- Ngôn ngữ chính
- Rust
- Star
- 130
- Fork
- 96
- Merge trung bình
- 1 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 84
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc 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 daisy/MathCAT
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
daisy/MathCAT#946 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
discussion
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Review French navigation fileĐang mởdiscussion translation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
daisy/MathCAT#675 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của daisy/MathCAT
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
quarto-dev/q2#1155 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backlog priority: low ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
storytold/vectorcraft#6445 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: cli kind:docs priority: P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
tursodatabase/libsql#2312 ·
Maintainer thường phản hồi trong vòng 11 ngày
-
`NodeOwned::size_in_bytes` does not count the `ChildrenNodesOwned` heap allocation (since #216)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
paritytech/trie#251 ·
Maintainer thường phản hồi trong vòng 1 ngày