Skip to content

Instantly share code, notes, and snippets.

@EfratVil
Last active January 19, 2018 14:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EfratVil/5491da82bda8d0673e4b18ef5140a2e4 to your computer and use it in GitHub Desktop.
Save EfratVil/5491da82bda8d0673e4b18ef5140a2e4 to your computer and use it in GitHub Desktop.
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