Repository: plotly/plotly.py

Issue:
`.to_html()` method produces incorrectly formatted `<div>` element string for `full_html=False` option
When one invokes `plotly.io.to_html(fig, include_plotlyjs=False, full_html=False)` the following
example output is produced:

```bash
'<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](https://user-images.githubusercontent.com/8843728/81926539-035c2100-95da-11ea-91ad-01510ea5e0dc.png)

**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 



Discussion:

Resolving patch:
diff --git a/packages/python/plotly/plotly/io/_html.py b/packages/python/plotly/plotly/io/_html.py
--- a/packages/python/plotly/plotly/io/_html.py
+++ b/packages/python/plotly/plotly/io/_html.py
@@ -230,14 +230,14 @@ def to_html(
     # Serialize config dict to JSON
     jconfig = json.dumps(config)
 
-    script = """
-                if (document.getElementById("{id}")) {{
-                    Plotly.newPlot(
-                        '{id}',
-                        {data},
-                        {layout},
-                        {config}
-                    ){then_addframes}{then_animate}{then_post_script}
+    script = """\
+                if (document.getElementById("{id}")) {{\
+                    Plotly.newPlot(\
+                        "{id}",\
+                        {data},\
+                        {layout},\
+                        {config}\
+                    ){then_addframes}{then_animate}{then_post_script}\
                 }}""".format(
         id=plotdivid,
         data=jdata,
@@ -333,25 +333,24 @@ def to_html(
 Invalid value of type {typ} received as the include_mathjax argument
     Received value: {val}
 
-include_mathjax may be specified as False, 'cdn', or a string ending with '.js' 
+include_mathjax may be specified as False, 'cdn', or a string ending with '.js'
     """.format(
                 typ=type(include_mathjax), val=repr(include_mathjax)
             )
         )
 
     plotly_html_div = """\
-<div>
-        {mathjax_script}
-        {load_plotlyjs}
-            <div id="{id}" class="plotly-graph-div" \
-style="height:{height}; width:{width};"></div>
-            <script type="text/javascript">
-                {require_start}
-                    window.PLOTLYENV=window.PLOTLYENV || {{}};{base_url_line}
-                    {script};
-                {require_end}
-            </script>
-        </div>""".format(
+        <div>\
+            {mathjax_script}\
+            {load_plotlyjs}\
+                <div id="{id}" class="plotly-graph-div" \
+                    style="height:{height}; width:{width};">\
+                </div>\
+                <script type="text/javascript">\
+                    {require_start}window.PLOTLYENV=window.PLOTLYENV || {{}};{base_url_line}{script};{require_end}\
+                </script>\
+        </div>\
+        """.format(
         mathjax_script=mathjax_script,
         load_plotlyjs=load_plotlyjs,
         id=plotdivid,
@@ -361,7 +360,7 @@ def to_html(
         require_start=require_start,
         script=script,
         require_end=require_end,
-    )
+    ).strip()
 
     if full_html:
         return """\


Test patch: