@antora/document-converter 3.0.0-beta.4 → 3.0.0-rc.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/lib/convert-document.js +16 -17
- package/lib/convert-documents.js +6 -6
- package/package.json +6 -4
package/lib/convert-document.js
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
loadAsciiDoc: _loadAsciiDoc,
|
|
5
|
-
extractAsciiDocMetadata: _extractAsciiDocMetadata,
|
|
6
|
-
} = require('@antora/asciidoc-loader')
|
|
7
|
-
|
|
8
3
|
/**
|
|
9
4
|
* Converts the contents on the specified file from AsciiDoc to embedded HTML.
|
|
10
5
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* the
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* the mediaType property is updated to 'text/html'.
|
|
6
|
+
* This function first delegates to the AsciiDoc loader to load the AsciiDoc contents on the
|
|
7
|
+
* specified virtual file to a Document object. If the asciidoc property is not set on the virtual
|
|
8
|
+
* file, it then extracts the metadata from that document and assigns it to the asciidoc property.
|
|
9
|
+
* This metadata includes the document attributes, doctitle, xreftext, and navtitle. If the
|
|
10
|
+
* keepSource option on the AsciiDoc config is true or the page-partial attributes is set, it backs
|
|
11
|
+
* up the AsciiDoc source to the src.contents property. It then converts the Document to embedded
|
|
12
|
+
* HTML, wraps it in a Buffer, and assigns it to the contents property on the file. Finally, it
|
|
13
|
+
* updates the mediaType property on the file to 'text/html'.
|
|
20
14
|
*
|
|
21
15
|
* @memberof document-converter
|
|
22
16
|
*
|
|
@@ -27,9 +21,10 @@ const {
|
|
|
27
21
|
* @returns {File} The virtual file that was converted.
|
|
28
22
|
*/
|
|
29
23
|
function convertDocument (file, contentCatalog = undefined, asciidocConfig = {}) {
|
|
30
|
-
const {
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
const {
|
|
25
|
+
extractAsciiDocMetadata = requireAsciiDocLoader().extractAsciiDocMetadata,
|
|
26
|
+
loadAsciiDoc = requireAsciiDocLoader(),
|
|
27
|
+
} = this ? this.getFunctions(false) : {}
|
|
33
28
|
const doc = loadAsciiDoc(file, contentCatalog, asciidocConfig)
|
|
34
29
|
if (!file.asciidoc) {
|
|
35
30
|
file.asciidoc = extractAsciiDocMetadata(doc)
|
|
@@ -40,4 +35,8 @@ function convertDocument (file, contentCatalog = undefined, asciidocConfig = {})
|
|
|
40
35
|
return file
|
|
41
36
|
}
|
|
42
37
|
|
|
38
|
+
function requireAsciiDocLoader () {
|
|
39
|
+
return requireAsciiDocLoader.cache || (requireAsciiDocLoader.cache = require('@antora/asciidoc-loader'))
|
|
40
|
+
}
|
|
41
|
+
|
|
43
42
|
module.exports = convertDocument
|
package/lib/convert-documents.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const _convertDocument = require('./convert-document')
|
|
4
|
-
const {
|
|
5
|
-
loadAsciiDoc: _loadAsciiDoc,
|
|
6
|
-
extractAsciiDocMetadata: _extractAsciiDocMetadata,
|
|
7
|
-
} = require('@antora/asciidoc-loader')
|
|
8
4
|
|
|
9
5
|
/**
|
|
10
6
|
* Converts the contents of publishable pages with the media type text/asciidoc
|
|
@@ -31,8 +27,8 @@ const {
|
|
|
31
27
|
function convertDocuments (contentCatalog, siteAsciiDocConfig = {}) {
|
|
32
28
|
const {
|
|
33
29
|
convertDocument = _convertDocument,
|
|
34
|
-
extractAsciiDocMetadata =
|
|
35
|
-
loadAsciiDoc =
|
|
30
|
+
extractAsciiDocMetadata = requireAsciiDocLoader().extractAsciiDocMetadata,
|
|
31
|
+
loadAsciiDoc = requireAsciiDocLoader(),
|
|
36
32
|
} = this ? this.getFunctions(false) : {}
|
|
37
33
|
const mainAsciiDocConfigs = new Map()
|
|
38
34
|
contentCatalog.getComponents().forEach(({ name: component, versions }) => {
|
|
@@ -85,4 +81,8 @@ function registerPageAliases (aliases, targetFile, contentCatalog) {
|
|
|
85
81
|
.forEach((spec) => (spec = spec.trim()) && contentCatalog.registerPageAlias(spec, targetFile))
|
|
86
82
|
}
|
|
87
83
|
|
|
84
|
+
function requireAsciiDocLoader () {
|
|
85
|
+
return requireAsciiDocLoader.cache || (requireAsciiDocLoader.cache = require('@antora/asciidoc-loader'))
|
|
86
|
+
}
|
|
87
|
+
|
|
88
88
|
module.exports = Object.assign(convertDocuments, { convertDocuments, convertDocument: _convertDocument })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antora/document-converter",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-rc.2",
|
|
4
4
|
"description": "Converts AsciiDoc documents to embeddable HTML for use in an Antora documentation pipeline.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"author": "OpenDevise Inc. (https://opendevise.com)",
|
|
@@ -16,8 +16,11 @@
|
|
|
16
16
|
"url": "https://gitlab.com/antora/antora/issues"
|
|
17
17
|
},
|
|
18
18
|
"main": "lib/index.js",
|
|
19
|
+
"scripts": {
|
|
20
|
+
"test": "_mocha"
|
|
21
|
+
},
|
|
19
22
|
"dependencies": {
|
|
20
|
-
"@antora/asciidoc-loader": "3.0.0-
|
|
23
|
+
"@antora/asciidoc-loader": "3.0.0-rc.2"
|
|
21
24
|
},
|
|
22
25
|
"engines": {
|
|
23
26
|
"node": ">=12.21.0"
|
|
@@ -35,6 +38,5 @@
|
|
|
35
38
|
"static site",
|
|
36
39
|
"web publishing"
|
|
37
40
|
],
|
|
38
|
-
"gitHead": "
|
|
39
|
-
"readmeFilename": "README.md"
|
|
41
|
+
"gitHead": "b64861391b7e55ea31fcecce4490b9cc02fec1c7"
|
|
40
42
|
}
|