Skip to content

Commit

Permalink
Add and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolaru committed Apr 22, 2024
1 parent c879c8b commit ba8e043
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions reference/references.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ inputs["integrals"] = [
L"\int \int \int"
]

input["linebreaks"] = [
L"we clearly see $x = 22$\\and $y > x^2$"
]

inputs["punctuation"] = [
L"x!",
L"23.17",
Expand Down
8 changes: 7 additions & 1 deletion src/parser/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,5 +203,11 @@ function texparse(tex ; root = TeXExpr(:lines), showdebug = false)
if length(stack) > 1
throw(TeXParseError("unexpected end of input", stack, length(tex), tex))
end
return only(stack)

lines = only(stack)
if length(lines.args) == 1
return only(lines.args)
else
return lines
end
end
8 changes: 7 additions & 1 deletion test/parser.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function test_parse(input, args... ; broken=false)
arg = (:expr, args...)
arg = (:line, args...)
if broken
@test_broken texparse(input) == manual_texexpr(arg)
else
Expand Down Expand Up @@ -114,6 +114,12 @@ end
)
end

@testset "Linebreak" begin
expr = texparse(L"$A$\\$B$\\$C$")
@test expr.head == :lines
@test length(expr.args) == 3
end

@testset "LaTeXString input" begin
@test texparse(raw"$\gamma$") == texparse(L"\gamma")
end
Expand Down

0 comments on commit ba8e043

Please sign in to comment.