mirror of
https://github.com/storytold/wordcraft.git
synced 2026-10-29 21:07:24 -06:00
LaTeX: a "[" after a line break or at the start of a list item stays text (#1099)
* Contributors: add Jason Brashear to people.toml * LaTeX: a "[" after a line break or at the start of a list item stays text
This commit is contained in:
@@ -72,3 +72,7 @@ sync_github_name = false
|
||||
real_name = "Manuel Carmona"
|
||||
display_name = "manucarcor"
|
||||
[people.odedigo]
|
||||
|
||||
[people.webdevtodayjason]
|
||||
display_name = "Jason Brashear"
|
||||
sync_github_name = false
|
||||
|
||||
@@ -416,6 +416,8 @@ pub fn escape_text(s: &str) -> String {
|
||||
'>' => o.push_str("\\textgreater{}"),
|
||||
'|' => o.push_str("\\textbar{}"),
|
||||
'\u{A0}' => o.push('~'),
|
||||
// An opening bracket here would become an optional item or line-break argument.
|
||||
'[' if !line_has_text => o.push_str("{[}"),
|
||||
// Keep TeX from joining `--`, ``` `` ``` and `''` into dashes and quotes.
|
||||
'-' if prev == '-' => o.push_str("{}-"),
|
||||
'`' => o.push_str("\\textasciigrave{}"),
|
||||
@@ -3029,6 +3031,15 @@ Caf\'e na\"ive \c{c}a \v{s}\'{e} and {\bfseries grouped bold} after.
|
||||
assert!(md.contains("π r^2"), "{md}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn leading_brackets_stay_text() {
|
||||
// `\item [x]` and `\\ [1]` would read the bracket as an optional argument.
|
||||
assert_eq!(escape_text("[x] a\n [1] b [c]"), "{[}x] a\\\\\n {[}1] b [c]");
|
||||
let doc = crate::markdown::import("- [x] done");
|
||||
let back = import(export(&doc).as_bytes());
|
||||
assert_eq!(back.plain_text(Default::default()), "[x] done");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn special_characters_round_trip() {
|
||||
let text = "50% of $5 & #1_a {b} ~c^ \\d <e> |f| -- ``g'' tab\there";
|
||||
|
||||
Reference in New Issue
Block a user