Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

code-line-numbers

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code-line-numbers - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

46

dist/code-line-numbers.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class CodeLineNumbers {
static addCodeLineNumbers(selector = CodeLineNumbers.DEFAULT_SELECTOR) {
let els = document.querySelectorAll(selector);
els.forEach(el => {
CodeLineNumbers.addLineNumbersTo(el);
});
var CodeLineNumbers = /** @class */ (function () {
function CodeLineNumbers() {
}
static addCodeLineNumbersOnLoad(selector = CodeLineNumbers.DEFAULT_SELECTOR) {
document.addEventListener("DOMContentLoaded", () => {
CodeLineNumbers.addCodeLineNumbers = function (selector) {
if (selector === void 0) { selector = CodeLineNumbers.DEFAULT_SELECTOR; }
var els = document.querySelectorAll(selector);
for (var i = 0; i < els.length; i++)
CodeLineNumbers.addLineNumbersTo(els[i]);
};
CodeLineNumbers.addCodeLineNumbersOnLoad = function (selector) {
if (selector === void 0) { selector = CodeLineNumbers.DEFAULT_SELECTOR; }
document.addEventListener("DOMContentLoaded", function () {
CodeLineNumbers.addCodeLineNumbers(selector);
});
}
static addLineNumbersTo(elCode) {
let lines = elCode.innerHTML.split("\n");
};
CodeLineNumbers.addLineNumbersTo = function (elCode) {
var lines = elCode.innerHTML.split("\n");
if (lines.length === 0 || (lines.length === 1 && lines[0].length === 0))
return;
let digitsCount = ("" + lines.length).length;
for (let n = 0; n < lines.length; n++) {
let numberWithZeros = "" + n;
var digitsCount = ("" + lines.length).length;
for (var n = 0; n < lines.length; n++) {
var numberWithZeros = "" + n;
if (numberWithZeros.length < digitsCount) {
let zeros = "";
for (let i = 0; i < digitsCount - numberWithZeros.length; i++)
var zeros = "";
for (var i = 0; i < digitsCount - numberWithZeros.length; i++)
zeros += "0";
numberWithZeros = `<span class="hljs-line-numbers__number__zeros">${zeros}</span>${n}`;
numberWithZeros = "<span class=\"hljs-line-numbers__number__zeros\">" + zeros + "</span>" + n;
}
lines[n] = `<span class="hljs-line-numbers__number">${numberWithZeros}</span>` + lines[n];
lines[n] = "<span class=\"hljs-line-numbers__number\">" + numberWithZeros + "</span>" + lines[n];
}
elCode.innerHTML = lines.join("\n");
}
}
CodeLineNumbers.DEFAULT_SELECTOR = "pre > code";
};
CodeLineNumbers.DEFAULT_SELECTOR = "pre > code";
return CodeLineNumbers;
}());
exports.CodeLineNumbers = CodeLineNumbers;
{
"name": "code-line-numbers",
"version": "0.0.2",
"version": "0.0.3",
"description": "Adding line numbers for code, HighLight.js is supported too",

@@ -5,0 +5,0 @@ "main": "./dist/code-line-numbers.js",

{
"compilerOptions": {
"target": "es2015",
"target": "es5",
"module": "commonjs",

@@ -5,0 +5,0 @@ "declaration": true,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc