1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
(function (Opal) {
function initialize (Opal) {
//OPAL-GENERATED-CODE//
}
var mainModule
function resolveModule (name) {
if (!mainModule) {
checkAsciidoctor()
initialize(Opal)
mainModule = Opal.const_get_qualified(Opal.Asciidoctor, 'InterdocReftext')
}
if (!name) {
return mainModule
}
return Opal.const_get_qualified(mainModule, name)
}
function checkAsciidoctor () {
if (typeof Opal.Asciidoctor === 'undefined') {
throw new TypeError('Asciidoctor.js is not loaded')
}
}
/**
* @param {Object} opts
* @param {String[]} opts.asciidocExts AsciiDoc file extensions (e.g. `.adoc`).
* Default is `['.adoc', '.asciidoc', '.ad']`.
* @param {boolean} opts.raiseExceptions Whether to raise exceptions (`true`),
* or just log them (`false`). Default is `true`.
* @return A new instance of `Asciidoctor::InterdocReftext::Processor`.
*/
function TreeProcessor (opts) {
opts = opts || {}
var processor = resolveModule('Processor').$new(Opal.hash({
resolver_class: opts.resolverClass,
asciidoc_exts: opts.asciidocExts,
logger: opts.logger,
raise_exceptions: opts.raiseExceptions,
}))
processor.process = processor.$process
return processor
}
/**
* @return {string} Version of this extension.
*/
function getVersion () {
return resolveModule().$$const.VERSION.toString()
}
/**
* Creates and configures the Inter-doc Reference Text extension and registers
* it in the extensions 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)
})
// custom registry
} else if (typeof registry.block === 'function') {
registry.treeProcessor(processor)
} else {
throw new TypeError('Invalid registry object')
}
}
var facade = {
TreeProcessor: TreeProcessor,
getVersion: getVersion,
register: register,
}
if (typeof module !== 'undefined' && module.exports) {
module.exports = facade
}
return facade
})(Opal);
|