Socket
Socket
Sign inDemoInstall

@antora/asciidoc-loader

Package Overview
Dependencies
Maintainers
2
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antora/asciidoc-loader - npm Package Compare versions

Comparing version 3.0.3 to 3.1.0

lib/asciidoctor.js

104

lib/load-asciidoc.js
'use strict'
const Asciidoctor = require('@asciidoctor/core')()
const Asciidoctor = require('./asciidoctor')
const { Extensions, LoggerManager, NullLogger } = Asciidoctor

@@ -10,4 +10,4 @@ const Opal = global.Opal

const { posix: path } = require('path')
const resolveAsciiDocConfig = require('./config/resolve-asciidoc-config')
const resolveIncludeFile = require('./include/resolve-include-file')
const userRequire = require('@antora/user-require-helper')

@@ -85,18 +85,26 @@ const BLANK_LINE_BUF = Buffer.from('\n\n')

} finally {
if (extensions.length) freeExtensions()
if (extensions.length) {
// low-level operation to free objects from memory that have been weaved into an extension DSL module
EXTENSION_DSL_TYPES.forEach((type) => (Opal.const_get_local(Extensions, type).$$iclasses.length = 0))
}
}
}
function computePageAttrs ({ component: componentName, version, module: module_, relative, origin }, contentCatalog) {
function computePageAttrs ({ component, version, module: module_, relative, origin, editUrl }, contentCatalog) {
const attrs = {}
attrs['page-component-name'] = componentName
attrs['page-component-name'] = component
attrs['page-component-version'] = attrs['page-version'] = version
const component = contentCatalog && contentCatalog.getComponent(componentName)
if (component) {
if ((component = contentCatalog && contentCatalog.getComponent(component))) {
attrs['page-component-title'] = component.title
const componentVersion = component.versions.find((it) => it.version === version)
if (componentVersion) attrs['page-component-display-version'] = componentVersion.displayVersion
attrs['page-component-title'] = component.title
if (componentVersion) {
attrs['page-component-display-version'] = componentVersion.displayVersion
const latestVersion = component.latest.version
if (version === latestVersion) attrs['page-component-version-is-latest'] = ''
attrs['page-component-latest-version'] = latestVersion
}
}
attrs['page-module'] = module_
attrs['page-relative-src-path'] = relative
if (editUrl) attrs['page-edit-url'] = editUrl
if (origin) {

@@ -106,9 +114,4 @@ attrs['page-origin-type'] = origin.type

attrs['page-origin-start-path'] = origin.startPath
if (origin.branch) {
attrs['page-origin-refname'] = attrs['page-origin-branch'] = origin.branch
attrs['page-origin-reftype'] = 'branch'
} else {
attrs['page-origin-refname'] = attrs['page-origin-tag'] = origin.tag
attrs['page-origin-reftype'] = 'tag'
}
attrs['page-origin-reftype'] = origin.reftype
attrs['page-origin-refname'] = attrs['page-origin-' + origin.reftype] = origin.refname
if (origin.worktree) {

@@ -120,2 +123,3 @@ attrs['page-origin-worktree'] = origin.worktree

}
if (origin.private) attrs['page-origin-private'] = ''
}

@@ -136,70 +140,2 @@ return attrs

/**
* Resolves a global AsciiDoc configuration object from data in the playbook.
*
* Reads data from the asciidoc category of the playbook and resolves it into a global AsciiDoc configuration object
* that can be used by the loadAsciiDoc function. This configuration object consists of built-in attributes as well as a
* shallow clone of the data from the asciidoc category in the playbook.
*
* The main purpose of this function is to resolve extension references in the playbook to extension
* functions. If the extension is scoped, the function is stored in this object. If the extension is global, it is
* registered with the global extension registry, then discarded.
*
* @memberof asciidoc-loader
*
* @param {Object} playbook - The configuration object for Antora (default: {}).
* @param {Object} playbook.asciidoc - The AsciiDoc configuration data in the playbook.
*
* @returns {Object} A resolved configuration object to be used by the loadAsciiDoc function.
*/
function resolveAsciiDocConfig (playbook = {}) {
const attributes = {
env: 'site',
'env-site': '',
'site-gen': 'antora',
'site-gen-antora': '',
'attribute-missing': 'warn',
'data-uri': null,
icons: 'font',
sectanchors: '',
'source-highlighter': 'highlight.js',
}
if (playbook.site) {
const site = playbook.site
if (site.title) attributes['site-title'] = site.title
if (site.url) attributes['site-url'] = site.url
}
if (!playbook.asciidoc) return { attributes }
// TODO process !name attributes
const { extensions, ...config } = Object.assign({ attributes }, playbook.asciidoc, {
attributes: Object.assign(attributes, playbook.asciidoc.attributes),
})
if (extensions && extensions.length) {
const userRequireContext = { dot: playbook.dir, paths: [playbook.dir || '', __dirname] }
const scopedExtensions = extensions.reduce((accum, extensionPath) => {
const extension = userRequire(extensionPath, userRequireContext)
if ('register' in extension) {
accum.push(extension)
} else if (!isExtensionRegistered(extension, Extensions)) {
// QUESTION should we assign an antora-specific group name?
Extensions.register(extension)
}
return accum
}, [])
if (scopedExtensions.length) config.extensions = scopedExtensions
}
return config
}
function isExtensionRegistered (ext, registry) {
return Object.values(registry.getGroups()).includes(ext)
}
/**
* Low-level operation to free objects from memory that have been weaved into an extension DSL module
*/
function freeExtensions () {
EXTENSION_DSL_TYPES.forEach((type) => (Opal.const_get_local(Extensions, type).$$iclasses.length = 0))
}
module.exports = Object.assign(loadAsciiDoc, {

@@ -206,0 +142,0 @@ loadAsciiDoc,

{
"name": "@antora/asciidoc-loader",
"version": "3.0.3",
"version": "3.1.0",
"description": "Loads AsciiDoc content into an Asciidoctor Document object (AST) for use in an Antora documentation pipeline.",

@@ -19,4 +19,10 @@ "license": "MPL-2.0",

"main": "lib/index.js",
"exports": {
".": "./lib/index.js",
"./config/collate-asciidoc-attributes": "./lib/config/collate-asciidoc-attributes.js",
"./util/compute-relative-url-path": "./lib/util/compute-relative-url-path.js",
"./package.json": "./package.json"
},
"dependencies": {
"@antora/logger": "3.0.3",
"@antora/logger": "3.1.0",
"@antora/user-require-helper": "~2.0",

@@ -26,3 +32,3 @@ "@asciidoctor/core": "~2.2"

"engines": {
"node": ">=12.21.0"
"node": ">=16.0.0"
},

@@ -29,0 +35,0 @@ "files": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc