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

Cannot do LaTeX or markdown in description of @NTBond #13

Open
dmetivie opened this issue May 30, 2023 · 3 comments
Open

Cannot do LaTeX or markdown in description of @NTBond #13

dmetivie opened this issue May 30, 2023 · 3 comments

Comments

@dmetivie
Copy link

I tried doing something like

using LaTeXStrings
@bind nt @NTBond L"f(x) = x" begin
	b = (md"*Bold* field", Slider(1:10))
end

or

using LaTeXStrings
@bind nt @NTBond md"f(x) = x" begin
	b = (md"*Bold* field", Slider(1:10))
end

either I get

UndefVarError: `@L_str` not defined

or

Failed to show value:
"Markdown.MD is not showable as text/javascript"

How can I get a fancy (non-basic string) in the title of my bond table?

@disberd
Copy link
Owner

disberd commented May 30, 2023

So while I thought I did support arbitrary descriptions, that is not working due to some implementation detail.
Unfortunately I don't have much time now for creating a fix PR, but you can very hackily put non-string values obtained via @htl or @md_str using the code example below:

# ╔═╡ eca4593d-e17d-4f68-ba58-3e052b95c895
macro NTBondHack(desc, block)
	desc = esc(desc)
	:(@NTBond($Bypass($desc), $block))
end

# ╔═╡ 83742bf5-900d-4fc1-9eae-e946908d64e4
struct Bypass
	content
end

# ╔═╡ b35b354f-d648-45c0-89df-b16e497af964
function Base.show(io::IO, ::MIME"text/javascript", o::Bypass) 
	write(io, "`")
	Base.show(io, MIME"text/html"(), o.content)
	write(io, "`")
end

# ╔═╡ e0f356ef-f0ba-4b6e-a939-13d62cf2b498
@bind bb @NTBondHack md"$f(x) = x$" begin
	b = (md"*Bold* field", Slider(1:10))
end

# ╔═╡ d5290c4e-f2de-4511-bc6a-1064980e9804
bb

I don't understand exactly why it still doesn't work with @L_str from LaTeXStrings though, but between md"" and htl you should probably get most of the things you want.
I defintely have to take this into account for the next version of the package

@dmetivie
Copy link
Author

Amazing! This works!

disberd added a commit that referenced this issue Jul 10, 2023
@disberd disberd reopened this Jul 10, 2023
@disberd
Copy link
Owner

disberd commented Jul 10, 2023

Reopening as the problem is still there, and I implemented an internal fix in commit #
b2c15fb as part of the new PR #18

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

No branches or pull requests

2 participants