highlight-html-syntax
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "highlight-html-syntax", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Syntax Highlighter for HTML code", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,1 +0,68 @@ | ||
# highlight-syntax | ||
# highlight-html-syntax | ||
Install the package from NPM: | ||
```node | ||
$ npm install --save highlight-html-syntax | ||
``` | ||
Import the CSS for highlighting: | ||
```css | ||
@import 'node_modules/highlight-html-syntax/syntax.css' | ||
``` | ||
Require the Highlight package in your project: | ||
```javascript | ||
var Highlight = require('highlight-html-syntax') | ||
``` | ||
Then use it in your code! | ||
```javascript | ||
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> */ | ||
``` | ||
<h1> EXAMPLE </h1> | ||
In your frontend: | ||
```javascript | ||
var code = document.getElementById('code').value; | ||
var syntax = Highlight(code); | ||
var result = document.getElementById('result'); | ||
result.innerText = syntax; | ||
``` | ||
This HTML code | ||
```html | ||
<form> | ||
<input type="text" placeholder="John Doe"/> | ||
</form> | ||
``` | ||
Turns into -> | ||
```code | ||
<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 | ||
<link rel="stylesheet" href="./syntax.css"> | ||
<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> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
5753
5
27
69
0