Skip to content

Commit 3ef6572

Browse files
authored
Merge pull request google#108 from google/test-backslashes
Test `extract_messages` with backslashes
2 parents 6812d57 + 1959ee5 commit 3ef6572

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

i18n-helpers/src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,24 @@ The document[^1] text.
10581058
);
10591059
}
10601060

1061+
#[test]
1062+
fn extract_messages_backslashes() {
1063+
// Demonstrate how a single backslash in the Markdown becomes
1064+
// a backslash-escaped backslash when we extract the text.
1065+
// This is consistent with the CommonMark spec:
1066+
// https://spec.commonmark.org/0.30/#backslash-escapes.
1067+
// However, it causes problems for LaTeX preprocessors:
1068+
// https://github.com/google/mdbook-i18n-helpers/issues/105.
1069+
assert_extract_messages(
1070+
r#"
1071+
$$
1072+
\sum_{n=1}^{\infty} 2^{-n} = 1
1073+
$$
1074+
"#,
1075+
vec![(2, r#"$$ \\sum\_{n=1}^{\infty} 2^{-n} = 1 $$"#)],
1076+
)
1077+
}
1078+
10611079
#[test]
10621080
fn test_is_comment_skip_directive_simple() {
10631081
assert_eq!(

0 commit comments

Comments
 (0)