asciidoctor-katex
Advanced tools
Comparing version 0.1.0 to 0.1.1
(function (Opal) { | ||
function initializeGeneratedCode () { | ||
function initialize (Opal) { | ||
/* Generated by Opal 0.11.1 */ | ||
@@ -17,3 +17,3 @@ Opal.modules["asciidoctor/katex/version"] = function(Opal) { | ||
Opal.const_set($nesting[0], 'VERSION', "0.1.0") | ||
Opal.const_set($nesting[0], 'VERSION', "0.1.1") | ||
})($nesting[0], $nesting) | ||
@@ -381,27 +381,25 @@ })($nesting[0], $nesting) | ||
var katexModule; | ||
var mainModule | ||
function resolveModule (name) { | ||
if (!katexModule) { | ||
initializeGeneratedCode(); | ||
katexModule = Opal.const_get_qualified(Opal.Asciidoctor, 'Katex'); | ||
if (!mainModule) { | ||
checkAsciidoctor() | ||
initialize(Opal) | ||
mainModule = Opal.const_get_qualified(Opal.Asciidoctor, 'Katex') | ||
} | ||
if (!name) { | ||
return katexModule | ||
return mainModule | ||
} | ||
return Opal.const_get_qualified(katexModule, name); | ||
return Opal.const_get_qualified(mainModule, name) | ||
} | ||
/** | ||
* @return {String} version of this extension. | ||
*/ | ||
function getVersion () { | ||
return resolveModule().$$const.VERSION.toString(); | ||
function checkAsciidoctor () { | ||
if (typeof Opal.Asciidoctor === 'undefined') { | ||
throw new TypeError('Asciidoctor.js is not loaded') | ||
} | ||
} | ||
/** | ||
* Creates and configures a new instance of Asciidoctor::Katex::Treeprocessor. | ||
* | ||
* @param {Object} opts | ||
* @param {Object} opts.katex The katex object to use for rendering. | ||
* @param opts.katex The katex object to use for rendering. | ||
* Defaults to `require('katex')`. | ||
@@ -413,12 +411,12 @@ * @param {boolean} opts.requireStemAttr `true` to not process math expressions | ||
* Defaults to empty object. | ||
* @return {TreeProcessor} | ||
* @return A new instance of `Asciidoctor::Katex::Treeprocessor`. | ||
*/ | ||
function TreeProcessor (opts) { | ||
opts = opts || {}; | ||
opts = opts || {} | ||
var KatexAdapterClass = resolveModule('KatexAdapter'); | ||
var TreeprocessorClass = resolveModule('Treeprocessor'); | ||
var KatexAdapterClass = resolveModule('KatexAdapter') | ||
var TreeprocessorClass = resolveModule('Treeprocessor') | ||
var katex = opts.katex || require('katex'); | ||
var adapter = KatexAdapterClass.$new(Opal.hash(opts.katexOptions || {}), katex); | ||
var katex = opts.katex || require('katex') | ||
var adapter = KatexAdapterClass.$new(Opal.hash(opts.katexOptions || {}), katex) | ||
@@ -428,28 +426,40 @@ return TreeprocessorClass.$new(Opal.hash({ | ||
katex_renderer: adapter, | ||
})); | ||
})) | ||
} | ||
/** | ||
* @return {string} Version of this extension. | ||
*/ | ||
function getVersion () { | ||
return resolveModule().$$const.VERSION.toString(); | ||
} | ||
/** | ||
* Creates and configures the Katex extension and registers it into the given | ||
* extensions registry. | ||
* | ||
* @param {Object} registry The Asciidoctor extensions registry to register this | ||
* extension into. It should be `Asciidoctor().Extensions` or | ||
* `Asciidoctor.Extensions.create()`. | ||
* @param {Object} opts See {TreeProcessor}. | ||
* @return The given *registry*. | ||
* @param registry The Asciidoctor extensions registry to register this | ||
* extension into. Defaults to the global Asciidoctor registry. | ||
* @param {Object} opts See {TreeProcessor} (optional). | ||
* @throws {TypeError} if the *registry* is invalid or Asciidoctor.js is not loaded. | ||
*/ | ||
function register (registry, opts) { | ||
if (!registry) { | ||
checkAsciidoctor() | ||
registry = Opal.Asciidoctor.Extensions | ||
} | ||
var processor = TreeProcessor(opts); | ||
// global registry | ||
if (typeof registry.register === 'function') { | ||
registry.register(function () { | ||
this.treeProcessor(processor); | ||
this.treeProcessor(processor) | ||
}) | ||
// custom registry | ||
} else if (typeof registry.block === 'function') { | ||
registry.treeProcessor(processor); | ||
registry.treeProcessor(processor) | ||
} else { | ||
throw new TypeError('Invalid registry object'); | ||
throw new TypeError('Invalid registry object') | ||
} | ||
return registry; | ||
return registry | ||
} | ||
@@ -461,8 +471,8 @@ | ||
register: register, | ||
}; | ||
} | ||
if (typeof module !== 'undefined' && module.exports) { | ||
module.exports = facade; | ||
module.exports = facade | ||
} | ||
return facade; | ||
return facade | ||
})(Opal); |
{ | ||
"name": "asciidoctor-katex", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Asciidoctor extension that converts latexmath to HTML using KaTeX at build-time", | ||
@@ -33,6 +33,10 @@ "author": "Jakub Jirutka <jakub@jirutka.cz>", | ||
"dependencies": { | ||
"asciidoctor.js": "~1.5.6", | ||
"katex": "^0.9.0", | ||
"opal-runtime": "^1.0.3" | ||
"katex": "^0.9.0" | ||
}, | ||
"devDependencies": { | ||
"asciidoctor.js": "~1.5.6" | ||
}, | ||
"peerDependencies": { | ||
"asciidoctor.js": "~1.5.6" | ||
} | ||
} |
2
380
27034
1
4
- Removedasciidoctor.js@~1.5.6
- Removedopal-runtime@^1.0.3
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@7.1.3(transitive)
- Removedopal-runtime@1.0.14(transitive)
- Removedunxhr@1.0.1(transitive)