Skip to content

Commit

Permalink
fix(#230): fix dict parsing by manually getting document content in s…
Browse files Browse the repository at this point in the history
…pan so quotes aren't escaped
  • Loading branch information
grantlemons committed Dec 9, 2024
1 parent 24e0551 commit c63d41a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions harper-core/src/parsers/typst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,10 @@ fn map_token(
constant_token!(doc, float, TokenKind::Number(float.get().into(), None))
}
Expr::Numeric(a) => constant_token!(doc, a, TokenKind::Unlintable),
Expr::Str(text) => parse_english(text.get(), doc, parser, &text.span()),
Expr::Str(text) => {
// Using `text.get()` doesn't work here, because it escapes quotes
parse_english(doc.get(doc.range(text.span())?)?, doc, parser, &text.span())
}
Expr::Code(a) => constant_token!(doc, a, TokenKind::Unlintable),
Expr::Content(content_block) => {
recursive_env(&mut content_block.body().exprs(), doc, parser)
Expand Down Expand Up @@ -478,7 +481,7 @@ mod tests {
dbg!(typst_tree.exprs().collect_vec());

let charslice = source.chars().collect_vec();
assert_eq!(tokens[2].span.get_content_string(&charslice), "Typst");
assert_eq!(tokens[3].span.get_content_string(&charslice), "Typst");
assert!(matches!(
token_kinds.as_slice(),
&[
Expand Down

0 comments on commit c63d41a

Please sign in to comment.