@asciidoctor/core 4.0.0-alpha.1 → 4.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/browser/index.js +14 -12
- package/build/node/index.cjs +14 -12
- package/package.json +9 -4
- package/src/abstract_block.js +11 -3
- package/src/converter/html5.js +2 -8
- package/types/abstract_block.d.ts +5 -2
- package/types/index.d.cts +75 -0
package/build/browser/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var version = "4.0.0-alpha.
|
|
1
|
+
var version = "4.0.0-alpha.2";
|
|
2
2
|
const packageJson = {
|
|
3
3
|
version: version};
|
|
4
4
|
|
|
@@ -3743,7 +3743,7 @@ class AbstractBlock extends AbstractNode {
|
|
|
3743
3743
|
* - `'reject'` → skip the node and its children
|
|
3744
3744
|
* - `'stop'` → include the node (if it matched) and stop the entire traversal
|
|
3745
3745
|
*
|
|
3746
|
-
* @param {Object} [selector={}] - Selector criteria object
|
|
3746
|
+
* @param {Object|Function} [selector={}] - Selector criteria object, or a filter callback when called as `findBy(callback)`.
|
|
3747
3747
|
* @param {Function|null} [filter=null] - Per-node filter callback.
|
|
3748
3748
|
* @returns {AbstractBlock[]} array of matching block-level nodes.
|
|
3749
3749
|
*
|
|
@@ -3758,6 +3758,9 @@ class AbstractBlock extends AbstractNode {
|
|
|
3758
3758
|
*
|
|
3759
3759
|
* @example <caption>All image blocks including those inside AsciiDoc table cells</caption>
|
|
3760
3760
|
* const images = doc.findBy({ context: 'image', traverseDocuments: true })
|
|
3761
|
+
*
|
|
3762
|
+
* @example <caption>Filter-only shorthand (no selector)</caption>
|
|
3763
|
+
* const verbatim = doc.findBy((b) => b.contentModel === ContentModel.VERBATIM)
|
|
3761
3764
|
*/
|
|
3762
3765
|
findBy(selector = {}, filter = null) {
|
|
3763
3766
|
const result = [];
|
|
@@ -3766,8 +3769,13 @@ class AbstractBlock extends AbstractNode {
|
|
|
3766
3769
|
selector && typeof selector === 'object' && !Array.isArray(selector)
|
|
3767
3770
|
? selector
|
|
3768
3771
|
: {};
|
|
3769
|
-
// Normalise:
|
|
3770
|
-
const normFilter =
|
|
3772
|
+
// Normalise: support findBy(callback) shorthand — selector is the filter when it's a function.
|
|
3773
|
+
const normFilter =
|
|
3774
|
+
typeof filter === 'function'
|
|
3775
|
+
? filter
|
|
3776
|
+
: typeof selector === 'function'
|
|
3777
|
+
? selector
|
|
3778
|
+
: null;
|
|
3771
3779
|
try {
|
|
3772
3780
|
this.#findByInternal(normSelector, result, normFilter);
|
|
3773
3781
|
} catch (e) {
|
|
@@ -20967,10 +20975,7 @@ ${await node.content()}
|
|
|
20967
20975
|
img =
|
|
20968
20976
|
(await this.readSvgContents(node, target)) ||
|
|
20969
20977
|
`<span class="alt">${node.getAlt()}</span>`;
|
|
20970
|
-
} else if (
|
|
20971
|
-
node.hasOption('interactive') &&
|
|
20972
|
-
node.document.safe >= SafeMode.SERVER
|
|
20973
|
-
) {
|
|
20978
|
+
} else if (node.hasOption('interactive')) {
|
|
20974
20979
|
const fallback = node.hasAttribute('fallback')
|
|
20975
20980
|
? `<img src="${await node.imageUri(node.getAttribute('fallback'))}" alt="${this._encodeAttrValue(node.getAlt())}"${widthAttr}${heightAttr}${slash}>`
|
|
20976
20981
|
: `<span class="alt">${node.getAlt()}</span>`;
|
|
@@ -21811,10 +21816,7 @@ Your browser does not support the video tag.
|
|
|
21811
21816
|
img =
|
|
21812
21817
|
(await this.readSvgContents(node, target)) ||
|
|
21813
21818
|
`<span class="alt">${node.getAlt()}</span>`;
|
|
21814
|
-
} else if (
|
|
21815
|
-
node.hasOption('interactive') &&
|
|
21816
|
-
node.document.safe >= SafeMode.SERVER
|
|
21817
|
-
) {
|
|
21819
|
+
} else if (node.hasOption('interactive')) {
|
|
21818
21820
|
const fallback = node.hasAttribute('fallback')
|
|
21819
21821
|
? `<img src="${await node.imageUri(node.getAttribute('fallback'))}" alt="${this._encodeAttrValue(node.getAlt())}"${attrs}${this._voidSlash}>`
|
|
21820
21822
|
: `<span class="alt">${node.getAlt()}</span>`;
|
package/build/node/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@ const node_fs = require('node:fs');
|
|
|
5
5
|
const path = require('node:path');
|
|
6
6
|
|
|
7
7
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
8
|
-
var version = "4.0.0-alpha.
|
|
8
|
+
var version = "4.0.0-alpha.2";
|
|
9
9
|
const packageJson = {
|
|
10
10
|
version: version};
|
|
11
11
|
|
|
@@ -3750,7 +3750,7 @@ class AbstractBlock extends AbstractNode {
|
|
|
3750
3750
|
* - `'reject'` → skip the node and its children
|
|
3751
3751
|
* - `'stop'` → include the node (if it matched) and stop the entire traversal
|
|
3752
3752
|
*
|
|
3753
|
-
* @param {Object} [selector={}] - Selector criteria object
|
|
3753
|
+
* @param {Object|Function} [selector={}] - Selector criteria object, or a filter callback when called as `findBy(callback)`.
|
|
3754
3754
|
* @param {Function|null} [filter=null] - Per-node filter callback.
|
|
3755
3755
|
* @returns {AbstractBlock[]} array of matching block-level nodes.
|
|
3756
3756
|
*
|
|
@@ -3765,6 +3765,9 @@ class AbstractBlock extends AbstractNode {
|
|
|
3765
3765
|
*
|
|
3766
3766
|
* @example <caption>All image blocks including those inside AsciiDoc table cells</caption>
|
|
3767
3767
|
* const images = doc.findBy({ context: 'image', traverseDocuments: true })
|
|
3768
|
+
*
|
|
3769
|
+
* @example <caption>Filter-only shorthand (no selector)</caption>
|
|
3770
|
+
* const verbatim = doc.findBy((b) => b.contentModel === ContentModel.VERBATIM)
|
|
3768
3771
|
*/
|
|
3769
3772
|
findBy(selector = {}, filter = null) {
|
|
3770
3773
|
const result = [];
|
|
@@ -3773,8 +3776,13 @@ class AbstractBlock extends AbstractNode {
|
|
|
3773
3776
|
selector && typeof selector === 'object' && !Array.isArray(selector)
|
|
3774
3777
|
? selector
|
|
3775
3778
|
: {};
|
|
3776
|
-
// Normalise:
|
|
3777
|
-
const normFilter =
|
|
3779
|
+
// Normalise: support findBy(callback) shorthand — selector is the filter when it's a function.
|
|
3780
|
+
const normFilter =
|
|
3781
|
+
typeof filter === 'function'
|
|
3782
|
+
? filter
|
|
3783
|
+
: typeof selector === 'function'
|
|
3784
|
+
? selector
|
|
3785
|
+
: null;
|
|
3778
3786
|
try {
|
|
3779
3787
|
this.#findByInternal(normSelector, result, normFilter);
|
|
3780
3788
|
} catch (e) {
|
|
@@ -21038,10 +21046,7 @@ ${await node.content()}
|
|
|
21038
21046
|
img =
|
|
21039
21047
|
(await this.readSvgContents(node, target)) ||
|
|
21040
21048
|
`<span class="alt">${node.getAlt()}</span>`;
|
|
21041
|
-
} else if (
|
|
21042
|
-
node.hasOption('interactive') &&
|
|
21043
|
-
node.document.safe >= SafeMode.SERVER
|
|
21044
|
-
) {
|
|
21049
|
+
} else if (node.hasOption('interactive')) {
|
|
21045
21050
|
const fallback = node.hasAttribute('fallback')
|
|
21046
21051
|
? `<img src="${await node.imageUri(node.getAttribute('fallback'))}" alt="${this._encodeAttrValue(node.getAlt())}"${widthAttr}${heightAttr}${slash}>`
|
|
21047
21052
|
: `<span class="alt">${node.getAlt()}</span>`;
|
|
@@ -21882,10 +21887,7 @@ Your browser does not support the video tag.
|
|
|
21882
21887
|
img =
|
|
21883
21888
|
(await this.readSvgContents(node, target)) ||
|
|
21884
21889
|
`<span class="alt">${node.getAlt()}</span>`;
|
|
21885
|
-
} else if (
|
|
21886
|
-
node.hasOption('interactive') &&
|
|
21887
|
-
node.document.safe >= SafeMode.SERVER
|
|
21888
|
-
) {
|
|
21890
|
+
} else if (node.hasOption('interactive')) {
|
|
21889
21891
|
const fallback = node.hasAttribute('fallback')
|
|
21890
21892
|
? `<img src="${await node.imageUri(node.getAttribute('fallback'))}" alt="${this._encodeAttrValue(node.getAlt())}"${attrs}${this._voidSlash}>`
|
|
21891
21893
|
: `<span class="alt">${node.getAlt()}</span>`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asciidoctor/core",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.2",
|
|
4
4
|
"description": "Asciidoctor.js: AsciiDoc in JavaScript powered by Asciidoctor",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/node/index.cjs",
|
|
@@ -9,9 +9,14 @@
|
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"browser": "./build/browser/index.js",
|
|
12
|
-
"require":
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
"require": {
|
|
13
|
+
"types": "./types/index.d.cts",
|
|
14
|
+
"default": "./build/node/index.cjs"
|
|
15
|
+
},
|
|
16
|
+
"import": {
|
|
17
|
+
"types": "./types/index.d.ts",
|
|
18
|
+
"default": "./src/index.js"
|
|
19
|
+
}
|
|
15
20
|
}
|
|
16
21
|
},
|
|
17
22
|
"engines": {
|
package/src/abstract_block.js
CHANGED
|
@@ -502,7 +502,7 @@ export class AbstractBlock extends AbstractNode {
|
|
|
502
502
|
* - `'reject'` → skip the node and its children
|
|
503
503
|
* - `'stop'` → include the node (if it matched) and stop the entire traversal
|
|
504
504
|
*
|
|
505
|
-
* @param {Object} [selector={}] - Selector criteria object
|
|
505
|
+
* @param {Object|Function} [selector={}] - Selector criteria object, or a filter callback when called as `findBy(callback)`.
|
|
506
506
|
* @param {Function|null} [filter=null] - Per-node filter callback.
|
|
507
507
|
* @returns {AbstractBlock[]} array of matching block-level nodes.
|
|
508
508
|
*
|
|
@@ -517,6 +517,9 @@ export class AbstractBlock extends AbstractNode {
|
|
|
517
517
|
*
|
|
518
518
|
* @example <caption>All image blocks including those inside AsciiDoc table cells</caption>
|
|
519
519
|
* const images = doc.findBy({ context: 'image', traverseDocuments: true })
|
|
520
|
+
*
|
|
521
|
+
* @example <caption>Filter-only shorthand (no selector)</caption>
|
|
522
|
+
* const verbatim = doc.findBy((b) => b.contentModel === ContentModel.VERBATIM)
|
|
520
523
|
*/
|
|
521
524
|
findBy(selector = {}, filter = null) {
|
|
522
525
|
const result = []
|
|
@@ -525,8 +528,13 @@ export class AbstractBlock extends AbstractNode {
|
|
|
525
528
|
selector && typeof selector === 'object' && !Array.isArray(selector)
|
|
526
529
|
? selector
|
|
527
530
|
: {}
|
|
528
|
-
// Normalise:
|
|
529
|
-
const normFilter =
|
|
531
|
+
// Normalise: support findBy(callback) shorthand — selector is the filter when it's a function.
|
|
532
|
+
const normFilter =
|
|
533
|
+
typeof filter === 'function'
|
|
534
|
+
? filter
|
|
535
|
+
: typeof selector === 'function'
|
|
536
|
+
? selector
|
|
537
|
+
: null
|
|
530
538
|
try {
|
|
531
539
|
this.#findByInternal(normSelector, result, normFilter)
|
|
532
540
|
} catch (e) {
|
package/src/converter/html5.js
CHANGED
|
@@ -840,10 +840,7 @@ ${await node.content()}
|
|
|
840
840
|
img =
|
|
841
841
|
(await this.readSvgContents(node, target)) ||
|
|
842
842
|
`<span class="alt">${node.getAlt()}</span>`
|
|
843
|
-
} else if (
|
|
844
|
-
node.hasOption('interactive') &&
|
|
845
|
-
node.document.safe >= SafeMode.SERVER
|
|
846
|
-
) {
|
|
843
|
+
} else if (node.hasOption('interactive')) {
|
|
847
844
|
const fallback = node.hasAttribute('fallback')
|
|
848
845
|
? `<img src="${await node.imageUri(node.getAttribute('fallback'))}" alt="${this._encodeAttrValue(node.getAlt())}"${widthAttr}${heightAttr}${slash}>`
|
|
849
846
|
: `<span class="alt">${node.getAlt()}</span>`
|
|
@@ -1684,10 +1681,7 @@ Your browser does not support the video tag.
|
|
|
1684
1681
|
img =
|
|
1685
1682
|
(await this.readSvgContents(node, target)) ||
|
|
1686
1683
|
`<span class="alt">${node.getAlt()}</span>`
|
|
1687
|
-
} else if (
|
|
1688
|
-
node.hasOption('interactive') &&
|
|
1689
|
-
node.document.safe >= SafeMode.SERVER
|
|
1690
|
-
) {
|
|
1684
|
+
} else if (node.hasOption('interactive')) {
|
|
1691
1685
|
const fallback = node.hasAttribute('fallback')
|
|
1692
1686
|
? `<img src="${await node.imageUri(node.getAttribute('fallback'))}" alt="${this._encodeAttrValue(node.getAlt())}"${attrs}${this._voidSlash}>`
|
|
1693
1687
|
: `<span class="alt">${node.getAlt()}</span>`
|
|
@@ -201,7 +201,7 @@ export abstract class AbstractBlock<TContent extends string | any[] = string> ex
|
|
|
201
201
|
* - `'reject'` → skip the node and its children
|
|
202
202
|
* - `'stop'` → include the node (if it matched) and stop the entire traversal
|
|
203
203
|
*
|
|
204
|
-
* @param {Object} [selector={}] - Selector criteria object
|
|
204
|
+
* @param {Object|Function} [selector={}] - Selector criteria object, or a filter callback when called as `findBy(callback)`.
|
|
205
205
|
* @param {Function|null} [filter=null] - Per-node filter callback.
|
|
206
206
|
* @returns {AbstractBlock[]} array of matching block-level nodes.
|
|
207
207
|
*
|
|
@@ -216,8 +216,11 @@ export abstract class AbstractBlock<TContent extends string | any[] = string> ex
|
|
|
216
216
|
*
|
|
217
217
|
* @example <caption>All image blocks including those inside AsciiDoc table cells</caption>
|
|
218
218
|
* const images = doc.findBy({ context: 'image', traverseDocuments: true })
|
|
219
|
+
*
|
|
220
|
+
* @example <caption>Filter-only shorthand (no selector)</caption>
|
|
221
|
+
* const verbatim = doc.findBy((b) => b.contentModel === ContentModel.VERBATIM)
|
|
219
222
|
*/
|
|
220
|
-
findBy(selector?: any, filter?: Function | null): AbstractBlock[];
|
|
223
|
+
findBy(selector?: any | Function, filter?: Function | null): AbstractBlock[];
|
|
221
224
|
/** Alias for {@link findBy}. */
|
|
222
225
|
query(selector?: {}, filter?: any): AbstractBlock<string>[];
|
|
223
226
|
/**
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* Get the version of Asciidoctor.js.
|
|
4
|
+
*
|
|
5
|
+
* @returns {string} - the version of Asciidoctor.js
|
|
6
|
+
*/
|
|
7
|
+
export function getVersion(): string;
|
|
8
|
+
/**
|
|
9
|
+
* Get Asciidoctor core version number.
|
|
10
|
+
*
|
|
11
|
+
* @returns {string} - the version of Asciidoctor core (Ruby)
|
|
12
|
+
*/
|
|
13
|
+
export function getCoreVersion(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Parse the AsciiDoc source input into a Document.
|
|
16
|
+
*
|
|
17
|
+
* @param {string|string[]|Buffer} input - the AsciiDoc source as a String, String Array, or Buffer
|
|
18
|
+
* @param {Object} [options={}] - a plain object of options to control processing
|
|
19
|
+
* @returns {Promise<Document>} - the parsed Document
|
|
20
|
+
*/
|
|
21
|
+
export function load(input: string | string[] | Buffer, options?: any): Promise<Document>;
|
|
22
|
+
/**
|
|
23
|
+
* Parse the contents of the AsciiDoc source file into a Document.
|
|
24
|
+
*
|
|
25
|
+
* @param {string} filename - the path to the AsciiDoc source file
|
|
26
|
+
* @param {Object} [options={}] - a plain object of options to control processing
|
|
27
|
+
* @returns {Promise<Document>} - the parsed Document
|
|
28
|
+
*/
|
|
29
|
+
export function loadFile(filename: string, options?: any): Promise<Document>;
|
|
30
|
+
import { Document } from './document.js';
|
|
31
|
+
import { convert } from './convert.js';
|
|
32
|
+
import { convertFile } from './convert.js';
|
|
33
|
+
import { DocumentTitle } from './document.js';
|
|
34
|
+
import { Author } from './document.js';
|
|
35
|
+
import { Footnote } from './document.js';
|
|
36
|
+
import { ImageReference } from './document.js';
|
|
37
|
+
import { RevisionInfo } from './document.js';
|
|
38
|
+
import { Logger } from './logging.js';
|
|
39
|
+
import { AbstractNode } from './abstract_node.js';
|
|
40
|
+
import { AbstractBlock } from './abstract_block.js';
|
|
41
|
+
import { Inline } from './inline.js';
|
|
42
|
+
import { Block } from './block.js';
|
|
43
|
+
import { List } from './list.js';
|
|
44
|
+
import { ListItem } from './list.js';
|
|
45
|
+
import { Section } from './section.js';
|
|
46
|
+
import { Reader } from './reader.js';
|
|
47
|
+
import { SyntaxHighlighterBase } from './syntax_highlighter.js';
|
|
48
|
+
import { LoggerManager } from './logging.js';
|
|
49
|
+
import { MemoryLogger } from './logging.js';
|
|
50
|
+
import { NullLogger } from './logging.js';
|
|
51
|
+
import { SafeMode } from './constants.js';
|
|
52
|
+
import { ContentModel } from './constants.js';
|
|
53
|
+
import { Timings } from './timings.js';
|
|
54
|
+
import { Registry } from './extensions.js';
|
|
55
|
+
import { Processor } from './extensions.js';
|
|
56
|
+
import { ProcessorExtension } from './extensions.js';
|
|
57
|
+
import { Preprocessor } from './extensions.js';
|
|
58
|
+
import { TreeProcessor } from './extensions.js';
|
|
59
|
+
import { Postprocessor } from './extensions.js';
|
|
60
|
+
import { IncludeProcessor } from './extensions.js';
|
|
61
|
+
import { DocinfoProcessor } from './extensions.js';
|
|
62
|
+
import { BlockProcessor } from './extensions.js';
|
|
63
|
+
import { InlineMacroProcessor } from './extensions.js';
|
|
64
|
+
import { BlockMacroProcessor } from './extensions.js';
|
|
65
|
+
import { Extensions } from './extensions.js';
|
|
66
|
+
import { Cursor } from './reader.js';
|
|
67
|
+
import { Converter } from './converter.js';
|
|
68
|
+
import { ConverterBase } from './converter.js';
|
|
69
|
+
import { CustomFactory } from './converter.js';
|
|
70
|
+
import { DefaultFactory as DefaultConverterFactory } from './converter.js';
|
|
71
|
+
import { deriveBackendTraits } from './converter.js';
|
|
72
|
+
import { DefaultFactory as DefaultSyntaxHighlighterFactory } from './syntax_highlighter.js';
|
|
73
|
+
import Html5Converter from './converter/html5.js';
|
|
74
|
+
import { SyntaxHighlighter } from './syntax_highlighter.js';
|
|
75
|
+
export { convert, convertFile, Document, DocumentTitle, Author, Footnote, ImageReference, RevisionInfo, Logger, AbstractNode, AbstractBlock, Inline, Block, List, ListItem, Section, Reader, SyntaxHighlighterBase, LoggerManager, MemoryLogger, NullLogger, SafeMode, ContentModel, Timings, Registry, Processor, ProcessorExtension, Preprocessor, TreeProcessor, Postprocessor, IncludeProcessor, DocinfoProcessor, BlockProcessor, InlineMacroProcessor, BlockMacroProcessor, Extensions, Cursor, Converter as ConverterFactory, ConverterBase, CustomFactory as ConverterCustomFactory, DefaultConverterFactory, deriveBackendTraits, DefaultSyntaxHighlighterFactory, Html5Converter, SyntaxHighlighter };
|