Skip to content

Instantly share code, notes, and snippets.

@EfratVil EfratVil/index.html

Last active Jan 19, 2018
Embed
What would you like to do?
highlight.js

Using highlight.js

<html lang="en">
<head>
<meta charset="UTF-8" />
<title>highlight.js</title>
<script src="//d3js.org/d3.v4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.9.1/highlight.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.9.1/styles/default.min.css" rel="stylesheet" />
<script>hljs.initHighlightingOnLoad();</script>
<style>
#code1{ width: 300px;}
</style>
</head>
<body>
<div class="container">
<pre><code class="javascript" id="code1">
</code>
</pre>
</div>
<script type="text/javascript">
var data = [{ "id": 1, "name": "A", "size": 3 },
{ "id": 2, "name": "B", "size": 8 },
{ "id": 3, "name": "C", "size": 2 },
{ "id": 4, "name": "D", "size": 5 },
{ "id": 5, "name": "E", "size": 4 }
];
d3.select("#code1").html(JSON.stringify(data, false, 2));
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.