Menu

Code Snippet in HTML

 Times we need to snip some code into HTML. A few method we can use.

One is using gist.github.com login with you GitHub ID and create snippet. Copy script and add to HTML.

<body>
<script src="https://gist.github.com/username/f12ae1f2ds1f21ds2f1ds.js"></script>
</body>

Second is using highlight.js


<pre><code class="javascript">
$(document).ready(function() {
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
});
</code></pre>
<link href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/styles/default.min.css" rel="stylesheet"></link>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
view raw highlight-js.js hosted with ❤ by GitHub

No comments:

Post a Comment