Skip to content

.to_html() method produces incorrectly formatted <div> element string for full_html=False option #2468

Closed
@tallamjr

Description

@tallamjr

When one invokes plotly.io.to_html(fig, include_plotlyjs=False, full_html=False) the following
example output is produced:

'<div>\n        \n        \n            <div id="8a9f01d7-9e37-401b-a602-15b3bbdac943"
class="plotly-graph-div" style="height:100%; width:100%;"></div>\n            <script
type="text/javascript">\n                \n                    window.PLOTLYENV=window.PLOTLYENV ||
{};\n                    \n                if
(document.getElementById("8a9f01d7-9e37-401b-a602-15b3bbdac943")) {\n
Plotly.newPlot(\n                        \'8a9f01d7-9e37-401b-a602-15b3bbdac943\',\n
...

Note the \n characters as well as a single quoted id.

The resulting <div> element appears like this when placed in a markdown document, i.e no plot
showing up:
image

Note I have ensured to include:

<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>

above the <div> element.

Removing the \n characters and replacing the single quoted id with double quotes seems to
resolve this issue.

See PR #2469

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions