From 5e79e6962cb3b5e540210164cdfa16d6d8baa3b6 Mon Sep 17 00:00:00 2001 From: Jakob Peters Date: Mon, 8 Jul 2024 03:50:50 -0700 Subject: [PATCH] Don't insert an empty parameter when `@typst_cmd` has no parameters --- NEWS.md | 1 + src/Commands.jl | 4 ++-- test/TestCommands.jl | 2 +- test/TestStrings.jl | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 1033ce6..068b6e5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -29,5 +29,6 @@ - No longer errors during interpolation when `TypstString` isn't loaded - Handle interpolation and escaped interpolation in the same manner as double quotation marks - `print` and `show` now correspond +- A `@typst_cmd` with no parameters no longer inserts an empty parameter - `AbstractFloat` values that satisfy `isinf` and `isnan` now correspond to `calc.inf` and `calc.nan`, respectively - `AbstractString` and `Text` no longer escape `$` diff --git a/src/Commands.jl b/src/Commands.jl index afca341..2a7ea34 100644 --- a/src/Commands.jl +++ b/src/Commands.jl @@ -114,7 +114,7 @@ typst`compile input.typ output.typ` ``` """ macro typst_cmd(parameters) - :(TypstCommand(map(string, split($parameters, " ")))) + :(TypstCommand($(isempty(parameters) ? String[] : map(string, split(parameters, " "))))) end """ @@ -455,7 +455,7 @@ Print a [`TypstError`](@ref) when failing to [`run`](@ref) a [`TypstCommand`](@r ```jldoctest julia> showerror(stdout, TypstError(typst``)) -TypstError: failed to `run` a `TypstCommand([""])` +TypstError: failed to `run` a `TypstCommand(String[])` ``` """ showerror(io::IO, te::TypstError) = print(io, diff --git a/test/TestCommands.jl b/test/TestCommands.jl index 8555942..e96b2ef 100644 --- a/test/TestCommands.jl +++ b/test/TestCommands.jl @@ -5,7 +5,7 @@ using Test: @test, @testset, @test_throws, @test_warn using Typstry const tc = typst`help` -const tc_error = typst`` +const tc_error = typst`a` const tc_ignorestatus = ignorestatus(tc_error) @testset "`Typstry`" begin diff --git a/test/TestStrings.jl b/test/TestStrings.jl index 05cc909..e6624b7 100644 --- a/test/TestStrings.jl +++ b/test/TestStrings.jl @@ -8,6 +8,7 @@ using Typstry # TODO: test characters with multiple codeunits # TODO: test string escaping in `@typst_str`, `show`, `print`, `regex`, `TypstText`, etc +# TODO: remove unnesessary methods (`IOBuffer`, `codeunit`, `pointer`)? struct X end