@antora/epub-extension 1.0.0-beta.1
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/README.md +30 -0
- package/lib/converter.js +29 -0
- package/lib/index.js +15 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Antora EPUB Extension
|
|
2
|
+
|
|
3
|
+
The Antora EPUB extension is an Antora extension and exporter for Assembler.
|
|
4
|
+
It configures and invokes Assembler and it provides the converter function and metadata that Assembler uses to export content to the EPUB format (specifically EPUB3).
|
|
5
|
+
This extension is the official extension for exporting content in an Antora site to EPUB.
|
|
6
|
+
|
|
7
|
+
This extension first delegates to Assembler, passing it the converter metadata, to construct assembly files from pages per component version using the navigation as a model.
|
|
8
|
+
Assembler then iterates over those assembly files and, using the converter provided by this extension, converts them to EPUB using Asciidoctor EPUB3 (or the specified command).
|
|
9
|
+
Finally, Assembler adds those EPUBs to the content catalog as exports, which Antora then publishes alongside the other files in the site.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Once this package is installed in the playbook project, register it in the Antora playbook as follows:
|
|
14
|
+
|
|
15
|
+
**antora-playbook.yml**
|
|
16
|
+
|
|
17
|
+
```yaml
|
|
18
|
+
antora:
|
|
19
|
+
extensions:
|
|
20
|
+
- '@antora/epub-extension'
|
|
21
|
+
# ...
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
You can configure the behavior of the extension using the optional _antora-assembler.yml_ file.
|
|
25
|
+
|
|
26
|
+
## Copyright and License
|
|
27
|
+
|
|
28
|
+
Copyright (C) 2022-present by OpenDevise Inc. and the individual contributors of this project.
|
|
29
|
+
|
|
30
|
+
Use of this software is granted under the terms of the [Mozilla Public License Version 2.0](https://www.mozilla.org/en-US/MPL/2.0/) (MPL-2.0).
|
package/lib/converter.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const fsp = require('node:fs/promises')
|
|
4
|
+
const ospath = require('node:path')
|
|
5
|
+
|
|
6
|
+
const DEFAULT_COMMAND = 'asciidoctor-epub3'
|
|
7
|
+
|
|
8
|
+
async function convert (runCommand, file, convertAttributes, buildConfig) {
|
|
9
|
+
const { cwd = process.cwd(), command = await getDefaultCommand(cwd) } = buildConfig
|
|
10
|
+
const args = convertAttributes.toArgs('-a', command).concat('-o', convertAttributes.outfile, '-')
|
|
11
|
+
await runCommand(command, args, { parse: true, cwd, stdin: file.contents, stdout: 'print', stderr: 'print' })
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function getDefaultCommand (cwd) {
|
|
15
|
+
return fsp.access(ospath.join(cwd, 'Gemfile.lock')).then(
|
|
16
|
+
() => `bundle exec ${DEFAULT_COMMAND}`,
|
|
17
|
+
() => DEFAULT_COMMAND
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = {
|
|
22
|
+
bind (thisArg, runCommand) {
|
|
23
|
+
return Object.assign({}, this, { convert: convert.bind(thisArg, runCommand) })
|
|
24
|
+
},
|
|
25
|
+
convert,
|
|
26
|
+
backend: 'epub3',
|
|
27
|
+
extname: '.epub',
|
|
28
|
+
mediaType: 'application/epub+zip',
|
|
29
|
+
}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const converter = require('./converter')
|
|
4
|
+
const runCommand = require('@antora/run-command-helper')
|
|
5
|
+
|
|
6
|
+
module.exports.register = function ({ config }, providers) {
|
|
7
|
+
requireAssembler(this).configure(this, converter.bind(this, runCommand), config, providers)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function requireAssembler (context, packageName = '@antora/assembler') {
|
|
11
|
+
try {
|
|
12
|
+
return context.require(packageName) // when installed with Antora
|
|
13
|
+
} catch {}
|
|
14
|
+
return require(packageName) // when installed separate from Antora, perhaps in project
|
|
15
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@antora/epub-extension",
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
|
+
"description": "An Antora extension that uses Assembler to merge pages into assembly files, export them to the EPUB format, and publishe them with the site.",
|
|
5
|
+
"license": "MPL-2.0",
|
|
6
|
+
"author": "OpenDevise Inc. (https://opendevise.com)",
|
|
7
|
+
"contributors": [
|
|
8
|
+
"Dan Allen <dan@opendevise.com>",
|
|
9
|
+
"Sarah White <sarah@opendevise.com>"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://antora.org",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://gitlab.com/antora/antora-assembler.git",
|
|
15
|
+
"directory": "packages/epub-extension"
|
|
16
|
+
},
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://gitlab.com/antora/antora-assembler/issues"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "node --test test/*-test.js",
|
|
22
|
+
"prepublishOnly": "npx -y downdoc --prepublish",
|
|
23
|
+
"postpublish": "npx -y downdoc --postpublish"
|
|
24
|
+
},
|
|
25
|
+
"main": "lib/index.js",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": "./lib/index.js",
|
|
28
|
+
"./converter": "./lib/converter.js",
|
|
29
|
+
"./package.json": "./package.json"
|
|
30
|
+
},
|
|
31
|
+
"imports": {
|
|
32
|
+
"#package": "./package.json"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@antora/assembler": "1.0.0-beta.1",
|
|
36
|
+
"@antora/run-command-helper": "~1.0"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=16.0.0"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"lib/"
|
|
43
|
+
],
|
|
44
|
+
"keywords": [
|
|
45
|
+
"antora",
|
|
46
|
+
"antora-extension",
|
|
47
|
+
"asciidoc",
|
|
48
|
+
"asciidoctor",
|
|
49
|
+
"epub",
|
|
50
|
+
"generator",
|
|
51
|
+
"documentation"
|
|
52
|
+
]
|
|
53
|
+
}
|