Example of embedding Markdown output in an SVG.
See foreignObject for more details.
license: mit |
Example of embedding Markdown output in an SVG.
See foreignObject for more details.
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<body> | |
<script src="//d3js.org/d3.v3.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/remarkable/1.7.1/remarkable.js"></script> | |
<script> | |
var svg = d3.select("body").append("svg") | |
.attr("width", 960) | |
.attr("height", 500); | |
var md = new Remarkable(); | |
var content = `# Title | |
Introductory **paragraph** goes _here_ | |
* item | |
* item | |
* item`; | |
svg.append("foreignObject") | |
.attr("width", 480) | |
.attr("height", 500) | |
.append("xhtml:body") | |
.style("font", "14px 'Helvetica Neue'") | |
.html(md.render(content)); | |
</script> |