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

Is it feasible to suppress the module name Main.Notebook? #143

Closed
MHellmund opened this issue May 31, 2024 · 3 comments · Fixed by #149
Closed

Is it feasible to suppress the module name Main.Notebook? #143

MHellmund opened this issue May 31, 2024 · 3 comments · Fixed by #149

Comments

@MHellmund
Copy link
Contributor

test.qmd:

---
engine: julia
format: pdf
---

```{julia}
struct M a::Int end
x = M(22)
print(x)
```

output test4.pdf or:

Main.Notebook.M(22)

Is it feasible to suppress the module name Main.Notebook?

@jkrumbiegel
Copy link
Collaborator

Ah that's interesting, seems that if you manually call print, you circumvent the mechanism we otherwise use, which prints with the :module context set to the current temporary module, to avoid these prefixes:

:module => NotebookState.notebook_module(),

@MHellmund
Copy link
Contributor Author

Indeed,

```{julia}
import QuartoNotebookWorker
Base.stdout = QuartoNotebookWorker.with_context(stdout)

struct M a::Int end
x = M(22)
print(x)
```

works as desired. But I'm not such a julia guru that I could assess all side effects of using this globally.

@MHellmund
Copy link
Contributor Author

Another remark:

# with this line:
Base.active_module()  = Main.Notebook
# this works, too:
@show x;     
dump(x)

see https://github.com/JuliaLang/julia/blob/master/base/show.jl#L516-L520 and
https://github.com/JuliaLang/julia/blob/master/base/show.jl#L3073-L3077

@MichaelHatherly MichaelHatherly linked a pull request Jun 11, 2024 that will close this issue
MichaelHatherly added a commit that referenced this issue Jun 13, 2024
* Fix #143, pass `:module` to `IOCapture.capture`

* Compat bound for `IOCapture`
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