Can Observable return the full HTML markup?

If I write this in VS Code (a notebook)

data1 = [[0, 80], [50, 20], [100, 50], [150, 30],
  [200, 40], [250, 90], [400, 20], [450, 70], [500, 60]];

line1 = d3.line()(data1)

const svgns = ''
  let svg ='#here')
    .attr('xmlns', svgns)
    .attr("viewBox", "0 0 1200 100");


The browser shows me the markup

<svg xmlns="" viewBox="0 0 1200 100">
  <path d="M0,80L50,20L100,50L150,30L200,40L250,90L400,20L450,70L500,60" stroke="black" fill="none" />

How can I ask Observable to return the completed HTML markup for me to inspect?

You’ll need to return something from your cell. Observable cells are similar to arrow functions. With just one expression you can leave off the return statement, but if you have curly braces around the contents, it needs a return.

@mythmon thanks.

But how do I implement this knowledge in my case and have the markup returned? I am new to observable.

You should name the cell that contains the DIV that contains your SVG. You can then call


To get the SVG element. If you want to see the textual form of that SVG, you could do


Here’s an implementation:

Note that creating an HTML cell containing a DIV with an ID and then selecting that DIV by ID is not recommended.

1 Like

Awesome - that’s what I need. Thanks !!!

1 Like