Handle empty expressions

finchie
Nov 11, 2023, 1:57 PM
I5IZPMTHBVJWTR4RWCNMD75E3FHAHN3KY4XQPKAEV72PCDNFDOLQC

Dependencies

  • [2] CQEA2ZDI Parse evaluated Typst code instead of AST
  • [3] BA5Y6VSE Output Rust code using `syn`
  • [4] YKL5NCLH Import items from `syn`
  • [5] 2N3KOCP7 Create MVP Pandoc->Rust compiler
  • [6] HEIF2O2E Migrate from `pandoc` to `typst` for AST processing
  • [7] GYTRFADR Support Typst subdirectories
  • [8] BSJYWOYS Implement MVP Typst embedding
  • [9] JCYJWUI3 Add support for various text formats

Change contents

  • replacement in docs/test.typ at line 1
    [3.242][3.0:15]()
    = Heading
    hello
    [3.242]
    #let add(x, y) = x + y
    Sum is #add(2, 3)
  • edit in crates/typser/src/lib.rs at line 16
    [3.402][3.424:457]()
    use typst::syntax::ast::AstNode;
  • replacement in crates/typser/src/lib.rs at line 321
    [3.2143][2.143:209]()
    fn typst_expr_to_xilem(value: &typst::eval::Value) -> syn::Expr {
    [3.2143]
    [2.209]
    fn typst_expr_to_xilem(value: &typst::eval::Value) -> Option<syn::Expr> {
  • replacement in crates/typser/src/lib.rs at line 323
    [2.227][2.227:319]()
    typst::eval::Value::Str(string) => syn::Expr::Lit(literal_string(string.as_str())),
    [2.227]
    [2.319]
    typst::eval::Value::Str(string) => Some(syn::Expr::Lit(literal_string(string.as_str()))),
  • replacement in crates/typser/src/lib.rs at line 325
    [2.369][2.369:510]()
    let supported_content = content::SupportedContent::downcast(content).unwrap();
    supported_content.to_xilem().unwrap()
    [2.369]
    [3.2211]
    dbg!(content);
    let supported_content = content::SupportedContent::downcast(content)?;
    Some(supported_content.to_xilem()?)
  • replacement in crates/typser/src/lib.rs at line 348
    [2.729][2.729:747]()
    panic!();
    [2.729]
    [2.747]
    dbg!(root);
    todo!();
  • edit in crates/typser/src/lib.rs at line 355
    [3.2389]
    [3.2389]
    // Remove any empty expressions (`None`)
    .filter_map(|expr| expr)
  • replacement in crates/typser/src/content.rs at line 16
    [2.3326][2.3326:3385]()
    if let Some(heading) = value.to::<HeadingElem>() {
    [2.3326]
    [2.3385]
    if value.is_empty() {
    None
    } else if let Some(heading) = value.to::<HeadingElem>() {
  • replacement in crates/typser/src/content.rs at line 26
    [2.3662][2.3662:3679]()
    None
    [2.3662]
    [2.3679]
    todo!()