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

Rendering HTML Ouput from @example block #1149

Closed
kiranshila opened this issue Oct 7, 2019 · 4 comments
Closed

Rendering HTML Ouput from @example block #1149

kiranshila opened this issue Oct 7, 2019 · 4 comments

Comments

@kiranshila
Copy link

I have a block of code that returns an HTML{String} object, but I can't seem to find a way to capture this outputted HTML into a @raw html context to render in the final document.

The reasoning for this is to include the fully interactive PlotlyJS graphs in my documentation. If there is another way to do this, I'd love to hear it.

Thanks!

@fredrikekre
Copy link
Member

Can you include an example?

@kiranshila
Copy link
Author

Ah, just figured it out. I need to include the framework somewhere as the exported html doesn't include a link to the plotly.js file. Is there a simple way to add frameworks to the entire document? If not, I can keep manually add <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>.

@mortenpi
Copy link
Member

mortenpi commented Oct 7, 2019

You could drop a copy of the .js file into docs/src and use HTML's assets keyword to include it.

@baggepinnen
Copy link
Contributor

baggepinnen commented Apr 3, 2020

I would be interested in learning how to display a html file generated by Plotly. The naive

savefig("fig.html"); nothing # hide

followed by

![](fig.html)

does not work for html. Could I somehow make use of the @raw block to display the figure?

EDIT:
Something like this appears to be working, I just need to figure out how to adjust the height properly

\```@raw html
<object type="text/html" data="fig.html" width="800px" height="800px"></object>
\```

According to https://stackoverflow.com/questions/18297567/height-attribute-is-not-working-as-expected-for-html-object-tag
a css file should be modified, but my zero experience with css is not helping me here..

EDIT2:
It works if the height is specified like this

\```@raw html
<object type="text/html" data="chirp_dists.html" style="width:100%;height:450px;"></object>
\```

a relative height like 100% does not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants