- if(this.hasTagMismatch(line)) {
- return line;
- }
-
- return before + line + after;
- }
-
- getLineMarkup(lineNumber, line, extraClasses = []) {
- let extraClassesStr = (extraClasses.length ? " " + extraClasses.join(" ") : "");
-
- if (this.isHighlighted(lineNumber)) {
- return this.splitLineMarkup(line, ``);
- }
- if (this.isHighlightedAdd(lineNumber)) {
- return this.splitLineMarkup(line, ``);
- }
- if (this.isHighlightedRemove(lineNumber)) {
- return this.splitLineMarkup(line, ``);
- }
-
- return this.splitLineMarkup( line, ``);
- }
-}
-
-module.exports = HighlightLinesGroup;
diff --git a/src/PrismLoader.js b/src/PrismLoader.js
deleted file mode 100644
index a3515a2..0000000
--- a/src/PrismLoader.js
+++ /dev/null
@@ -1,42 +0,0 @@
-const Prism = require("prismjs");
-const PrismLoader = require("prismjs/components/index.js");
-// Avoid "Language does not exist: " console logs
-PrismLoader.silent = true;
-
-const PrismAlias = require("./PrismNormalizeAlias");
-
-module.exports = function(language) {
- let diffRemovedRawName = language;
- if(language.startsWith("diff-")) {
- diffRemovedRawName = language.substr("diff-".length);
- }
- // aliasing should ignore diff-
- let aliasedName = PrismAlias(diffRemovedRawName);
-
- if(!Prism.languages[ aliasedName ]) {
- PrismLoader(aliasedName);
- }
- if(!Prism.languages[ aliasedName ]) {
- throw new Error(`"${language}" is not a valid Prism.js language for eleventy-plugin-syntaxhighlight`);
- }
-
- if(!language.startsWith("diff-")) {
- return Prism.languages[ aliasedName ];
- }
-
- // language has diff- prefix
- let fullLanguageName = `diff-${aliasedName}`;
-
- if(!Prism.languages.diff) {
- PrismLoader("diff");
- // Bundled Plugin
- require("prismjs/plugins/diff-highlight/prism-diff-highlight");
- }
-
- // Store into with aliased keys
- // ts -> diff-typescript
- // js -> diff-javascript
- Prism.languages[ fullLanguageName ] = Prism.languages.diff;
-
- return Prism.languages[ fullLanguageName ];
-};
diff --git a/src/PrismNormalizeAlias.js b/src/PrismNormalizeAlias.js
deleted file mode 100644
index 40e9bb3..0000000
--- a/src/PrismNormalizeAlias.js
+++ /dev/null
@@ -1,42 +0,0 @@
-const Prism = require("prismjs");
-
-const HARDCODED_ALIASES = {
- njk: "jinja2",
- nunjucks: "jinja2",
-};
-
-// This was added to make `ts` resolve to `typescript` correctly.
-// The Prism loader doesn’t seem to always handle aliasing correctly.
-module.exports = function(language) {
- try {
- // Careful this is not public API stuff:
- // https://github.com/PrismJS/prism/issues/2146
- const PrismComponents = require("prismjs/components.json");
- let langs = PrismComponents.languages;
-
- // Manual override
- if(HARDCODED_ALIASES[language]) {
- language = HARDCODED_ALIASES[language];
- }
-
- if(langs[ language ]) {
- return language;
- }
- for(let langName in langs) {
- if(Array.isArray(langs[langName].alias)) {
- for(let alias of langs[langName].alias) {
- if(alias === language) {
- return langName;
- }
- }
- } else if(langs[langName].alias === language) {
- return langName;
- }
- }
- } catch(e) {
- // Couldn’t find the components file, aliases may not resolve correctly
- // See https://github.com/11ty/eleventy-plugin-syntaxhighlight/issues/19
- }
-
- return language;
-}
diff --git a/src/getAttributes.js b/src/getAttributes.js
deleted file mode 100644
index 603c6a5..0000000
--- a/src/getAttributes.js
+++ /dev/null
@@ -1,62 +0,0 @@
-function attributeEntryToString(attribute, context) {
- let [key, value] = attribute;
-
- if (typeof value === "function") { // Callback must return a string or a number
- value = value(context); // Run the provided callback and store the result
- }
-
- if (typeof value !== "string" && typeof value !== "number") {
- throw new Error(
- `Attribute "${key}" must have, or evaluate to, a value of type string or number, not "${typeof value}".`
- );
- }
-
- return `${key}="${value}"`;
-}
-
-/**
- * ## Usage
- * The function `getAttributes` is used to convert an object, `attributes`, with HTML attributes as keys and the values as the corresponding HTML attribute's values.
- * If it is falsey, an empty string will be returned.
- *
- * ```js
- getAttributes({
- tabindex: 0,
- 'data-language': function (context) { return context.language; },
- 'data-otherStuff': 'value'
- }) // => ' tabindex="0" data-language="JavaScript" data-otherStuff="value"'
- ```
- *
- * @param {{[s: string]: string | number}} attributes An object with key-value pairs that represent attributes.
- * @param {object} context An object with the current context.
- * @param {string} context.content The code to parse and highlight.
- * @param {string} context.language The language for the current instance.
- * @param {object} context.options The options passed to the syntax highlighter.
- * @returns {string} A string containing the above HTML attributes preceded by a single space.
- */
-function getAttributes(attributes, context = {}) {
- let langClass = context.language ? `language-${context.language}` : "";
-
- if (!attributes) {
- return langClass ? ` class="${langClass}"` : "";
- } else if (typeof attributes === "object") {
- if(!("class" in attributes) && langClass) {
- // class attribute should be first in order
- let tempAttrs = { class: langClass };
- for(let key in attributes) {
- tempAttrs[key] = attributes[key];
- }
- attributes = tempAttrs;
- }
-
- const formattedAttributes = Object.entries(attributes).map(
- entry => attributeEntryToString(entry, context)
- );
-
- return formattedAttributes.length ? ` ${formattedAttributes.join(" ")}` : "";
- } else if (typeof attributes === "string") {
- throw new Error("Syntax highlighter plugin custom attributes on and must be an object. Received: " + JSON.stringify(attributes));
- }
-}
-
-module.exports = getAttributes;