@antora/html-single-extension 1.0.0-rc.7 → 1.0.0-rc.9

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.
Files changed (2) hide show
  1. package/lib/converter.js +15 -23
  2. package/package.json +2 -2
package/lib/converter.js CHANGED
@@ -8,30 +8,22 @@ const PACKAGE_NAME = require('../package.json').name
8
8
 
9
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: conversionAttributes,
24
- extension_registry: extRegistry,
25
- mkdirs: true,
26
- safe: 'safe',
27
- sourcemap: true,
28
- to_file: conversionAttributes.outfile,
29
- })
30
- } finally {
31
- if (exts.length) {
32
- for (const type of extDslTypes) Extensions[type].$$iclasses.length = 0
33
- }
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,
34
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)
35
27
  } else {
36
28
  const { command, cwd = process.cwd(), attributeOptionFlag, stderr = 'print' } = buildConfig
37
29
  if (!command) return null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antora/html-single-extension",
3
- "version": "1.0.0-rc.7",
3
+ "version": "1.0.0-rc.9",
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)",
@@ -32,7 +32,7 @@
32
32
  "#package": "./package.json"
33
33
  },
34
34
  "dependencies": {
35
- "@antora/assembler": "1.0.0-rc.7"
35
+ "@antora/assembler": "1.0.0-rc.9"
36
36
  },
37
37
  "engines": {
38
38
  "node": ">=20.0.0"