Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
highlight-html-syntax
Advanced tools
Install the package from NPM:
$ npm install --save highlight-html-syntax
Import the CSS for highlighting:
@import 'node_modules/highlight-html-syntax/syntax.css'
Require the Highlight package in your project:
var Highlight = require('highlight-html-syntax')
Then use it in your code!
var html = '<p>hello world!</p>';
var result = Highlight(html);
console.log(result);
/* <span class="method"><p</span>
<span class="method">></span>
hello world!
<span class="method"></p</span>
<span class="method">></span> */
In your frontend:
var code = document.getElementById('code').value;
var syntax = Highlight(code);
var result = document.getElementById('result');
result.innerText = syntax;
This HTML code
<form>
<input type="text" placeholder="John Doe"/>
</form>
Turns into ->
<span class="method"><form<span class="method">></span></span> <span class="global">
<span class="method"><input</span> type=<span class="string">"text"</span> placeholder</span>=<span class="string">"John Doe"</span><span class="method">/></span>
<span class="method"></form<span class="method">></span></span>
Which looks like this
FAQs
Simple Syntax Highlighter for HTML code
We found that highlight-html-syntax demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.