mirror of
https://github.com/Garmelon/Arbeitszeitdokumentationsgenerator.git
synced 2026-04-12 08:45:05 +02:00
Fix string quoting
This commit is contained in:
parent
d918e3f724
commit
b14284b6ac
1 changed files with 12 additions and 2 deletions
|
|
@ -60,8 +60,18 @@ pub struct Timesheet {
|
|||
///////////////////////
|
||||
|
||||
fn fmt_str(s: &str) -> String {
|
||||
// https://github.com/typst/typst/blob/69dcc89d84176838c293b2d59747cd65e28843ad/crates/typst-syntax/src/ast.rs#L1041-L1082
|
||||
format!("\"{}\"", s.replace('\\', "\\\\"))
|
||||
// https://github.com/typst/typst/blob/v0.11.0/crates/typst-syntax/src/lexer.rs#L699-L713
|
||||
// https://github.com/typst/typst/blob/v0.11.0/crates/typst-syntax/src/ast.rs#L1041-L1082
|
||||
let quoted = s
|
||||
.chars()
|
||||
.map(|c| match c {
|
||||
'"' => "\\\"".to_string(),
|
||||
'\\' => "\\\\".to_string(),
|
||||
c => c.to_string(),
|
||||
})
|
||||
.collect::<String>();
|
||||
|
||||
format!("\"{}\"", quoted)
|
||||
}
|
||||
|
||||
fn fmt_int(n: u32) -> String {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue