-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
f161fd9
commit 84761e2
Showing
7 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/QuartoNotebookWorker/ext/QuartoNotebookWorkerLaTeXStringsExt.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module QuartoNotebookWorkerLaTeXStringsExt | ||
|
||
import QuartoNotebookWorker as QNW | ||
import LaTeXStrings as LS | ||
|
||
QNW._mimetype_wrapper(s::LS.LaTeXString) = LaTeXStringWrapper(s) | ||
|
||
struct LaTeXStringWrapper <: QNW.WrapperType | ||
value::LS.LaTeXString | ||
end | ||
|
||
Base.show(io::IO, ::MIME"text/markdown", s::LaTeXStringWrapper) = print(io, s.value) | ||
Base.showable(::MIME"text/markdown", ::LaTeXStringWrapper) = true | ||
|
||
end |
17 changes: 17 additions & 0 deletions
17
src/QuartoNotebookWorker/ext/QuartoNotebookWorkerSymPyCoreExt.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module QuartoNotebookWorkerSymPyCoreExt | ||
|
||
import QuartoNotebookWorker as QNW | ||
import SymPyCore as SPC | ||
|
||
QNW._mimetype_wrapper(s::SPC.SymbolicObject) = SymWrapper(s) | ||
QNW._mimetype_wrapper(s::AbstractArray{<:SPC.Sym}) = SymWrapper(s) | ||
QNW._mimetype_wrapper(s::Dict{T,S}) where {T<:SPC.SymbolicObject,S<:Any} = SymWrapper(s) | ||
|
||
struct SymWrapper <: QNW.WrapperType | ||
value::Any | ||
end | ||
|
||
Base.show(io::IO, ::MIME"text/markdown", s::SymWrapper) = show(io, "text/latex", s.value) | ||
Base.showable(::MIME"text/markdown", ::SymWrapper) = true | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
title: SymPy integration | ||
julia: | ||
exeflags: ["--project=SymPy"] | ||
--- | ||
|
||
```{julia} | ||
ENV["PYTHON"] = "" | ||
Pkg.build("PyCall") | ||
using SymPy | ||
``` | ||
|
||
```{julia} | ||
@syms x | ||
integrate(sin(x)*cos(x), x) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[deps] | ||
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" | ||
SymPy = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
include("../../utilities/prelude.jl") | ||
|
||
test_example(joinpath(@__DIR__, "../../examples/integrations/SymPy.qmd")) do json | ||
cells = json["cells"] | ||
cell = cells[4] | ||
output = cell["outputs"][1] | ||
|
||
@test output["data"]["text/markdown"] == raw"$\frac{\sin^{2}{\left(x \right)}}{2}$" | ||
@test output["data"]["text/latex"] == raw"$\frac{\sin^{2}{\left(x \right)}}{2}$" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters