Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetching output of display #255

Open
gbruer15 opened this issue Sep 18, 2024 · 2 comments · May be fixed by #256
Open

Fetching output of display #255

gbruer15 opened this issue Sep 18, 2024 · 2 comments · May be fixed by #256

Comments

@gbruer15
Copy link
Contributor

gbruer15 commented Sep 18, 2024

I have some display() calls in my code, but it seems they're not showing up in the generated markdown.

#128 marks this as fixed, but perhaps it only fixed it for the notebook output.

@fredrikekre This was fixed for notebooks in ceff7a3 and a TODO was added for markdown. Would the fix for markdown be similar to the notebook fix? Or is it more complicated? If it's straightforward, I can make a PR with the changes for markdown.

@fredrikekre
Copy link
Owner

Do you have a MWE?

@gbruer15
Copy link
Contributor Author

Here is a minimum example.

$ cat example.jl
struct DF x end
Base.show(io::IO, ::MIME"text/plain", df::DF) = print(io, "DF($(df.x)) as text/plain")
Base.show(io::IO, ::MIME"text/html", df::DF) = print(io, "DF($(df.x)) as text/html")
Base.show(io::IO, ::MIME"text/latex", df::DF) = print(io, "DF($(df.x)) as text/latex")
#-
foreach(display, [DF(1), DF(2)])
DF(3)
#-
display(MIME("text/latex"), DF(4))
$ julia example.jl 
DF(1) as text/plain
DF(2) as text/plain
DF(4) as text/latex
$ julia --project=. -e 'import Literate; Literate.markdown("example.jl", "mfe"; execute=true)'
[ Info: generating markdown page from `~/a/curr_research/Literate.jl/example.jl`
[ Info: writing result to `~/a/curr_research/Literate.jl/mfe/example.md`
$ cat mfe/example.md 
```@meta
EditURL = "../example.jl"
```

````julia
struct DF x end
Base.show(io::IO, ::MIME"text/plain", df::DF) = print(io, "DF($(df.x)) as text/plain")
Base.show(io::IO, ::MIME"text/html", df::DF) = print(io, "DF($(df.x)) as text/html")
Base.show(io::IO, ::MIME"text/latex", df::DF) = print(io, "DF($(df.x)) as text/latex")
````

````julia
foreach(display, [DF(1), DF(2)])
DF(3)
````

```@raw html
DF(3) as text/html
```

````julia
display(MIME("text/latex"), DF(4))
````

---

*This page was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*

@gbruer15 gbruer15 linked a pull request Sep 18, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants