diff --git a/.eleventy.js b/.eleventy.js
index c8c787b..3af4272 100644
--- a/.eleventy.js
+++ b/.eleventy.js
@@ -1,59 +1,78 @@
const pkg = require("./package.json");
-const Prism = require("prismjs");
const hasTemplateFormat = require("./src/hasTemplateFormat");
const HighlightPairedShortcode = require("./src/HighlightPairedShortcode");
const LiquidHighlightTag = require("./src/LiquidHighlightTag");
-const CharacterWrap = require("./src/CharacterWrap");
+// const CharacterWrap = require("./src/CharacterWrap");
const markdownPrismJs = require("./src/markdownSyntaxHighlightOptions");
module.exports = {
- initArguments: { Prism },
- configFunction: function(eleventyConfig, options = {}) {
+ // initArguments: { Prism },
+ configFunction: function (eleventyConfig, options = {}) {
try {
eleventyConfig.versionCheck(pkg["11ty"].compatibility);
- } catch(e) {
- console.log( `WARN: Eleventy Plugin (${pkg.name}) Compatibility: ${e.message}` );
+ } catch (e) {
+ console.log(
+ `WARN: Eleventy Plugin (${pkg.name}) Compatibility: ${e.message}`
+ );
}
- options = Object.assign({
- alwaysWrapLineHighlights: false,
- // eligible to change the default to \n in a new major version.
- lineSeparator: "
",
- preAttributes: {},
- codeAttributes: {}
- }, options);
+ options = Object.assign(
+ {
+ theme: "onedark",
+ lineNumbers: false,
+ /* lineNumbersStyle: "table",*/ /* "table" or "inline" */
+ alwaysWrapLineHighlights: false,
+ // eligible to change the default to \n in a new major version.
+ lineSeparator: "
",
+ preAttributes: {},
+ codeAttributes: {
+ theme: "onedark",
+ },
+ },
+ options
+ );
- // TODO hbs?
- if( hasTemplateFormat(options.templateFormats, "liquid") ) {
+ if (hasTemplateFormat(options.templateFormats, "liquid")) {
eleventyConfig.addLiquidTag("highlight", (liquidEngine) => {
- // {% highlight js 0 2 %}
+ // {% highlight js 0,2 %}
let highlight = new LiquidHighlightTag(liquidEngine);
return highlight.getObject(options);
});
}
- if( hasTemplateFormat(options.templateFormats, "njk") ) {
- eleventyConfig.addPairedNunjucksShortcode("highlight", (content, args) => {
- // {% highlight "js 0 2-3" %}
- let [language, ...highlightNumbers] = args.split(" ");
- return HighlightPairedShortcode(content, language, highlightNumbers.join(" "), options);
- });
+ if (hasTemplateFormat(options.templateFormats, "njk")) {
+ eleventyConfig.addPairedNunjucksShortcode(
+ "highlight",
+ (content, args) => {
+ // {% highlight "js 0,2-3" %}
+ return HighlightPairedShortcode(content, args, options);
+ }
+ );
}
- if( hasTemplateFormat(options.templateFormats, "md") ) {
+ if (hasTemplateFormat(options.templateFormats, "md")) {
// ```js/0,2-3
eleventyConfig.addMarkdownHighlighter(markdownPrismJs(options));
}
- if( hasTemplateFormat(options.templateFormats, "11ty.js") ) {
- eleventyConfig.addJavaScriptFunction("highlight", (language, content, highlight1, highlight2) => {
- let highlightLines = [highlight1, highlight2].filter(entry => entry).join(" ");
- let result = HighlightPairedShortcode(content, language, highlightLines, options);
- return result;
- });
- }
- }
+ // if (hasTemplateFormat(options.templateFormats, "11ty.js")) {
+ // eleventyConfig.addJavaScriptFunction(
+ // "highlight",
+ // (language, content, highlight1, highlight2) => {
+ // let highlightLines = [highlight1, highlight2]
+ // .filter((entry) => entry)
+ // .join(" ");
+ // let result = HighlightPairedShortcode(
+ // content,
+ // args,
+ // options
+ // );
+ // return result;
+ // }
+ // );
+ // }
+ },
};
module.exports.pairedShortcode = HighlightPairedShortcode;
-module.exports.CharacterWrap = CharacterWrap;
+// module.exports.CharacterWrap = CharacterWrap;
diff --git a/README.md b/README.md
index c55781d..7ee7470 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,41 @@