mirror of
https://github.com/typst/typst
synced 2025-05-14 17:15:28 +08:00
Add non-breaking space 🔒
This commit is contained in:
parent
696560622d
commit
d0e252d116
@ -104,7 +104,17 @@ impl Parser<'_> {
|
|||||||
self.with_span(SyntaxNode::Code(Code { lang, lines, block }))
|
self.with_span(SyntaxNode::Code(Code { lang, lines, block }))
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Text(text) => self.with_span(SyntaxNode::Text(text.to_string())),
|
Token::Text(text) => {
|
||||||
|
let mut text_s = String::with_capacity(text.len());
|
||||||
|
let mut iter = text.chars();
|
||||||
|
while let Some(c) = iter.next() {
|
||||||
|
match c {
|
||||||
|
'~' => text_s.push('\u{00A0}'),
|
||||||
|
_ => text_s.push(c),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.with_span(SyntaxNode::Text(text_s.to_string()))
|
||||||
|
},
|
||||||
|
|
||||||
Token::UnicodeEscape { sequence, terminated } => {
|
Token::UnicodeEscape { sequence, terminated } => {
|
||||||
if !terminated {
|
if !terminated {
|
||||||
@ -1006,6 +1016,7 @@ mod tests {
|
|||||||
t!("*hi" => B, T("hi"));
|
t!("*hi" => B, T("hi"));
|
||||||
t!("hi_" => T("hi"), I);
|
t!("hi_" => T("hi"), I);
|
||||||
t!("hi you" => T("hi"), S, T("you"));
|
t!("hi you" => T("hi"), S, T("you"));
|
||||||
|
t!("special~name" => T("special\u{00A0}name"));
|
||||||
t!("\\u{1f303}" => T("🌃"));
|
t!("\\u{1f303}" => T("🌃"));
|
||||||
t!("\n\n\nhello" => P, T("hello"));
|
t!("\n\n\nhello" => P, T("hello"));
|
||||||
t!(r"a\ b" => T("a"), L, S, T("b"));
|
t!(r"a\ b" => T("a"), L, S, T("b"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user