Skip to content

Commit

Permalink
Don't insert an empty parameter when @typst_cmd has no parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobjpeters committed Jul 8, 2024
1 parent 22c3830 commit 5e79e69
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `$`
4 changes: 2 additions & 2 deletions src/Commands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

"""
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion test/TestCommands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/TestStrings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 5e79e69

Please sign in to comment.