@antora/html-single-extension 1.0.0-beta.20 → 1.0.0-rc.10

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/converter.js CHANGED
@@ -6,48 +6,48 @@ const ospath = require('node:path')
6
6
  const DEFAULT_COMMAND = 'asciidoctor'
7
7
  const PACKAGE_NAME = require('../package.json').name
8
8
 
9
- async function convert (file, convertAttributes, buildConfig, { logCommand, runCommand }) {
9
+ async function convert (file, conversionAttributes, buildConfig, { logCommand, runCommand }) {
10
10
  if (buildConfig.command === false) {
11
- const Asciidoctor = this.require('@asciidoctor/core')()
12
- const Extensions = Asciidoctor.Extensions
13
- const exts = this.getVariables().siteAsciiDocConfig?.extensions || []
14
- let extRegistry, extDslTypes
15
- try {
16
- if (exts.length) {
17
- const contentCatalog = this.getVariables().contentCatalog
18
- extDslTypes = Extensions.$constants(false).filter((name) => name.endsWith('Dsl'))
19
- extRegistry = Extensions.create()
20
- exts.forEach((ext) => ext.register(extRegistry, { file, contentCatalog }))
21
- }
22
- Asciidoctor.convert(file.contents, {
23
- attributes: convertAttributes,
24
- extension_registry: extRegistry,
25
- mkdirs: true,
26
- safe: 'safe',
27
- sourcemap: true,
28
- to_file: convertAttributes.outfile,
29
- })
30
- } finally {
31
- if (exts.length) extDslTypes.forEach((type) => (Opal.const_get_local(Extensions, type).$$iclasses.length = 0))
11
+ const { loadAsciiDoc } = this.getFunctions()
12
+ const { contentCatalog, siteAsciiDocConfig } = this.getVariables()
13
+ const asciidocConfig = {
14
+ antoraResourceRefs: false,
15
+ attributes: conversionAttributes,
16
+ docdir: conversionAttributes.docdir,
17
+ docfile: conversionAttributes.docfile,
18
+ extensions: siteAsciiDocConfig?.extensions,
19
+ safe: 'unsafe',
20
+ sourcemap: true,
21
+ standalone: true,
32
22
  }
23
+ const doc = loadAsciiDoc(file, contentCatalog, asciidocConfig)
24
+ const html = typeof doc.withLogger === 'function' ? doc.withLogger(() => doc.convert()) : doc.convert()
25
+ await fsp.mkdir(conversionAttributes.outdir, { force: true, recursive: true })
26
+ await fsp.writeFile(conversionAttributes.outfile, html)
33
27
  } else {
34
- const { command, cwd = process.cwd(), attributeOptionFlag = '-a', stderr = 'print' } = buildConfig
35
- logCommand?.(command, file, convertAttributes, attributeOptionFlag)
36
- const args = convertAttributes.toArgs(attributeOptionFlag, command).concat('-o', convertAttributes.outfile, '-')
37
- return runCommand(command, args, { parse: true, cwd, stdin: file.contents, stdout: 'print', stderr })
28
+ const { command, cwd = process.cwd(), attributeOptionFlag, stderr = 'print' } = buildConfig
29
+ if (!command) return null
30
+ const outputOptionFlag = buildConfig.outputOptionFlag || (buildConfig.outputOptionFlag === false ? false : '-o')
31
+ const extraArgs = conversionAttributes.toArgs(attributeOptionFlag || '-a', outputOptionFlag)
32
+ const stdout = outputOptionFlag ? 'print' : 'buffer'
33
+ logCommand?.(command, extraArgs, file, conversionAttributes)
34
+ return runCommand(command, extraArgs.concat('-'), { parse: true, cwd, stdin: file.contents, stdout, stderr })
38
35
  }
39
36
  }
40
37
 
41
- function getDefaultCommand (cwd) {
42
- return fsp.access(ospath.join(cwd, 'Gemfile.lock')).then(
43
- () => `bundle exec ${DEFAULT_COMMAND}`,
44
- () => DEFAULT_COMMAND
38
+ function getDefaultCommand (cwd, playbook) {
39
+ const defaultCommand = playbook?.runtime.stacktrace ? `${DEFAULT_COMMAND} --trace` : DEFAULT_COMMAND
40
+ const bundleLockfile = playbook?.env.BUNDLE_LOCKFILE ?? `${playbook?.env.BUNDLE_GEMFILE ?? 'Gemfile'}.lock`
41
+ return fsp.access(ospath.resolve(cwd, bundleLockfile)).then(
42
+ () => `bundle exec ${defaultCommand}`,
43
+ () => defaultCommand
45
44
  )
46
45
  }
47
46
 
48
47
  module.exports = {
49
48
  convert,
50
- backend: 'html',
49
+ backend: 'html-single',
50
+ format: 'html',
51
51
  getDefaultCommand,
52
52
  extname: '.html',
53
53
  mediaType: 'text/html',
package/lib/index.js CHANGED
@@ -1,14 +1,8 @@
1
1
  'use strict'
2
2
 
3
+ const { configure: configureAssembler } = require('@antora/assembler')
3
4
  const converter = require('./converter')
4
5
 
5
6
  module.exports.register = function ({ config }, providers) {
6
- requireAssembler(this).configure(this, converter, config, providers)
7
- }
8
-
9
- function requireAssembler (context, packageName = '@antora/assembler') {
10
- try {
11
- return context.require(packageName) // when installed with Antora
12
- } catch {}
13
- return require(packageName) // when installed separate from Antora, perhaps in project
7
+ configureAssembler(this, converter, config, providers)
14
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antora/html-single-extension",
3
- "version": "1.0.0-beta.20",
3
+ "version": "1.0.0-rc.10",
4
4
  "description": "An Antora extension that uses Assembler to merge pages into assembly files, export them to standalone HTML documents, and publish them with the site.",
5
5
  "license": "MPL-2.0",
6
6
  "author": "OpenDevise Inc. (https://opendevise.com)",
@@ -19,8 +19,8 @@
19
19
  },
20
20
  "scripts": {
21
21
  "test": "node --test test/*-test.js",
22
- "prepublishOnly": "npx -y downdoc --prepublish",
23
- "postpublish": "npx -y downdoc --postpublish"
22
+ "prepublishOnly": "npx -y downdoc@latest --prepublish",
23
+ "postpublish": "npx -y downdoc@latest --postpublish"
24
24
  },
25
25
  "main": "lib/index.js",
26
26
  "exports": {
@@ -32,10 +32,10 @@
32
32
  "#package": "./package.json"
33
33
  },
34
34
  "dependencies": {
35
- "@antora/assembler": "1.0.0-beta.20"
35
+ "@antora/assembler": "1.0.0-rc.10"
36
36
  },
37
37
  "engines": {
38
- "node": ">=16.0.0"
38
+ "node": ">=20.0.0"
39
39
  },
40
40
  "files": [
41
41
  "lib/"