How do I display "html" in Jupyter Notebook with Julia? I've tried searching for a package, but didn't find any specific.
You can just use the html
string macro!
Thanks, Mason. Any other way using a function? I'm writing a package, so I guess using a macro is not the best way. I'm trying to write a wrapper to plot visualizations with D3.js. Do you think that using the "html" macro would be adequate?
I'm not sure I understand the connection between not wanting to use a macro and developing a package
But to answer your question, yes there is a HTML
function that the html
string macro will use during parse time.
julia> HTML("hi") == html"hi"
true
But in case there's a confusion here, there is no reason not to use macros in package development. In many cases, a macro (when applicable) can be more efficient than a function, like with the regex string macros, because they allow the regex to be compiled at macroexpansion instead of at runtime
Thanks Mason! It was a thing I read somewhere. Although I probably misinterpreted.
Probably the advice you heard was that many users first learning about metaprogramming overuse it, and that beginners should not be encouraged to create their own macros
I think that while it's true that many new metaprogrammers will overdo it, I think that's a good thing! Doing something a lot (even when it's not necessary) is the fastest way to learn how to do something well.
@Davi Sales Barreira If your string needs to be informed by the Julia processing context, you might also want to look at HypertextLiteral.jl
@Clark C. Evans that's an awesome package! Thanks for pointing out.
Last updated: Dec 28 2024 at 04:38 UTC